aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-25 15:19:16 -0700
committerAdam Soltys <[email protected]>2026-11-25 15:19:16 -0700
commitd707d2c696184b5ad90132cb0a4b5673d15d6644 (patch)
treecd29a6907b2fb7c859610a752544cda360f65a85 /src/routes/(app)
parenta5de0f07779a5ecdf30c9a2411e0d5ee4360997c (diff)
downloadcoinos-ui-d707d2c696184b5ad90132cb0a4b5673d15d6644.tar.gz
coinos-ui-d707d2c696184b5ad90132cb0a4b5673d15d6644.zip
Fund page: show the discontinued notice only when someone acts on a fund
The history is shown without the notice. Manage, and old sweep, authorize and access links, bring up the notice instead of doing anything; the sweep link no longer creates an account for signed-out visitors first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6W9CsdxmhFrfaKNVHU
Diffstat (limited to 'src/routes/(app)')
-rw-r--r--src/routes/(app)/fund/[id]/+page.svelte37
-rw-r--r--src/routes/(app)/fund/[id]/access/+page.server.ts10
-rw-r--r--src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts41
-rw-r--r--src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts61
4 files changed, 48 insertions, 101 deletions
diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte
index 087c8c95..289d1859 100644
--- a/src/routes/(app)/fund/[id]/+page.svelte
+++ b/src/routes/(app)/fund/[id]/+page.svelte
@@ -23,6 +23,11 @@
let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2)));
$effect(() => ($loginRedirect = $page.url.pathname));
+ // Funds are discontinued: the notice only appears once someone tries to
+ // act on the fund (Manage, or an old withdraw/authorize link redirecting
+ // here with ?discontinued).
+ let discontinued = $state($page.url.searchParams.has("discontinued"));
+
let show = $state();
let toggle = () => (show = !show);
let href = $derived(encodeURIComponent($page.url.href));
@@ -37,12 +42,14 @@
<div
class="md:shadow-xl rounded-3xl md:px-10 pt-5 pb-10 space-y-5 w-full md:mx-5"
>
- <div class="alert alert-warning text-left">
- <iconify-icon icon="ph:info-bold" width="24"></iconify-icon>
- <span>
- {notFound ? $t("funds.notFound") : $t("funds.discontinued")}
- </span>
- </div>
+ {#if notFound || discontinued}
+ <div class="alert alert-warning text-left">
+ <iconify-icon icon="ph:info-bold" width="24"></iconify-icon>
+ <span>
+ {notFound ? $t("funds.notFound") : $t("funds.discontinued")}
+ </span>
+ </div>
+ {/if}
{#if !notFound}
{#if show}
<div class="max-w-[360px] mx-auto">
@@ -75,6 +82,24 @@
<div>{$t("funds.anyone")}</div>
{/if}
</div>
+
+ {#if (user && !managers.length) || managers.some((m) => m.id === user?.id)}
+ <button
+ type="button"
+ onclick={() => (discontinued = true)}
+ class="btn !w-auto ml-auto text-secondary grow"
+ >
+ <iconify-icon icon="ph:gear-bold" width={32}></iconify-icon>
+ {$t("funds.manage")}
+ </button>
+ {/if}
+ </div>
+ <div class="flex gap-2" data-sveltekit-prefetch="off">
+ <a href={`/qr/${href}`} class="btn !w-auto grow">
+ <iconify-icon noobserver icon="ph:link-bold" width="32"
+ ></iconify-icon>
+ <div class="my-auto">{$t("payments.shareLink")}</div>
+ </a>
</div>
<Payments {payments} fund={true} {locale} {user} />
{/if}
diff --git a/src/routes/(app)/fund/[id]/access/+page.server.ts b/src/routes/(app)/fund/[id]/access/+page.server.ts
index 36191643..d409061d 100644
--- a/src/routes/(app)/fund/[id]/access/+page.server.ts
+++ b/src/routes/(app)/fund/[id]/access/+page.server.ts
@@ -1,9 +1,9 @@
-import { auth, fd, get, post } from "$lib/utils";
-import { fail } from "@sveltejs/kit";
+import { auth, fd, post } from "$lib/utils";
+import { fail, redirect } from "@sveltejs/kit";
-export const load = async ({ params: { id } }) => {
- const managers = await get(`/fund/${id}/managers`);
- return { managers, id };
+// Funds are discontinued; managers can no longer be changed.
+export const load = ({ params: { id } }) => {
+ redirect(307, `/fund/${id}?discontinued`);
};
export const actions = {
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..82faa387 100644
--- a/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts
+++ b/src/routes/(app)/fund/[id]/authorize/[...amount]/+page.server.ts
@@ -1,36 +1,7 @@
-import getRates from "$lib/rates";
-import { auth, get, post, sats } from "$lib/utils";
-import { error, redirect } from "@sveltejs/kit";
+import { 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;
-
- 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.amount;
- } else if (currency) {
- fiat = amount;
- amount = Math.round((fiat * sats) / rate);
- }
-
- 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}`);
- }
-
- return { amount, currency, id, rate, rates };
-}
+// Funds are discontinued; old withdraw/authorize links land on the fund page
+// with the notice instead.
+export const load = ({ params: { id } }) => {
+ redirect(307, `/fund/${id}?discontinued`);
+};
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..82faa387 100644
--- a/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
+++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
@@ -1,56 +1,7 @@
-import { randomName, randomPassword } from "$lib/random";
-import getRates from "$lib/rates";
-import { auth, get, post, register, sats } from "$lib/utils";
-import { error, redirect } from "@sveltejs/kit";
-import { env } from "$env/dynamic/private";
+import { redirect } from "@sveltejs/kit";
-export async function load({ cookies, request, params, parent }) {
- 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 (!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();
-
- if (!amount) redirect(307, `/fund/${id}`);
- if (!user) {
- const ip = request.headers.get("cf-connecting-ip");
-
- 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}`;
-
- 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);
- }
-
- try {
- ({ amount } = await post("/take", { amount, id }, auth(cookies)));
- } catch (e) {
- redirect(307, `/fund/${id}`);
- }
-
- return { amount, currency, id, rate, rates, password };
-}
+// Funds are discontinued; old withdraw/authorize links land on the fund page
+// with the notice instead.
+export const load = ({ params: { id } }) => {
+ redirect(307, `/fund/${id}?discontinued`);
+};