aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/invoice
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-11 17:51:24 -0800
committerAdam Soltys <[email protected]>2026-02-11 17:51:24 -0800
commit13466248004327e9a026cb89f94926f9b060d1c1 (patch)
tree47b4972c33809ccdf866b043c92cd3e0ecf5dcd0 /src/routes/(app)/invoice
parent3aa9ce1b5985397d7f568887ec6f881df13c1034 (diff)
downloadcoinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.tar.gz
coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.zip
linting
Diffstat (limited to 'src/routes/(app)/invoice')
-rw-r--r--src/routes/(app)/invoice/+page.server.ts38
-rw-r--r--src/routes/(app)/invoice/+server.ts14
-rw-r--r--src/routes/(app)/invoice/[id]/+layout.server.ts66
-rw-r--r--src/routes/(app)/invoice/[id]/+page.server.ts2
-rw-r--r--src/routes/(app)/invoice/[id]/memo/+page.server.ts2
-rw-r--r--src/routes/(app)/invoice/[id]/tip/+page.server.ts84
-rw-r--r--src/routes/(app)/invoice/[id]/tip/+page.svelte6
-rw-r--r--src/routes/(app)/invoice/sent/+page.svelte3
8 files changed, 106 insertions, 109 deletions
diff --git a/src/routes/(app)/invoice/+page.server.ts b/src/routes/(app)/invoice/+page.server.ts
index 64c49ebc..dc024229 100644
--- a/src/routes/(app)/invoice/+page.server.ts
+++ b/src/routes/(app)/invoice/+page.server.ts
@@ -4,29 +4,29 @@ import { auth, post } from "$lib/utils";
import { error, redirect } from "@sveltejs/kit";
export const load = async ({ cookies, parent }) => {
- const aid = cookies.get("aid");
- let { subject, user } = await parent();
+ const aid = cookies.get("aid");
+ let { subject, user } = await parent();
- const rates = await getRates();
- if (aid === user.id) redirect(307, `/${user.username}/receive`);
+ const rates = await getRates();
+ if (aid === user.id) redirect(307, `/${user.username}/receive`);
- let invoice: Invoice = {
- aid,
- rate: rates[user?.currency || subject?.currency],
- };
+ let invoice: Invoice = {
+ aid,
+ rate: rates[user?.currency || subject?.currency],
+ };
- if (!user) user = subject;
+ if (!user) user = subject;
- try {
- invoice = await post("/invoice", { invoice, aid, user }, auth(cookies));
- } catch (e) {
- console.log(e);
- error(500, "Failed to generate invoice");
- }
+ try {
+ invoice = await post("/invoice", { invoice, aid, user }, auth(cookies));
+ } catch (e) {
+ console.log(e);
+ error(500, "Failed to generate invoice");
+ }
- const { id } = invoice;
+ const { id } = invoice;
- if (invoice.memoPrompt && !invoice.memo) {
- redirect(307, `/invoice/${id}/memo`);
- } else redirect(307, `/invoice/${id}`);
+ if (invoice.memoPrompt && !invoice.memo) {
+ redirect(307, `/invoice/${id}/memo`);
+ } else redirect(307, `/invoice/${id}`);
};
diff --git a/src/routes/(app)/invoice/+server.ts b/src/routes/(app)/invoice/+server.ts
index f494c153..b18eae15 100644
--- a/src/routes/(app)/invoice/+server.ts
+++ b/src/routes/(app)/invoice/+server.ts
@@ -2,11 +2,11 @@ import { auth, post } from "$lib/utils";
import { error, json } from "@sveltejs/kit";
export const POST = async ({ cookies, request }) => {
- try {
- const body = await request.json();
- return json(await post("/invoice", body, auth(cookies)));
- } catch (e) {
- const { message } = e as Error;
- error(500, message);
- }
+ try {
+ const body = await request.json();
+ return json(await post("/invoice", body, auth(cookies)));
+ } catch (e) {
+ const { message } = e as Error;
+ error(500, message);
+ }
};
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts
index ce76d150..d6ee4246 100644
--- a/src/routes/(app)/invoice/[id]/+layout.server.ts
+++ b/src/routes/(app)/invoice/[id]/+layout.server.ts
@@ -2,43 +2,43 @@ 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");
- const token = cookies.get("token");
- let { subject, user } = await parent();
- const { 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}`);
- const options = !!url.searchParams.get("options");
- let { amount, pending, received } = invoice;
- amount = parseInt(amount);
+ if (id) {
+ invoice = await get(`/invoice/${id}`);
+ const options = !!url.searchParams.get("options");
+ let { amount, pending, received } = invoice;
+ amount = parseInt(amount);
- 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" : ""));
- }
+ 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" : ""));
+ }
- subject = invoice.user;
+ subject = invoice.user;
- const aid = cookies.get("aid") || user?.id;
- if (
- user &&
- (invoice.uid !== user?.id || aid !== invoice.aid) &&
- !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
- !options
- ) {
- if (invoice.prompt && invoice.tip === null)
- redirect(307, `/invoice/${id}/tip`);
- else {
- redirect(307, `/send/invoice/${id}`);
- }
- }
- }
+ const aid = cookies.get("aid") || user?.id;
+ if (
+ user &&
+ (invoice.uid !== user?.id || aid !== invoice.aid) &&
+ !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
+ !options
+ ) {
+ if (invoice.prompt && invoice.tip === null)
+ redirect(307, `/invoice/${id}/tip`);
+ else {
+ redirect(307, `/send/invoice/${id}`);
+ }
+ }
+ }
- const theme = cookies.get("theme") || "light";
- return { id, invoice, subject, user, token, theme };
+ const theme = cookies.get("theme") || "light";
+ return { id, invoice, subject, user, token, theme };
}
diff --git a/src/routes/(app)/invoice/[id]/+page.server.ts b/src/routes/(app)/invoice/[id]/+page.server.ts
index d54ff30d..a57efa64 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 d54ff30d..a57efa64 100644
--- a/src/routes/(app)/invoice/[id]/memo/+page.server.ts
+++ b/src/routes/(app)/invoice/[id]/memo/+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]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts
index 851d3f1b..16cc22fa 100644
--- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts
+++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts
@@ -3,53 +3,53 @@ import { auth, fd, get, post } from "$lib/utils";
import { fail, redirect } from "@sveltejs/kit";
export async function load({ cookies, params, parent }) {
- const { id } = params;
- const rates = await getRates();
- let { invoice, subject, user } = await parent();
- if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`);
- const pin = cookies.get("pin");
+ const { id } = params;
+ const rates = await getRates();
+ let { invoice, subject, user } = await parent();
+ if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`);
+ const pin = cookies.get("pin");
- if (user) {
- const trust = await get("/trust", auth(cookies));
- const trusted = trust.includes(invoice.uid);
- if (trusted && (pin || !user.haspin)) {
- let p;
- try {
- if (invoice.tip === null && invoice.user.prompt) {
- if (user.tip > 0) {
- invoice.tip = Math.round(invoice.amount * (user.tip / 100));
- invoice = await post(`/invoice/${id}`, { invoice }, auth(cookies));
- p = await post("/payments", { ...invoice, pin }, auth(cookies));
- }
- } else {
- p = await post("/payments", { ...invoice, pin }, auth(cookies));
- }
- } catch (e) {
- const { message } = e as Error;
- fail(400, { message });
- }
- if (p) redirect(307, `/sent/${p.id}`);
- }
- }
+ if (user) {
+ const trust = await get("/trust", auth(cookies));
+ const trusted = trust.includes(invoice.uid);
+ if (trusted && (pin || !user.haspin)) {
+ let p;
+ try {
+ if (invoice.tip === null && invoice.user.prompt) {
+ if (user.tip > 0) {
+ invoice.tip = Math.round(invoice.amount * (user.tip / 100));
+ invoice = await post(`/invoice/${id}`, { invoice }, auth(cookies));
+ p = await post("/payments", { ...invoice, pin }, auth(cookies));
+ }
+ } else {
+ p = await post("/payments", { ...invoice, pin }, auth(cookies));
+ }
+ } catch (e) {
+ const { message } = e as Error;
+ fail(400, { message });
+ }
+ if (p) redirect(307, `/sent/${p.id}`);
+ }
+ }
- const rate = rates[subject?.currency];
- const invoiceRate = rates[invoice.currency];
- return { rate, invoiceRate };
+ const rate = rates[subject?.currency];
+ const invoiceRate = rates[invoice.currency];
+ return { rate, invoiceRate };
}
export const actions = {
- default: async ({ cookies, request }) => {
- const form = await fd(request);
- const invoice = {
- tip: form.tip ?? null,
- };
+ default: async ({ cookies, request }) => {
+ const form = await fd(request);
+ const invoice = {
+ tip: form.tip ?? null,
+ };
- const { id } = await post(
- `/invoice/${form.id}`,
- { invoice },
- auth(cookies),
- );
+ const { id } = await post(
+ `/invoice/${form.id}`,
+ { invoice },
+ auth(cookies),
+ );
- redirect(307, `/invoice/${id}`);
- },
+ redirect(307, `/invoice/${id}`);
+ },
};
diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte
index 4d3af188..1183093e 100644
--- a/src/routes/(app)/invoice/[id]/tip/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte
@@ -173,11 +173,7 @@
</div>
{/if}
- <button
- type="submit"
- bind:this={submit}
- aria-label="Submit tip"
- ></button>
+ <button type="submit" bind:this={submit} aria-label="Submit tip"></button>
</form>
{#if showCustomAmount}
diff --git a/src/routes/(app)/invoice/sent/+page.svelte b/src/routes/(app)/invoice/sent/+page.svelte
index f8a05801..457ff108 100644
--- a/src/routes/(app)/invoice/sent/+page.svelte
+++ b/src/routes/(app)/invoice/sent/+page.svelte
@@ -1,5 +1,6 @@
<script lang="ts">
- import Avatar from "$comp/Avatar.svelte"; import { request } from "$lib/store";
+ import Avatar from "$comp/Avatar.svelte";
+ import { request } from "$lib/store";
</script>
Invoice sent to