From b5b7fe81ba245f85ecc1a67318eeb92a34949861 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 6 Feb 2023 22:52:37 -0800 Subject: fix internal sends --- src/routes/(app)/send/+layout.svelte | 24 +++++++++++- src/routes/(app)/send/[...text]/+page.svelte | 2 +- .../user/[username]/[...amount]/+page.server.js | 6 +-- .../send/user/[username]/[...amount]/+page.svelte | 45 +++++++--------------- 4 files changed, 40 insertions(+), 37 deletions(-) (limited to 'src/routes/(app)/send') diff --git a/src/routes/(app)/send/+layout.svelte b/src/routes/(app)/send/+layout.svelte index c9122466..2fb732e8 100644 --- a/src/routes/(app)/send/+layout.svelte +++ b/src/routes/(app)/send/+layout.svelte @@ -1,18 +1,38 @@ {#if loaded && user.haspin && $pin?.length !== 6} - + {/if} diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index 46f5e56a..cd83ddfc 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -90,7 +90,7 @@

{$t('user.send.contacts')}

{#each contacts as c} - +
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 46172175..42b47c8f 100644 --- a/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js +++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js @@ -4,9 +4,9 @@ import { btc as asset, auth, get, post } from '$lib/utils'; export async function load({ params, parent }) { let { user } = await parent(); let { amount } = params; - let recipient = await get(`/users/${params.username}`); - if (recipient.username === user?.username) throw error(500, { message: 'Cannot send to self' }); - return { amount, recipient }; + let subject = await get(`/users/${params.username}`); + if (subject.username === user?.username) throw error(500, { message: 'Cannot send to self' }); + return { amount, 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 87eba733..9704e3c6 100644 --- a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte @@ -3,14 +3,14 @@ import { goto } from '$app/navigation'; import { pin, selectedRate } from '$lib/store'; import { enhance } from '$app/forms'; - import { Avatar, Icon, Numpad, Spinner } from '$comp'; + import { AppHeader, Avatar, Icon, Numpad, Spinner } from '$comp'; import { page } from '$app/stores'; - import { back, f, post, s, sats } from '$lib/utils'; + import { f, post, s, sat, sats } from '$lib/utils'; export let data; export let form; - let { recipient, rates, user } = data; + let { subject, rates, user } = data; let currency = user?.currency || 'USD'; let amount = form?.amount || data.amount; @@ -24,23 +24,16 @@ amount = a; amountFiat = af; - ({ hash } = await post(`/${recipient.username}/invoice`, { + ({ hash } = await post(`/${subject.username}/invoice`, { invoice: { amount, - rate: rates[recipient.currency], + rate: rates[subject.currency], type: 'internal' }, - user: recipient + user: subject })); }; - let handleBack = () => { - if (amount) { - amount = undefined; - goto(`/send/user/${recipient.username}`); - } else back(); - }; - let loading; let submit = () => (loading = true); @@ -51,9 +44,7 @@ }; - + {#if form?.message}
@@ -63,20 +54,12 @@
{#if amount} -
-

- {fiat ? f(amountFiat, currency) : s(amount)} - {#if !fiat} - sats - {/if} -

- -

to

- -
- -

{recipient.username}

-
+

Sending

+
+

+ {f(amountFiat, currency)} +

+

{sat(amount)}

{:else} @@ -84,7 +67,7 @@
- + -- cgit v1.2.3