From 388f820bfc073efb4f66c1aa2394fa5a4b8a8709 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 23 Feb 2023 15:47:31 -0800 Subject: show tips for sender --- .../[username]/invoice/[hash]/paid/+page.svelte | 29 +++++++++++---------- src/routes/(app)/payment/[id]/+page.svelte | 20 ++++++++++++--- .../bitcoin/[address]/[...amount]/+page.server.js | 2 +- .../bitcoin/[address]/[...amount]/+page.svelte | 30 +++++++++++++--------- .../(app)/send/pot/[name]/[...amount]/+page.svelte | 2 +- src/routes/(app)/sent/+page.svelte | 26 ++++++++++++++----- 6 files changed, 72 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte index 432b137a..3a281728 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte @@ -4,7 +4,7 @@ import { toast } from '@zerodevx/svelte-toast'; import { browser } from '$app/environment'; import { t } from '$lib/translations'; - import { f, s, sat, sats } from '$lib/utils'; + import { fiat, f, s, sat, sats } from '$lib/utils'; import { goto } from '$app/navigation'; export let data; @@ -12,10 +12,6 @@ $: data && ({ amount, currency, rate, received, pending, tip, user, id } = data.invoice); toast.pop(0); - - $: amountFiat = parseFloat((((received - tip) * rate) / sats).toFixed(2)); - $: pendingFiat = parseFloat((((pending - tip) * rate) / sats).toFixed(2)); - $: tipFiat = parseFloat(((tip * rate) / sats).toFixed(2));
@@ -25,15 +21,20 @@ {#if received}

{$t('invoice.paymentSuccessful')}

- {f(amountFiat, currency)} + {f(fiat(received - tip, rate), currency)} {#if tip} - + {f(tipFiat, currency)} + + + {f(fiat(tip, rate), currency)} + {/if}

- {sat(received - tip)} + ⚡️{s(received - tip)} + {#if tip} - +{sat(tip)} + + + ⚡️{s(tip)} + {/if}

{/if} @@ -41,15 +42,17 @@ {#if pending}

Payment detected

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

- {sat(pending - tip)} + ⚡️{s(pending - tip)} {#if tip} - +{sat(tip)} + + + ⚡️{s(tip)} + {/if}

{/if} diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 2988ddb5..b8a23605 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -8,7 +8,7 @@ export let data; let { user, payment: p } = data; let { username } = user; - let { id, amount, created, rate, type, ref, ourfee, fee, currency } = p; + let { id, amount, created, rate, type, ref, tip, ourfee, fee, currency } = p; let a = Math.abs(amount); fee = fee || 0; @@ -26,12 +26,14 @@ {#if p.with}
{amount > 0 ? 'From' : 'To'} +
-
{p.with.username}
+
{p.with.username}
+
{/if} @@ -39,7 +41,19 @@ Amount
{f(fiat(a, rate), currency)} - ⚡️{`${s(a)}`} + {#if tip} + + + {f(fiat(tip, rate), currency)} + + {/if} + ⚡️{`${s(a)}`} + + {#if tip} + + + ⚡️{s(tip)} + + {/if} +
diff --git a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js b/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js index 6fbe9c7c..92a754ae 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js +++ b/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js @@ -23,7 +23,7 @@ export const actions = { seen[ts] = 1; setTimeout(() => delete seen[ts], 30000); - await post('/bitcoin/send', { pin, tx }, auth(cookies)); + await post('/bitcoin/send', { pin, subtract, tx }, auth(cookies)); } catch (e) { return fail(400, { message: e.message }); } diff --git a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte index 0a6733de..b3a944f4 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte @@ -4,7 +4,7 @@ import { enhance } from '$app/forms'; import { Toggle, Slider, Icon, Numpad, Spinner } from '$comp'; import { page } from '$app/stores'; - import { fiat as af, f, back, s, sat } from '$lib/utils'; + import { fiat as toFiat, f, back, s, sat } from '$lib/utils'; import { pin, selectedRate } from '$lib/store'; export let data; @@ -12,15 +12,17 @@ let { address, amount } = $page.params; let { balance, currency } = data.user; - let loading, submit, fiat, confirmed, feeRate, min, max, fee, stale, subtract; + let loading, submit, fiat, confirmed, feeRate, min, max, fee, ourfee, stale, subtract, adjusting; let toggle = () => (loading = true); + let toggleAdjusting = () => (adjusting = !adjusting); $: update(form); let update = () => { loading = false; if (form?.message?.includes('pin')) $pin = undefined; - if (form) ({ min, max, feeRate, fee, subtract } = form); + if (form) ({ min, max, feeRate, fee, ourfee, subtract } = form); + if (!ourfee) ourfee = 0; if (feeRate) confirmed = true; stale = false; }; @@ -57,22 +59,26 @@

{$t('payments.send')}

-
{address}
+
{address}
{#if confirmed}

- {f(af(amount, $selectedRate), currency)} + {f(toFiat(amount, $selectedRate), currency)}

-

{sat(amount)}

+

⚡️{s(amount)}

with fee

-

- {f(af(fee, $selectedRate), currency)} -

-

{sat(fee)}

+ +
+

+ {f(toFiat(fee + ourfee, $selectedRate), currency)} +

+

⚡️{s(fee + ourfee)}

+ +
{:else} @@ -88,7 +94,7 @@ - {#if confirmed} + {#if confirmed && adjusting}
Slower (~40 blocks)
Faster (~1 block)
@@ -98,7 +104,7 @@
- +
{/if} diff --git a/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte b/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte index bb11ddde..da761cc2 100644 --- a/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte @@ -16,7 +16,7 @@ let submit = () => (loading = true); $: update(form); let update = () => { - if (form?.message.includes('pin')) $pin = undefined; + if (form?.message?.includes('pin')) $pin = undefined; loading = false; }; diff --git a/src/routes/(app)/sent/+page.svelte b/src/routes/(app)/sent/+page.svelte index 79a0aa6e..72511487 100644 --- a/src/routes/(app)/sent/+page.svelte +++ b/src/routes/(app)/sent/+page.svelte @@ -1,5 +1,5 @@ @@ -23,12 +22,25 @@

Sent!

- {f(fiat, user.currency)} + {f(fiat(amount, rate), currency)} + {#if tip} + + + {f(fiat(tip, rate), currency)} + + {/if}

-

{sat(amount)}

+

+ ⚡️{s(amount)} + + {#if tip} + + + ⚡️{s(tip)} + + {/if} +

- +
-- cgit v1.2.3