Added valid/invalid logic

ref #11
This commit is contained in:
Nicolai Ort 2021-04-06 18:00:05 +02:00
parent db4d63da8b
commit c0555c0662
1 changed files with 9 additions and 2 deletions

View File

@ -9,6 +9,7 @@
let lastscan_time = "";
let lastscan_laptime = "";
let lastscan_totaldistance = "";
let lastscan_valid = true;
let card = "";
// live clock at the top
let time = new Date();
@ -83,6 +84,7 @@
) +
"s";
lastscan_laptime = response.data.lapTime;
lastscan_valid = response.data.valid;
lastscan_totaldistance =
Math.floor(response.data.runner.distance / 1000) +
"km " +
@ -112,14 +114,19 @@
/>
</label>
{#if lastscan_totaldistance}
<h1 class="text-3xl font-bold text-center">last scan</h1>
<h1 class="text-5xl font-bold text-center">{lastscan_time}</h1>
{#if !lastscan_valid}
<svg xmlns="http://www.w3.org/2000/svg" width=20rem height=20rem class="ml-auto mr-auto" version="1.0" viewBox="0 0 100 100"><g fill="none" stroke="red"><path d="M6 6l88 88" stroke-width="18.1"/><path d="M6 94L94 6" stroke-width="17.8"/></g></svg>
{:else}
<svg xmlns="http://www.w3.org/2000/svg" width=20rem height=20rem class="ml-auto mr-auto" viewBox="0 0 600 600"><path d="M8 405s115 129 138 182h99c41-126 203-429 341-535 28-37-43-52-102-27-87 36-252 317-283 384-44 12-90-74-90-74z" fill="#181"/></svg>
{/if}
<h1 class="text-3xl font-bold text-center">total distance</h1>
<h1 class="text-8xl font-bold text-center">
{lastscan_totaldistance}
</h1>
<h1 class="text-3xl font-bold text-center">lap time</h1>
<h1 class="text-8xl font-bold text-center">{lastscan_laptime}</h1>
<h1 class="text-3xl font-bold text-center">last scan</h1>
<h1 class="text-5xl font-bold text-center">{lastscan_time}</h1>
{:else}
<h1 class="text-3xl font-bold text-center">
{$_("please_scan_a_card")}