diff --git a/app/carnet/page.tsx b/app/carnet/page.tsx index 80eff925..5651984a 100644 --- a/app/carnet/page.tsx +++ b/app/carnet/page.tsx @@ -92,9 +92,29 @@ export default function CarnetPage() { } }; - const handleNoteSave = (note: Note) => { - // TODO: Implement note saving logic - console.log('Saving note:', note); + const handleNoteSave = async (note: Note) => { + try { + const response = await fetch('/api/carnet', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + content: note.content, + date: note.lastEdited.toISOString(), + category: 'Notes' + }), + }); + + if (!response.ok) { + throw new Error('Failed to save note'); + } + + const result = await response.json(); + console.log('Note saved successfully:', result); + } catch (error) { + console.error('Error saving note:', error); + } }; if (isLoading) { diff --git a/components/carnet/editor.tsx b/components/carnet/editor.tsx index 5406d7bc..05178b22 100644 --- a/components/carnet/editor.tsx +++ b/components/carnet/editor.tsx @@ -8,8 +8,9 @@ interface EditorProps { id: string; title: string; content: string; + lastEdited: Date; }; - onSave?: (note: { id: string; title: string; content: string }) => void; + onSave?: (note: { id: string; title: string; content: string; lastEdited: Date }) => void; } export const Editor: React.FC = ({ note, onSave }) => { @@ -36,7 +37,8 @@ export const Editor: React.FC = ({ note, onSave }) => { onSave?.({ id: note.id, title, - content + content, + lastEdited: new Date() }); } };