aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-10-07 23:30:52 -0700
committerAdam Soltys <[email protected]>2023-10-07 23:30:52 -0700
commit222bbc9080fbb15861cc5c0802449fcf06a53532 (patch)
tree95f9ef93daacf8f9b5bf7e5f3a181b46747f08df /src
parent6b7f03fcf87d346f8e25a954220570da5b9a5c3d (diff)
downloadcoinos-ui-222bbc9080fbb15861cc5c0802449fcf06a53532.tar.gz
coinos-ui-222bbc9080fbb15861cc5c0802449fcf06a53532.zip
fix more options invoices
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/+layout.server.js (renamed from src/routes/(app)/[username]/invoice/[hash]/+layout.server.js)20
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/+layout.svelte (renamed from src/routes/(app)/[username]/invoice/[hash]/+layout.svelte)0
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/+page.server.js (renamed from src/routes/(app)/[username]/invoice/[hash]/+page.server.js)0
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/+page.svelte (renamed from src/routes/(app)/[username]/invoice/[hash]/+page.svelte)0
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte (renamed from src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte)1
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js (renamed from src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js)0
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte (renamed from src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte)0
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.svelte15
8 files changed, 21 insertions, 15 deletions
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[id]/+layout.server.js
index eef24555..4d7fd3b8 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js
+++ b/src/routes/(app)/[username]/invoice/[id]/+layout.server.js
@@ -6,20 +6,26 @@ export async function load({ depends, params, url, parent }) {
depends('app:invoice');
let { user } = await parent();
- let { hash } = params;
- let invoice = await get(`/invoice/${hash}`);
+ let { id } = params;
+ let invoice = await get(`/invoice/${id}`);
+ let options = !!url.searchParams.get('options');
- if (user && invoice.uid !== user.id && !url.pathname.includes('tip') && !url.searchParams.get('options'))
- throw redirect(307, `/send/invoice/${hash}`);
+ if (user && invoice.uid !== user.id && !url.pathname.includes('tip') && !options) {
+ throw redirect(307, `/send/invoice/${id}`);
+ }
let { amount, pending, received } = invoice;
amount = parseInt(amount);
let paid = (!amount && received) || (amount > 0 && (pending >= amount || received >= amount));
- if (paid && !url.pathname.endsWith('paid'))
- throw redirect(307, `/${params.username}/invoice/${hash}/paid`);
+ if (paid && !url.pathname.endsWith('paid')) {
+ throw redirect(
+ 307,
+ `/${params.username}/invoice/${id}/paid` + (options ? '?options=true' : '')
+ );
+ }
let sm = Qr.drawImg(invoice.text || '', { size: 300 });
- return { hash, invoice, sm, lg: sm };
+ return { id, invoice, sm, lg: sm };
}
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.svelte b/src/routes/(app)/[username]/invoice/[id]/+layout.svelte
index 4fa864ce..4fa864ce 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+layout.svelte
+++ b/src/routes/(app)/[username]/invoice/[id]/+layout.svelte
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.server.js b/src/routes/(app)/[username]/invoice/[id]/+page.server.js
index 1068f273..1068f273 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+page.server.js
+++ b/src/routes/(app)/[username]/invoice/[id]/+page.server.js
diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/+page.svelte
index 508550ba..508550ba 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[id]/+page.svelte
diff --git a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte
index 969fb6c7..84e493d9 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte
@@ -5,7 +5,6 @@
import { browser } from '$app/environment';
import { t } from '$lib/translations';
import { fiat, f, s, sat, sats } from '$lib/utils';
- import { goto } from '$app/navigation';
export let data;
let amount, currency, rate, received, pending, tip, user, id;
diff --git a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js b/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js
index 814900fb..814900fb 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js
+++ b/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js
diff --git a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte
index fe6c67be..fe6c67be 100644
--- a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte
diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte
index 554eef6f..a71c697a 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/send/invoice/[id]/+page.svelte
@@ -28,12 +28,13 @@
let submit = () => (loading = true);
let external = async () => {
- let invoice = { type: 'lightning', amount };
- let { hash } = await post(`/${recipient.username}/invoice`, {
- invoice
+ let invoice = { type: 'lightning', amount, currency };
+ let {id }= await post(`/${recipient.username}/invoice`, {
+ invoice,
+ user: { username: recipient.username }
});
- goto(`/${recipient.username}/invoice/${hash}`, { invalidateAll: true });
+ goto(`/${recipient.username}/invoice/${id}?options=true`, { invalidateAll: true });
};
$: rate = data.rate * (rates[user.currency] / rates[data.currency]);
@@ -139,7 +140,7 @@
{/if}
</div>
</form>
- <div class="flex my-20">
- <button class="mx-auto" on:click={external}>{$t('payments.moreOptions')}</button>
- </div>
+ <div class="flex my-20">
+ <button class="mx-auto" on:click={external}>{$t('payments.moreOptions')}</button>
+ </div>
</div>