carnet api

This commit is contained in:
alma 2025-04-20 12:29:56 +02:00
parent aa4b50950d
commit 2765730b47
2 changed files with 27 additions and 5 deletions

View File

@ -92,9 +92,29 @@ 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/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) { if (isLoading) {

View File

@ -8,8 +8,9 @@ interface EditorProps {
id: string; id: string;
title: string; title: string;
content: 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<EditorProps> = ({ note, onSave }) => { export const Editor: React.FC<EditorProps> = ({ note, onSave }) => {
@ -36,7 +37,8 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave }) => {
onSave?.({ onSave?.({
id: note.id, id: note.id,
title, title,
content content,
lastEdited: new Date()
}); });
} }
}; };