From a6b1d421ccfb830a1c5e447a1487294d80ba6255 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Wed, 10 Jul 2024 18:21:52 -0400 Subject: [PATCH] errors and not found screens --- frontend/src/routes/planner/+page.svelte | 23 ++++++++++++++++--- frontend/src/routes/visited/+page.svelte | 23 ++++++++++++++++--- .../routes/worldtravel/[id]/+page.server.ts | 8 ++----- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/frontend/src/routes/planner/+page.svelte b/frontend/src/routes/planner/+page.svelte index 0d8c11b..00d216f 100644 --- a/frontend/src/routes/planner/+page.svelte +++ b/frontend/src/routes/planner/+page.svelte @@ -6,6 +6,8 @@ import type { PageData } from './$types'; import EditAdventure from '$lib/components/EditAdventure.svelte'; + import Lost from '$lib/assets/undraw_lost.svg'; + export let data: PageData; console.log(data); @@ -80,7 +82,10 @@ -

Planned Adventures

+{#if adventures.length > 0} +

Planned Adventures

+{/if} +
{#each adventures as adventure} @@ -88,7 +93,19 @@
{#if adventures.length === 0} -
-

No planned adventures yet!

+
+
+
+ Lost +
+

+ No planned adventures found +

+

+ There are no adventures to display. Add some using the plus button at the bottom right! +

+
{/if} diff --git a/frontend/src/routes/visited/+page.svelte b/frontend/src/routes/visited/+page.svelte index 89f37cb..3e64a7b 100644 --- a/frontend/src/routes/visited/+page.svelte +++ b/frontend/src/routes/visited/+page.svelte @@ -6,6 +6,8 @@ import type { PageData } from './$types'; import EditAdventure from '$lib/components/EditAdventure.svelte'; + import Lost from '$lib/assets/undraw_lost.svg'; + export let data: PageData; console.log(data); @@ -80,7 +82,10 @@
-

Visited Adventures

+{#if adventures.length > 0} +

Visited Adventures

+{/if} +
{#each adventures as adventure} @@ -88,7 +93,19 @@
{#if adventures.length === 0} -
-

No visited adventures yet!

+
+
+
+ Lost +
+

+ No visited adventures found +

+

+ There are no adventures to display. Add some using the plus button at the bottom right! +

+
{/if} diff --git a/frontend/src/routes/worldtravel/[id]/+page.server.ts b/frontend/src/routes/worldtravel/[id]/+page.server.ts index 38ed4c8..b13ad43 100644 --- a/frontend/src/routes/worldtravel/[id]/+page.server.ts +++ b/frontend/src/routes/worldtravel/[id]/+page.server.ts @@ -1,5 +1,6 @@ const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL']; import type { Country, Region, VisitedRegion } from '$lib/types'; +import { redirect } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000'; @@ -19,16 +20,11 @@ export const load = (async (event) => { }); if (!res.ok) { console.error('Failed to fetch regions'); - return { status: 500 }; + return redirect(302, '/404'); } else { regions = (await res.json()) as Region[]; } - if (regions.length === 0) { - console.error('No regions found'); - return { status: 404 }; - } - res = await fetch(`${endpoint}/api/${id}/visits/`, { method: 'GET', headers: {