diff options
| author | Adam Soltys <[email protected]> | 2025-07-19 17:59:56 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-19 18:07:57 -0700 |
| commit | d87ecae6ee46af4790e1f57cd5d82a35ab29e646 (patch) | |
| tree | 5fa86b7b8902315f625eca493861f3ad97de5a5c /src/routes/(app)/send | |
| parent | fea147df07046f240e77075e7c743959d85b1271 (diff) | |
| download | coinos-ui-d87ecae6ee46af4790e1f57cd5d82a35ab29e646.tar.gz coinos-ui-d87ecae6ee46af4790e1f57cd5d82a35ab29e646.zip | |
prompt for tip for auto pays
Diffstat (limited to 'src/routes/(app)/send')
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.ts | 19 |
1 files changed, 12 insertions, 7 deletions
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}`); |
