aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/invoice
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-13 23:18:40 -0700
committerAdam Soltys <[email protected]>2022-09-13 23:18:40 -0700
commitdfe32780e0862515eb4b2ddebae9fcfb2198704a (patch)
treef8b463ccc51291393c71cc3c95ca3725c74d341b /src/routes/invoice
parentcfdc6ed4a98e1eb60aba653d4403138a8fcaa4c2 (diff)
downloadcoinos-ui-dfe32780e0862515eb4b2ddebae9fcfb2198704a.tar.gz
coinos-ui-dfe32780e0862515eb4b2ddebae9fcfb2198704a.zip
currency formatting helpers
Diffstat (limited to 'src/routes/invoice')
-rw-r--r--src/routes/invoice/[id]/+page.svelte26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/routes/invoice/[id]/+page.svelte b/src/routes/invoice/[id]/+page.svelte
index df25c359..978e2b9a 100644
--- a/src/routes/invoice/[id]/+page.svelte
+++ b/src/routes/invoice/[id]/+page.svelte
@@ -1,12 +1,11 @@
<script>
import { LottiePlayer } from '@lottiefiles/svelte-lottie-player';
- import { get, post, reverseFormat } from '$lib/utils';
+ import { copy, f, get, post, reverseFormat, s } from '$lib/utils';
import { browser } from '$app/environment';
import { invoices, user } from '$lib/store';
import { Icon, Image, Qr } from '$comp';
import { goto, invalidate } from '$app/navigation';
import { onMount, tick } from 'svelte';
- import { copy } from '$lib/utils';
import { t } from '$lib/translations';
export let data;
@@ -49,14 +48,11 @@
$: tipAmount = ((tip * rate) / 100000000).toFixed(2);
- $: tipAmountFormatted = new Intl.NumberFormat('en-US', {
- style: 'currency',
- currency
- }).format(tipAmount);
+ $: tipAmountFormatted = f(tipAmount, currency);
- $: tipAmountSats = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(tip);
+ $: tipAmountSats = s(tip);
- $: totalAmountSats = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(
+ $: totalAmountSats = s(
amount + parseFloat(tipAmountSats.replace(/,/g, ''))
);
@@ -79,19 +75,11 @@
goto(`/invoice/${r}`);
};
- $: totalAmountFormatted = new Intl.NumberFormat('en-US', {
- style: 'currency',
- currency
- }).format(amountFiat + parseFloat(tipAmount));
+ $: totalAmountFormatted = f(amountFiat + parseFloat(tipAmount), currency);
- const amountFormatted = new Intl.NumberFormat('en-US', {
- maximumFractionDigits: 0
- }).format(amount);
+ const amountFormatted = f(amount, currency);
- $: invoiceAmountFiatFormatted = new Intl.NumberFormat('en-US', {
- style: 'currency',
- currency
- }).format(amountFiat);
+ $: invoiceAmountFiatFormatted = f(amountFiat, currency);
let customTipAmount;