aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte34
-rw-r--r--src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte8
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.server.js3
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.svelte6
-rw-r--r--src/routes/(app)/send/user/[username]/[...amount]/+page.svelte2
5 files changed, 30 insertions, 23 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index d807e75b..6dfde23a 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -115,24 +115,26 @@
</button>
</div>
{/if}
+ {/if}
- {#if !subject.anon && subject.username !== user?.username}
- <div class="w-full flex">
- <a
- href={user ? `/send/${subject.username}` : `/${subject.username}/receive`}
- class="mx-auto"
- >
- <button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
- <div class="mx-auto flex">
- <Icon icon="send" style="mr-2" />
- <div class="mt-1">{$t('user.pay')}</div>
- </div>
- </button>
- </a>
- </div>
- {/if}
-
+ {#if !subject.anon && subject.username !== user?.username}
<div class="w-full flex">
+ <a
+ href={user ? `/send/${subject.username}` : `/${subject.username}/receive`}
+ class="mx-auto"
+ >
+ <button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
+ <div class="mx-auto flex">
+ <Icon icon="send" style="mr-2" />
+ <div class="mt-1">{$t('user.pay')}</div>
+ </div>
+ </button>
+ </a>
+ </div>
+ {/if}
+
+ {#if user && user.username !== subject.username && subject.pubkey}
+ <div class="w-full flex">
<a href={`/${subject.username}/messages`} class="mx-auto">
<button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
<div class="mx-auto flex">
diff --git a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte
index 9d9021a6..c0b504f8 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte
@@ -56,7 +56,7 @@
export let data;
$: refresh(data);
- let { invoice, id, user } = data;
+ let { invoice, id, user, rates } = data;
let {
amount,
hash,
@@ -82,17 +82,19 @@
amount,
hash,
type,
- rate,
received,
prompt,
text,
tip,
- user: { username, currency }
+ user: { username }
} = invoice);
tipPercent = (tip / amount) * 100;
};
+ $: currency = user?.currency || invoice.currency;
+ $: rate = invoice.rate * (rates[currency] / rates[invoice.currency]);
+
$: tip = Math.round((amount / 100) * tipPercent);
$: amountFiat = parseFloat(((amount * rate) / sats).toFixed(2));
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.js b/src/routes/(app)/send/invoice/[id]/+page.server.js
index c9c2b222..50e72d94 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.server.js
+++ b/src/routes/(app)/send/invoice/[id]/+page.server.js
@@ -7,6 +7,7 @@ export async function load({ params: { id }, parent, url }) {
let {
amount,
address,
+ currency,
hash,
rate,
prompt,
@@ -17,7 +18,7 @@ export async function load({ params: { id }, parent, url }) {
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' });
- return { amount, address, hash, tip, rate, payreq: text, recipient };
+ return { amount, address, currency, hash, tip, rate, payreq: text, recipient };
}
export const actions = {
diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte
index c9cb9392..d2471891 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/send/invoice/[id]/+page.svelte
@@ -9,8 +9,8 @@
export let data;
export let form;
- let { address, payreq, recipient, rate, tip, user } = data;
- let { currency } = user;
+ let { address, rate, payreq, recipient, tip, rates, user } = data;
+ let { currency } = user;
let amount = form?.amount || data.amount;
let a,
@@ -26,6 +26,8 @@
let loading;
let submit = () => (loading = true);
+ $: rate = data.rate * (rates[user.currency] / rates[data.currency]);
+
$: update(form);
let update = () => {
if (form?.message.includes('pin')) $pin = undefined;
diff --git a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte
index af6a6368..6562de8a 100644
--- a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte
+++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte
@@ -11,7 +11,7 @@
export let form;
let { subject, rates, user } = data;
- let currency = user?.currency || 'USD';
+ let currency = subject.currency || 'USD';
let amount = form?.amount || data.amount;
let a,