From f22464cf997b72d5fd99ddabb152401d7ef71ecb Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 15 Mar 2025 21:27:44 -0700 Subject: fund ui --- src/locales/en.json | 32 +++++---- src/routes/(app)/fund/[id]/+page.server.ts | 1 + src/routes/(app)/fund/[id]/+page.svelte | 88 +++++++++++++++-------- src/routes/(app)/fund/[id]/access/+page.server.ts | 26 ++++++- src/routes/(app)/fund/[id]/access/+page.svelte | 38 +++++++++- 5 files changed, 137 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/locales/en.json b/src/locales/en.json index 0146cf58..347bb129 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,17 +1,25 @@ { + "funds": { + "anyone": "Anyone with the link", + "addManager": "Add manager", + "manage": "Manage", + "withdrawAccess": "Withdraw access", + "username": "Username", + "returnToFund": "Back to fund" + }, "notes": { "contents": "Note contents", "notFound": "No notes found" }, "accounts": { - "qr": "QR", - "edit": "Edit", - "payments": "Payments", - "notifications": "Notifications", - "on": "On", - "off": "Off", - "maxfee": "Max routing fee", - "maxfeeDesc": "The default is 1% of the payment value if this is not set", + "qr": "QR", + "edit": "Edit", + "payments": "Payments", + "notifications": "Notifications", + "on": "On", + "off": "Off", + "maxfee": "Max routing fee", + "maxfeeDesc": "The default is 1% of the payment value if this is not set", "per": "per", "none": "None", "day": "day", @@ -24,7 +32,7 @@ "yearly": "Yearly", "never": "Never", "newConection": "New connection", - "connect": "Connect", + "connect": "Connect", "name": "Name", "pubkey": "Pubkey", "secret": "Secret", @@ -387,9 +395,9 @@ } }, "payments": { - "pending": "Pending", - "minted": "Minted", - "redeemed": "Redeemed", + "pending": "Pending", + "minted": "Minted", + "redeemed": "Redeemed", "exchangeRate": "Exchange rate", "viewFund": "View fund", "zappedEvent": "Zapped event", diff --git a/src/routes/(app)/fund/[id]/+page.server.ts b/src/routes/(app)/fund/[id]/+page.server.ts index 9ea33627..a4f402af 100644 --- a/src/routes/(app)/fund/[id]/+page.server.ts +++ b/src/routes/(app)/fund/[id]/+page.server.ts @@ -5,6 +5,7 @@ import { redirect } from "@sveltejs/kit"; 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"]; diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index ae0a97c6..6cb3b05d 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -14,7 +14,7 @@ let { data } = $props(); - let { amount, payments, rate, user } = data; + let { amount, payments, managers, rate, user } = data; let { id } = $page.params; let locale = loc(user); @@ -26,10 +26,10 @@ let show = $state(); let toggle = () => (show = !show); let href = $derived(encodeURIComponent($page.url.href)); - let withdrawUrl = encoder.encode( - `${$page.url.origin}/api/fund/${id}/withdraw`, - ); - let lnurlw = bech32.encode("lnurl", bech32.toWords(withdrawUrl), 20000); + // let withdrawUrl = encoder.encode( + // `${$page.url.origin}/api/fund/${id}/withdraw`, + // ); + // let lnurlw = bech32.encode("lnurl", bech32.toWords(withdrawUrl), 20000);
@@ -49,11 +49,35 @@
-
-
Access: Anyone with the link
- +
+
+
+
{$t("funds.withdrawAccess")}
+
+ {#if managers.length} +
+ {#each managers as c, i} +
0}> + + + +
+ {/each} +
+ {:else} +
{$t("funds.anyone")}
+ {/if} +
+ + + + {$t("funds.manage")} +
- diff --git a/src/routes/(app)/fund/[id]/access/+page.server.ts b/src/routes/(app)/fund/[id]/access/+page.server.ts index 9a8a9dbc..c38cb29b 100644 --- a/src/routes/(app)/fund/[id]/access/+page.server.ts +++ b/src/routes/(app)/fund/[id]/access/+page.server.ts @@ -1,3 +1,25 @@ -export const load = async () => { - return { managers: [] }; +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 }; +}; + +export const actions = { + default: async ({ cookies, request }) => { + const form = await fd(request); + + try { + console.log("SUBMITTING", form); + const managers = await post("/fund/managers", form, auth(cookies)); + + console.log(managers); + + return { managers }; + } catch (e) { + const { message } = e as Error; + return fail(400, { message }); + } + }, }; diff --git a/src/routes/(app)/fund/[id]/access/+page.svelte b/src/routes/(app)/fund/[id]/access/+page.svelte index 754ddf87..f18d6357 100644 --- a/src/routes/(app)/fund/[id]/access/+page.svelte +++ b/src/routes/(app)/fund/[id]/access/+page.svelte @@ -1,8 +1,19 @@
@@ -15,15 +26,36 @@ {#each managers as c} - -
+ +

{c.username}

+
{/each} + +
+ + + +
+ + + + {$t("funds.returnToFund")}
-- cgit v1.2.3