carnet panel

This commit is contained in:
alma 2025-04-20 18:31:59 +02:00
parent 1af876097b
commit 126ae41d31

View File

@ -37,6 +37,7 @@ export default function CarnetPage() {
const [showNotes, setShowNotes] = useState(true); const [showNotes, setShowNotes] = useState(true);
const [nextcloudFolders, setNextcloudFolders] = useState<string[]>([]); const [nextcloudFolders, setNextcloudFolders] = useState<string[]>([]);
const [selectedFolder, setSelectedFolder] = useState<string>('Notes'); const [selectedFolder, setSelectedFolder] = useState<string>('Notes');
const [notes, setNotes] = useState<Note[]>([]);
// Panel widths state // Panel widths state
const [navWidth, setNavWidth] = useState(220); const [navWidth, setNavWidth] = useState(220);
@ -137,9 +138,37 @@ export default function CarnetPage() {
} }
}; };
const handleNoteSave = (note: Note) => { const handleNoteSave = async (note: Note) => {
// TODO: Implement note saving logic try {
console.log('Saving note:', note); const response = await fetch('/api/nextcloud/files', {
method: note.id ? 'PUT' : 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: note.id,
title: note.title,
content: note.content,
folder: selectedFolder
}),
});
if (!response.ok) {
throw new Error('Failed to save note');
}
const savedNote = await response.json();
setSelectedNote(savedNote);
// Refresh the notes list
const notesResponse = await fetch(`/api/nextcloud/files?folder=${selectedFolder}`);
if (notesResponse.ok) {
const notes = await notesResponse.json();
setNotes(notes);
}
} catch (error) {
console.error('Error saving note:', error);
}
}; };
const handleFolderSelect = (folder: string) => { const handleFolderSelect = (folder: string) => {
@ -183,8 +212,6 @@ export default function CarnetPage() {
style={{ width: `${navWidth}px` }} style={{ width: `${navWidth}px` }}
> >
<Navigation <Navigation
layout={layoutMode}
onLayoutChange={setLayoutMode}
nextcloudFolders={nextcloudFolders} nextcloudFolders={nextcloudFolders}
onFolderSelect={handleFolderSelect} onFolderSelect={handleFolderSelect}
/> />