diff options
| author | Adam Soltys <[email protected]> | 2024-11-26 13:08:08 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-26 13:20:53 -0800 |
| commit | 0bf630c39fe290ea2718eab7a0759d978c736ef9 (patch) | |
| tree | a670c3ae954d5075c851126c2aca7a1a45d1b41d /src/routes/(app)/payments | |
| parent | 41ee0027e1767e4d116330bdee2e0456fd45f940 (diff) | |
| download | coinos-ui-0bf630c39fe290ea2718eab7a0759d978c736ef9.tar.gz coinos-ui-0bf630c39fe290ea2718eab7a0759d978c736ef9.zip | |
bip21 and socket fixes
Diffstat (limited to 'src/routes/(app)/payments')
| -rw-r--r-- | src/routes/(app)/payments/[...page]/+page.server.ts | 2 | ||||
| -rw-r--r-- | src/routes/(app)/payments/[...page]/+page.svelte | 186 |
2 files changed, 90 insertions, 98 deletions
diff --git a/src/routes/(app)/payments/[...page]/+page.server.ts b/src/routes/(app)/payments/[...page]/+page.server.ts index 268fd32b..05ed2d64 100644 --- a/src/routes/(app)/payments/[...page]/+page.server.ts +++ b/src/routes/(app)/payments/[...page]/+page.server.ts @@ -1,4 +1,4 @@ -import { get, auth } from "$lib/utils"; +import { auth, get } from "$lib/utils"; const limit = 25; diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte index cda7c350..146a286d 100644 --- a/src/routes/(app)/payments/[...page]/+page.svelte +++ b/src/routes/(app)/payments/[...page]/+page.svelte @@ -11,8 +11,9 @@ import { goto, invalidate } from "$app/navigation"; import locales from "$lib/locales"; let { data } = $props(); + let { start, end, user, rates, payments, incoming, outgoing } = + $derived(data); - let { start, end, user, rates, payments } = $state(data); let locale = locales[user.language]; let change = ({ target: { value } }) => goto(value); @@ -55,19 +56,13 @@ ); let p = $state(), - incoming = $state(), - outgoing = $state(), pages = $state([]); - run(() => { - data && - ({ page: p, pages, start, end, incoming, outgoing, payments } = data); - }); - run(() => { - $page && ($newPayment = false); - }); - run(() => { - $newPayment && invalidate(`/users/${user.username}`); + $effect(() => { + if ($newPayment) { + $newPayment = false; + invalidate(`/users/${user.username}`); + } }); let path = $derived( @@ -204,104 +199,101 @@ <div class="text-base"> {#each payments as p, i} - <div - class="grid grid-cols-12 border-b border-base-200 hover:bg-base-200 px-1 py-2 lg:p-4 cursor-pointer" - class:border-b-0={i === payments.length - 1} - class:text-error={p.amount < 0} - onclick={() => goto(`/payment/${p.id}`)} - > - <div class="whitespace-nowrap my-auto col-span-3"> - <div - class="font-bold flex items-center" - > - <div class="flex items-center"> - <iconify-icon - icon="ph:lightning-fill" - width="24" - class="text-yellow-300" - ></iconify-icon> - <div>{s(Math.abs(p.amount))}</div> - </div> + <div + class="grid grid-cols-12 border-b border-base-200 hover:bg-base-200 px-1 py-2 lg:p-4 cursor-pointer" + class:border-b-0={i === payments.length - 1} + class:text-error={p.amount < 0} + onclick={() => goto(`/payment/${p.id}`)} + > + <div class="whitespace-nowrap my-auto col-span-3"> + <div class="font-bold flex items-center"> + <div class="flex items-center"> + <iconify-icon + icon="ph:lightning-fill" + width="24" + class="text-yellow-300" + ></iconify-icon> + <div>{s(Math.abs(p.amount))}</div> </div> + </div> - <div class="text-secondary flex items-center text-base"> - {f(Math.abs(p.amount) * (p.rate / sats), p.currency)} + <div class="text-secondary flex items-center text-base"> + {f(Math.abs(p.amount) * (p.rate / sats), p.currency)} - {#if p.tip} - <span class="text-sm text-secondary"> - +{Math.round((p.tip / Math.abs(p.amount)) * 100)}% - </span> - {/if} - </div> + {#if p.tip} + <span class="text-sm text-secondary"> + +{Math.round((p.tip / Math.abs(p.amount)) * 100)}% + </span> + {/if} </div> + </div> - <div - class="flex my-auto col-span-6 truncate text-ellipsis overflow-hidden mx-auto" - > - {#if p.type === types.pot} - <a href={`/pot/${p.memo}`}> - <div class="text-secondary flex"> - <div class="my-auto mr-1"> - <img src="/images/moneypot.png" class="w-12" alt="Pot" /> - </div> - - <div class="my-auto">Pot</div> - </div> - </a> - {:else if p.with} - <div class="flex"> - <div class="my-auto"> - <Avatar user={p.with} size={12} disabled={true} /> - </div> - <div class="my-auto ml-1 text-secondary"> - {p.with.username} + <div + class="flex my-auto col-span-6 truncate text-ellipsis overflow-hidden mx-auto" + > + {#if p.type === types.pot} + <a href={`/pot/${p.memo}`}> + <div class="text-secondary flex"> + <div class="my-auto mr-1"> + <img src="/images/moneypot.png" class="w-12" alt="Pot" /> </div> - </div> - {:else} - <div class="text-secondary flex items-center gap-1"> - {#if p.type === types.lightning} - <iconify-icon - icon="ph:lightning-fill" - class="text-yellow-300 text-3xl" - ></iconify-icon> - {:else if p.type === types.ecash} - <img src="/images/cash.png" class="w-12" /> - {:else if p.type === types.reconcile} - <iconify-icon icon="ph:scales-bold" width="32" - ></iconify-icon> - {:else if p.type === types.bitcoin} - <iconify-icon icon="logos:bitcoin" class="text-3xl" - ></iconify-icon> - {:else if p.type === types.liquid} - <div class="my-auto"> - <img - src="/images/liquid.svg" - class="w-10 border-4 border-transparent" - alt="Liquid" - /> - </div> - {/if} + <div class="my-auto">Pot</div> + </div> + </a> + {:else if p.with} + <div class="flex"> + <div class="my-auto"> + <Avatar user={p.with} size={12} disabled={true} /> + </div> + <div class="my-auto ml-1 text-secondary"> + {p.with.username} + </div> + </div> + {:else} + <div class="text-secondary flex items-center gap-1"> + {#if p.type === types.lightning} + <iconify-icon + icon="ph:lightning-fill" + class="text-yellow-300 text-3xl" + ></iconify-icon> + {:else if p.type === types.ecash} + <img src="/images/cash.png" class="w-12" /> + {:else if p.type === types.reconcile} + <iconify-icon icon="ph:scales-bold" width="32"></iconify-icon> + {:else if p.type === types.bitcoin} + <iconify-icon icon="logos:bitcoin" class="text-3xl" + ></iconify-icon> + {:else if p.type === types.liquid} <div class="my-auto"> - {p.amount > 0 - ? p.confirmed - ? "Received" - : "Pending" - : "Sent"} + <img + src="/images/liquid.svg" + class="w-10 border-4 border-transparent" + alt="Liquid" + /> </div> - </div> - {/if} - </div> + {/if} - <div class="text-secondary text-right text-sm my-auto col-span-3"> - <div> - {format(new Date(p.created), "h:mm aaa", { locale })} - </div> - <div> - {format(new Date(p.created), "MMM d, yy", { locale })} + <div class="my-auto"> + {p.amount > 0 + ? p.confirmed + ? "Received" + : "Pending" + : "Sent"} + </div> </div> + {/if} + </div> + + <div class="text-secondary text-right text-sm my-auto col-span-3"> + <div> + {format(new Date(p.created), "h:mm aaa", { locale })} + </div> + <div> + {format(new Date(p.created), "MMM d, yy", { locale })} </div> </div> + </div> {:else} <p class="text-secondary text-lg text-center">{$t("payments.empty")}</p> {/each} |
