aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-30 21:53:52 -0800
committerAdam Soltys <[email protected]>2024-12-30 21:53:52 -0800
commit38e786c0d3c2280dd69f22ddf7cdf6ca804e6048 (patch)
tree48893b5eb0253104dfb2847fd0ac371eb1b492ce /src/routes/(app)
parentd96e1580757a1d0531fec0854e4238214ec8c00b (diff)
downloadcoinos-ui-38e786c0d3c2280dd69f22ddf7cdf6ca804e6048.tar.gz
coinos-ui-38e786c0d3c2280dd69f22ddf7cdf6ca804e6048.zip
scrap key generation
Diffstat (limited to 'src/routes/(app)')
-rw-r--r--src/routes/(app)/+layout.server.ts5
-rw-r--r--src/routes/(app)/fund/[id]/+page.svelte18
-rw-r--r--src/routes/(app)/generate/+page.svelte64
-rw-r--r--src/routes/(app)/generate/+server.ts12
-rw-r--r--src/routes/(app)/payments/[...page]/+page.svelte17
5 files changed, 20 insertions, 96 deletions
diff --git a/src/routes/(app)/+layout.server.ts b/src/routes/(app)/+layout.server.ts
index acf19ada..ef25388d 100644
--- a/src/routes/(app)/+layout.server.ts
+++ b/src/routes/(app)/+layout.server.ts
@@ -45,11 +45,6 @@ export async function load({ cookies, request, url, params }) {
redirect(307, `/${user.username}`);
}
- if (user && !user.pubkey && !pathname.includes("generate")) {
- console.log("user missing pubkey", user);
- redirect(303, "/generate");
- }
-
const theme = cookies.get("theme") || "light";
return { user, token, subject, theme };
}
diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte
index 36a63a9b..5d6ca777 100644
--- a/src/routes/(app)/fund/[id]/+page.svelte
+++ b/src/routes/(app)/fund/[id]/+page.svelte
@@ -26,7 +26,9 @@
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 withdrawUrl = encoder.encode(
+ `${$page.url.origin}/api/fund/${id}/withdraw`,
+ );
let lnurlw = bech32.encode("lnurl", bech32.toWords(withdrawUrl), 20000);
</script>
@@ -51,7 +53,8 @@
<div class="grow">
<a href={`/send/fund/${id}`}>
<button class="btn">
- <iconify-icon noobserver icon="ph:plus-bold" width="32"></iconify-icon>
+ <iconify-icon noobserver icon="ph:plus-bold" width="32"
+ ></iconify-icon>
{$t("payments.addFunds")}
</button>
</a>
@@ -59,7 +62,8 @@
<div class="grow">
<a href={`/fund/${id}/withdraw`}>
<button class="btn">
- <iconify-icon noobserver
+ <iconify-icon
+ noobserver
icon="ph:hand-coins-bold"
width="32"
flip="horizontal"
@@ -71,11 +75,13 @@
</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>
+ <iconify-icon noobserver icon="ph:link-bold" width="32"
+ ></iconify-icon>
<div class="my-auto">{$t("payments.shareLink")}</div>
</a>
<a href={`/qr/${lnurlw}`} class="btn !w-auto grow">
- <iconify-icon noobserver
+ <iconify-icon
+ noobserver
icon="ph:lightning-fill"
width="24"
class="text-yellow-300"
@@ -83,7 +89,7 @@
{$t("payments.lnurlw")}
</a>
</div>
- <Payments {payments} fund={true} />
+ <Payments {payments} fund={true} {locale} />
</div>
</div>
</div>
diff --git a/src/routes/(app)/generate/+page.svelte b/src/routes/(app)/generate/+page.svelte
deleted file mode 100644
index 72ca2485..00000000
--- a/src/routes/(app)/generate/+page.svelte
+++ /dev/null
@@ -1,64 +0,0 @@
-<script>
- import { run } from 'svelte/legacy';
-
- import { fail, post, wait } from "$lib/utils";
- import { onMount } from "svelte";
- import { goto, invalidate } from "$app/navigation";
- import Pin from "$comp/Pin.svelte";
- import Spinner from "$comp/Spinner.svelte";
- import { loginRedirect, pin, password } from "$lib/store";
- import { generate } from "$lib/nostr";
- import { browser } from "$app/environment";
-
- let { data } = $props();
- let { user } = $state(data);
-
- let loaded = $state();
- let gen = async () => {
- if (!browser) return;
-
- if (user.pubkey) {
- goto($loginRedirect || `/${user.username}`, { invalidateAll: true });
- return;
- }
-
- try {
- await generate(user);
- } catch (e) {
- console.log("error generating", e);
- }
-
- try {
- user.pin = $pin;
- await post(`/generate`, user);
- goto($loginRedirect || `/${user.username}`, { invalidateAll: true });
- } catch (e) {
- $pin = "";
- if (e.message?.startsWith("Pin")) {
- fail("Wrong pin, try again");
- } else {
- fail("Failed to generate keys");
- goto("/");
- }
- }
- };
-
- onMount(() => browser && setTimeout(() => (loaded = true) && gen(), 50));
-
- run(() => {
- $pin?.length === 6 && gen(user);
- });
-</script>
-
-{#if loaded && user?.haspin && $pin?.length !== 6}
- <Pin />
-{/if}
-
-<div class="container px-4 text-center mx-auto">
- <h1 class="text-3xl md:text-4xl font-bold mb-6">
- Generating new account keys
- </h1>
- <div class="flex w-full py-5 max-w-[200px] mx-auto bg-black rounded-2xl">
- <Spinner />
- </div>
-</div>
diff --git a/src/routes/(app)/generate/+server.ts b/src/routes/(app)/generate/+server.ts
deleted file mode 100644
index b16d0b37..00000000
--- a/src/routes/(app)/generate/+server.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { auth, post } from "$lib/utils";
-import { error, json } from "@sveltejs/kit";
-
-export async function POST({ cookies, request }) {
- try {
- const body = await request.json();
- return json(await post("/user", body, auth(cookies)));
- } catch (e: any) {
- console.log(e);
- error(500, e.message);
- }
-}
diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte
index ccdfa34c..9ef38df5 100644
--- a/src/routes/(app)/payments/[...page]/+page.svelte
+++ b/src/routes/(app)/payments/[...page]/+page.svelte
@@ -9,7 +9,6 @@
import { page } from "$app/stores";
import { differenceInDays, getUnixTime, sub } from "date-fns";
import { goto, invalidate } from "$app/navigation";
- import locales from "$lib/locales";
let { data } = $props();
let {
start,
@@ -22,8 +21,7 @@
page: p,
} = $derived(data);
- let locale = locales[user.language];
- let userLocale = loc(user);
+ let locale = loc(user);
let change = ({ target: { value } }) => goto(value);
let link = (p) => {
@@ -203,7 +201,7 @@
{/if}
</div>
- <Payments {payments} />
+ <Payments {payments} locale={locale} />
<div class="grid grid-cols-3 w-full text-center text-lg">
{#each Object.keys(incoming) as c}
@@ -230,18 +228,18 @@
>{$t("payments.income")}</span
>
<!-- <span><b>{subtotalIn ? f(subtotalIn, c) : "-"}</b></span> -->
- <span><b>{tipsIn > 0 ? f(tipsIn, c, userLocale) : "-"}</b></span>
+ <span><b>{tipsIn > 0 ? f(tipsIn, c, locale) : "-"}</b></span>
<span class="text-right"
- ><b>{totalIn > 0 ? f(totalIn, c, userLocale) : "-"}</b></span
+ ><b>{totalIn > 0 ? f(totalIn, c, locale) : "-"}</b></span
>
<span class="text-left text-base text-secondary"
>{$t("payments.expenditure")}</span
>
<!-- <span><b>{subtotalOut ? f(subtotalOut, c) : "-"}</b></span> -->
- <span><b>{tipsOut > 0 ? f(tipsOut, c, userLocale) : "-"}</b></span>
+ <span><b>{tipsOut > 0 ? f(tipsOut, c, locale) : "-"}</b></span>
<span class="text-right"
- ><b>{totalOut > 0 ? f(totalOut, c, userLocale) : "-"}</b></span
+ ><b>{totalOut > 0 ? f(totalOut, c, locale) : "-"}</b></span
>
{/each}
</div>
@@ -249,7 +247,8 @@
<div class="flex justify-center">
<button class="btn !w-auto" onclick={csv}>
- <iconify-icon noobserver icon="ph:floppy-disk-bold" width="32"></iconify-icon>
+ <iconify-icon noobserver icon="ph:floppy-disk-bold" width="32"
+ ></iconify-icon>
<div class="my-auto">{$t("payments.export")}</div>
</button>
</div>