carnet api
This commit is contained in:
parent
aa4b50950d
commit
2765730b47
@ -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) {
|
||||
|
||||
@ -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<EditorProps> = ({ note, onSave }) => {
|
||||
@ -36,7 +37,8 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave }) => {
|
||||
onSave?.({
|
||||
id: note.id,
|
||||
title,
|
||||
content
|
||||
content,
|
||||
lastEdited: new Date()
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user