This commit is contained in:
Sean Morley
2024-07-24 10:40:48 -04:00
parent 9e610c250c
commit dad42c4a3a
4 changed files with 15338 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
import type { Adventure } from '$lib/types';
import type { Adventure, VisitedRegion } from '$lib/types';
const endpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
export const load = (async (event) => {
@@ -13,6 +13,20 @@ export const load = (async (event) => {
Cookie: `${event.cookies.get('auth')}`
}
});
let visitedRegionsFetch = await fetch(`${endpoint}/api/visitedregion/`, {
headers: {
Cookie: `${event.cookies.get('auth')}`
}
});
let visitedRegions = (await visitedRegionsFetch.json()) as VisitedRegion[];
let USfetch = await fetch(`${endpoint}/static/data/us.json`);
let USjson = await USfetch.json();
if (!USjson) {
console.error('Failed to fetch US GeoJSON');
}
if (!visitedFetch.ok) {
console.error('Failed to fetch visited adventures');
return redirect(302, '/login');
@@ -29,9 +43,12 @@ export const load = (async (event) => {
type: adventure.type
};
});
return {
props: {
markers
markers,
USjson,
visitedRegions
}
};
}