mirror of
https://github.com/R0m1k3/noteflow.git
synced 2026-10-16 19:58:31 +02:00
[dyad] wrote 5 file(s)
This commit is contained in:
1 parent
1ce71f37c2
commit
209c48ee6b
4 files changed
+90
-53
No files matched your search
@@ -35,7 +35,14 @@ class NotesService {
|
||||
throw new Error("Erreur lors de la récupération des notes");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
const notes = await response.json();
|
||||
|
||||
// Ensure todos and images are always arrays
|
||||
return notes.map((note: Note) => ({
|
||||
...note,
|
||||
todos: note.todos || [],
|
||||
images: note.images || []
|
||||
}));
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : "Erreur serveur");
|
||||
return [];
|
||||
@@ -55,7 +62,12 @@ class NotesService {
|
||||
}
|
||||
|
||||
showSuccess("Note créée avec succès");
|
||||
return await response.json();
|
||||
const note = await response.json();
|
||||
return {
|
||||
...note,
|
||||
todos: note.todos || [],
|
||||
images: note.images || []
|
||||
};
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : "Erreur serveur");
|
||||
return null;
|
||||
@@ -69,7 +81,11 @@ class NotesService {
|
||||
const response = await fetch(`/api/notes/${note.id}`, {
|
||||
method: "PUT",
|
||||
headers: AuthService.getHeaders(),
|
||||
body: JSON.stringify(note)
|
||||
body: JSON.stringify({
|
||||
...note,
|
||||
todos: note.todos || [],
|
||||
images: note.images || []
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in new issue
Block a user