From d87ecae6ee46af4790e1f57cd5d82a35ab29e646 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 19 Jul 2025 17:59:56 -0700 Subject: prompt for tip for auto pays --- src/routes/(app)/send/invoice/[id]/+page.server.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/routes/(app)/send') diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index ac3c910e..38507343 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -15,17 +15,22 @@ export async function load({ cookies, depends, params: { id }, parent }) { if (trusted && (pin || !user.haspin)) { let p; try { - if (!invoice.tip && invoice.user.prompt && user.tip > 0) { - invoice.tip = Math.round(invoice.amount * (user.tip / 100)); - invoice = await post( - "/invoice", - { invoice, user: subject }, - auth(cookies), - ); + if (!invoice.tip && invoice.user.prompt) { + if (user.tip > 0) { + invoice.tip = Math.round(invoice.amount * (user.tip / 100)); + invoice = await post( + "/invoice", + { invoice, user: subject }, + auth(cookies), + ); + } else { + throw new Error("tip"); + } } p = await post("/payments", { ...invoice, pin }, auth(cookies)); } catch (e) { const { message } = e as Error; + if (message === "tip") redirect(307, `/invoice/${id}/tip`); fail(400, { message }); } if (p) redirect(307, `/sent/${p.id}`); -- cgit v1.2.3