diff options
| author | Adam Soltys <[email protected]> | 2022-09-13 20:49:45 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-13 20:49:45 -0700 |
| commit | 5800a0b4909e662ddfeb21a0ddb72bbe0f0be2e7 (patch) | |
| tree | ee720c160a0b1292988eaf5db30c4546622057ec /src | |
| parent | 08892d218602c4bed671bfa632991eaa9511709c (diff) | |
| download | coinos-ui-5800a0b4909e662ddfeb21a0ddb72bbe0f0be2e7.tar.gz coinos-ui-5800a0b4909e662ddfeb21a0ddb72bbe0f0be2e7.zip | |
fix tips again
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/invoice/[id]/+page.svelte | 16 |
1 files changed, 4 insertions, 12 deletions
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 @@ <button class="bg-primary w-16 md:w-20 py-3 m-1 rounded-2xl font-semibold {customTipAmount ? '' - : tipPercent === amount.slice(0, 2) || - ((tipPercent === 0 || tipPercent === '0') && amount === 'None') + : Math.round(tipPercent) === parseInt(amount.slice(0, 2)) || + (!tipPercent && amount === 'None') ? '!bg-black text-white' : ''}" on:click={() => handleTipButtonClick(amount)}>{amount}</button |
