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 Path from '$lib/components/Path.svelte';
import Splash from '$lib/components/Splash.svelte';
import { onMount } from 'svelte';
import {getRouteCategories} from '$lib/repo';
let categories = [];
onMount(async () => {
categories = await getRouteCategories();
})
export let data;
let categories = data.categories;
</script>
<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">
import Header from '$lib/components/Header.svelte';
import Tabs from '$lib/components/Tabs.svelte';
import { onMount } from 'svelte';
export let data: App.Route;
let divider;
const mapClick = () => {};
console.log(data)
</script>
<Header></Header>
@ -15,8 +16,8 @@
<div bind:this={divider} id="divider">
<div id="banner">
<p>Percorso <b>{data.name_it}</b></p>
<p id="duration">Dislivello {data.route_sport_details[0].elevation_gain} m</p>
<p>Percorso <b>{data.title_it}</b></p>
<p id="duration">Dislivello {data?.route_sport_details[0]?.elevation_gain} m</p>
</div>
<Tabs on:map-click={mapClick} route={data}></Tabs>
</div>

View file

@ -1,7 +1,14 @@
import { getRouteByCategory } from '$lib/repo.js';
import { getRoute } from '$lib/repo.js';
import { error } from '@sveltejs/kit';
/** @type {import('./$types').PageLoad} */
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;
}