diff --git a/frontend/src/lib/components/NoteCard.svelte b/frontend/src/lib/components/NoteCard.svelte
index 02e6af6..d64a532 100644
--- a/frontend/src/lib/components/NoteCard.svelte
+++ b/frontend/src/lib/components/NoteCard.svelte
@@ -6,13 +6,25 @@
const dispatch = createEventDispatcher();
import Launch from '~icons/mdi/launch';
- import FileDocumentEdit from '~icons/mdi/file-document-edit';
+ import TrashCan from '~icons/mdi/trash-can';
export let note: Note;
function editNote() {
dispatch('edit', note);
}
+
+ async function deleteNote() {
+ const res = await fetch(`/api/notes/${note.id}`, {
+ method: 'DELETE'
+ });
+ if (res.ok) {
+ addToast('success', 'Note deleted successfully');
+ dispatch('delete', note.id);
+ } else {
+ addToast('Failed to delete note', 'error');
+ }
+ }
Open
+
diff --git a/frontend/src/lib/components/NoteModal.svelte b/frontend/src/lib/components/NoteModal.svelte
index 7d38701..27fe793 100644
--- a/frontend/src/lib/components/NoteModal.svelte
+++ b/frontend/src/lib/components/NoteModal.svelte
@@ -8,10 +8,6 @@
export let note: Note | null = null;
export let collection: Collection;
- let editing: boolean = true;
-
- console.log(collection);
-
let newNote = {
name: note?.name || '',
content: note?.content || '',
@@ -20,10 +16,6 @@
collection: collection.id,
is_public: collection.is_public
};
- console.log(note);
-
- export let startDate: string | null = null;
- export let endDate: string | null = null;
let initialName: string = note?.name || '';
@@ -70,7 +62,10 @@
body: JSON.stringify(newNote)
});
if (res.ok) {
- dispatch('close');
+ let data = await res.json();
+ if (data) {
+ dispatch('create', data);
+ }
} else {
let data = await res.json();
console.error('Failed to save note', data);
@@ -89,7 +84,7 @@
Editing note {initialName}
{/if}
-