diff --git a/frontend/svelte/src/models/PomeloUtils.ts b/frontend/svelte/src/models/PomeloUtils.ts index e61190e..5d290ae 100644 --- a/frontend/svelte/src/models/PomeloUtils.ts +++ b/frontend/svelte/src/models/PomeloUtils.ts @@ -24,6 +24,7 @@ export async function bearerFetch(endpoint: string, jwt: string, baseUrl: string const getJwtCookie = () => { + // @ts-ignore return parseCookies("/").jwt; }; diff --git a/frontend/svelte/src/routes/+page.svelte b/frontend/svelte/src/routes/+page.svelte index 060fd09..f52d418 100644 --- a/frontend/svelte/src/routes/+page.svelte +++ b/frontend/svelte/src/routes/+page.svelte @@ -1,20 +1,28 @@ @@ -114,45 +123,45 @@
-
- -
- +
+ +
+ +
-
-
-
- {#if notes.length !== 0} - -
    - {#each notes as note} -
  • handleMouseOverLi(note.id)} - on:mouseout={() => handleMouseOutLi(note.id)}> -
    -
    onNoteLiClick(note)}> -
    - {note.attributes.title} +
    +
    + {#if notes} + +
      + {#each notes as note} +
    • handleMouseOverLi(note.id)} + on:mouseout={() => handleMouseOutLi(note.id)}> +
      +
      onNoteLiClick(note)}> +
      + {note.attributes.title} +
      +
      + {note.attributes.lastViewed.toLocaleDateString()} +
      -
      - {note.attributes.lastViewed} + +
      +
      - -
      - -
      -
      -
    • - {/each} -
    - {/if} +
  • + {/each} +
+ {/if} +
-
@@ -235,5 +244,6 @@ .list-date-text { color: var(--sub-txt-color); + font-size: 0.8314159265358979323846264338rem; } \ No newline at end of file diff --git a/frontend/svelte/src/routes/+page.ts b/frontend/svelte/src/routes/+page.ts index e5159f4..49e20b3 100644 --- a/frontend/svelte/src/routes/+page.ts +++ b/frontend/svelte/src/routes/+page.ts @@ -1,18 +1,20 @@ import {bearerFetch, jwt} from "../models/PomeloUtils"; -// -// /** @type {import('./$types').PageLoad} */ -// export async function load() { -// let invalid = !jwt; -// -// if (!invalid) { -// const request = await bearerFetch("/users/me", jwt); -// const response = await request.json(); -// -// invalid = "error" in response; -// } -// -// if (invalid) { -// // @ts-ignore -// window.location = "/login"; -// } -// } \ No newline at end of file + +/** @type {import('./$types').PageLoad} */ +export async function load() { + let invalid = !jwt; + + if (!invalid) { + const request = await bearerFetch("/users/me", jwt); + const response = await request.json(); + + invalid = "error" in response; + } + + if (invalid) { + if (typeof window !== 'undefined') { + // @ts-ignore + window.location = "/login"; + } + } +} \ No newline at end of file