From 5800a0b4909e662ddfeb21a0ddb72bbe0f0be2e7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Sep 2022 20:49:45 -0700 Subject: fix tips again --- src/routes/invoice/[id]/+page.svelte | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/routes/invoice/[id]/+page.svelte b/src/routes/invoice/[id]/+page.svelte index bb34a421..56511d15 100644 --- a/src/routes/invoice/[id]/+page.svelte +++ b/src/routes/invoice/[id]/+page.svelte @@ -41,6 +41,8 @@ tipPercent = (tip / amount) * 100; }; + $: tip = Math.round((amount / 100) * tipPercent); + $invoices[id] = { amount, id, rate, status, text, tip, username }; $: amountFiat = parseFloat(((amount * rate) / 100000000).toFixed(2)); @@ -60,16 +62,6 @@ amount + parseFloat(tipAmountSats.replace(/,/g, '')) ); - $: updateTip(tipPercent); - let updateTip = (tipPercent) => { - tip = Math.round((amount / 100) * tipPercent); - tipAmountSats = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(tip); - tipAmount = ((tip * rate) / 100000000).toFixed(2); - tipAmountFormatted = new Intl.NumberFormat('en-US', { - style: 'currency', - currency - }).format(tipAmount); - }; let apply = async () => { tipPercent = (customTipAmount / amountFiat) * 100; @@ -210,8 +202,8 @@