diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Numpad.svelte | 27 | ||||
| -rw-r--r-- | src/lib/store.ts | 1 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+page.svelte | 3 | ||||
| -rw-r--r-- | src/routes/(static)/login/+page.server.ts | 2 |
4 files changed, 16 insertions, 17 deletions
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 07d1ef4c..1cd59abe 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -1,13 +1,14 @@ <script> + import { onMount } from "svelte"; + import { fiat } from "$lib/store"; import Left from "$comp/Left.svelte"; import Icon from "$comp/Icon.svelte"; import { f, s, focus, warning, sat, sats } from "$lib/utils"; import { t } from "$lib/translations"; - export let amount, + export let amount = 0, currency, element, - fiat = !amount, rate, submit = undefined; @@ -17,7 +18,7 @@ $: update(amount, amountFiat); let update = (a, f) => { - if (fiat) { + if ($fiat) { amount = Math.round(f / (rate / sats)); } else { amountFiat = ((a * rate) / sats).toFixed(2); @@ -49,7 +50,7 @@ if (selecting) amount = 0; selecting = false; - if (fiat) { + if ($fiat) { if (amountFiat === 0 && value !== "." && value !== "<" && value !== "0") { amountFiat = value; } else if ((amountFiat === 0 || amountFiat === "0") && value === "0") { @@ -102,7 +103,7 @@ } }; - $: html = fiat ? amountFiat : s(amount); + $: html = $fiat ? amountFiat : s(amount); let prev = ""; @@ -122,7 +123,7 @@ .replace(/\./g, "") .replace("F", "."); - if (fiat) clean = clean.replace(",", ""); + if ($fiat) clean = clean.replace(",", ""); if (clean !== html) { html = clean; i = html.length; @@ -134,7 +135,7 @@ i--; } - if (fiat) { + if ($fiat) { amountFiat = html; } else { amount = parseInt(html.replace(/,/g, "")); @@ -143,7 +144,7 @@ if (!amount) amount = null; setTimeout(() => { - if (!fiat) { + if (!$fiat) { let p = prev.split(",")[0].length; if (html.length > prev.length && p === 3) i++; if (html.length < prev.length && p === 1 && i > 1) i--; @@ -183,7 +184,7 @@ e.key === "Enter" && (e.preventDefault() || submit.click()); let swap = () => { - if (fiat) { + if ($fiat) { amount = parseInt((amountFiat / (rate / sats)).toFixed(0)); } else { amountFiat = @@ -191,7 +192,7 @@ ? (amount * (rate / sats)).toFixed(2) : 0; } - fiat = !fiat; + $fiat = !$fiat; }; </script> @@ -201,8 +202,8 @@ <div class="text-5xl md:text-6xl font-semibold tracking-widest flex justify-center" > - <div class="my-auto" class:text-5xl={!fiat}> - {fiat ? symbol : "⚡️"} + <div class="my-auto" class:text-5xl={!$fiat}> + {$fiat ? symbol : "⚡️"} </div> <div use:focus @@ -220,7 +221,7 @@ class="flex items-center justify-center text-2xl cursor-pointer" on:click|preventDefault|stopPropagation={swap} > - {fiat ? "⚡️" + s(amount) : f(amountFiat, currency)} + {$fiat ? "⚡️" + s(amount) : f(amountFiat, currency)} </div> </div> diff --git a/src/lib/store.ts b/src/lib/store.ts index e294329e..2532018d 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -44,6 +44,7 @@ export const avatar = writable(); export const banner = writable(); export const event = writable(); export const events = writable({}); +export const fiat = persistLocal("fiat", true); export const installPrompt = writable(); export const invoice = writable(); export const last = writable(); diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte index c87d972b..4a838433 100644 --- a/src/routes/(app)/invoice/[id]/+page.svelte +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -81,11 +81,10 @@ if (subject?.prompt) url += "/tip"; else url += "?options=true"; - console.log("GO", url); goto(url, { invalidateAll: true, noScroll: true }); }); - let newAmount = $state(); + let newAmount = $state(0); let settingAmount = $state(); let toggleAmount = $state(() => (settingAmount = !settingAmount)); let fiat = $state(true); diff --git a/src/routes/(static)/login/+page.server.ts b/src/routes/(static)/login/+page.server.ts index d06c4895..f77f24f2 100644 --- a/src/routes/(static)/login/+page.server.ts +++ b/src/routes/(static)/login/+page.server.ts @@ -12,8 +12,6 @@ export const actions = { let { username, password, token, loginRedirect } = form; const user = { username, password, token }; - console.log("LOGIN", user, form); - if (loginRedirect === "undefined") loginRedirect = undefined; try { |
