diff options
| author | Adam Soltys <[email protected]> | 2024-10-31 09:34:16 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-31 09:34:16 -0700 |
| commit | 243abb0a3d29e8e34e263eec843488e3bdb468a4 (patch) | |
| tree | be55931ba0f3c110c3001f56a5339cb63e78b761 /src/routes/(app)/invoice | |
| parent | 4742e72ec25823ceeea7848fb2e1f868bed7f472 (diff) | |
| download | coinos-ui-243abb0a3d29e8e34e263eec843488e3bdb468a4.tar.gz coinos-ui-243abb0a3d29e8e34e263eec843488e3bdb468a4.zip | |
biome
Diffstat (limited to 'src/routes/(app)/invoice')
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+layout.server.ts | 56 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+page.server.ts | 2 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/memo/+page.server.ts | 10 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/tip/+page.server.ts | 10 |
4 files changed, 39 insertions, 39 deletions
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts index bad43c97..a844b928 100644 --- a/src/routes/(app)/invoice/[id]/+layout.server.ts +++ b/src/routes/(app)/invoice/[id]/+layout.server.ts @@ -3,38 +3,38 @@ import { get } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; export async function load({ cookies, depends, params, url, parent }) { - depends("app:invoice"); + depends("app:invoice"); - let token = cookies.get("token"); - let { subject, user } = await parent(); - let { id } = params; - let invoice; + const token = cookies.get("token"); + let { subject, user } = await parent(); + const { id } = params; + let invoice; - if (id) { - invoice = await get(`/invoice/${id}`); - let options = !!url.searchParams.get("options"); + if (id) { + invoice = await get(`/invoice/${id}`); + const options = !!url.searchParams.get("options"); - if ( - user && - invoice.uid !== user.id && - !(url.pathname.includes("tip") || url.pathname.includes("memo")) && - !options - ) { - redirect(307, `/send/invoice/${id}`); - } + if ( + user && + invoice.uid !== user.id && + !(url.pathname.includes("tip") || url.pathname.includes("memo")) && + !options + ) { + redirect(307, `/send/invoice/${id}`); + } - let { amount, pending, received } = invoice; - amount = parseInt(amount); - subject = user || invoice.user; + let { amount, pending, received } = invoice; + amount = parseInt(amount); + subject = user || invoice.user; - let paid = - (!amount && (pending || received)) || - (amount > 0 && (pending >= amount || received >= amount)); - if (paid && !url.pathname.endsWith("paid")) { - redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : "")); - } - } + const paid = + (!amount && (pending || received)) || + (amount > 0 && (pending >= amount || received >= amount)); + if (paid && !url.pathname.endsWith("paid")) { + redirect(307, `/invoice/${id}/paid` + (options ? "?options=true" : "")); + } + } - let src = Qr.drawImg(invoice?.text || "", { size: 500 }); - return { id, invoice, subject, src, user, token }; + const src = Qr.drawImg(invoice?.text || "", { size: 500 }); + return { id, invoice, subject, src, user, token }; } diff --git a/src/routes/(app)/invoice/[id]/+page.server.ts b/src/routes/(app)/invoice/[id]/+page.server.ts index a57efa64..d54ff30d 100644 --- a/src/routes/(app)/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/+page.server.ts @@ -1,5 +1,5 @@ import invoice from "$lib/invoice"; export const actions = { - default: invoice, + default: invoice, }; diff --git a/src/routes/(app)/invoice/[id]/memo/+page.server.ts b/src/routes/(app)/invoice/[id]/memo/+page.server.ts index 24dec1af..a2609658 100644 --- a/src/routes/(app)/invoice/[id]/memo/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/memo/+page.server.ts @@ -2,12 +2,12 @@ import invoice from "$lib/invoice"; import { redirect } from "@sveltejs/kit"; export async function load({ parent, params }) { - let { invoice } = await parent(); - if (!invoice.amount) { - redirect(307, `/invoice/${invoice.id}`); - } + const { invoice } = await parent(); + if (!invoice.amount) { + redirect(307, `/invoice/${invoice.id}`); + } } export const actions = { - default: invoice, + default: invoice, }; diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts index f5a1b220..a1ba8924 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts @@ -3,13 +3,13 @@ import invoice from "$lib/invoice"; import { redirect } from "@sveltejs/kit"; export async function load({ parent }) { - let rates = await get("/rates"); - let { invoice } = await parent(); - if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`); + const rates = await get("/rates"); + const { invoice } = await parent(); + if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`); - return { rates }; + return { rates }; } export const actions = { - default: invoice, + default: invoice, }; |
