From d4c3d52fdde5fef8f72c1f572f1ce7c70da86b23 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 19 Sep 2024 15:55:38 -0700 Subject: progress on accounts --- src/routes/(app)/[username]/receive/+page.svelte | 343 +++++++++++++++++++++ src/routes/(app)/account/pass/+page.svelte | 65 +++- src/routes/(app)/account/seed/+page.svelte | 5 +- src/routes/(app)/account/setup/+page.svelte | 4 +- src/routes/(app)/invoice/+page.server.ts | 7 +- src/routes/(app)/invoice/[id]/+layout.server.ts | 42 +-- src/routes/(app)/invoice/[id]/+page.svelte | 56 ++-- src/routes/(app)/invoice/[id]/tip/+page.server.ts | 2 +- src/routes/(app)/invoice/[id]/tip/+page.svelte | 3 + src/routes/(app)/logout/+page.server.ts | 2 +- src/routes/(app)/send/[...text]/+page.svelte | 6 +- src/routes/(app)/send/ecash/+page.svelte | 13 +- .../(app)/send/lightning/[payreq]/+page.svelte | 17 +- 13 files changed, 475 insertions(+), 90 deletions(-) create mode 100644 src/routes/(app)/[username]/receive/+page.svelte (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte new file mode 100644 index 00000000..7d7958f1 --- /dev/null +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -0,0 +1,343 @@ + + +
+ {#if $showQr} +
+ + {txt} + +
+ {:else} +
+ {txt} +
+ {/if} + + {#each invoice.items as i} +
+
{i.quantity}
+
+ {i.name} +
+
+ {f(i.price * i.quantity, currency)} +
+
+ {sat(btc(i.price * i.quantity, rate))} +
+
+ {/each} + + {#if amount > 0} +
+
+ {f(amountFiat, currency)} + + {#if tip} + + +{f(tip * (rate / sats), currency)} + + {/if} +
+
+ ⚡️{`${s(amount)}`} + + {#if tip} + + +⚡️{s(tip)} + + {/if} +
+
+ {/if} + +
+ + + {#if user?.id === invoice?.user?.id} + + {:else} + + + + {/if} + +
+ +
+
+ + {#if account_id === user.id} +
+ + + + + + + {#if user?.id === invoice?.user?.id} + + + + {/if} +
+ + {#if type === types.liquid} +
+
+ {$t("payments.onlyLbtc")} + L-BTC, + {$t("payments.dontDeposit")} +
+
+ {/if} + {/if} +
+ +{#if settingAmount} +
+
+
+ +
+ + +
+ + +
+
{$t("payments.amountPrompt")}
+ +
+
+
+{/if} + + diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte index ee29d2c3..0eb16072 100644 --- a/src/routes/(app)/account/pass/+page.svelte +++ b/src/routes/(app)/account/pass/+page.svelte @@ -18,7 +18,7 @@ let { user } = data; - let confirm, password; + let confirm, password, revealPassword, revealConfirm; onMount(() => { if (!$mnemonic) goto("/account/savings"); @@ -65,13 +65,66 @@ class="container w-full mx-auto text-lg px-4 max-w-xl space-y-5" >

- Please add a password to the account. It should be different than your - login password. We won't be able to reset it. You'll - need it to make withdrawals. + Careful! If you lose this password you won't be able to use the account. + We can't recover it for you.

- - +
+ {#if revealPassword} + + {:else} + + {/if} + +
+ +
+ {#if revealConfirm} + + {:else} + + {/if} + +
- - {/if} - {#if type === types.liquid} -
-
- {$t("payments.onlyLbtc")} - L-BTC, - {$t("payments.dontDeposit")} -
+ {#if user?.id === invoice?.user?.id} +
+ + + {/if}
- {/if} - {#if user?.id === invoice?.user?.id} - - - + {#if type === types.liquid} +
+
+ {$t("payments.onlyLbtc")} + L-BTC, + {$t("payments.dontDeposit")} +
+
+ {/if} {/if} diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts index 8417de91..48ebf970 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts @@ -1,7 +1,7 @@ import invoice from "$lib/invoice"; import { redirect } from "@sveltejs/kit"; -export async function load({ parent, params }) { +export async function load({ parent }) { let { invoice } = await parent(); if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`); diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte index 35b24bf1..e4510693 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.svelte +++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte @@ -59,6 +59,7 @@ $: refresh(data); let { invoice, id, user, rates } = data; let { + account_id, amount, hash, items, @@ -81,6 +82,7 @@ ({ invoice, id } = data); ({ + account_id, amount, hash, items, @@ -111,6 +113,7 @@
+ diff --git a/src/routes/(app)/logout/+page.server.ts b/src/routes/(app)/logout/+page.server.ts index 9c2a029c..03dff6a8 100644 --- a/src/routes/(app)/logout/+page.server.ts +++ b/src/routes/(app)/logout/+page.server.ts @@ -7,7 +7,7 @@ const opts = { export async function load({ cookies }) { let lang = cookies.get("lang"); - cookies.set("account", "", opts); + cookies.set("account_id", "", opts); cookies.set("lang", "", opts); cookies.set("username", "", opts); cookies.set("token", "", opts); diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index d1b6cc23..be7fc664 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -18,7 +18,7 @@ let el, text, pasted, w; - let keypress = (e) => e.key === "Enter" && (e.preventDefault() || el.click()); + let keypress = (e) => e.key === "Enter" ? (e.preventDefault() || el.click()) : (pasted = false); let paste = async () => { text = await navigator.clipboard.readText(); @@ -52,7 +52,7 @@ name="text" placeholder={$t("user.send.placeholder")} on:keypress={keypress} - class="w-full p-4 border rounded-xl h-48 text-xl" + class="w-full p-4 border rounded-xl h-32 text-xl" bind:value={text} on:paste={() => (pasted = true)} autocapitalize="none" @@ -95,7 +95,7 @@ type="button" class="flex border rounded-2xl px-6 py-5 w-full font-bold gap-2 justify-center text-xl bg-primary" > - +
{$t("payments.createEcash")}
diff --git a/src/routes/(app)/send/ecash/+page.svelte b/src/routes/(app)/send/ecash/+page.svelte index 615c068a..ef8e368c 100644 --- a/src/routes/(app)/send/ecash/+page.svelte +++ b/src/routes/(app)/send/ecash/+page.svelte @@ -30,18 +30,14 @@
-

- {$t("payments.createEcash")} -

- -
+
{#if submitting} {:else} - {$t("payments.mint")} + +
{$t("payments.mint")}
{/if}
diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte index 57a17e01..74c100f8 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte @@ -58,11 +58,7 @@ let toggle = () => (show = !show); - - -
+
{#if amount} {#if form?.message}
@@ -81,12 +77,9 @@

⚡️{s(amount)}

-
-
- {$t("payments.to")} -
- -

{alias}

+
+ {$t("payments.to")} + {alias}
{#if ourfee} @@ -109,7 +102,7 @@ use:enhance on:submit={submit} action="?/send" - class="space-y-5" + class="space-y-2" > -- cgit v1.2.3