Fix missing sport details values
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Alessio Davoli 2023-11-27 06:39:00 +01:00
parent 74963c446f
commit 610b4d6552
4 changed files with 31 additions and 11 deletions

View file

@ -2,13 +2,10 @@
import BottomAppBar from '$lib/components/BottomAppBar.svelte'; import BottomAppBar from '$lib/components/BottomAppBar.svelte';
import Path from '$lib/components/Path.svelte'; import Path from '$lib/components/Path.svelte';
import Splash from '$lib/components/Splash.svelte'; import Splash from '$lib/components/Splash.svelte';
import { onMount } from 'svelte';
import {getRouteCategories} from '$lib/repo';
let categories = []; export let data;
onMount(async () => { let categories = data.categories;
categories = await getRouteCategories();
})
</script> </script>
<Splash /> <Splash />

View file

@ -0,0 +1,15 @@
import { getRouteCategories } from '$lib/repo.js';
import { error } from '@sveltejs/kit';
/** @type {import('./$types').PageLoad} */
export async function load() {
let categories = [];
try {
categories = await getRouteCategories();
} catch (ex) {
error(500);
}
return { categories };
}

View file

@ -1,13 +1,14 @@
<script lang="ts"> <script lang="ts">
import Header from '$lib/components/Header.svelte'; import Header from '$lib/components/Header.svelte';
import Tabs from '$lib/components/Tabs.svelte'; import Tabs from '$lib/components/Tabs.svelte';
import { onMount } from 'svelte';
export let data: App.Route; export let data: App.Route;
let divider; let divider;
const mapClick = () => {}; const mapClick = () => {};
console.log(data)
</script> </script>
<Header></Header> <Header></Header>
@ -15,8 +16,8 @@
<div bind:this={divider} id="divider"> <div bind:this={divider} id="divider">
<div id="banner"> <div id="banner">
<p>Percorso <b>{data.name_it}</b></p> <p>Percorso <b>{data.title_it}</b></p>
<p id="duration">Dislivello {data.route_sport_details[0].elevation_gain} m</p> <p id="duration">Dislivello {data?.route_sport_details[0]?.elevation_gain} m</p>
</div> </div>
<Tabs on:map-click={mapClick} route={data}></Tabs> <Tabs on:map-click={mapClick} route={data}></Tabs>
</div> </div>

View file

@ -1,7 +1,14 @@
import { getRouteByCategory } from '$lib/repo.js'; import { getRoute } from '$lib/repo.js';
import { error } from '@sveltejs/kit'; import { error } from '@sveltejs/kit';
/** @type {import('./$types').PageLoad} */ /** @type {import('./$types').PageLoad} */
export async function load({ params }) { export async function load({ params }) {
return await getRouteByCategory(params.slug); const routeId = Number(params.slug);
const route = await getRoute(routeId);
if (!route) {
error(404);
}
return route;
} }