Skip to content

Commit

Permalink
Merge pull request #21 from spektrumrf/dev
Browse files Browse the repository at this point in the history
Hide checkbox before event has started
  • Loading branch information
jonaswesterlund authored Mar 21, 2024
2 parents e2d3480 + 744eb6c commit 448eed7
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/routes/[year]/gps/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script lang="ts">
import L from 'leaflet';
import { onMount } from 'svelte';
import { account, positions, type Position } from '$lib/stores';
import { account, positions, event } from '$lib/stores';
import Loading from '$lib/components/Loading.svelte';
import dayjs from 'dayjs';
let map: any;
let allowGps = $account?.allowGps;
let loading = false;
Expand Down Expand Up @@ -41,17 +42,27 @@
`${position.expand?.team?.name} kl.${new Date(position?.created).toLocaleTimeString('fi-FI').slice(0, 5)}`;
const updateMapPosition = (position: any) =>
(map = map.setView([position.latitude, position.longitude], 16));
$: hasStarted = dayjs().toISOString() > dayjs($event?.startTime).toISOString();
</script>

<h3 class="font-bold text-2xl mb-5">GPS</h3>
<div class="max-w-xs">
<label class="label cursor-pointer">
<span class="label-text">Dela din position</span>
<Loading {loading}>
<input type="checkbox" class="toggle" bind:checked={allowGps} on:change={toggleAllowGps} />
</Loading>
</label>
</div>
{#if hasStarted}
<div class="max-w-xs">
<label class="label cursor-pointer">
<span class="label-text">Dela din position</span>
<Loading {loading}>
<input
type="checkbox"
class="toggle disabled"
bind:checked={allowGps}
on:change={toggleAllowGps}
/>
</Loading>
</label>
</div>
{:else}
<p>Ladda om sidan då Vasagatan har börjat</p>
{/if}
<div id="map" bind:this={map}></div>
{#if allowGps}
<h4 class="font-bold text-xl mt-5 mb-2">Positioner</h4>
Expand Down

0 comments on commit 448eed7

Please sign in to comment.