Card Assignment for Mobile

{#if state.includes("scan_")} {#if state === "scan_runner"}

Scan Runner (Selfservice QR)

{/if} {#if state === "scan_card"}

Runner Scanned

{runnerinfo.firstname} {runnerinfo.lastname} [#{runnerinfo.id}]

Scan Card (Code 128 Barcode)

{/if} { console.log({ type: "DETECT", code: e.detail.decodedText }); if (state === "scan_runner") { if ( e.detail.decodedText.includes( "https://portal.lauf-fuer-kaya.de/profile/" ) ) { const runnerID = JSON.parse( atob( e.detail.decodedText .replace("https://portal.lauf-fuer-kaya.de/profile/", "") .split(".")[1] ) ).id; new Audio("/beep.mp3").play(); RunnerService.runnerControllerGetOne(runnerID).then((runner) => { console.log(runner); runnerinfo = runner; }); state = "scan_card"; } } if (state === "scan_card") { if ( !e.detail.decodedText.includes( "https://portal.lauf-fuer-kaya.de/profile/" ) ) { cardCode = e.detail.decodedText; new Audio("/beep.mp3").play(); state = "assigning"; RunnerCardService.runnerCardControllerGetAll().then((cards) => { console.log(cards); const card = cards.find((c) => c.code === cardCode); if (card) { console.log("card found", card); RunnerCardService.runnerCardControllerPut(card.id, { enabled: true, id: card.id, runner: runnerinfo.id, }).then(() => { state = "done"; }); } else { state = "error_card_404"; } }); } } }} width={320} height={320} class="w-full max-w-sm bg-neutral-300 rounded-lg overflow-hidden" /> {#if state === "scan_card"} {/if} {:else} {#if state === "assigning"}

Assigning Card {cardCode} ⌛

Please wait a moment while we assign the card...

{/if} {#if state === "done"}

Assigned Card {cardCode} to {runnerinfo.firstname} {runnerinfo.lastname} [#{runnerinfo.id}] ✅

{/if} {/if}