diff options
| author | Adam Soltys <[email protected]> | 2025-01-24 18:14:26 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-01-24 18:14:26 -0800 |
| commit | 52f2bda928624e2f54b17d43a74362a69e2945c3 (patch) | |
| tree | 51df01f302c480207ee333bf9fe0dc4159e99ee2 /src | |
| parent | 23fc55bc2378d54121d3836d7f55e7756f7b87ed (diff) | |
| download | coinos-ui-52f2bda928624e2f54b17d43a74362a69e2945c3.tar.gz coinos-ui-52f2bda928624e2f54b17d43a74362a69e2945c3.zip | |
parse payment memos
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Event.svelte | 3 | ||||
| -rw-r--r-- | src/locales/en.json | 4 | ||||
| -rw-r--r-- | src/routes/(app)/account/[id]/+page.svelte | 22 | ||||
| -rw-r--r-- | src/routes/(app)/e/[id]/+page.svelte | 2 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.svelte | 50 | ||||
| -rw-r--r-- | src/routes/(app)/send/lightning/[payreq]/+page.svelte | 2 |
6 files changed, 49 insertions, 34 deletions
diff --git a/src/components/Event.svelte b/src/components/Event.svelte index aa8d1ac8..eb26de0a 100644 --- a/src/components/Event.svelte +++ b/src/components/Event.svelte @@ -6,6 +6,7 @@ import { sign } from "$lib/nostr"; import Pin from "$comp/Pin.svelte"; import { pin } from "$lib/store"; + import { page } from "$app/stores"; let amount = 21; let { event, minimal, last = true, user } = $props(); @@ -18,12 +19,14 @@ try { const body = new FormData(); + if (!user) return goto(`/register?redirect=${$page.url.pathname}`); let request = await post("/post/zapRequest", { amount, id }); let { pr: payreq } = await post("/post/zap", { event: await sign(request), }); await post("/post/payments", { amount, payreq }); } catch (e) { + console.log(e); fail(e.message); } }; diff --git a/src/locales/en.json b/src/locales/en.json index e3d328a0..c82cfc9b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -352,6 +352,10 @@ } }, "payments": { + "viewFund": "View fund", + "zappedEvent": "Zapped event", + "accountSettings": "Account settings", + "advancedSettings": "Advanced settings", "moreOptions": "More options...", "other": "Other", "ok": "Ok", diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index ccdaf98c..a8dcd70b 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -48,7 +48,9 @@ </script> <div class="space-y-5"> - <h1 class="text-center text-3xl font-semibold">Account settings</h1> + <h1 class="text-center text-3xl font-semibold"> + {$t("payments.accountSettings")} + </h1> <div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-2"> <form class="space-y-5" method="POST"> @@ -57,12 +59,14 @@ <Mnemonic {mnemonic} /> <button onclick={() => copy(mnemonic)} type="button" class="btn"> - <iconify-icon noobserver icon="ph:copy-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:copy-bold" width="32" + ></iconify-icon> <div class="my-auto">{$t("accounts.copy")}</div></button > {:else if seed} <button onclick={toggle} type="button" class="btn"> - <iconify-icon noobserver icon="ph:eye-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:eye-bold" width="32" + ></iconify-icon> <div class="my-auto">{$t("accounts.revealMnemonic")}</div></button > {:else if nwc} @@ -70,25 +74,29 @@ {nwc} </div> <button onclick={() => copy(nwc)} type="button" class="btn"> - <iconify-icon noobserver icon="ph:copy-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:copy-bold" width="32" + ></iconify-icon> <div class="my-auto">{$t("accounts.copy")}</div></button > <a href={`/qr/${encodeURIComponent(nwc)}`} class="my-auto block"> <button onclick={() => copy(nwc)} type="button" class="btn"> - <iconify-icon noobserver icon="ph:qr-code-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:qr-code-bold" width="32" + ></iconify-icon> <div class="my-auto">{$t("user.receive.showQR")}</div></button > </a> {:else} <button onclick={revealNwc} type="button" class="btn"> - <iconify-icon noobserver icon="ph:eye-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:eye-bold" width="32" + ></iconify-icon> <div class="my-auto">{$t("accounts.revealNwc")}</div></button > {/if} {#if seed} <button onclick={del} type="button" class="btn"> - <iconify-icon noobserver icon="ph:trash-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:trash-bold" width="32" + ></iconify-icon> <div class="my-auto">{$t("accounts.deleteAccount")}</div></button > {/if} diff --git a/src/routes/(app)/e/[id]/+page.svelte b/src/routes/(app)/e/[id]/+page.svelte index 623e1aa7..820d449d 100644 --- a/src/routes/(app)/e/[id]/+page.svelte +++ b/src/routes/(app)/e/[id]/+page.svelte @@ -3,8 +3,6 @@ let { data } = $props(); let { event, user } = $derived(data); - - let zap = () => {}; </script> <div class="container px-4 max-w-xl mx-auto space-y-5"> diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 3fae32dc..20f41588 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -80,7 +80,10 @@ <span class="text-lg text-secondary">{$t(title)}</span> <div class="flex gap-2 items-end"> <div class="flex items-center"> - <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300" + <iconify-icon + noobserver + icon="ph:lightning-fill" + class="text-yellow-300" ></iconify-icon>{s(amount, userLocale)} </div> <span class="text-secondary text-lg"> @@ -106,23 +109,6 @@ </div> </a> {/if} - {#if p.type === types.fund} - <div> - <span class="text-lg text-secondary my-auto mr-2">{direction}</span> - <a href={`/fund/${p.memo}`}> - <div class="flex"> - <div class="my-auto"> - <iconify-icon noobserver - icon="ph:lightning-fill" - width="24" - class="text-yellow-300" - ></iconify-icon> - </div> - <div class="my-auto ml-1">{p.memo}</div> - </div> - </a> - </div> - {/if} {@render field("payments.amount", a)} @@ -146,16 +132,32 @@ </div> {#if type === types.ecash && amount < 0} - <a href={`/ecash/${memo}`} class="block"> - <button class="btn"> - <img src="/images/cash.png" class="w-8" alt="Cash" /> - <div>{$t("payments.ecashToken")}</div> - </button> + <a href={`/ecash/${memo}`} class="btn"> + <img src="/images/cash.png" class="w-8" alt="Cash" /> + <div>{$t("payments.ecashToken")}</div> + </a> + {:else if type === types.fund} + <a href={`/fund/${memo}`} class="btn btn-accent"> + <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300" + ></iconify-icon>{$t("payments.viewFund")} + </a> + {:else if memo?.includes("9734")} + {@const eid = JSON.parse(memo).tags.find((t) => t[0] === "e")[1]} + <a href={`/e/${eid}`} class="btn btn-accent"> + <img src="/images/nostr.png" class="w-8" /> + <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300" + ></iconify-icon>{$t("payments.zappedEvent")} </a> {:else if memo} <div> <span class="text-lg text-secondary">{$t("payments.memo")}</span> - <div>{memo}</div> + <div> + {#if memo.includes("text/plain")} + {JSON.parse(memo)[0][1]} + {:else} + {memo} + {/if} + </div> </div> {/if} diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte index b8caaecc..bc526d16 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte @@ -115,7 +115,7 @@ {#if !(form?.message || showMax)} <button type="button" class="btn" onclick={() => (showMax = !showMax)} - >Advanced settings</button + >{$t("payments.advancedSettings")}</button > <input name="maxfee" type="hidden" bind:value={maxfee} /> {/if} |
