From 60b24b3d5951e159d09f42ed766c404e4b1acc4e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 11 Feb 2023 00:38:55 -0800 Subject: invoice type toggle --- .../(app)/[username]/invoice/[hash]/+page.svelte | 43 ++++++++++++++++++++-- .../[username]/payments/[...page]/+page.svelte | 12 +++--- .../[username]/receive/[...param]/+page.svelte | 5 --- src/routes/(app)/payment/[id]/+page.server.js | 4 +- src/routes/(app)/payment/[id]/+page.svelte | 31 +++++++++------- 5 files changed, 65 insertions(+), 30 deletions(-) (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte index ad9721e7..b5571f23 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte @@ -1,12 +1,14 @@
+
+ + + +
{:else if p.with} - -
-
- -
-
{p.with.username}
+
+
+
-
+
{p.with.username}
+
{:else if p.type === types.classic} {amount ? $t('payments.next') : $t('payments.sendersChoice')} - -
- {type[0].toUpperCase() + type.substring(1, type.length)} - -
diff --git a/src/routes/(app)/payment/[id]/+page.server.js b/src/routes/(app)/payment/[id]/+page.server.js index cbd7355e..1c90ab69 100644 --- a/src/routes/(app)/payment/[id]/+page.server.js +++ b/src/routes/(app)/payment/[id]/+page.server.js @@ -1,6 +1,6 @@ import { auth, get } from '$lib/utils'; export async function load({ cookies, params }) { - let tx = await get(`/payments/${params.id}`, auth(cookies)); - return { tx }; + let payment = await get(`/payments/${params.id}`, auth(cookies)); + return { payment }; } diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index a961d14d..da21400a 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -6,33 +6,41 @@ import { PUBLIC_EXPLORER as expl } from '$env/static/public'; export let data; - let { user, tx } = data; + let { user, payment: p } = data; let { username } = user; - let { id, amount, created, rate, type, ref, fee, currency } = tx; + let { id, amount, created, rate, type, ref, fee, currency } = p; fee = fee || 0; - let fiat = (Math.abs(amount) * rate) / sats; + let total = amount > 0 ? amount : -amount + fee; + let fiat = (total * rate) / sats; -
+

{$t(amount < 0 ? 'payments.sent' : 'payments.received')}

+ {#if p.with} +
+
+ +
+
{p.with.username}
+
+ {/if} +
-
{$t('payments.amount')}
{f(fiat, currency)} - ⚡️{`${s(Math.abs(amount) + fee)}`} + ⚡️{`${s(total)}`}
-
{$t('payments.date')}
{format(new Date(created), 'MMMM d')}, {format(new Date(created), 'h:mm aaa')} @@ -46,17 +54,14 @@ {ref}
- {:else} + {:else if type === 'bitcoin'}
-
{$t('payments.id')}
- {id} + {id}
-- cgit v1.2.3