aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-28 08:04:46 -0800
committerAdam Soltys <[email protected]>2024-11-28 08:04:46 -0800
commit380da842ffdb597eebb88f217f89a9268cbfaf6a (patch)
tree1cf3067d057a8d6c1be3bb89f96ee9deaa8ab05d /src/routes/(app)
parentc1098927eddb6c9c5beac8420e5cf48edc526731 (diff)
downloadcoinos-ui-380da842ffdb597eebb88f217f89a9268cbfaf6a.tar.gz
coinos-ui-380da842ffdb597eebb88f217f89a9268cbfaf6a.zip
currency locale
Diffstat (limited to 'src/routes/(app)')
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte1
-rw-r--r--src/routes/(app)/[username]/receive/+page.svelte21
-rw-r--r--src/routes/(app)/invoice/[id]/+page.svelte4
-rw-r--r--src/routes/(app)/payments/[...page]/+page.server.ts23
-rw-r--r--src/routes/(app)/payments/[...page]/+page.svelte40
-rw-r--r--src/routes/(app)/reset/[code]/+page.svelte37
-rw-r--r--src/routes/(app)/send/lightning/[payreq]/+page.svelte3
7 files changed, 66 insertions, 63 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index f6a9edae..55ea9f2d 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -288,7 +288,6 @@
></iconify-icon>
{s((1 * sats) / rates[currency])} =
{f(1, currency)}
- {currency}
</div>
</div>
</div>
diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte
index 89f3a1f3..e8092c11 100644
--- a/src/routes/(app)/[username]/receive/+page.svelte
+++ b/src/routes/(app)/[username]/receive/+page.svelte
@@ -1,6 +1,17 @@
<script>
import { run } from "svelte/legacy";
- import { btc, post, copy, f, get, types, sat, s, sats } from "$lib/utils";
+ import {
+ btc,
+ loc,
+ post,
+ copy,
+ f,
+ get,
+ types,
+ sat,
+ s,
+ sats,
+ } from "$lib/utils";
import { tick, onMount, onDestroy } from "svelte";
import { browser } from "$app/environment";
import { last, showQr, amountPrompt } from "$lib/store";
@@ -18,6 +29,7 @@
let { id, rates, subject, user, text } = $state(data);
let { src } = $derived(data);
+ let locale = loc(user);
let { currency, username } = subject;
let rate = rates[currency];
@@ -48,7 +60,10 @@
user: { username, currency },
}));
- goto(`/invoice/${id}?options=true`, { invalidateAll: true, noScroll: true });
+ goto(`/invoice/${id}?options=true`, {
+ invalidateAll: true,
+ noScroll: true,
+ });
}
};
@@ -95,6 +110,7 @@
<div class="invoice container mx-auto max-w-xl px-4 space-y-2">
<InvoiceData
{src}
+ {locale}
{link}
{qr}
{txt}
@@ -127,6 +143,7 @@
bind:newAmount
bind:fiat
{currency}
+ locale={loc(user)}
{rate}
{submit}
{settingAmount}
diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte
index 3b7b33ef..b66e394a 100644
--- a/src/routes/(app)/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/+page.svelte
@@ -2,7 +2,7 @@
import { untrack } from "svelte";
import { enhance } from "$app/forms";
import { send } from "$lib/socket";
- import { btc, post, copy, f, get, types, sat, s, sats } from "$lib/utils";
+ import { btc, loc, post, copy, f, get, types, sat, s, sats } from "$lib/utils";
import { tick, onMount, onDestroy } from "svelte";
import { browser } from "$app/environment";
import { last, showQr, amountPrompt } from "$lib/store";
@@ -29,6 +29,7 @@
let { invoice, src } = $derived(data);
let { aid, amount, rate, tip, hash, text, type } = $derived(invoice);
let { username, currency } = $derived(invoice.user);
+ let locale = loc(user);
let tipPercent = $derived(tip ? (tip / amount) * 100 : 0);
@@ -119,6 +120,7 @@
{amount}
{amountFiat}
{currency}
+ {locale}
{tip}
{rate}
showQr={$showQr}
diff --git a/src/routes/(app)/payments/[...page]/+page.server.ts b/src/routes/(app)/payments/[...page]/+page.server.ts
index 05ed2d64..6b9f47e2 100644
--- a/src/routes/(app)/payments/[...page]/+page.server.ts
+++ b/src/routes/(app)/payments/[...page]/+page.server.ts
@@ -1,6 +1,6 @@
-import { auth, get } from "$lib/utils";
+import { auth, get, str } from "$lib/utils";
-const limit = 25;
+const limit = 5;
export async function load({ cookies, depends, params }) {
depends("app:payments");
@@ -17,15 +17,22 @@ export async function load({ cookies, depends, params }) {
if (!parseInt(page)) page = 1;
const offset = (page - 1) * limit;
- if (!start) start = Date.now() / 1000 - 24 * 60 * 60;
- let url = `/payments?aid=${aid}&start=${
- start * 1000
- }&limit=${limit}&offset=${offset}`;
- if (end) url += `&end=${end * 1000}`;
+ const q = new URLSearchParams();
+ q.set("limit", str(limit));
+ q.set("offset", str(offset));
+ if (aid) q.set("aid", aid);
+ if (start) q.set("start", str(start * 1000));
+ if (end) q.set("end", str(end * 1000));
- const { count, payments, incoming, outgoing } = await get(url, auth(cookies));
+ const { count, payments, incoming, outgoing } = await get(
+ `/payments?${str(q)}`,
+ auth(cookies),
+ );
+
+ console.log("payments", payments.length);
const pages = new Array(Math.ceil(count / limit));
+ console.log("pages", pages);
return { payments, page, pages, start, end, incoming, outgoing };
}
diff --git a/src/routes/(app)/payments/[...page]/+page.svelte b/src/routes/(app)/payments/[...page]/+page.svelte
index 146a286d..529c8c63 100644
--- a/src/routes/(app)/payments/[...page]/+page.svelte
+++ b/src/routes/(app)/payments/[...page]/+page.svelte
@@ -5,14 +5,23 @@
import { format } from "date-fns";
import { newPayment } from "$lib/store";
import { t } from "$lib/translations";
- import { get, f, s, si, sat, sats, types } from "$lib/utils";
+ import { get, f, s, si, sat, loc, sats, types } from "$lib/utils";
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, end, user, rates, payments, incoming, outgoing } =
- $derived(data);
+ let {
+ start,
+ end,
+ user,
+ rates,
+ payments,
+ incoming,
+ outgoing,
+ pages,
+ page: p,
+ } = $derived(data);
let locale = locales[user.language];
@@ -55,9 +64,6 @@
: 0,
);
- let p = $state(),
- pages = $state([]);
-
$effect(() => {
if ($newPayment) {
$newPayment = false;
@@ -135,7 +141,8 @@
}
};
- let showPage = $derived((i) => {
+ let showPage = (i) => {
+ console.log("SHOW", i);
const currentPage = parseInt(p);
const maxVisiblePages = 10;
@@ -153,13 +160,10 @@
}
return i >= start && i <= end;
- });
+ };
- let isEllipsis = $derived((i) => {
- return (
- (i === 1 && !showPage(i)) || (i === pages.length - 2 && !showPage(i))
- );
- });
+ let isEllipsis = (i) =>
+ (i === 1 && !showPage(i)) || (i === pages.length - 2 && !showPage(i));
</script>
<div class="space-y-5">
@@ -218,7 +222,7 @@
</div>
<div class="text-secondary flex items-center text-base">
- {f(Math.abs(p.amount) * (p.rate / sats), p.currency)}
+ {f(Math.abs(p.amount) * (p.rate / sats), p.currency, loc(user))}
{#if p.tip}
<span class="text-sm text-secondary">
@@ -322,15 +326,15 @@
>{$t("payments.income")}</span
>
<!-- <span><b>{subtotalIn ? f(subtotalIn, c) : "-"}</b></span> -->
- <span><b>{tipsIn ? f(tipsIn, c) : "-"}</b></span>
- <span><b>{totalIn ? f(totalIn, c) : "-"}</b></span>
+ <span><b>{tipsIn ? f(tipsIn, c, loc(user)) : "-"}</b></span>
+ <span><b>{totalIn ? f(totalIn, c, loc(user)) : "-"}</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 ? f(tipsOut, c) : "-"}</b></span>
- <span><b>{totalOut ? f(totalOut, c) : "-"}</b></span>
+ <span><b>{tipsOut ? f(tipsOut, c, loc(user)) : "-"}</b></span>
+ <span><b>{totalOut ? f(totalOut, c, loc(user)) : "-"}</b></span>
{/each}
</div>
</div>
diff --git a/src/routes/(app)/reset/[code]/+page.svelte b/src/routes/(app)/reset/[code]/+page.svelte
index 144c73a9..df9d1144 100644
--- a/src/routes/(app)/reset/[code]/+page.svelte
+++ b/src/routes/(app)/reset/[code]/+page.svelte
@@ -1,5 +1,6 @@
<script>
import { t } from "$lib/translations";
+ import PasswordInput from "$comp/PasswordInput.svelte";
import Icon from "$comp/Icon.svelte";
import Spinner from "$comp/Spinner.svelte";
import { fly } from "svelte/transition";
@@ -8,7 +9,6 @@
let { form } = $props();
let email;
let loading;
- let revealPassword = $state();
</script>
<div class="pt-10">
@@ -31,37 +31,10 @@
{/if}
<form class="space-y-5" method="POST">
- <div class="relative">
- <label for="password" class="block font-semibold"
- >{$t("login.newPassword")}</label
- >
- {#if revealPassword}
- <input
- name="password"
- type="text"
- required
- class="bg-primary"
- bind:value={$password}
- autocapitalize="none"
- />
- {:else}
- <input
- name="password"
- type="password"
- required
- class="bg-primary"
- bind:value={$password}
- autocapitalize="none"
- />
- {/if}
- <button
- type="button"
- onclick={() => (revealPassword = !revealPassword)}
- class="absolute right-5 top-10"
- >
- <Icon icon={revealPassword ? "eye" : "eye-off"} />
- </button>
- </div>
+ <PasswordInput
+ bind:value={$password}
+ placeholder={$t("login.password")}
+ />
<div class="text-secondary">
A new seed phrase will be generated for your account. You'll need to
diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte
index 2d981326..a4474fe0 100644
--- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte
+++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte
@@ -1,4 +1,5 @@
<script>
+ import { untrack } from "svelte";
import { t } from "$lib/translations";
import { enhance } from "$app/forms";
import Amount from "$comp/Amount.svelte";
@@ -30,7 +31,7 @@
let next = $state();
let toggle = () => (show = !show);
let amount = $derived(form?.amount || data.amount);
- let maxfee = $state(Math.max(5, Math.round(amount * 0.005)));
+ let maxfee = $state(Math.max(5, Math.round(untrack(amount) * 0.005)));
</script>
<div class="container px-4 max-w-xl mx-auto text-center space-y-2">