Add account
diff --git a/src/routes/(app)/[username]/+layout.server.ts b/src/routes/(app)/[username]/+layout.server.ts
index 11e6d45c..c340544d 100644
--- a/src/routes/(app)/[username]/+layout.server.ts
+++ b/src/routes/(app)/[username]/+layout.server.ts
@@ -1,17 +1,25 @@
import { get } from "$lib/utils";
import { error } from "@sveltejs/kit";
-export let load = async ({ cookies, depends, params: { username } }) => {
+export let load = async ({
+ cookies,
+ depends,
+ params: { username },
+ parent,
+}) => {
depends("app:user");
try {
let subject = await get(`/users/${username}`);
+ let { user } = await parent();
+ if (!user) user = subject;
+ console.log("SUBJECT", subject)
let expires = new Date();
expires.setSeconds(expires.getSeconds() + 380 * 24 * 60 * 60);
cookies.set("username", username, { path: "/", expires });
- return { subject };
+ return { subject, user };
} catch (e) {
error(500, "Unable to retrieve user account data");
}
diff --git a/src/routes/(app)/[username]/+layout.svelte b/src/routes/(app)/[username]/+layout.svelte
index cd517fa9..98569f59 100644
--- a/src/routes/(app)/[username]/+layout.svelte
+++ b/src/routes/(app)/[username]/+layout.svelte
@@ -1,5 +1,4 @@
-
diff --git a/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.server.ts b/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.server.ts
deleted file mode 100644
index c2cd5683..00000000
--- a/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.server.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { get, auth } from "$lib/utils";
-
-let limit = 25;
-
-export async function load({ cookies, depends, params }) {
- depends("app:payments");
-
- let parts = params.page.split("/");
-
- let start, end, page;
- if (parts.length === 1) [page] = parts;
- if (parts.length === 2) [start, page] = parts;
- if (parts.length === 3) [start, end, page] = parts;
- if (!parseInt(page)) page = 1;
-
- let offset = (page - 1) * limit;
- if (!start) start = Date.now() / 1000 - 24 * 60 * 60;
-
- let url = `/payments?account=${params.account}&start=${
- start * 1000
- }&limit=${limit}&offset=${offset}`;
- if (end) url += `&end=${end * 1000}`;
-
- let { count, payments, incoming, outgoing } = await get(url, auth(cookies));
- let pages = new Array(Math.ceil(count / limit));
-
- return { payments, page, pages, start, end, incoming, outgoing };
-}
diff --git a/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.svelte b/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.svelte
deleted file mode 100644
index 1efdc2ec..00000000
--- a/src/routes/(app)/[username]/[...account]/payments/[...page]/+page.svelte
+++ /dev/null
@@ -1,315 +0,0 @@
-
-
-
-
- {$t("payments.header")}
-
-
-
-
-
- {#each presets as { start, end, title }, i}
-
-
- {title}
-
-
- {/each}
-
-
-
-
- {#if pages.length > 1}
- {#each pages as _, i}
-
-
- {i + 1}
-
-
- {/each}
- {/if}
-
-
-
-
-
- {#each Object.keys(incoming) as c}
-
-
-
-
-
- {#if tipsIn || tipsOut}{$t("payments.tips")}{/if}
-
- {$t("payments.total")}
-
- {@const totalIn = incoming[c]?.fiat || 0}
- {@const tipsIn = incoming[c]?.fiatTips || 0}
- {@const subtotalIn = totalIn - tipsIn}
-
- {@const totalOut = -outgoing[c]?.fiat || 0}
- {@const tipsOut = outgoing[c]?.fiatTips || 0}
- {@const subtotalOut = totalOut - tipsOut}
-
- {$t("payments.income")}
-
- {tipsIn ? f(tipsIn, c) : "-"}
- {totalIn ? f(totalIn, c) : "-"}
-
- {$t("payments.expenditure")}
-
- {tipsOut ? f(tipsOut, c) : "-"}
- {totalOut ? f(totalOut, c) : "-"}
- {/each}
-
-
-
-
- {$t("payments.export")}
-
-
-
-
-
diff --git a/src/routes/(app)/[username]/[...account]/payments/[...page]/+server.ts b/src/routes/(app)/[username]/[...account]/payments/[...page]/+server.ts
deleted file mode 100644
index a81faaf3..00000000
--- a/src/routes/(app)/[username]/[...account]/payments/[...page]/+server.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { get, auth } from "$lib/utils";
-import { json } from "@sveltejs/kit";
-
-export async function GET({ cookies, params }) {
- let parts = params.page.split("/");
-
- let start, end;
- if (parts.length === 1) [start] = parts;
- if (parts.length === 2) [start, end] = parts;
-
- if (!start) start = Date.now() / 1000 - 24 * 60 * 60;
-
- let url = `/payments?start=${start * 1000}`;
- if (end) url += `&end=${end * 1000}`;
-
- let { payments } = await get(url, auth(cookies));
- return json({ payments });
-}
diff --git a/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.server.ts b/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.server.ts
deleted file mode 100644
index d9614a1c..00000000
--- a/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.server.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { error, redirect } from "@sveltejs/kit";
-import { auth, post } from "$lib/utils";
-import type { Invoice } from "$lib/types";
-
-export let load = async ({ cookies, params, parent }) => {
- let { account } = params;
- let { subject, user, rates } = await parent();
-
- let invoice: Invoice = {
- account,
- type: account ? "bitcoin" : "lightning",
- rate: rates[user?.currency || subject?.currency],
- };
-
- if (!user) user = subject;
-
- try {
- invoice = await post("/invoice", { invoice, account, user }, auth(cookies));
- } catch (e) {
- console.log(e);
- error(500, "Failed to generate invoice");
- }
-
- let { id } = invoice;
-
- if (invoice.memoPrompt && !invoice.memo) {
- redirect(307, `/${user.username}/invoice/${id}/memo`);
- } else redirect(307, `/${user.username}/invoice/${id}`);
-};
diff --git a/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.svelte b/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.svelte
deleted file mode 100644
index f9267105..00000000
--- a/src/routes/(app)/[username]/[...account]/receive/[...param]/+page.svelte
+++ /dev/null
@@ -1,116 +0,0 @@
-
-
-
-
-
-
-
- {$t("payments.send")}
-
-
-
-
- {#if contacts.length}
-
-
- {$t("user.send.contacts")}
-
-
- {#each contacts as c}
-
-
-
- {/each}
-
-
- {/if}
-
diff --git a/src/routes/(app)/[username]/account/setup/+page.svelte b/src/routes/(app)/[username]/account/setup/+page.svelte
deleted file mode 100644
index 9636ff2a..00000000
--- a/src/routes/(app)/[username]/account/setup/+page.svelte
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
Account setup
-
Step 1
-
-
-
- The keys to your savings account are derived from a seed phrase. When
- you're ready, write it down and keep it safe.
-
-
-
- Whoever knows these words in the correct order can withdraw funds from the account. We can't
- recover them if you lose them.
-
-
- {#if reveal}
-
- {$mnemonic}
-
-
-
- {:else}
-
-
-
- {$t("user.settings.revealSeed")}
-
-
- {/if}
-
-
diff --git a/src/routes/(app)/[username]/account/setup/step2/+page.svelte b/src/routes/(app)/[username]/account/setup/step2/+page.svelte
deleted file mode 100644
index 8169ce06..00000000
--- a/src/routes/(app)/[username]/account/setup/step2/+page.svelte
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
Account setup
- Step 2
-
-
-
-
- Add an additional password to your seed phrase. It should be different
- than your login password. We can't reset it if you lose it.
-
-
-
-
-
- Submit
-
-
-
diff --git a/src/routes/(app)/[username]/address/+page.server.ts b/src/routes/(app)/[username]/address/+page.server.ts
deleted file mode 100644
index 2f7841ab..00000000
--- a/src/routes/(app)/[username]/address/+page.server.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { auth, post } from "$lib/utils";
-import { redirect } from "@sveltejs/kit";
-
-export async function load({ cookies, parent }) {
- let user = (await parent()).subject;
- let invoice = { type: "bitcoin" };
- let { id } = await post(`/invoice`, { invoice, user }, auth(cookies));
- redirect(307, `/${user.username}/invoice/${id}`);
-}
diff --git a/src/routes/(app)/[username]/address/+page.svelte b/src/routes/(app)/[username]/address/+page.svelte
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/routes/(app)/[username]/card/[serial]/+page.server.ts b/src/routes/(app)/[username]/card/[serial]/+page.server.ts
deleted file mode 100644
index 945eee30..00000000
--- a/src/routes/(app)/[username]/card/[serial]/+page.server.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { auth, get } from "$lib/utils";
-import { redirect } from "@sveltejs/kit";
-
-export let load = async ({ cookies, params }) => {
- let { serial } = params;
- let fund;
- try {
- fund = await get(`/fund/${serial}`, auth(cookies));
- } catch (e) {
- console.log(e);
- }
-
- if (fund) redirect(307, `/fund/${serial}`);
-
- return params;
-};
diff --git a/src/routes/(app)/[username]/card/[serial]/+page.svelte b/src/routes/(app)/[username]/card/[serial]/+page.svelte
deleted file mode 100644
index 1d11ebee..00000000
--- a/src/routes/(app)/[username]/card/[serial]/+page.svelte
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
diff --git a/src/routes/(app)/[username]/customers/+page.svelte b/src/routes/(app)/[username]/customers/+page.svelte
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/routes/(app)/[username]/funds/+page.server.ts b/src/routes/(app)/[username]/funds/+page.server.ts
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/routes/(app)/[username]/funds/+page.svelte b/src/routes/(app)/[username]/funds/+page.svelte
deleted file mode 100644
index 25686e86..00000000
--- a/src/routes/(app)/[username]/funds/+page.svelte
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- Funds
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Pot
-
-
-
-
-
-
-
-
-
- {$t("payments.create")}
-
-
-
-
-
diff --git a/src/routes/(app)/[username]/generate/+page.svelte b/src/routes/(app)/[username]/generate/+page.svelte
deleted file mode 100644
index 767b7545..00000000
--- a/src/routes/(app)/[username]/generate/+page.svelte
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-{#if loaded && user?.haspin && $pin?.length !== 6}
-
-{/if}
-
-
-
- Generating new account keys
-
-
-
-
-
diff --git a/src/routes/(app)/[username]/generate/+server.ts b/src/routes/(app)/[username]/generate/+server.ts
deleted file mode 100644
index 5a442982..00000000
--- a/src/routes/(app)/[username]/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 {
- let 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)/[username]/invoice/+server.ts b/src/routes/(app)/[username]/invoice/+server.ts
deleted file mode 100644
index 5e3d0300..00000000
--- a/src/routes/(app)/[username]/invoice/+server.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { auth, post } from "$lib/utils";
-import { json } from "@sveltejs/kit";
-
-export let POST = async ({ cookies: c, request: r }) => {
- let j = await r.json();
- return json(await post("/invoice", j, auth(c)));
-};
diff --git a/src/routes/(app)/[username]/invoice/[id]/+layout.server.ts b/src/routes/(app)/[username]/invoice/[id]/+layout.server.ts
deleted file mode 100644
index 41554c9f..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/+layout.server.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import Qr from "qrcode-base64";
-import { get } from "$lib/utils";
-import { redirect } from "@sveltejs/kit";
-
-export async function load({ depends, params, url, parent }) {
- depends("app:invoice");
-
- let { subject, user } = await parent();
- let { id } = params;
- let invoice = await get(`/invoice/${id}`);
- let options = !!url.searchParams.get("options");
-
- if (
- user &&
- invoice.uid !== user.id &&
- !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
- !options
- ) {
- redirect(307, `/send/invoice/${id}`);
- }
-
- let { amount, pending, received } = invoice;
- amount = parseInt(amount);
-
- let paid =
- (!amount && (pending || received)) ||
- (amount > 0 && (pending >= amount || received >= amount));
- if (paid && !url.pathname.endsWith("paid")) {
- redirect(
- 307,
- `/${params.username}/invoice/${id}/paid` +
- (options ? "?options=true" : "")
- );
- }
-
- let src = Qr.drawImg(invoice.text || "", { size: 340 });
-
- return { id, invoice, subject, src };
-}
diff --git a/src/routes/(app)/[username]/invoice/[id]/+layout.svelte b/src/routes/(app)/[username]/invoice/[id]/+layout.svelte
deleted file mode 100644
index 4fa864ce..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/+layout.svelte
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.server.ts b/src/routes/(app)/[username]/invoice/[id]/+page.server.ts
deleted file mode 100644
index a57efa64..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/+page.server.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import invoice from "$lib/invoice";
-
-export const actions = {
- default: invoice,
-};
diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/+page.svelte
deleted file mode 100644
index 1f2bbb51..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/+page.svelte
+++ /dev/null
@@ -1,344 +0,0 @@
-
-
-
- {#if $showQr}
-
- {: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}
-
-
-
copy(txt)}
- >
-
-
- {$t("payments.copy")}
-
-
-
- {#if user?.id === invoice?.user?.id}
-
-
- {$t("payments.setAmount")}
-
- {:else}
-
-
-
- {$t("payments.openLink")}
-
-
- {/if}
-
-
-
($showQr = !$showQr)}
- >
- {#if $showQr}
-
- {:else}
-
- {/if}
-
- {$showQr ? $t("payments.showText") : $t("payments.showQr")}
-
-
-
-
- {#if !account}
-
-
setType(types.bitcoin)}
- >
-
- Bitcoin
-
-
-
setType(types.liquid)}
- >
-
- Liquid
-
-
-
setType(types.lightning)}
- >
-
- Lightning
-
-
- {/if}
-
- {#if type === types.liquid}
-
-
- {$t("payments.onlyLbtc")}
- L-BTC ,
- {$t("payments.dontDeposit")}
-
-
- {/if}
-
- {#if user?.id === invoice?.user?.id}
-
-
-
-
- {$t("payments.redeemVoucher")}
-
-
- {/if}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/routes/(app)/[username]/invoice/[id]/memo/+page.server.ts b/src/routes/(app)/[username]/invoice/[id]/memo/+page.server.ts
deleted file mode 100644
index 58d56018..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/memo/+page.server.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import invoice from "$lib/invoice";
-import { redirect } from "@sveltejs/kit";
-
-export async function load({ parent, params }) {
- let { invoice } = await parent();
- if (!invoice.amount) {
- redirect(307, `/${params.username}/invoice/${invoice.id}`);
- }
-}
-
-export const actions = {
- default: invoice,
-};
diff --git a/src/routes/(app)/[username]/invoice/[id]/memo/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/memo/+page.svelte
deleted file mode 100644
index 4d23ff19..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/memo/+page.svelte
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- {$t("invoice.addMemo")}
-
-
-
{invoice.memoPrompt}
-
-
-
- {$t("payments.next")}
-
-
diff --git a/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte
deleted file mode 100644
index 700ac972..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
- {#if received}
-
-
-
-
-
- {$t("invoice.paymentSuccessful")}
-
-
-
- {f(fiat(received - tip, rate), currency)}
- {#if tip}
-
- + {f(fiat(tip, rate), currency)}
-
- {/if}
-
-
- ⚡️{s(received - tip)}
-
- {#if tip}
-
- + ⚡️{s(tip)}
-
- {/if}
-
- {/if}
-
- {#if pending}
-
-
-
-
-
Payment detected
-
- {f(fiat(pending - tip, rate), currency)}
- {#if tip}
- + {f(fiat(tip, rate), currency)}
- {/if}
-
-
-
- ⚡️{s(pending - tip)}
- {#if tip}
-
- + ⚡️{s(tip)}
-
- {/if}
-
- {/if}
-
-
-
-
-
-
-
- {$t("payments.tapAnywhere")}
-
diff --git a/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.ts
deleted file mode 100644
index b81e2364..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import invoice from "$lib/invoice";
-import { redirect } from "@sveltejs/kit";
-
-export async function load({ parent, params }) {
- let { invoice } = await parent();
- if (!invoice.amount)
- redirect(307, `/${params.username}/invoice/${invoice.id}`);
-}
-
-export const actions = {
- default: invoice,
-};
diff --git a/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte
deleted file mode 100644
index 35b24bf1..00000000
--- a/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte
+++ /dev/null
@@ -1,209 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- {#if invoice.memoPrompt}
-
- {/if}
-
- {$t("invoice.addTipq")}
- {#if !showCustomAmount}
- {Math.round(tipPercent)}%
-
-
-
-
-
-
- {f(amountFiat, currency)}
- +{f(tipAmount, currency)}
-
-
-
-
- {sat(amount)}
- +{sat(tip)}
-
-
-
- {#if tip}
-
- submit.click()}>Next
- (tipPercent = 0)}>Reset
-
- {:else}
- {#each tipAmounts as amount}
- handleTipButtonClick(amount)}>{amount}
- {/each}
- {/if}
-
-
- (showCustomAmount = true)}
- >Custom
-
- {/if}
-
-
-
-
- {#if showCustomAmount}
-
-
- $
- handleCustomTipAmount(e)}
- class="pl-10"
- placeholder="Custom amount"
- use:focus
- />
- Apply
-
-
- {/if}
-
-
-
diff --git a/src/routes/(app)/[username]/invoice/sent/+page.svelte b/src/routes/(app)/[username]/invoice/sent/+page.svelte
deleted file mode 100644
index b95bc85e..00000000
--- a/src/routes/(app)/[username]/invoice/sent/+page.svelte
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-Invoice sent to
-
-
-
{$request.requester.username} is ready to pay
-
diff --git a/src/routes/(app)/[username]/items/[id]/+page.server.ts b/src/routes/(app)/[username]/items/[id]/+page.server.ts
deleted file mode 100644
index 67cebd93..00000000
--- a/src/routes/(app)/[username]/items/[id]/+page.server.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { fd, auth, get, post } from "$lib/utils";
-import { fail, redirect } from "@sveltejs/kit";
-
-export let load = async ({ params: { id } }) => {
- let item = await get(`/items/${id}`);
- return { item };
-};
-
-export const actions = {
- default: async ({ cookies, request, url }) => {
- let form = await fd(request);
- try {
- await post(`/items`, form, auth(cookies));
- } catch (e: any) {
- return fail(400, { message: e.message });
- }
-
- let success = `/${url.pathname.split("/")[1]}`;
- redirect(307, success);
- },
-};
diff --git a/src/routes/(app)/[username]/items/[id]/+page.svelte b/src/routes/(app)/[username]/items/[id]/+page.svelte
deleted file mode 100644
index 65720350..00000000
--- a/src/routes/(app)/[username]/items/[id]/+page.svelte
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- {$t("items.edit")}
-
-
-
diff --git a/src/routes/(app)/[username]/items/create/+page.server.ts b/src/routes/(app)/[username]/items/create/+page.server.ts
deleted file mode 100644
index 2e006a3e..00000000
--- a/src/routes/(app)/[username]/items/create/+page.server.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { fail, redirect } from "@sveltejs/kit";
-import { fd, auth, post } from "$lib/utils";
-
-export const actions = {
- default: async ({ cookies, request, url }) => {
- let form = await fd(request);
- try {
- await post("/items", form, auth(cookies));
- } catch (e: any) {
- return fail(400, { message: e.message });
- }
-
- let success = `/${url.pathname.split("/")[1]}`;
- redirect(307, success);
- },
-};
diff --git a/src/routes/(app)/[username]/items/create/+page.svelte b/src/routes/(app)/[username]/items/create/+page.svelte
deleted file mode 100644
index b82889c9..00000000
--- a/src/routes/(app)/[username]/items/create/+page.svelte
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- {$t("items.add")}
-
-
-
diff --git a/src/routes/(app)/[username]/map/+page.server.ts b/src/routes/(app)/[username]/map/+page.server.ts
deleted file mode 100644
index 616d28f6..00000000
--- a/src/routes/(app)/[username]/map/+page.server.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { get } from "$lib/utils";
-
-// export const prerender = true;
-export let load = async () => {
- let data = { locations: [] };
-
- try {
- data = await get("/locations");
- } catch (e) {}
-
- return data;
-};
diff --git a/src/routes/(app)/[username]/map/+page.svelte b/src/routes/(app)/[username]/map/+page.svelte
deleted file mode 100644
index bfa115e4..00000000
--- a/src/routes/(app)/[username]/map/+page.svelte
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/src/routes/(app)/[username]/messages/+page.server.ts b/src/routes/(app)/[username]/messages/+page.server.ts
deleted file mode 100644
index 94659621..00000000
--- a/src/routes/(app)/[username]/messages/+page.server.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { get } from "$lib/utils";
-import { redirect } from "@sveltejs/kit";
-
-interface Message {
- created_at: number;
-}
-
-interface Note {
- created_at: number;
- seen: number;
-}
-
-export async function load({ params, parent, }) {
- let { user } = await parent();
- if (user.username !== params.username) redirect(307, `/${params.username}`);
- let { since = 0 } = params;
-
- let messages = [],
- notes = [];
-
- if (user?.pubkey) {
- let { pubkey } = user;
- try {
- messages = await get(`/${pubkey}/${since}/messages`);
- messages = messages.sort((a: Message, b: Message) => b.created_at - a.created_at);
- } catch (e) {
- console.log(`failed to fetch nostr messages`, e);
- }
-
- try {
- notes = await get(`/${pubkey}/notes`);
- } catch (e) {
- console.log(`failed to fetch nostr notes for ${pubkey}`, e);
- }
-
- notes.map((e: Note) => {
- e.seen = e.created_at;
- });
- }
-
- return { messages, notes };
-}
diff --git a/src/routes/(app)/[username]/messages/+page.svelte b/src/routes/(app)/[username]/messages/+page.svelte
deleted file mode 100644
index 4738ea2c..00000000
--- a/src/routes/(app)/[username]/messages/+page.svelte
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
- {$t("user.messages")}
-
- {#if latest.length && user?.id === subject.id}
-
- {:else}
-
{$t("user.noMessages")}
- {/if}
-
diff --git a/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts b/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts
deleted file mode 100644
index 6be9f6ec..00000000
--- a/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { get } from "$lib/utils";
-import type { Message } from "$lib/types";
-
-export async function load({ params, parent }) {
- let { user } = await parent();
- let { since = 0 } = params;
-
- let messages: Message[] = [];
- let recipient = await get(`/users/${params.recipient}`);
-
- try {
- messages = await get(`/${user.pubkey}/${since}/messages`);
-
- messages = messages
- .filter(
- (m: Message) => m.recipient?.id === recipient.id || m.author?.id === recipient.id
- )
- .sort((a, b) => a.created_at - b.created_at);
- } catch (e) {
- console.log(`failed to fetch nostr messages`, e);
- }
-
- return { messages, recipient, user };
-}
diff --git a/src/routes/(app)/[username]/messages/[recipient]/+page.svelte b/src/routes/(app)/[username]/messages/[recipient]/+page.svelte
deleted file mode 100644
index 98638389..00000000
--- a/src/routes/(app)/[username]/messages/[recipient]/+page.svelte
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/routes/(app)/[username]/reset/+server.ts b/src/routes/(app)/[username]/reset/+server.ts
deleted file mode 100644
index f7dba02c..00000000
--- a/src/routes/(app)/[username]/reset/+server.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { json } from "@sveltejs/kit";
-import { auth, post } from "$lib/utils";
-
-export async function POST({ cookies, request, params }) {
- let { username } = params;
- let r = await request.json();
- let { password } = r;
- let result = await post("/reset", { password, username }, auth(cookies));
- return json(result);
-}
diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts b/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts
deleted file mode 100644
index 42639b38..00000000
--- a/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { fail, redirect } from "@sveltejs/kit";
-import { fd, auth, get, post } from "$lib/utils";
-
-export function load({ cookies, params, url }) {
- if (url.pathname.endsWith("settings"))
- redirect(307, url.pathname + "/account");
- params.cookies = cookies.getAll();
- return { cookies: cookies.getAll(), tab: params.tab };
-}
-
-export const actions = {
- default: async ({ cookies, request }) => {
- let form = await fd(request);
-
- if (form.tab === "pos") {
- form.notify = form.notify === "on";
- form.nip5 = form.nip5 === "on";
- form.prompt = form.prompt === "on";
- form.autowithdraw = form.autowithdraw === "on";
- }
-
- let user = { ...(await get("/me", auth(cookies))), ...form };
-
- try {
- ({ user } = await post(`/user`, user, auth(cookies)));
- } catch (e: any) {
- return fail(400, { message: e.message });
- }
-
- if (user.language) cookies.set("lang", user.language, { path: "/" });
-
- return { user, success: true };
- },
-};
diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte
deleted file mode 100644
index 12980291..00000000
--- a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte
+++ /dev/null
@@ -1,257 +0,0 @@
-
-
-{#if user.haspin && $pin?.length !== 6}
-
-{/if}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {#if submitting}
-
- {:else}
- {$t("user.settings.saveSettings")}
- {/if}
-
-
-
-
-
diff --git a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte
deleted file mode 100644
index 8e3323c7..00000000
--- a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte
+++ /dev/null
@@ -1,190 +0,0 @@
-
-
-
-
{$t("user.settings.username")}
-
-
-
-
-
-
- {$t("user.settings.displayName")}
-
-
-
-
-
{$t("user.settings.email")}
-
- {$t("user.settings.emailDescription")}
-
-
-
-
- {#if user.verified}
-
- {:else if user.email}
-
- {/if}
-
-
-
-
-
{$t("user.settings.profileImage")}
-
-
- {#if $avatar || user.profile}
-
-
-
- {:else}
-
-
-
- {/if}
-
-
- {$t("user.settings.select")}
- handleFile(e, "profile")}
- />
-
-
-
- {#if tooLarge["avatar"]}
-
Max file size 10MB
- {/if}
-
-
-
-
- {$t("user.settings.bannerImage")}
-
-
- {#if $banner || user.banner}
-
- {:else}
-
- {/if}
-
-
{$t("user.settings.select")}
-
handleFile(e, "banner")}
- />
-
- {#if tooLarge["banner"]}
-
Max file size 10MB
- {/if}
-
-
-
- {$t("user.settings.about")}
-
-
diff --git a/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte b/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte
deleted file mode 100644
index 6a1c92a1..00000000
--- a/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte
+++ /dev/null
@@ -1,238 +0,0 @@
-
-
-
- {$t("user.settings.locale")}
-
-
-
-
- {$t("user.settings.localCurrency")}
-
- {#each fiats as fiat}
- {fiat}
- {/each}
-
-
-
-
- {$t("user.settings.memoPrompt")}
-
-
-
-
-
- {$t("user.settings.notifications")}
-
-
-
- {$t("user.settings.notificationsDesc")}
-
-
-
-
-
- {$t("user.settings.tipPrompt")}
-
-
-
- {$t("user.settings.tipPromptDescription")}
-
-
-
-
-
- {$t("user.settings.publishNip5")}
-
-
-
- {$t("user.settings.nip5a")}
- {user.username}@{$page.url.host}
- {$t("user.settings.nip5b")}
-
-
-
-
-
- {$t("user.settings.autoWithdraw")}
-
-
-
- {$t("user.settings.autoWithdrawDescription")}
-
-
-
-{#if user.autowithdraw}
-
- {$t("user.settings.destination")}
-
-
-
-
-
{$t("user.settings.threshold")}
-
-
- ⚡️
-
-
- {user.threshold}
-
-
-
-
- {$t("user.settings.thresholdDesc")}
-
-
-
-
-
{$t("user.settings.reserve")}
-
-
- ⚡️
-
-
- {user.reserve}
-
-
-
-
- {$t("user.settings.reserveDesc")}
-
-
-{/if}
-
-{#if editingThreshold}
-
-
-
- {$t("user.settings.threshold")}
-
-
-
- Ok
-
-
-{/if}
-
-{#if editingReserve}
-
-
-
- {$t("user.settings.reserve")}
-
-
- Ok
-
-
-{/if}
-
-
-
-
- {$t("user.settings.shopify")}
-
-
diff --git a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte
deleted file mode 100644
index 6b44f830..00000000
--- a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte
+++ /dev/null
@@ -1,321 +0,0 @@
-
-
-
-
-
-
- {$t("user.settings.newPassword")}
- {#if revealPassword}
-
- {:else}
-
- {/if}
-
-
-
-
-
-
-
{verifying
- ? $t("user.settings.verifyPIN")
- : $t("user.settings.securityPIN")}
-
- {$t("user.settings.securityPINDescription")}
-
- {#if verifying}
-
- {:else if settingPin}
-
- {:else}
-
- {user.haspin
- ? $t("user.settings.disablePIN")
- : $t("user.settings.enablePIN")}
- {/if}
-
-
-
-
{$t("user.settings.twofa")}
-
- {$t("user.settings.twofaDescription")}
-
-
- {#if setting2fa}
-
-
-
-
-
- {$t("user.settings.accountId")}
- {otp.secret}
-
-
-
-
- Confirm
-
- {:else if user.twofa}
-
-
- {$t("user.settings.twofaDisable")}
-
- {:else}
-
-
- {$t("user.settings.twofaSetup")}
-
- {/if}
-
- {#if confirming2fa || disabling2fa}
-
- {/if}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{$t("user.settings.nostrKeys")}
-
-
- {$t("user.settings.nostrDescription")}
-
-
-
-
- {#if revealNsec}
-
- {$t("user.settings.hideNsec")}
- {:else}
-
- {$t("user.settings.revealNsec")}
- {/if}
-
-
-
-
- {$t("user.settings.import")}
-
-
-
- {#if importing}
-
- {/if}
-
- {#if revealNsec}
-
- {nsec}
-
-
-
copy(nsec)}>
-
- Copy
-
- {/if}
-
diff --git a/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte b/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte
deleted file mode 100644
index 0266fa9c..00000000
--- a/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
-
Admin API token (Optional)
-
- Coinos can automatically mark orders as Paid if you provide an API token.
-
-
-
- Create a new app in Apps > App Development
-
-
-
- Edit the Admin API scopes to enable write_orders permission then install the app into your store and copy the Admin API access
- token here.
-
-
-
-
diff --git a/src/routes/(app)/[username]/verify/[code]/+page.server.ts b/src/routes/(app)/[username]/verify/[code]/+page.server.ts
deleted file mode 100644
index fec1a85c..00000000
--- a/src/routes/(app)/[username]/verify/[code]/+page.server.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { get } from "$lib/utils";
-import { redirect } from "@sveltejs/kit";
-
-export let load = async ({ params: { code } }) => {
- let user;
- try {
- user = await get(`/verify/${code}`);
- } catch (e) {
- console.log(e);
- return { error: "Verification failed" };
- }
-
- redirect(307, `/${user.username}/settings/account?verified=true`);
-};
diff --git a/src/routes/(app)/[username]/verify/[code]/+page.svelte b/src/routes/(app)/[username]/verify/[code]/+page.svelte
deleted file mode 100644
index 1e099dae..00000000
--- a/src/routes/(app)/[username]/verify/[code]/+page.svelte
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
- {#if error}
-
- Email verification failed
-
- {:else if user.verified}
-
-
-
-
-
- Email verified successfully!
-
- {/if}
-
-
-
-
-
-
-
- {$t("payments.tapAnywhere")}
-
diff --git a/src/routes/(app)/account/setup/+page.svelte b/src/routes/(app)/account/setup/+page.svelte
new file mode 100644
index 00000000..5a15316a
--- /dev/null
+++ b/src/routes/(app)/account/setup/+page.svelte
@@ -0,0 +1,64 @@
+
+
+
+
Account setup
+
Step 1
+
+
+
+ The keys to your savings account are derived from a seed phrase. When
+ you're ready, write it down and keep it safe.
+
+
+
+ Whoever knows these words in the correct order can withdraw funds from the account. We can't
+ recover them if you lose them.
+
+
+ {#if reveal}
+
+ {$mnemonic}
+
+
+
+ {:else}
+
+
+
+ {$t("user.settings.revealSeed")}
+
+
+ {/if}
+
+
diff --git a/src/routes/(app)/account/setup/step2/+page.svelte b/src/routes/(app)/account/setup/step2/+page.svelte
new file mode 100644
index 00000000..8169ce06
--- /dev/null
+++ b/src/routes/(app)/account/setup/step2/+page.svelte
@@ -0,0 +1,52 @@
+
+
+
+
+
Account setup
+ Step 2
+
+
+
+
+ Add an additional password to your seed phrase. It should be different
+ than your login password. We can't reset it if you lose it.
+
+
+
+
+
+ Submit
+
+
+
diff --git a/src/routes/(app)/admin/+page.svelte b/src/routes/(app)/admin/+page.svelte
index c61a2e45..214bf5b3 100644
--- a/src/routes/(app)/admin/+page.svelte
+++ b/src/routes/(app)/admin/+page.svelte
@@ -1,7 +1,7 @@
diff --git a/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte b/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte
index 679fbe76..89de4b58 100644
--- a/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte
+++ b/src/routes/(app)/ecash/[id]/[...version]/+layout.svelte
@@ -1,5 +1,4 @@
+
+{#if loaded && user?.haspin && $pin?.length !== 6}
+
+{/if}
+
+
+
+ Generating new account keys
+
+
+
+
+
diff --git a/src/routes/(app)/generate/+server.ts b/src/routes/(app)/generate/+server.ts
new file mode 100644
index 00000000..5a442982
--- /dev/null
+++ b/src/routes/(app)/generate/+server.ts
@@ -0,0 +1,12 @@
+import { auth, post } from "$lib/utils";
+import { error, json } from "@sveltejs/kit";
+
+export async function POST({ cookies, request }) {
+ try {
+ let 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)/invoice/+page.server.ts b/src/routes/(app)/invoice/+page.server.ts
new file mode 100644
index 00000000..83127457
--- /dev/null
+++ b/src/routes/(app)/invoice/+page.server.ts
@@ -0,0 +1,29 @@
+import { auth, post } from "$lib/utils";
+import { error, redirect } from "@sveltejs/kit";
+import type { Invoice } from "$lib/types";
+
+export let load = async ({ cookies, params, parent }) => {
+ let { account } = params;
+ let { subject, user, rates } = await parent();
+
+ let invoice: Invoice = {
+ account,
+ type: account ? "bitcoin" : "lightning",
+ rate: rates[user?.currency || subject?.currency],
+ };
+
+ if (!user) user = subject;
+
+ try {
+ invoice = await post("/invoice", { invoice, account, user }, auth(cookies));
+ } catch (e) {
+ console.log(e);
+ error(500, "Failed to generate invoice");
+ }
+
+ let { id } = invoice;
+
+ if (invoice.memoPrompt && !invoice.memo) {
+ redirect(307, `/invoice/${id}/memo`);
+ } else redirect(307, `/invoice/${id}`);
+};
diff --git a/src/routes/(app)/invoice/+page.svelte b/src/routes/(app)/invoice/+page.svelte
new file mode 100644
index 00000000..e69de29b
diff --git a/src/routes/(app)/invoice/+server.ts b/src/routes/(app)/invoice/+server.ts
new file mode 100644
index 00000000..5e3d0300
--- /dev/null
+++ b/src/routes/(app)/invoice/+server.ts
@@ -0,0 +1,7 @@
+import { auth, post } from "$lib/utils";
+import { json } from "@sveltejs/kit";
+
+export let POST = async ({ cookies: c, request: r }) => {
+ let j = await r.json();
+ return json(await post("/invoice", j, auth(c)));
+};
diff --git a/src/routes/(app)/invoice/[id]/+layout.server.ts b/src/routes/(app)/invoice/[id]/+layout.server.ts
new file mode 100644
index 00000000..e7144b15
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/+layout.server.ts
@@ -0,0 +1,36 @@
+import Qr from "qrcode-base64";
+import { get } from "$lib/utils";
+import { redirect } from "@sveltejs/kit";
+
+export async function load({ depends, params, url, parent }) {
+ depends("app:invoice");
+
+ let { subject, user } = await parent();
+ let { id } = params;
+ let invoice = await get(`/invoice/${id}`);
+ let options = !!url.searchParams.get("options");
+
+ if (
+ user &&
+ invoice.uid !== user.id &&
+ !(url.pathname.includes("tip") || url.pathname.includes("memo")) &&
+ !options
+ ) {
+ redirect(307, `/send/invoice/${id}`);
+ }
+
+ let { amount, pending, received } = invoice;
+ amount = parseInt(amount);
+
+ let paid =
+ (!amount && (pending || received)) ||
+ (amount > 0 && (pending >= amount || received >= amount));
+ if (paid && !url.pathname.endsWith("paid")) {
+ redirect( 307, `/invoice/${id}/paid` + (options ? "?options=true" : "")
+ );
+ }
+
+ let src = Qr.drawImg(invoice.text || "", { size: 340 });
+
+ return { id, invoice, subject, src };
+}
diff --git a/src/routes/(app)/invoice/[id]/+layout.svelte b/src/routes/(app)/invoice/[id]/+layout.svelte
new file mode 100644
index 00000000..4fa864ce
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/+layout.svelte
@@ -0,0 +1 @@
+
diff --git a/src/routes/(app)/invoice/[id]/+page.server.ts b/src/routes/(app)/invoice/[id]/+page.server.ts
new file mode 100644
index 00000000..a57efa64
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/+page.server.ts
@@ -0,0 +1,5 @@
+import invoice from "$lib/invoice";
+
+export const actions = {
+ default: invoice,
+};
diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte
new file mode 100644
index 00000000..c4810889
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/+page.svelte
@@ -0,0 +1,351 @@
+
+
+
+ {#if $showQr}
+
+ {: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}
+
+
+
copy(txt)}
+ >
+
+
+ {$t("payments.copy")}
+
+
+
+ {#if user?.id === invoice?.user?.id}
+
+
+ {$t("payments.setAmount")}
+
+ {:else}
+
+
+
+ {$t("payments.openLink")}
+
+
+ {/if}
+
+
+
($showQr = !$showQr)}
+ >
+ {#if $showQr}
+
+ {:else}
+
+ {/if}
+
+ {$showQr ? $t("payments.showText") : $t("payments.showQr")}
+
+
+
+
+ {#if !account}
+
+
setType(types.bitcoin)}
+ >
+
+ Bitcoin
+
+
+
setType(types.liquid)}
+ >
+
+ Liquid
+
+
+
setType(types.lightning)}
+ >
+
+ Lightning
+
+
+ {/if}
+
+ {#if type === types.liquid}
+
+
+ {$t("payments.onlyLbtc")}
+ L-BTC ,
+ {$t("payments.dontDeposit")}
+
+
+ {/if}
+
+ {#if user?.id === invoice?.user?.id}
+
+
+
+
+ {$t("payments.redeemVoucher")}
+
+
+ {/if}
+
+
+{#if settingAmount}
+
+
+
+
+
+
+
+
+ {$t("payments.amountPrompt")}
+
+
+
+
+{/if}
+
+
diff --git a/src/routes/(app)/invoice/[id]/memo/+page.server.ts b/src/routes/(app)/invoice/[id]/memo/+page.server.ts
new file mode 100644
index 00000000..24dec1af
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/memo/+page.server.ts
@@ -0,0 +1,13 @@
+import invoice from "$lib/invoice";
+import { redirect } from "@sveltejs/kit";
+
+export async function load({ parent, params }) {
+ let { invoice } = await parent();
+ if (!invoice.amount) {
+ redirect(307, `/invoice/${invoice.id}`);
+ }
+}
+
+export const actions = {
+ default: invoice,
+};
diff --git a/src/routes/(app)/invoice/[id]/memo/+page.svelte b/src/routes/(app)/invoice/[id]/memo/+page.svelte
new file mode 100644
index 00000000..4d23ff19
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/memo/+page.svelte
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$t("invoice.addMemo")}
+
+
+
{invoice.memoPrompt}
+
+
+
+ {$t("payments.next")}
+
+
diff --git a/src/routes/(app)/invoice/[id]/paid/+page.svelte b/src/routes/(app)/invoice/[id]/paid/+page.svelte
new file mode 100644
index 00000000..df05f12b
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/paid/+page.svelte
@@ -0,0 +1,85 @@
+
+
+
+ {#if received}
+
+
+
+
+
+ {$t("invoice.paymentSuccessful")}
+
+
+
+ {f(fiat(received - tip, rate), currency)}
+ {#if tip}
+
+ + {f(fiat(tip, rate), currency)}
+
+ {/if}
+
+
+ ⚡️{s(received - tip)}
+
+ {#if tip}
+
+ + ⚡️{s(tip)}
+
+ {/if}
+
+ {/if}
+
+ {#if pending}
+
+
+
+
+
Payment detected
+
+ {f(fiat(pending - tip, rate), currency)}
+ {#if tip}
+ + {f(fiat(tip, rate), currency)}
+ {/if}
+
+
+
+ ⚡️{s(pending - tip)}
+ {#if tip}
+
+ + ⚡️{s(tip)}
+
+ {/if}
+
+ {/if}
+
+
+
+
+
+
+
+ {$t("payments.tapAnywhere")}
+
diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts
new file mode 100644
index 00000000..8417de91
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts
@@ -0,0 +1,12 @@
+import invoice from "$lib/invoice";
+import { redirect } from "@sveltejs/kit";
+
+export async function load({ parent, params }) {
+ let { invoice } = await parent();
+ if (!invoice.amount)
+ redirect(307, `/invoice/${invoice.id}`);
+}
+
+export const actions = {
+ default: invoice,
+};
diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte
new file mode 100644
index 00000000..35b24bf1
--- /dev/null
+++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte
@@ -0,0 +1,209 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {#if invoice.memoPrompt}
+
+ {/if}
+
+ {$t("invoice.addTipq")}
+ {#if !showCustomAmount}
+ {Math.round(tipPercent)}%
+
+
+
+
+
+
+ {f(amountFiat, currency)}
+ +{f(tipAmount, currency)}
+
+
+
+
+ {sat(amount)}
+ +{sat(tip)}
+
+
+
+ {#if tip}
+
+ submit.click()}>Next
+ (tipPercent = 0)}>Reset
+
+ {:else}
+ {#each tipAmounts as amount}
+ handleTipButtonClick(amount)}>{amount}
+ {/each}
+ {/if}
+
+
+ (showCustomAmount = true)}
+ >Custom
+
+ {/if}
+
+
+
+
+ {#if showCustomAmount}
+
+
+ $
+ handleCustomTipAmount(e)}
+ class="pl-10"
+ placeholder="Custom amount"
+ use:focus
+ />
+ Apply
+
+
+ {/if}
+
+
+
diff --git a/src/routes/(app)/invoice/sent/+page.svelte b/src/routes/(app)/invoice/sent/+page.svelte
new file mode 100644
index 00000000..b95bc85e
--- /dev/null
+++ b/src/routes/(app)/invoice/sent/+page.svelte
@@ -0,0 +1,11 @@
+
+
+Invoice sent to
+
+
+
{$request.requester.username} is ready to pay
+
diff --git a/src/routes/(app)/items/[id]/+page.server.ts b/src/routes/(app)/items/[id]/+page.server.ts
new file mode 100644
index 00000000..67cebd93
--- /dev/null
+++ b/src/routes/(app)/items/[id]/+page.server.ts
@@ -0,0 +1,21 @@
+import { fd, auth, get, post } from "$lib/utils";
+import { fail, redirect } from "@sveltejs/kit";
+
+export let load = async ({ params: { id } }) => {
+ let item = await get(`/items/${id}`);
+ return { item };
+};
+
+export const actions = {
+ default: async ({ cookies, request, url }) => {
+ let form = await fd(request);
+ try {
+ await post(`/items`, form, auth(cookies));
+ } catch (e: any) {
+ return fail(400, { message: e.message });
+ }
+
+ let success = `/${url.pathname.split("/")[1]}`;
+ redirect(307, success);
+ },
+};
diff --git a/src/routes/(app)/items/[id]/+page.svelte b/src/routes/(app)/items/[id]/+page.svelte
new file mode 100644
index 00000000..65720350
--- /dev/null
+++ b/src/routes/(app)/items/[id]/+page.svelte
@@ -0,0 +1,18 @@
+
+
+
+
+ {$t("items.edit")}
+
+
+
diff --git a/src/routes/(app)/items/create/+page.server.ts b/src/routes/(app)/items/create/+page.server.ts
new file mode 100644
index 00000000..2e006a3e
--- /dev/null
+++ b/src/routes/(app)/items/create/+page.server.ts
@@ -0,0 +1,16 @@
+import { fail, redirect } from "@sveltejs/kit";
+import { fd, auth, post } from "$lib/utils";
+
+export const actions = {
+ default: async ({ cookies, request, url }) => {
+ let form = await fd(request);
+ try {
+ await post("/items", form, auth(cookies));
+ } catch (e: any) {
+ return fail(400, { message: e.message });
+ }
+
+ let success = `/${url.pathname.split("/")[1]}`;
+ redirect(307, success);
+ },
+};
diff --git a/src/routes/(app)/items/create/+page.svelte b/src/routes/(app)/items/create/+page.svelte
new file mode 100644
index 00000000..b82889c9
--- /dev/null
+++ b/src/routes/(app)/items/create/+page.svelte
@@ -0,0 +1,19 @@
+
+
+
+
+ {$t("items.add")}
+
+
+
diff --git a/src/routes/(app)/ln/[lnurl]/+page.server.ts b/src/routes/(app)/ln/[lnurl]/+page.server.ts
index d1b1b86e..c078ae8e 100644
--- a/src/routes/(app)/ln/[lnurl]/+page.server.ts
+++ b/src/routes/(app)/ln/[lnurl]/+page.server.ts
@@ -70,6 +70,6 @@ export const actions = {
let c = callback.includes("?") ? "&" : "?";
await fetch(`${callback}${c}k1=${k1}&pr=${pr}`).then((r) => r.json());
- redirect(307, `/${username}/payments`);
+ redirect(307, `/payments`);
},
};
diff --git a/src/routes/(app)/ln/withdrawal/sent/+page.svelte b/src/routes/(app)/ln/withdrawal/sent/+page.svelte
index c1a2bdb2..90814960 100644
--- a/src/routes/(app)/ln/withdrawal/sent/+page.svelte
+++ b/src/routes/(app)/ln/withdrawal/sent/+page.svelte
@@ -19,7 +19,7 @@
Request Sent!
-