diff options
| author | Adam Soltys <[email protected]> | 2022-09-26 23:20:13 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-26 23:20:13 -0700 |
| commit | bc8e1f7a365b16b7d5fe5a77fcc0754b13a40d0c (patch) | |
| tree | 014c1740c3aed16cd2efe41197124cd21989460c | |
| parent | 577f74832a1122c16bb2c747eab5acc07dbc7410 (diff) | |
| download | coinos-ui-bc8e1f7a365b16b7d5fe5a77fcc0754b13a40d0c.tar.gz coinos-ui-bc8e1f7a365b16b7d5fe5a77fcc0754b13a40d0c.zip | |
cleanup
| -rw-r--r-- | src/routes/invoice/[id]/+page.svelte | 33 | ||||
| -rw-r--r-- | src/routes/invoice/[id]/paid/+page.svelte | 6 |
2 files changed, 13 insertions, 26 deletions
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 @@ <h1 class="hidden md:block text-4xl font-semibold">{$t('invoice.addTipq')}</h1> {#if !showCustomAmount} <div> - <span class="font-semibold mr-1">{tipAmountFormatted}</span><span - class="text-secondary font-semibold text-sm">{`(${tipAmountSats} SAT)`}</span + <span class="font-semibold mr-1">{f(tipAmount, currency)}</span><span + class="text-secondary font-semibold text-sm">{`(${s(tip)} SAT)`}</span > <span class="block text-secondary text-sm">{Math.round(tipPercent)}%</span> </div> @@ -322,7 +305,7 @@ <span class="font-semibold text-sm">Invoice</span> <span class="font-semibold text-sm" >{invoiceAmountFiatFormatted} - <span class="text-secondary font-normal">{`(${amountFormatted} SAT)`}</span></span + <span class="text-secondary font-normal">{`(${s(amount)} SAT)`}</span></span > </div> @@ -330,8 +313,8 @@ <!-- found missing translation ---> <span class="font-semibold text-sm">Tip</span> <span class="font-semibold text-sm" - >{tipAmountFormatted} - <span class="text-secondary font-normal">{`(${tipAmountSats} SAT)`}</span></span + >{f(tipAmount, currency)} + <span class="text-secondary font-normal">{`(${s(tip)} SAT)`}</span></span > </div> @@ -339,8 +322,8 @@ <!-- found missing translation ---> <span class="font-bold mr-1">Total</span> <span class="font-bold" - >{totalAmountFormatted} - <span class="text-secondary font-normal">{`(${totalAmountSats} SAT)`}</span></span + >{f(amountFiat + parseFloat(tipAmount), currency)} + <span class="text-secondary font-normal">{`(${s(tip + amount)} SAT)`}</span></span > </div> </div> 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} <h1 class="text-3xl md:text-4xl font-bold mb-6">{$t('invoice.paymentSuccessful')}</h1> <h2 class="text-2xl md:text-3xl font-semibold"> - {f(invoice.amount, invoice.currency)} + {f(amountFiat, invoice.currency)} </h2> <h3 class="text-secondary md:text-lg mb-6 mt-1">({s(invoice.amount)} SAT)</h3> <button |
