aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/+layout.server.js4
-rw-r--r--src/routes/(app)/[username]/invoice/[id]/+page.svelte21
2 files changed, 19 insertions, 6 deletions
diff --git a/src/routes/(app)/[username]/invoice/[id]/+layout.server.js b/src/routes/(app)/[username]/invoice/[id]/+layout.server.js
index c9920052..41554c9f 100644
--- a/src/routes/(app)/[username]/invoice/[id]/+layout.server.js
+++ b/src/routes/(app)/[username]/invoice/[id]/+layout.server.js
@@ -5,7 +5,7 @@ import { redirect } from "@sveltejs/kit";
export async function load({ depends, params, url, parent }) {
depends("app:invoice");
- let { user } = await parent();
+ let { subject, user } = await parent();
let { id } = params;
let invoice = await get(`/invoice/${id}`);
let options = !!url.searchParams.get("options");
@@ -35,5 +35,5 @@ export async function load({ depends, params, url, parent }) {
let src = Qr.drawImg(invoice.text || "", { size: 340 });
- return { id, invoice, src };
+ return { id, invoice, subject, src };
}
diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/+page.svelte
index 9ad3fa14..cdffd199 100644
--- a/src/routes/(app)/[username]/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/[username]/invoice/[id]/+page.svelte
@@ -38,7 +38,7 @@
let readingerror = (e) => console.log("nfc error", e);
$: refresh(data);
- let { invoice, id, user, src } = data;
+ let { invoice, id, subject, user, src } = data;
let {
amount,
hash,
@@ -121,15 +121,22 @@
let setAmount = async () => {
settingAmount = false;
- invoice.amount = amount;
+ amount = newAmount;
+ invoice.amount = newAmount;
+ invoice.tip = 0;
({ id } = await post(`/${username}/invoice`, {
invoice,
user: { username, currency },
}));
- goto(`./${id}?options=true`, { invalidateAll: true, noScroll: true });
+ let url = `./${id}`;
+ if (subject?.prompt) url += "/tip";
+ else url += "?options=true";
+
+ goto(url, { invalidateAll: true, noScroll: true });
};
+ let newAmount;
let settingAmount;
let toggleAmount = () => (settingAmount = !settingAmount);
let fiat;
@@ -306,7 +313,13 @@
class="relative top-1/3 mx-auto p-12 border w-96 shadow-lg rounded-md bg-white space-y-5"
>
<form submit={setAmount}>
- <Numpad bind:amount bind:currency bind:rate bind:fiat bind:submit />
+ <Numpad
+ bind:amount={newAmount}
+ bind:currency
+ bind:rate
+ bind:fiat
+ bind:submit
+ />
<div class="w-full flex flex-wrap gap-2">
<button
type="submit"