diff options
| author | Adam Soltys <[email protected]> | 2023-03-29 08:08:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-29 08:08:41 -0700 |
| commit | f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8 (patch) | |
| tree | 2b838c3cf248b7d570459f7c5831e864be367a25 /src/routes/(app)/send/user | |
| parent | b51467da14e6a3def3ce12681b5222bf49484cd5 (diff) | |
| download | coinos-ui-f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8.tar.gz coinos-ui-f4507d0758c5e3e5e879d70cb1c5dbdbfd2186e8.zip | |
currency display
Diffstat (limited to 'src/routes/(app)/send/user')
| -rw-r--r-- | src/routes/(app)/send/user/[username]/[...amount]/+page.server.js | 5 | ||||
| -rw-r--r-- | src/routes/(app)/send/user/[username]/[...amount]/+page.svelte | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js b/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js index ba758036..a01cdcfc 100644 --- a/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js +++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js @@ -10,8 +10,9 @@ export async function load({ cookies, params, parent }) { if (subject.username === user?.username) throw error(500, { message: 'Cannot send to self' }); + let rate; if (amount) { - let rate = rates[currency ? currency.toUpperCase() : subject.currency]; + rate = rates[currency ? currency.toUpperCase() : subject.currency]; if (!rate) throw error(500, 'Invalid currency symbol'); if (currency) amount = (amount * sats) / rate; @@ -27,7 +28,7 @@ export async function load({ cookies, params, parent }) { throw redirect(307, `/${username}/invoice/${hash}`); } - return { amount, subject }; + return { amount, rate, subject }; } export const actions = { diff --git a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte index 6562de8a..2f59f492 100644 --- a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte @@ -10,18 +10,18 @@ export let data; export let form; - let { subject, rates, user } = data; - let currency = subject.currency || 'USD'; + let { subject, rate, rates, user } = data; + let currency = user.currency || subject.currency || 'USD'; let amount = form?.amount || data.amount; let a, af, fiat = !amount, hash, - rate, amountFiat = 0; selectedRate.subscribe((r) => rate || (amountFiat = amount * (r / sats))); + $: r = rate || rates[user.currency || subject.currency]; let setAmount = async () => { amount = a; @@ -60,7 +60,7 @@ {/if} <div class="container px-4 mt-20 max-w-xl mx-auto space-y-8"> - <Numpad bind:amount={a} bind:amountFiat={af} {currency} bind:fiat /> + <Numpad bind:amount={a} bind:amountFiat={af} {currency} bind:fiat bind:rate={r} /> <form method="POST" use:enhance on:submit={submit}> <input name="amount" value={amount} type="hidden" /> |
