aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/user
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-07 23:30:21 -0800
committerAdam Soltys <[email protected]>2023-03-07 23:30:21 -0800
commit90b84cbd4eb1465e30898a2ff3fd604ff8ec7cf1 (patch)
treedb87303cfbe06f609e266e87dc17d91b6143c436 /src/routes/(app)/send/user
parentb0217c7b18a042056cc4461823f15a7a77bc51c2 (diff)
downloadcoinos-ui-90b84cbd4eb1465e30898a2ff3fd604ff8ec7cf1.tar.gz
coinos-ui-90b84cbd4eb1465e30898a2ff3fd604ff8ec7cf1.zip
fix rate for internal payments
Diffstat (limited to 'src/routes/(app)/send/user')
-rw-r--r--src/routes/(app)/send/user/[username]/[...amount]/+page.server.js3
-rw-r--r--src/routes/(app)/send/user/[username]/[...amount]/+page.svelte10
2 files changed, 6 insertions, 7 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 18eda839..c63328e2 100644
--- a/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js
+++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js
@@ -13,9 +13,6 @@ export const actions = {
default: async ({ cookies, request }) => {
try {
let body = await fd(request);
- let { amount } = body;
- amount = parseInt(amount);
-
await post('/payments', body, auth(cookies));
} catch (e) {
console.log(e);
diff --git a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte
index 74da1fa8..1bb88277 100644
--- a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte
+++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte
@@ -17,14 +17,16 @@
let a,
af,
fiat = !amount,
- hash;
+ hash,
+ rate,
+ amountFiat = 0;
- $: amountFiat = amount * ($selectedRate / sats);
+ selectedRate.subscribe((r) => rate || (amountFiat = amount * (r / sats)));
let setAmount = async () => {
amount = a;
- amountFiat = af;
-
+ amountFiat = parseFloat(af).toFixed(2);
+ rate = fiat ? (sats * amountFiat) / amount : $selectedRate;
({ hash } = await post(`/${subject.username}/invoice`, {
invoice: {
amount,