diff --git a/frontend/svelte/src/models/types.ts b/frontend/svelte/src/models/types.ts index 9814953..5ded795 100644 --- a/frontend/svelte/src/models/types.ts +++ b/frontend/svelte/src/models/types.ts @@ -1,6 +1,11 @@ export interface Note { id: number; + attributes: Attribute; +} + +export interface Attribute { title: string; content: string; - lastOpened: string; + + lastViewed: Date; } \ No newline at end of file diff --git a/frontend/svelte/src/routes/+page.svelte b/frontend/svelte/src/routes/+page.svelte index c58033b..8818689 100644 --- a/frontend/svelte/src/routes/+page.svelte +++ b/frontend/svelte/src/routes/+page.svelte @@ -5,14 +5,11 @@ const endpoint = "/notes"; - let notes: Note[]; - // onMount(async () => { - // const response = await bearerFetch(endpoint, jwt); - // debugger; - // var data = await response.json(); - // console.log("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") - // }); + //:TODO TEMP!!! + const jsonStr = "[{\"id\":0,\"attributes\":{\"title\":\"mike\",\"content\":\"C Moasta\",\"lastViewed\":\"2022-09-27\"}},{\"id\":1,\"attributes\":{\"title\":\"samc\",\"content\":\"drupal gott\",\"lastViewed\":\"1999-09-09\"}}]"; + //:TODO TEMP!!! + let notes: Note[] = JSON.parse(jsonStr); onMount(() => { console.log("snasidbsa dghsasa"); }); @@ -34,29 +31,31 @@ let newTitle = prompt('Name of the new Note'); console.log(notes) if (newTitle != null && newTitle != '') { - addNote(newTitle); + // addNote(newTitle); console.log(notes) reloadNotesListing(); } } - /** - * Adds a new note to the "notes" Array with: - * * the latest id + 1 (or 0 if no notes exist) - * * no content - * @param title The title of the new Note - */ - function addNote(title: string) { - let date = new Date(); - let newNoteId = (notes.length == 0) ? 0 : notes[notes.length - 1].id + 1 - let note: Note = { - id: newNoteId, - title: title, - content: "", - lastOpened: date.toISOString() - }; - notes.push(note); - } + // //so a schas + // /** + // * Adds a new note to the "notes" Array with: + // * * the latest id + 1 (or 0 if no notes exist) + // * * no content + // * @param title The title of the new Note + // */ + // function addNote(title: string) { + // let date = new Date(); + // let newNoteId = (notes.length == 0) ? 0 : notes[notes.length - 1].id + 1 + // let note: Note = { + // id: newNoteId, + // attributes: + // title: title, + // content: "", + // lastOpened: date.toISOString() + // }; + // notes.push(note); + // } /** * Gives the user a prompt if they are sure to delete this note and deletes it if they confirm @@ -121,28 +120,30 @@