From dce12a5ccff91bd2b985c9664ca29a4c1a083cf2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 21 Mar 2023 09:58:45 -0700 Subject: pin code refactor --- src/components/Balance.svelte | 35 ++++++++++++++++-------- src/components/Pin.svelte | 62 +++++++++++++++++++++++++++++++------------ src/components/Pinpad.svelte | 3 +-- 3 files changed, 70 insertions(+), 30 deletions(-) (limited to 'src/components') diff --git a/src/components/Balance.svelte b/src/components/Balance.svelte index cc923b7d..fddaae3e 100644 --- a/src/components/Balance.svelte +++ b/src/components/Balance.svelte @@ -1,21 +1,34 @@ +{#if show && user.haspin && $pin?.length !== 6} + +{/if} +
-
- {#if isNaN($animatedRate)} -
—
- {:else} - {f((user.balance * $animatedRate) / sats, user.currency)} - {/if} -
+ {#if user.haspin && !$pin} + + {:else} +
+ {#if isNaN($animatedRate)} +
—
+ {:else} + {f((user.balance * $animatedRate) / sats, user.currency)} + {/if} +
-
- ⚡️{s(user.balance)} -
+
+ ⚡️{s(user.balance)} +
+ {/if}
diff --git a/src/components/Pin.svelte b/src/components/Pin.svelte index 1d7ed65b..40a53b8b 100644 --- a/src/components/Pin.svelte +++ b/src/components/Pin.svelte @@ -1,31 +1,59 @@ -
-
-

{title}

- -
- +{#if loaded} +
+
+

{title}

+ +
+ +
-
+{/if} diff --git a/src/components/Pinpad.svelte b/src/components/Pinpad.svelte index bf3778f7..f55dc40d 100644 --- a/src/components/Pinpad.svelte +++ b/src/components/Pinpad.svelte @@ -1,7 +1,6 @@ {#each users as { balance, username, expected }} -
+
{username}
{balance}
{expected}
+
+
+ +
{/each} -- cgit v1.2.3 From f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 29 Mar 2023 08:08:41 -0700 Subject: currency display --- src/components/Lnurlp.svelte | 6 ++++-- src/components/Lnurlw.svelte | 5 +++-- src/components/Numpad.svelte | 14 +++++++------- .../(app)/[username]/receive/[...param]/+page.svelte | 5 +++-- .../(app)/send/bitcoin/[address]/[...amount]/+page.svelte | 11 +++++++---- src/routes/(app)/send/lightning/[payreq]/+page.svelte | 5 +++-- src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte | 5 ++++- .../(app)/send/user/[username]/[...amount]/+page.server.js | 5 +++-- .../(app)/send/user/[username]/[...amount]/+page.svelte | 8 ++++---- 9 files changed, 38 insertions(+), 26 deletions(-) (limited to 'src/components') diff --git a/src/components/Lnurlp.svelte b/src/components/Lnurlp.svelte index ab0c50ce..9918a3f4 100644 --- a/src/components/Lnurlp.svelte +++ b/src/components/Lnurlp.svelte @@ -6,7 +6,9 @@ export let data, form; let { currency } = data.user; - let { minSendable, maxSendable, callback, metadata } = data; + let { minSendable, maxSendable, callback, metadata, rates } = data; + + $: rate = rates[currency]; let amount = Math.round(minSendable / 1000), loading; @@ -33,7 +35,7 @@
{/if} - +
diff --git a/src/components/Lnurlw.svelte b/src/components/Lnurlw.svelte index f2855b53..f780d755 100644 --- a/src/components/Lnurlw.svelte +++ b/src/components/Lnurlw.svelte @@ -7,7 +7,8 @@ export let data, form; let { currency, username } = data.user; - let { defaultDescription, minWithdrawable, maxWithdrawable, k1, callback } = data; + let { defaultDescription, minWithdrawable, maxWithdrawable, k1, callback, rates } = data; + $: rate = rates[currency]; let amount = Math.round(maxWithdrawable / 1000), loading; @@ -28,7 +29,7 @@
{/if} - + diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 77a4f38b..20bfe561 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -7,17 +7,19 @@ export let amount, currency, fiat = !amount, + rate, submit = undefined; export let amountFiat = 0; + let arrow = '<'; $: update(amount, amountFiat); let update = (a, f) => { if (fiat) { - amount = Math.round(f / ($selectedRate / sats)); + amount = Math.round(f / (rate / sats)); } else { - amountFiat = ((a * $selectedRate) / sats).toFixed(2); + amountFiat = ((a * rate) / sats).toFixed(2); } }; @@ -60,7 +62,7 @@ amount = 0; } } - } else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > $selectedRate) { + } else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > rate) { warning($t('user.receive.lessThan1BTCWarning')); } else if (amountFiat !== 0 && amountFiat.match(/\.../)) { return; @@ -184,12 +186,10 @@ type="button" on:click={() => { if (fiat) { - amount = parseInt((amountFiat / ($selectedRate / sats)).toFixed(0)); + amount = parseInt((amountFiat / (rate / sats)).toFixed(0)); } else { amountFiat = - (amount * ($selectedRate / sats)).toFixed(2) > 0.0 - ? (amount * ($selectedRate / sats)).toFixed(2) - : 0; + (amount * (rate / sats)).toFixed(2) > 0.0 ? (amount * (rate / sats)).toFixed(2) : 0; } fiat = !fiat; }}> @@ -37,7 +38,7 @@
- +
{:else} - + {/if} diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte index af07a565..cb1b539e 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte @@ -10,13 +10,14 @@ export let form; let { payreq } = $page.params; - let { alias } = data; + let { alias, rates } = data; let { currency } = data.user; let a; let maxfee = 100; $: amount = form?.amount || data.amount; + $: rate = rates[currency]; let loading; let submit = () => (loading = true); @@ -91,7 +92,7 @@ {:else} - + - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
1
- Bitcoin -
-
= {f(animatedRate, user.currency)}
-
-
-
-
⚡️{s((1 * sats) / animatedRate)} =
-
{f(1, user.currency)}
-
-
-
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js index 7cf87e14..04d413bb 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js +++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js @@ -12,10 +12,12 @@ export async function load({ depends, params, url, parent }) { if (user && invoice.uid !== user.id && !url.pathname.includes('tip')) throw redirect(307, `/send/invoice/${hash}`); - let { amount, received } = invoice; + let { amount, pending, received } = invoice; amount = parseInt(amount); - let paid = (!amount && received) || (amount > 0 && received >= amount); + console.log("PENDING", pending) + + let paid = (!amount && received) || (amount > 0 && (pending >= amount || received >= amount)); if (paid && !url.pathname.endsWith('paid')) throw redirect(307, `/${params.username}/invoice/${hash}/paid`); diff --git a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte index 4d7aae51..c9619cee 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte @@ -21,7 +21,7 @@ {#if received}

{$t('invoice.paymentSuccessful')}

- {f(fiat(received, rate), currency)} + {f(fiat(received - tip, rate), currency)} {#if tip} + {f(fiat(tip, rate), currency)} @@ -29,7 +29,7 @@ {/if}

- ⚡️{s(received)} + ⚡️{s(received - tip)} {#if tip} @@ -42,13 +42,13 @@ {#if pending}

Payment detected

- {f(fiat(pending, rate), currency)} + {f(fiat(pending - tip, rate), currency)} {#if tip} + {f(fiat(tip, rate), currency)} {/if}

- ⚡️{s(pending)} + ⚡️{s(pending - tip)} {#if tip} + ⚡️{s(tip)} diff --git a/src/routes/(app)/buy/+page.svelte b/src/routes/(app)/buy/+page.svelte index 2f556ada..22e7e9ec 100644 --- a/src/routes/(app)/buy/+page.svelte +++ b/src/routes/(app)/buy/+page.svelte @@ -1,7 +1,7 @@
@@ -141,7 +123,6 @@
1
Bitcoin
-
= {f($animatedRate, currency)}

3% credit card fee applies

diff --git a/src/routes/(app)/launch/purchase/+page.svelte b/src/routes/(app)/launch/purchase/+page.svelte index 3273752a..fbaa58c0 100644 --- a/src/routes/(app)/launch/purchase/+page.svelte +++ b/src/routes/(app)/launch/purchase/+page.svelte @@ -1,7 +1,6 @@ {#if need2fa} - + {/if}
-- cgit v1.2.3