From 0e481cb2264cf1f73e0e729075a0902676fcd818 Mon Sep 17 00:00:00 2001 From: derGraph Date: Tue, 20 Aug 2024 13:09:10 +0200 Subject: [PATCH] show active track on homepage --- src/routes/+page.svelte | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 8479490..17c6bb9 100755 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,10 +2,30 @@ // @ts-ignore import type { LatLngExpression } from 'leaflet'; import Leaflet from '$lib/Leaflet.svelte'; + import { onMount } from 'svelte'; + import errorStore from '$lib/errorStore.js'; + + export let data; + let tracks: null = null; const initialView: LatLngExpression = [43.95, 14.79]; + + async function getTrip(tripId: String) { + let response = await fetch('/api/Datapoints?tripId='+tripId); + if(!response.ok){ + $errorStore = response; + } + tracks = await response.json(); + } + + onMount(()=>{ + if(data.user){ + getTrip(data.user?.activeTripId); + } + }); +
- +