diff options
| author | Adam Soltys <[email protected]> | 2023-12-01 20:04:13 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-01 20:04:13 -0800 |
| commit | 216a600224fde22ce76b367557a02094ec693886 (patch) | |
| tree | d1189bbaa39db204633523132a7d4767b952717d /src/components/Pin.svelte | |
| parent | 7d9bc1f54dfd04172e8d6d43ebc2efd6f407e833 (diff) | |
| download | coinos-ui-216a600224fde22ce76b367557a02094ec693886.tar.gz coinos-ui-216a600224fde22ce76b367557a02094ec693886.zip | |
prettier
Diffstat (limited to 'src/components/Pin.svelte')
| -rw-r--r-- | src/components/Pin.svelte | 98 |
1 files changed, 51 insertions, 47 deletions
diff --git a/src/components/Pin.svelte b/src/components/Pin.svelte index 0cff904f..bd51cb0a 100644 --- a/src/components/Pin.svelte +++ b/src/components/Pin.svelte @@ -1,59 +1,63 @@ <script> - import { t } from '$lib/translations'; - import { post, success, fail, focus } from '$lib/utils'; - import { Pinpad } from '$comp'; - import { pin } from '$lib/store'; - import { onMount } from 'svelte'; + import { t } from "$lib/translations"; + import { post, success, fail, focus } from "$lib/utils"; + import { Pinpad } from "$comp"; + import { pin } from "$lib/store"; + import { onMount } from "svelte"; - export let value = ''; - export let title = $t('user.settings.verifyPIN'); - export let cancel = () => (p = ''); - export let persist = true; - export let notify = true; + export let value = ""; + export let title = $t("user.settings.verifyPIN"); + export let cancel = () => (p = ""); + export let persist = true; + export let notify = true; - let p = ''; + let p = ""; - $: update(value); - let update = (value) => (p = value); + $: update(value); + let update = (value) => (p = value); - $: p.toString().length > 5 && (value = p.toString()); + $: p.toString().length > 5 && (value = p.toString()); - let loaded; - onMount(() => setTimeout(() => (loaded = true), 500)); + let loaded; + onMount(() => setTimeout(() => (loaded = true), 500)); - $: loaded && checkPin(p); - let checkPin = async (p) => { - if (p?.length !== 6) return; - let result; - try { - result = await post('/pin', { pin: p }); - } catch (e) { - console.log('Pin check failed', e); - } + $: loaded && checkPin(p); + let checkPin = async (p) => { + if (p?.length !== 6) return; + let result; + try { + result = await post("/pin", { pin: p }); + } catch (e) { + console.log("Pin check failed", e); + } - if (result) { - if (notify) success('Pin confirmed'); - if (persist) $pin = p; - } else { - fail('Invalid pin'); - value = ''; - } - }; + if (result) { + if (notify) success("Pin confirmed"); + if (persist) $pin = p; + } else { + fail("Invalid pin"); + value = ""; + } + }; </script> {#if loaded} - <div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50"> - <div class="relative top-40 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white space-y-5"> - <h1 class="text-center text-2xl font-semibold">{title}</h1> - <Pinpad bind:v={p} {cancel} /> - <div class="w-full flex"> - <button - class="border-2 border-black rounded-xl font-semibold mx-auto py-3 w-40 hover:opacity-80 mx-auto" - on:click|preventDefault={cancel} - > - <div class="my-auto">Cancel</div> - </button> - </div> - </div> - </div> + <div + class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50" + > + <div + class="relative top-40 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white space-y-5" + > + <h1 class="text-center text-2xl font-semibold">{title}</h1> + <Pinpad bind:v={p} {cancel} /> + <div class="w-full flex"> + <button + class="border-2 border-black rounded-xl font-semibold mx-auto py-3 w-40 hover:opacity-80 mx-auto" + on:click|preventDefault={cancel} + > + <div class="my-auto">Cancel</div> + </button> + </div> + </div> + </div> {/if} |
