aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-11 10:21:02 -0800
committerAdam Soltys <[email protected]>2023-03-11 10:21:02 -0800
commit2810139cfb19643527c8be4589ab1562c441f618 (patch)
treee702122608f9f40ebfc1b6834b97bfe90d8281af /src
parent555eedf7804cf5fa4f963b7fcffeee4f97c0c911 (diff)
downloadcoinos-ui-2810139cfb19643527c8be4589ab1562c441f618.tar.gz
coinos-ui-2810139cfb19643527c8be4589ab1562c441f618.zip
prompt for tip on internal payments
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.server.js14
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.svelte24
-rw-r--r--src/routes/(app)/sent/+page.server.js1
3 files changed, 29 insertions, 10 deletions
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.js b/src/routes/(app)/send/invoice/[id]/+page.server.js
index 3db03123..c3ae0945 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.server.js
+++ b/src/routes/(app)/send/invoice/[id]/+page.server.js
@@ -1,22 +1,26 @@
import { error, fail, redirect } from '@sveltejs/kit';
import { fd, auth, get, post } from '$lib/utils';
-export async function load({ params: { id }, parent }) {
+export async function load({ params: { id }, parent, url }) {
let { user } = await parent();
- let { amount, address, tip, text, user: recipient } = await get(`/invoice/${id}`);
+ let { amount, address, rate, prompt, tip, text, user: recipient } = await get(`/invoice/${id}`);
+
+ console.log("AMOUNT, TIP", amount, tip)
+
+ if (prompt && tip === null) throw redirect(307, `/${recipient.username}/invoice/${id}/tip`);
if (recipient.username === user.username) throw error(500, { message: 'Cannot send to self' });
- if (tip) amount += tip;
- return { amount, address, payreq: text, recipient };
+ return { amount, address, tip, rate, payreq: text, recipient };
}
export const actions = {
default: async ({ cookies, params: { hash }, request }) => {
try {
let body = await fd(request);
- body.amount = parseInt(body.amount);
body.hash = hash;
+ console.log("SENDING BODY", body)
+
await post('/payments', body, auth(cookies));
} catch (e) {
return fail(400, { message: e.message });
diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte
index 7570a61a..c9cb9392 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/send/invoice/[id]/+page.svelte
@@ -5,11 +5,11 @@
import { enhance } from '$app/forms';
import { Avatar, Icon, Numpad, Spinner } from '$comp';
import { page } from '$app/stores';
- import { back, f, s, sats } from '$lib/utils';
+ import { back, f, fiat as toFiat, s, sats } from '$lib/utils';
export let data;
export let form;
- let { address, payreq, recipient, user } = data;
+ let { address, payreq, recipient, rate, tip, user } = data;
let { currency } = user;
let amount = form?.amount || data.amount;
@@ -49,9 +49,23 @@
<h1 class="text-xl md:text-2xl text-secondary mb-2">
{$t('payments.send')}
</h1>
- <p class="text-6xl break-words mb-4">
- {fiat ? f(amountFiat, currency) : '⚡️' + s(amount)}
- </p>
+ <h2 class="text-2xl md:text-3xl font-semibold">
+ {f(toFiat(amount, rate), currency)}
+ {#if tip}
+ <span class="text-lg">
+ + {f(toFiat(tip, rate), currency)}
+ </span>
+ {/if}
+ </h2>
+ <h3 class="text-secondary md:text-lg mb-6 mt-1">
+ ⚡️{s(amount)}
+
+ {#if tip}
+ <span class="text-lg">
+ + ⚡️{s(tip)}
+ </span>
+ {/if}
+ </h3>
<h1 class="text-xl md:text-2xl text-secondary mb-2">{$t('payments.to')}</h1>
diff --git a/src/routes/(app)/sent/+page.server.js b/src/routes/(app)/sent/+page.server.js
index 381ff32f..cfd43472 100644
--- a/src/routes/(app)/sent/+page.server.js
+++ b/src/routes/(app)/sent/+page.server.js
@@ -2,5 +2,6 @@ import { get, auth } from '$lib/utils';
export let load = async ({ cookies }) => {
let { payments } = await get('/payments', auth(cookies));
+ console.log("HUH", payments[0])
return { payments };
};