From bc8e1f7a365b16b7d5fe5a77fcc0754b13a40d0c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 26 Sep 2022 23:20:13 -0700 Subject: cleanup --- src/routes/invoice/[id]/+page.svelte | 33 ++++++++----------------------- src/routes/invoice/[id]/paid/+page.svelte | 6 +++++- 2 files changed, 13 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/routes/invoice/[id]/+page.svelte b/src/routes/invoice/[id]/+page.svelte index 26566034..60257ab7 100644 --- a/src/routes/invoice/[id]/+page.svelte +++ b/src/routes/invoice/[id]/+page.svelte @@ -46,27 +46,12 @@ $: tip = Math.round((amount / 100) * tipPercent); $invoices[id] = { amount, id, rate, received, text, tip, username }; - - let checkStatus = () => { - console.log("EH", id, $invoices[id]); - if ($invoices[id]?.received) goto(`/invoice/${id}/paid`); - }; - - - invoices.subscribe((a) => { - setTimeout(checkStatus); - }); + $: $invoices[id]?.received && goto(`/invoice/${id}/paid`); $: amountFiat = parseFloat(((amount * rate) / 100000000).toFixed(2)); $: tipAmount = ((tip * rate) / 100000000).toFixed(2); - $: tipAmountFormatted = f(tipAmount, currency); - - $: tipAmountSats = s(tip); - - $: totalAmountSats = s(amount + parseFloat(tipAmountSats.replace(/,/g, ''))); - let apply = async () => { if (customTipAmount > 0) { tipPercent = (customTipAmount / amountFiat) * 100; @@ -90,8 +75,6 @@ goto(`/invoice/${uuid}`); }; - $: totalAmountFormatted = f(amountFiat + parseFloat(tipAmount), currency); - const amountFormatted = s(amount); $: invoiceAmountFiatFormatted = f(amountFiat, currency); @@ -195,8 +178,8 @@

{$t('invoice.addTipq')}

{#if !showCustomAmount}
- {tipAmountFormatted}{`(${tipAmountSats} SAT)`}{f(tipAmount, currency)}{`(${s(tip)} SAT)`} {Math.round(tipPercent)}%
@@ -322,7 +305,7 @@ Invoice {invoiceAmountFiatFormatted} - {`(${amountFormatted} SAT)`}{`(${s(amount)} SAT)`} @@ -330,8 +313,8 @@ Tip {tipAmountFormatted} - {`(${tipAmountSats} SAT)`}{f(tipAmount, currency)} + {`(${s(tip)} SAT)`} @@ -339,8 +322,8 @@ Total {totalAmountFormatted} - {`(${totalAmountSats} SAT)`}{f(amountFiat + parseFloat(tipAmount), currency)} + {`(${s(tip + amount)} SAT)`} diff --git a/src/routes/invoice/[id]/paid/+page.svelte b/src/routes/invoice/[id]/paid/+page.svelte index e66c4900..04568297 100644 --- a/src/routes/invoice/[id]/paid/+page.svelte +++ b/src/routes/invoice/[id]/paid/+page.svelte @@ -9,8 +9,12 @@ export let data; let { invoice } = data; + let { amount, rate } = invoice; + toast.pop(0); + $: amountFiat = parseFloat(((amount * rate) / 100000000).toFixed(2)); + const handleDoneClick = () => { delete $invoices[invoice.uuid]; goto(`/${invoice.user.username}/receive`); @@ -32,7 +36,7 @@ {/if}

{$t('invoice.paymentSuccessful')}

- {f(invoice.amount, invoice.currency)} + {f(amountFiat, invoice.currency)}

({s(invoice.amount)} SAT)