From ca70bc2d452dd1bb942ae4a2e060a9db5021f6a4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 19 Dec 2022 20:55:21 -0800 Subject: move locations check --- src/components/About.svelte | 16 +++++++++------- src/routes/(app)/locations/+server.js | 12 ++++++++++-- src/routes/+page.svelte | 5 ++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/components/About.svelte b/src/components/About.svelte index 317c190e..c05f2dc2 100644 --- a/src/components/About.svelte +++ b/src/components/About.svelte @@ -85,10 +85,12 @@ -
-

{$t('about.locations.header')}

-

- {@html $t('about.locations.description')} -

- -
+{#if locations?.length} +
+

{$t('about.locations.header')}

+

+ {@html $t('about.locations.description')} +

+ +
+{/if} diff --git a/src/routes/(app)/locations/+server.js b/src/routes/(app)/locations/+server.js index 87f8975d..dd9e984b 100644 --- a/src/routes/(app)/locations/+server.js +++ b/src/routes/(app)/locations/+server.js @@ -2,6 +2,14 @@ import { get } from '$lib/utils'; import { json } from '@sveltejs/kit'; export async function GET({ fetch, setHeaders }) { - setHeaders({ 'cache-control': 'public, max-age=600' }); - return json(await get('/locations')); + let locations = []; + + try { + ({ locations } = await get('/locations')); + setHeaders({ 'cache-control': 'public, max-age=600' }); + } catch (e) { + console.log('failed to fetch locations'); + } + + return json({ locations }); } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index dd135b1b..bf191b7f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -17,6 +17,7 @@ export let data; let { user } = data; let { locations } = data; + console.log('LOCATIONS', locations); let howItWorks; let faq; @@ -93,9 +94,7 @@
- {#if locations?.length} - - {/if} +