aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/invoice
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-14 10:55:08 -0800
committerAdam Soltys <[email protected]>2024-11-14 10:55:08 -0800
commit614fbd99b7963ec89666b8b4252fa5f73c81653c (patch)
treed2231fb5aecde3de16242f96b1de5d8c805ebe57 /src/routes/(app)/invoice
parentd0f19f20021cab8c740bda8c3d360748fd6c30de (diff)
downloadcoinos-ui-614fbd99b7963ec89666b8b4252fa5f73c81653c.tar.gz
coinos-ui-614fbd99b7963ec89666b8b4252fa5f73c81653c.zip
amount component
Diffstat (limited to 'src/routes/(app)/invoice')
-rw-r--r--src/routes/(app)/invoice/[id]/+page.svelte6
-rw-r--r--src/routes/(app)/invoice/[id]/paid/+page.svelte21
2 files changed, 16 insertions, 11 deletions
diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte
index 54e71071..15dc97ae 100644
--- a/src/routes/(app)/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/+page.svelte
@@ -28,9 +28,8 @@
let { id, subject, user } = $state(data);
let { invoice, src } = $derived(data);
- let { hash, text } = $derived(invoice);
- let { aid, amount, type, rate, tip } = $state(invoice);
- let { username, currency } = invoice.user;
+ let { aid, amount, rate, tip, hash, text, type } = $derived(invoice);
+ let { username, currency } = $derived(invoice.user);
let tipPercent = $derived(tip ? (tip / amount) * 100 : 0);
@@ -69,7 +68,6 @@
let setAmount = $state(async () => {
if (typeof $amountPrompt === "undefined") $amountPrompt = true;
settingAmount = false;
- amount = newAmount;
invoice.amount = newAmount;
invoice.tip = 0;
({ id } = await post(`/invoice`, {
diff --git a/src/routes/(app)/invoice/[id]/paid/+page.svelte b/src/routes/(app)/invoice/[id]/paid/+page.svelte
index 1bbba082..d6cfaa46 100644
--- a/src/routes/(app)/invoice/[id]/paid/+page.svelte
+++ b/src/routes/(app)/invoice/[id]/paid/+page.svelte
@@ -1,15 +1,22 @@
<script>
- import { run } from 'svelte/legacy';
+ import { run } from "svelte/legacy";
import { scale } from "svelte/transition";
import Icon from "$comp/Icon.svelte";
import { toast } from "@zerodevx/svelte-toast";
import { browser } from "$app/environment";
import { t } from "$lib/translations";
- import { fiat, f, s, sat, sats } from "$lib/utils";
+ import { toFiat, f, s, sat, sats } from "$lib/utils";
let { data } = $props();
- let amount, currency = $state(), rate = $state(), received = $state(), pending = $state(), tip = $state(), user = $state(), id;
+ let amount,
+ currency = $state(),
+ rate = $state(),
+ received = $state(),
+ pending = $state(),
+ tip = $state(),
+ user = $state(),
+ id;
let update = (data) => {
({ amount, currency, rate, received, pending, tip, user, id } =
data.invoice);
@@ -35,10 +42,10 @@
</h1>
<h2 class="text-2xl md:text-3xl font-semibold">
- {f(fiat(received - tip, rate), currency)}
+ {f(toFiat(received - tip, rate), currency)}
{#if tip}
<span class="text-lg">
- + {f(fiat(tip, rate), currency)}
+ + {f(toFiat(tip, rate), currency)}
</span>
{/if}
</h2>
@@ -63,9 +70,9 @@
<h1 class="text-3xl md:text-4xl font-bold mb-6">Payment detected</h1>
<h2 class="text-2xl md:text-3xl font-semibold">
- {f(fiat(pending - tip, rate), currency)}
+ {f(toFiat(pending - tip, rate), currency)}
{#if tip}
- + {f(fiat(tip, rate), currency)}
+ + {f(toFiat(tip, rate), currency)}
{/if}
</h2>