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 --- src/routes/(app)/payment/[id]/+page.server.js | 4 ++-- src/routes/(app)/payment/[id]/+page.svelte | 31 ++++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'src/routes/(app)/payment') 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