diff options
| author | Adam Soltys <[email protected]> | 2026-02-11 17:51:24 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 17:51:24 -0800 |
| commit | 13466248004327e9a026cb89f94926f9b060d1c1 (patch) | |
| tree | 47b4972c33809ccdf866b043c92cd3e0ecf5dcd0 /src/routes/(app)/pay | |
| parent | 3aa9ce1b5985397d7f568887ec6f881df13c1034 (diff) | |
| download | coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.tar.gz coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.zip | |
linting
Diffstat (limited to 'src/routes/(app)/pay')
| -rw-r--r-- | src/routes/(app)/pay/[username]/[...amount]/+page.server.ts | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts b/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts index 9c2b1e3b..23918cb3 100644 --- a/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts +++ b/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts @@ -3,69 +3,69 @@ import { auth, fd, get, post, sats, types } from "$lib/utils"; import { error, fail, redirect } from "@sveltejs/kit"; export async function load({ cookies, params, parent }) { - const { username } = params; - const { user } = await parent(); - const rates = await getRates(); + const { username } = params; + const { user } = await parent(); + const rates = await getRates(); - if (user?.username === username) redirect(307, `/${username}/receive`); - const subject = await get(`/users/${username}`); + if (user?.username === username) redirect(307, `/${username}/receive`); + const subject = await get(`/users/${username}`); - let [amount, currency] = params.amount.split("/"); + let [amount, currency] = params.amount.split("/"); - const rate = rates[currency ? currency.toUpperCase() : subject.currency]; - if (currency && !rate) error(500, "Invalid currency symbol"); + const rate = rates[currency ? currency.toUpperCase() : subject.currency]; + if (currency && !rate) error(500, "Invalid currency symbol"); - if (amount) { - if (currency) amount = (amount * sats) / rate; + if (amount) { + if (currency) amount = (amount * sats) / rate; - const { id } = await post( - "/invoice", - { - invoice: { - amount, - currency: currency === subject.currency ? currency : undefined, - prompt: false, - rate: currency === subject.currency ? rate : undefined, - type: types.lightning, - }, - user: { username }, - }, - auth(cookies), - ); + const { id } = await post( + "/invoice", + { + invoice: { + amount, + currency: currency === subject.currency ? currency : undefined, + prompt: false, + rate: currency === subject.currency ? rate : undefined, + type: types.lightning, + }, + user: { username }, + }, + auth(cookies), + ); - redirect(307, `/invoice/${id}`); - } + redirect(307, `/invoice/${id}`); + } - return { amount, rate, subject }; + return { amount, rate, subject }; } export const actions = { - default: async ({ cookies, request }) => { - let id; - const body = await fd(request); - const { amount, rate, prompt, type, username } = body; + default: async ({ cookies, request }) => { + let id; + const body = await fd(request); + const { amount, rate, prompt, type, username } = body; - try { - ({ id } = await post( - "/invoice", - { - invoice: { - amount, - rate, - prompt, - type, - }, - user: { username }, - }, - auth(cookies), - )); - } catch (e) { - const { message } = e as Error; - return fail(400, { message }); - } + try { + ({ id } = await post( + "/invoice", + { + invoice: { + amount, + rate, + prompt, + type, + }, + user: { username }, + }, + auth(cookies), + )); + } catch (e) { + const { message } = e as Error; + return fail(400, { message }); + } - if (parseInt(amount) > 0 && prompt) redirect(307, `/invoice/${id}/tip`); - else if (parseInt(amount) <= 0) redirect(307, `/${username}/receive`); - redirect(307, `/invoice/${id}`); - }, + if (parseInt(amount) > 0 && prompt) redirect(307, `/invoice/${id}/tip`); + else if (parseInt(amount) <= 0) redirect(307, `/${username}/receive`); + redirect(307, `/invoice/${id}`); + }, }; |
