From 64ac39d0b73ad224c90ee52d5df0485a4cb154e0 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 5 May 2023 08:12:23 -0700 Subject: nfc wip --- src/routes/(app)/pot/[name]/+page.svelte | 91 ++++++++++++++-------- .../(app)/pot/[name]/withdraw/+page.server.js | 2 +- src/routes/(app)/pot/[name]/withdraw/+page.svelte | 5 +- src/routes/(app)/pot/[name]/withdraw/+server.js | 6 ++ 4 files changed, 69 insertions(+), 35 deletions(-) create mode 100644 src/routes/(app)/pot/[name]/withdraw/+server.js (limited to 'src/routes/(app)/pot') diff --git a/src/routes/(app)/pot/[name]/+page.svelte b/src/routes/(app)/pot/[name]/+page.svelte index 653166c7..d3f559a1 100644 --- a/src/routes/(app)/pot/[name]/+page.svelte +++ b/src/routes/(app)/pot/[name]/+page.svelte @@ -5,7 +5,7 @@ import { Avatar, Icon } from '$comp'; import { toast } from '@zerodevx/svelte-toast'; import { t } from '$lib/translations'; - import { copy, f, s, sat, sats } from '$lib/utils'; + import { types, copy, f, s, sat, sats } from '$lib/utils'; import { loginRedirect } from '$lib/store'; export let data; @@ -21,8 +21,8 @@ $: amountFiat = parseFloat(((amount * rate) / sats).toFixed(2)); $loginRedirect = $page.url.pathname; - let show; - let toggle = () => (show = !show); + let show; + let toggle = () => (show = !show);
@@ -32,17 +32,28 @@
-
-
+
+
- -

Money Pot

+ {#if name.split('-').length === 4} +

Card {name}

+ {:else} + +

Money Pot

+ {/if}
-

Anyone who knows the URL to this pot can add or take out funds

- {#if show} - {name} - {/if} +

+ Anyone who knows the URL to this page can add or take out funds from the pot +

+ {#if show} + {name} + + + {/if}

@@ -59,8 +70,8 @@

@@ -69,38 +80,52 @@
-
+
- -
{#each payments as p} - -
-
-
+ +
+
+
0}> + {f(Math.abs(p.amount) * (p.rate / sats), p.currency)} + {#if p.tip} + + +{Math.round((p.tip / Math.abs(p.amount)) * 100)}% + + {/if} +
+ +
+ {sat(Math.abs(p.amount) + (p.tip || 0))} +
+
+ +
+
- +
-
- {p.user.username} - {p.amount > 0 ? 'took out' : 'threw in'} -
-
-
- {sat(p.amount)} +
{p.user.username}
diff --git a/src/routes/(app)/pot/[name]/withdraw/+page.server.js b/src/routes/(app)/pot/[name]/withdraw/+page.server.js index ac33e940..e7ea29f1 100644 --- a/src/routes/(app)/pot/[name]/withdraw/+page.server.js +++ b/src/routes/(app)/pot/[name]/withdraw/+page.server.js @@ -1,4 +1,4 @@ -import { fail, redirect } from '@sveltejs/kit'; +import { fail, json, redirect } from '@sveltejs/kit'; import { fd, auth, post } from '$lib/utils'; export async function load({ parent }) { diff --git a/src/routes/(app)/pot/[name]/withdraw/+page.svelte b/src/routes/(app)/pot/[name]/withdraw/+page.svelte index bb11ddde..da564709 100644 --- a/src/routes/(app)/pot/[name]/withdraw/+page.svelte +++ b/src/routes/(app)/pot/[name]/withdraw/+page.svelte @@ -9,6 +9,7 @@ export let data; export let form; + let { rates } = data; let { amount, name } = $page.params; let { currency } = data.user; let loading; @@ -19,6 +20,8 @@ if (form?.message.includes('pin')) $pin = undefined; loading = false; }; + + $: rate = rates[currency];