diff options
| author | Adam Soltys <[email protected]> | 2023-11-09 16:49:10 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-11-11 00:04:22 -0800 |
| commit | efdbc67c17fab67bf3cdce448a30aa82f62c5212 (patch) | |
| tree | 8af4f6245ea63e0b8a2d36f5da88439fc8d38ff7 /src/routes/(app)/fund | |
| parent | 9d554851a47ca9b4efd38f2682f313bd2623f8bf (diff) | |
| download | coinos-ui-efdbc67c17fab67bf3cdce448a30aa82f62c5212.tar.gz coinos-ui-efdbc67c17fab67bf3cdce448a30aa82f62c5212.zip | |
funds
Diffstat (limited to 'src/routes/(app)/fund')
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.server.js | 23 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.svelte | 138 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/sweep/+page.server.js | 14 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/sweep/+page.svelte | 37 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/withdraw/+page.server.js | 20 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/withdraw/+page.svelte | 58 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/withdraw/+server.js | 6 |
7 files changed, 0 insertions, 296 deletions
diff --git a/src/routes/(app)/fund/[id]/+page.server.js b/src/routes/(app)/fund/[id]/+page.server.js deleted file mode 100644 index 4194deed..00000000 --- a/src/routes/(app)/fund/[id]/+page.server.js +++ /dev/null @@ -1,23 +0,0 @@ -import { error, redirect } from '@sveltejs/kit'; -import { auth, get, post } from '$lib/utils'; -import Qr from 'qrcode-base64'; - -export let load = async ({ params: { id }, url }) => { - let { amount, payments } = await get(`/fund/${id}`); - - let src = Qr.drawImg(url.href, { size: 300 }); - return { amount, payments, src }; -}; - -export const actions = { - default: async ({ cookies, locals, params, request }) => { - let { user } = locals; - - if (user) { - await post('/redeem', params, auth(cookies)); - throw redirect(307, `/${user.username}/payments`); - } - - throw redirect(307, '/register'); - } -}; diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte deleted file mode 100644 index d2d3079c..00000000 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ /dev/null @@ -1,138 +0,0 @@ -<script> - import { format } from 'date-fns'; - import { enhance } from '$app/forms'; - import { page } from '$app/stores'; - import { Avatar, Icon } from '$comp'; - import { toast } from '@zerodevx/svelte-toast'; - import { t } from '$lib/translations'; - import { types, copy, f, s, sat, sats } from '$lib/utils'; - import { loginRedirect } from '$lib/store'; - - export let data; - - let { amount, src, payments, rates, user } = data; - let { id } = $page.params; - - toast.pop(0); - - let currency = user ? user.currency : 'CAD'; - let rate = rates[currency]; - - $: amountFiat = parseFloat(((amount * rate) / sats).toFixed(2)); - $loginRedirect = $page.url.pathname; - - let show; - let toggle = () => (show = !show); -</script> - -<div class="container px-4 max-w-4xl mx-auto mt-10 space-y-5"> - <div class="flex justify-center items-center"> - <div class="md:shadow-xl rounded-3xl md:px-10 pt-5 pb-10 space-y-5 w-full md:mx-5"> - <div class="relative flex justify-center gap-2"> - <!-- <p class="absolute right-0 top-1 underline"><Icon icon="settings" /></p> --> - {#if id.split('-').length === 4} - <h1 class="text-2xl md:text-3xl font-semibold my-auto">Card {id}</h1> - {:else} - <img src="/images/moneypot.jpg" class="w-24" alt="Fund" /> - <div class="my-auto"> - <h1 class="text-2xl font-semibold my-auto">{$t('payments.fund')}</h1> - <h1 class="text-secondary my-auto">{id}</h1> - </div> - {/if} - </div> - {#if show} - <img {src} class="mx-auto" alt={id} /> - {/if} - <div class="flex justify-center gap-4"> - <div class="my-auto"> - <h2 class="text-2xl md:text-3xl font-semibold"> - {f(amountFiat, currency)} - </h2> - <h3 class="text-secondary md:text-lg mt-1"> - {sat(amount)} - </h3> - </div> - </div> - <div class="flex gap-2" data-sveltekit-prefetch="off"> - <div class="grow"> - <a href={`/send/fund/${id}`}> - <button - class="rounded-full border py-3 px-2 font-bold hover:opacity-80 flex gap-1 w-full justify-center" - > - <Icon icon="plus" /> - {$t('payments.addFunds')} - </button> - </a> - </div> - <div class="grow"> - <a href={`/fund/${id}/withdraw`}> - <button - class="rounded-full border py-3 px-2 font-bold hover:opacity-80 flex gap-1 w-full justify-center" - > - <Icon icon="minus" style="rotate-180" /> - {$t('payments.takeFunds')} - </button> - </a> - </div> - </div> - <div class="flex gap-2" data-sveltekit-prefetch="off"> - <button - class="rounded-full border py-3 px-2 font-bold hover:opacity-80 flex gap-1 w-full justify-center" - on:click={toggle} - > - <Icon icon="qr" style="invert" /> - {show ? $t('payments.hide') : $t('payments.show')} QR - </button> - <button - class="rounded-full border py-3 px-2 font-bold hover:opacity-80 flex gap-1 w-full justify-center" - on:click={() => copy($page.url.host + $page.url.pathname)} - > - <Icon icon="copy" style="w-6" /> - {$t('payments.copyLink')} - </button> - </div> - <div class="text-base"> - {#each payments as p} - <a href={`/payment/${p.id}`}> - <div class="grid grid-cols-3 border-b h-24 hover:bg-gray-100 px-4"> - <div class="whitespace-nowrap my-auto"> - <div class="font-bold" class:text-red-800={p.amount > 0}> - {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> - - <div class="text-secondary"> - {sat(Math.abs(p.amount) + (p.tip || 0))} - </div> - </div> - - <div class="flex my-auto"> - <div class="flex"> - <div class="my-auto"> - <Avatar user={p.user} size={16} disabled={true} /> - </div> - <div class="my-auto ml-1 text-secondary">{p.user.username}</div> - </div> - </div> - - <div class="text-secondary text-right text-sm my-auto"> - <div> - {format(new Date(p.created), 'h:mm aaa')} - </div> - <div> - {format(new Date(p.created), 'MMM d')} - </div> - </div> - </div> - </a> - {:else} - <p class="text-secondary text-lg text-center">{$t('payments.empty')}</p> - {/each} - </div> - </div> - </div> -</div> diff --git a/src/routes/(app)/fund/[id]/sweep/+page.server.js b/src/routes/(app)/fund/[id]/sweep/+page.server.js deleted file mode 100644 index 9fd244a3..00000000 --- a/src/routes/(app)/fund/[id]/sweep/+page.server.js +++ /dev/null @@ -1,14 +0,0 @@ -import { get, auth, post } from '$lib/utils'; -import { redirect } from '@sveltejs/kit'; - -export async function load({ cookies, params, parent }) { - let { user } = await parent(); - let { id } = params; - let { amount } = await get(`/fund/${id}`); - - - if (!amount) throw redirect(307, `/fund/${id}`); - if (!user) throw redirect(307, `/register?redirect=/fund/${id}/sweep`); - await post('/take', { amount, id }, auth(cookies)); - return { amount, id }; -} diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/+page.svelte deleted file mode 100644 index 64bed4dd..00000000 --- a/src/routes/(app)/fund/[id]/sweep/+page.svelte +++ /dev/null @@ -1,37 +0,0 @@ -<script> - import { scale } from 'svelte/transition'; - import { fiat, f, s } from '$lib/utils'; - import { Icon } from '$comp'; - import { t } from '$lib/translations'; - - export let data; - - let { amount, id, user, rates } = data; - let { currency } = user; - $: rate = rates[currency]; -</script> - -<div class="container px-4 max-w-xl mx-auto mt-10 space-y-5 text-center"> - <div class="w-full flex"> - <a href="/" class="mx-auto"> - <Icon icon="logo" /> - </a> - </div> - - <div class="flex w-full py-5 max-w-[200px] mx-auto" in:scale={{ start: 0.5 }}> - <Icon icon="check" style="mx-auto" /> - </div> - <h1 class="text-3xl md:text-4xl font-bold mb-6">{$t('payments.fundsClaimed')}</h1> - <h2 class="text-2xl md:text-3xl font-semibold"> - {f(fiat(amount, rate), currency)} - </h2> - <h3 class="text-secondary md:text-lg mb-6 mt-1"> - ⚡️{s(amount)} - </h3> -</div> - -<a href={`/${user.username}/payments`}> - <div class="opacity-0 w-screen h-screen fixed top-0 left-0 z-50" /> -</a> - -<div class="fixed bottom-10 w-full text-center">{$t('payments.tapAnywhere')}</div> diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.server.js b/src/routes/(app)/fund/[id]/withdraw/+page.server.js deleted file mode 100644 index 476149f2..00000000 --- a/src/routes/(app)/fund/[id]/withdraw/+page.server.js +++ /dev/null @@ -1,20 +0,0 @@ -import { fail, json, redirect } from '@sveltejs/kit'; -import { fd, auth, post } from '$lib/utils'; - -export async function load({ parent }) { - let { user } = await parent(); - if (!user) throw redirect(307, '/register'); -} - -export const actions = { - default: async ({ cookies, request }) => { - let body = await fd(request); - try { - await post('/take', body, auth(cookies)); - } catch (e) { - return fail(400, { message: e.message }); - } - - throw redirect(307, `/fund/${body.id}`); - } -}; diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.svelte b/src/routes/(app)/fund/[id]/withdraw/+page.svelte deleted file mode 100644 index 9cad945a..00000000 --- a/src/routes/(app)/fund/[id]/withdraw/+page.svelte +++ /dev/null @@ -1,58 +0,0 @@ -<script> - import { t } from '$lib/translations'; - import { enhance } from '$app/forms'; - import { Icon, Numpad, Spinner } from '$comp'; - import { page } from '$app/stores'; - import { back } from '$lib/utils'; - import { pin } from '$lib/store'; - - export let data; - export let form; - - let { rates } = data; - let { amount, id } = $page.params; - let { currency } = data.user; - let loading; - - let submit = () => (loading = true); - $: update(form); - let update = () => { - if (form?.message.includes('pin')) $pin = undefined; - loading = false; - }; - - $: rate = rates[currency]; -</script> - -<button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80" on:click={back}> - <Icon icon="arrow-left" style="w-10" /> -</button> - -{#if form?.message} - <div class="text-red-600 text-center"> - {form.message} - </div> -{/if} - -<div class="container px-4 mt-20 max-w-xl mx-auto"> - <Numpad bind:amount bind:currency bind:rate {submit} /> - - <form method="POST" use:enhance on:submit={submit}> - <input name="id" value={id} type="hidden" /> - <input name="amount" value={amount} type="hidden" /> - <input name="pin" value={$pin} type="hidden" /> - - <div class="flex w-full"> - <button - type="submit" - class="opacity-100 hover:opacity-80'} rounded-2xl border py-3 font-bold mx-auto mt-2 bg-black text-white px-4 w-24" - > - {#if loading} - <Spinner /> - {:else} - {$t('payments.send')} - {/if} - </button> - </div> - </form> -</div> diff --git a/src/routes/(app)/fund/[id]/withdraw/+server.js b/src/routes/(app)/fund/[id]/withdraw/+server.js deleted file mode 100644 index 0f9a23f3..00000000 --- a/src/routes/(app)/fund/[id]/withdraw/+server.js +++ /dev/null @@ -1,6 +0,0 @@ -import { json } from '@sveltejs/kit'; -import { auth, post } from '$lib/utils'; - -export async function POST({ cookies, request }) { - return json(await post('/take', await request.json(), auth(cookies))); -} |
