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)/fund | |
| parent | 3aa9ce1b5985397d7f568887ec6f881df13c1034 (diff) | |
| download | coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.tar.gz coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.zip | |
linting
Diffstat (limited to 'src/routes/(app)/fund')
| -rw-r--r-- | src/routes/(app)/fund/[id]/+layout.server.ts | 14 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.server.ts | 16 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.svelte | 4 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/access/+page.server.ts | 24 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts | 46 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/gift/+page.server.ts | 8 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/gift/+page.svelte | 3 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts | 75 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/withdraw/+page.server.ts | 34 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/withdraw/+server.ts | 2 |
10 files changed, 114 insertions, 112 deletions
diff --git a/src/routes/(app)/fund/[id]/+layout.server.ts b/src/routes/(app)/fund/[id]/+layout.server.ts index 3669eb7d..bf132e7b 100644 --- a/src/routes/(app)/fund/[id]/+layout.server.ts +++ b/src/routes/(app)/fund/[id]/+layout.server.ts @@ -2,11 +2,11 @@ import getRates from "$lib/rates"; import { get } from "$lib/utils"; export const load = async ({ depends, params: { id }, parent }) => { - depends("app:payments"); - const data = await get(`/fund/${id}`); - data.managers = await get(`/fund/${id}/managers`); - const rates = await getRates(); - const { user } = await parent(); - data.rate = rates[user?.currency || "USD"]; - return data; + depends("app:payments"); + const data = await get(`/fund/${id}`); + data.managers = await get(`/fund/${id}/managers`); + const rates = await getRates(); + const { user } = await parent(); + data.rate = rates[user?.currency || "USD"]; + return data; }; diff --git a/src/routes/(app)/fund/[id]/+page.server.ts b/src/routes/(app)/fund/[id]/+page.server.ts index cd2bd979..5a30e560 100644 --- a/src/routes/(app)/fund/[id]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/+page.server.ts @@ -2,14 +2,14 @@ import { auth, post } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; export const actions = { - default: async ({ cookies, locals, params }) => { - const { user } = locals; + default: async ({ cookies, locals, params }) => { + const { user } = locals; - if (user) { - await post("/redeem", params, auth(cookies)); - redirect(307, "/payments"); - } + if (user) { + await post("/redeem", params, auth(cookies)); + redirect(307, "/payments"); + } - redirect(307, "/register"); - }, + redirect(307, "/register"); + }, }; diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index c3fa7ce1..34e0d503 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -21,7 +21,9 @@ let currency = user ? user.currency : "CAD"; let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2))); - $effect(() => { $loginRedirect = $page.url.pathname; }); + $effect(() => { + $loginRedirect = $page.url.pathname; + }); let show = $state(); let toggle = () => (show = !show); diff --git a/src/routes/(app)/fund/[id]/access/+page.server.ts b/src/routes/(app)/fund/[id]/access/+page.server.ts index 36191643..6e995f1c 100644 --- a/src/routes/(app)/fund/[id]/access/+page.server.ts +++ b/src/routes/(app)/fund/[id]/access/+page.server.ts @@ -2,21 +2,21 @@ import { auth, fd, get, post } from "$lib/utils"; import { fail } from "@sveltejs/kit"; export const load = async ({ params: { id } }) => { - const managers = await get(`/fund/${id}/managers`); - return { managers, id }; + const managers = await get(`/fund/${id}/managers`); + return { managers, id }; }; export const actions = { - default: async ({ cookies, request }) => { - const form = await fd(request); + default: async ({ cookies, request }) => { + const form = await fd(request); - try { - const managers = await post("/fund/managers", form, auth(cookies)); + try { + const managers = await post("/fund/managers", form, auth(cookies)); - return { managers }; - } catch (e) { - const { message } = e as Error; - return fail(400, { message }); - } - }, + return { managers }; + } catch (e) { + const { message } = e as Error; + return fail(400, { message }); + } + }, }; diff --git a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts index e5683ae6..94d9ff62 100644 --- a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts @@ -3,34 +3,34 @@ import { auth, get, post, sats } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; export async function load({ cookies, params, parent }) { - const { user } = await parent(); - const { id } = params; - let [amount, currency] = params.amount.split("/"); - let fiat; + const { user } = await parent(); + const { id } = params; + let [amount, currency] = params.amount.split("/"); + let fiat; - if (!currency) currency = user?.currency; + if (!currency) currency = user?.currency; if (currency) currency = currency.toUpperCase(); - const rates = await getRates(); - const rate = rates[currency || "USD"]; - if (currency && !rate) error(500, "Invalid currency symbol"); + const rates = await getRates(); + const rate = rates[currency || "USD"]; + if (currency && !rate) error(500, "Invalid currency symbol"); - if (!amount) { - const balance = await get(`/fund/${id}`); - amount = balance.amount; - } else if (currency) { - fiat = amount; - amount = Math.round((fiat * sats) / rate); - } + if (!amount) { + const balance = await get(`/fund/${id}`); + amount = balance.amount; + } else if (currency) { + fiat = amount; + amount = Math.round((fiat * sats) / rate); + } - if (!amount) redirect(307, `/fund/${id}`); + if (!amount) redirect(307, `/fund/${id}`); - try { - await post("/authorize", { amount, currency, fiat, id }, auth(cookies)); - } catch (e) { - console.log("caught", e); - redirect(307, `/fund/${id}`); - } + try { + await post("/authorize", { amount, currency, fiat, id }, auth(cookies)); + } catch (e) { + console.log("caught", e); + redirect(307, `/fund/${id}`); + } - return { amount, currency, id, rate, rates }; + return { amount, currency, id, rate, rates }; } diff --git a/src/routes/(app)/fund/[id]/gift/+page.server.ts b/src/routes/(app)/fund/[id]/gift/+page.server.ts index bd39d82b..549fc9d0 100644 --- a/src/routes/(app)/fund/[id]/gift/+page.server.ts +++ b/src/routes/(app)/fund/[id]/gift/+page.server.ts @@ -1,6 +1,6 @@ export const load = async ({ params, parent }) => { - const p = await parent(); - const { amount, rate } = p; - const { id } = params; - return { amount, id, rate }; + const p = await parent(); + const { amount, rate } = p; + const { id } = params; + return { amount, id, rate }; }; diff --git a/src/routes/(app)/fund/[id]/gift/+page.svelte b/src/routes/(app)/fund/[id]/gift/+page.svelte index 4e1efad3..9bef9c64 100644 --- a/src/routes/(app)/fund/[id]/gift/+page.svelte +++ b/src/routes/(app)/fund/[id]/gift/+page.svelte @@ -1,7 +1,8 @@ <script lang="ts"> import Amount from "$comp/Amount.svelte"; import { t } from "$lib/translations"; - import { page } from "$app/stores"; import Qr from "$comp/Qr.svelte"; + import { page } from "$app/stores"; + import Qr from "$comp/Qr.svelte"; import { loc, copy } from "$lib/utils"; let { data } = $props(); diff --git a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts index 8cc463c2..82854fb2 100644 --- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts @@ -5,52 +5,51 @@ import { error, redirect } from "@sveltejs/kit"; import { env } from "$env/dynamic/private"; export async function load({ cookies, request, params, parent }) { - let { user } = await parent(); - const { id } = params; - let [amount, currency] = params.amount.split("/"); + let { user } = await parent(); + const { id } = params; + let [amount, currency] = params.amount.split("/"); - if (!currency) currency = user?.currency; - if (currency) currency = currency.toUpperCase(); - const rates = await getRates(); - const rate = rates[currency || "USD"]; - if (currency && !rate) error(500, "Invalid currency symbol"); + if (!currency) currency = user?.currency; + if (currency) currency = currency.toUpperCase(); + const rates = await getRates(); + const rate = rates[currency || "USD"]; + if (currency && !rate) error(500, "Invalid currency symbol"); - if (!amount) { - const balance = await get(`/fund/${id}`); - amount = balance.authorization || balance.amount; - } else if (currency) { - amount = Math.round((amount * sats) / rate); - } + if (!amount) { + const balance = await get(`/fund/${id}`); + amount = balance.authorization || balance.amount; + } else if (currency) { + amount = Math.round((amount * sats) / rate); + } - const username = randomName() + Math.floor(Math.random() * 99) + 1; - const password = randomPassword(); + const username = randomName() + Math.floor(Math.random() * 99) + 1; + const password = randomPassword(); - if (!amount) redirect(307, `/fund/${id}`); - if (!user) { - const ip = request.headers.get("cf-connecting-ip"); + if (!amount) redirect(307, `/fund/${id}`); + if (!user) { + const ip = request.headers.get("cf-connecting-ip"); - user = { - username, - password, - fresh: true, - }; + user = { + username, + password, + fresh: true, + }; - let redirectUrl = `/fund/${id}/sweep`; - if (params.amount && !params.currency) redirectUrl += `/${params.amount}`; - if (params.currency) redirectUrl += `/${params.amount}/params.currency}`; + let redirectUrl = `/fund/${id}/sweep`; + if (params.amount && !params.currency) redirectUrl += `/${params.amount}`; + if (params.currency) redirectUrl += `/${params.amount}/params.currency}`; - const extraHeaders: Record<string, string> = {}; - if (env.INTERNAL_API_KEY) - extraHeaders["x-api-key"] = env.INTERNAL_API_KEY; + const extraHeaders: Record<string, string> = {}; + if (env.INTERNAL_API_KEY) extraHeaders["x-api-key"] = env.INTERNAL_API_KEY; - await register(user, ip, cookies, redirectUrl, undefined, extraHeaders); - } + await register(user, ip, cookies, redirectUrl, undefined, extraHeaders); + } - try { - ({ amount } = await post("/take", { amount, id }, auth(cookies))); - } catch (e) { - redirect(307, `/fund/${id}`); - } + try { + ({ amount } = await post("/take", { amount, id }, auth(cookies))); + } catch { + redirect(307, `/fund/${id}`); + } - return { amount, currency, id, rate, rates, password }; + return { amount, currency, id, rate, rates, password }; } diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.server.ts b/src/routes/(app)/fund/[id]/withdraw/+page.server.ts index 696c52ff..d302b4c1 100644 --- a/src/routes/(app)/fund/[id]/withdraw/+page.server.ts +++ b/src/routes/(app)/fund/[id]/withdraw/+page.server.ts @@ -3,25 +3,25 @@ import { auth, fd, get, post } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; export async function load({ params, parent }) { - const { user } = await parent(); - if (!user) redirect(307, "/register"); - const rates = await getRates(); - const rate = rates[user.currency]; - const fund = await get(`/fund/${params.id}`); - const { amount: balance } = fund; - return { ...params, balance, rate }; + const { user } = await parent(); + if (!user) redirect(307, "/register"); + const rates = await getRates(); + const rate = rates[user.currency]; + const fund = await get(`/fund/${params.id}`); + const { amount: balance } = fund; + return { ...params, balance, rate }; } export const actions = { - default: async ({ cookies, request }) => { - const body = await fd(request); - try { - await post("/take", body, auth(cookies)); - } catch (e) { - const { message } = e as Error; - return fail(400, { message }); - } + default: async ({ cookies, request }) => { + const body = await fd(request); + try { + await post("/take", body, auth(cookies)); + } catch (e) { + const { message } = e as Error; + return fail(400, { message }); + } - redirect(307, `/fund/${body.id}`); - }, + redirect(307, `/fund/${body.id}`); + }, }; diff --git a/src/routes/(app)/fund/[id]/withdraw/+server.ts b/src/routes/(app)/fund/[id]/withdraw/+server.ts index dabef6f8..96d66413 100644 --- a/src/routes/(app)/fund/[id]/withdraw/+server.ts +++ b/src/routes/(app)/fund/[id]/withdraw/+server.ts @@ -2,5 +2,5 @@ import { json } from "@sveltejs/kit"; import { auth, post } from "$lib/utils"; export async function POST({ cookies, request }) { - return json(await post("/take", await request.json(), auth(cookies))); + return json(await post("/take", await request.json(), auth(cookies))); } |
