diff options
| author | Adam Soltys <[email protected]> | 2023-12-01 20:04:13 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-01 20:04:13 -0800 |
| commit | 216a600224fde22ce76b367557a02094ec693886 (patch) | |
| tree | d1189bbaa39db204633523132a7d4767b952717d /src/routes/(app)/payment | |
| parent | 7d9bc1f54dfd04172e8d6d43ebc2efd6f407e833 (diff) | |
| download | coinos-ui-216a600224fde22ce76b367557a02094ec693886.tar.gz coinos-ui-216a600224fde22ce76b367557a02094ec693886.zip | |
prettier
Diffstat (limited to 'src/routes/(app)/payment')
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.server.js | 6 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.svelte | 289 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/plain/+page.server.js | 6 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/plain/+page.svelte | 132 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/print/+server.js | 8 |
5 files changed, 233 insertions, 208 deletions
diff --git a/src/routes/(app)/payment/[id]/+page.server.js b/src/routes/(app)/payment/[id]/+page.server.js index 1c90ab69..5a364c65 100644 --- a/src/routes/(app)/payment/[id]/+page.server.js +++ b/src/routes/(app)/payment/[id]/+page.server.js @@ -1,6 +1,6 @@ -import { auth, get } from '$lib/utils'; +import { auth, get } from "$lib/utils"; export async function load({ cookies, params }) { - let payment = await get(`/payments/${params.id}`, auth(cookies)); - return { payment }; + let payment = await get(`/payments/${params.id}`, auth(cookies)); + return { payment }; } diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 98c5a68b..7e3c6792 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -1,158 +1,173 @@ <script> - import { t } from '$lib/translations'; - import { back, copy, f, s, fiat, post, sats, success, types } from '$lib/utils'; - import { Avatar, Icon } from '$comp'; - import { format } from 'date-fns'; - import { PUBLIC_EXPLORER as expl } from '$env/static/public'; + import { t } from "$lib/translations"; + import { + back, + copy, + f, + s, + fiat, + post, + sats, + success, + types, + } from "$lib/utils"; + import { Avatar, Icon } from "$comp"; + import { format } from "date-fns"; + import { PUBLIC_EXPLORER as expl } from "$env/static/public"; - export let data; - let { user, payment: p } = data; + export let data; + let { user, payment: p } = data; - let { username } = user; - let { id, amount, created, rate, type, ref, tip, ourfee, fee, currency } = p; - let a = Math.abs(amount); + let { username } = user; + let { id, amount, created, rate, type, ref, tip, ourfee, fee, currency } = p; + let a = Math.abs(amount); - let print = async () => { - await post(`/payment/${id}/print`, { id }); - success('Printing!'); - }; + let print = async () => { + await post(`/payment/${id}/print`, { id }); + success("Printing!"); + }; - fee = fee || 0; + fee = fee || 0; - let direction = amount > 0 ? $t('payments.from') : $t('payments.to') - direction = direction[0].toUpperCase() + direction.substr(1, direction.length); + let direction = amount > 0 ? $t("payments.from") : $t("payments.to"); + direction = + direction[0].toUpperCase() + direction.substr(1, direction.length); </script> <a href={`/${username}/payments`}> - <button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80"> - <Icon icon="arrow-left" style="w-10" /> - </button> + <button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80"> + <Icon icon="arrow-left" style="w-10" /> + </button> </a> <div class="container mx-auto max-w-lg px-4 space-y-8 break-all text-2xl"> - <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold mb-10"> - {$t(amount < 0 ? 'payments.sent' : 'payments.received')} - </h1> + <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold mb-10"> + {$t(amount < 0 ? "payments.sent" : "payments.received")} + </h1> - {#if p.with} - <div> - <span class="text-lg text-secondary my-auto mr-2">{direction}</span> - <a href={`/${p.with.username}`}> - <div class="flex"> - <div class="my-auto"> - <Avatar user={p.with} size={20} /> - </div> - <div class="my-auto ml-1">{p.with.username}</div> - </div> - </a> - </div> - {/if} - {#if p.type === types.fund} - <div> - <span class="text-lg text-secondary my-auto mr-2">{direction}</span> - <a href={`/fund/${p.memo}`}> - <div class="flex"> - <div class="my-auto"> - <img src="/images/moneypot.png" class="w-12" alt="Pot" /> - </div> - <div class="my-auto ml-1">{p.memo}</div> - </div> - </a> - </div> - {/if} - <div> - <span class="text-lg text-secondary">{$t('payments.amount')}</span> - <div> - {f(fiat(a, rate), currency)} - <span class="text-secondary text-lg"> - ⚡️{s(a)} - </span> - </div> - </div> + {#if p.with} + <div> + <span class="text-lg text-secondary my-auto mr-2">{direction}</span> + <a href={`/${p.with.username}`}> + <div class="flex"> + <div class="my-auto"> + <Avatar user={p.with} size={20} /> + </div> + <div class="my-auto ml-1">{p.with.username}</div> + </div> + </a> + </div> + {/if} + {#if p.type === types.fund} + <div> + <span class="text-lg text-secondary my-auto mr-2">{direction}</span> + <a href={`/fund/${p.memo}`}> + <div class="flex"> + <div class="my-auto"> + <img src="/images/moneypot.png" class="w-12" alt="Pot" /> + </div> + <div class="my-auto ml-1">{p.memo}</div> + </div> + </a> + </div> + {/if} + <div> + <span class="text-lg text-secondary">{$t("payments.amount")}</span> + <div> + {f(fiat(a, rate), currency)} + <span class="text-secondary text-lg"> + ⚡️{s(a)} + </span> + </div> + </div> - {#if tip} - <div> - <span class="text-lg text-secondary">{$t('invoice.tip')}</span> - <div> - {f(fiat(tip, rate), currency)} - ({Math.round((tip * 100) / Math.abs(a))}%) - <span class="text-secondary text-lg"> - ⚡️{s(tip)} - </span> - </div> - </div> + {#if tip} + <div> + <span class="text-lg text-secondary">{$t("invoice.tip")}</span> + <div> + {f(fiat(tip, rate), currency)} + ({Math.round((tip * 100) / Math.abs(a))}%) + <span class="text-secondary text-lg"> + ⚡️{s(tip)} + </span> + </div> + </div> - <div> - <span class="text-lg text-secondary">Total</span> - <div> - {f(fiat(a + (tip || 0), rate), currency)} - <span class="text-secondary text-lg">⚡️{`${s(a + (tip || 0))}`} </span> - </div> - </div> - {/if} + <div> + <span class="text-lg text-secondary">Total</span> + <div> + {f(fiat(a + (tip || 0), rate), currency)} + <span class="text-secondary text-lg">⚡️{`${s(a + (tip || 0))}`} </span> + </div> + </div> + {/if} - <div> - <span class="text-lg text-secondary">Network fee</span> - <div> - {f(fiat(fee, rate), currency)} - <span class="text-secondary text-lg">⚡️{`${s(fee)}`}</span> - </div> - </div> + <div> + <span class="text-lg text-secondary">Network fee</span> + <div> + {f(fiat(fee, rate), currency)} + <span class="text-secondary text-lg">⚡️{`${s(fee)}`}</span> + </div> + </div> - {#if ourfee > 0} - <div> - <span class="text-lg text-secondary">Platform fee</span> - <div> - {f(fiat(ourfee, rate), currency)} - <span class="text-secondary">⚡️{`${s(ourfee)}`}</span> - </div> - </div> - {/if} + {#if ourfee > 0} + <div> + <span class="text-lg text-secondary">Platform fee</span> + <div> + {f(fiat(ourfee, rate), currency)} + <span class="text-secondary">⚡️{`${s(ourfee)}`}</span> + </div> + </div> + {/if} - <div> - <span class="text-lg text-secondary">Date</span> - <div> - {format(new Date(created), 'MMMM d')}, - {format(new Date(created), 'h:mm aaa')} - </div> - </div> + <div> + <span class="text-lg text-secondary">Date</span> + <div> + {format(new Date(created), "MMMM d")}, + {format(new Date(created), "h:mm aaa")} + </div> + </div> - {#if type === 'bitcoin'} - <div> - <span class="text-lg text-secondary">Txid</span> - <div class="flex"> - <div> - <a href={`${expl}/tx/${id}`} target="_blank" rel="noreferrer">{id}</a> - </div> - <button class="flex font-bold hover:opacity-80 mb-auto my-auto" on:click={() => copy(id)} - ><Icon icon="copy" style="ml-2 w-20 my-auto" /> - </button> - </div> - </div> - {/if} + {#if type === "bitcoin"} + <div> + <span class="text-lg text-secondary">Txid</span> + <div class="flex"> + <div> + <a href={`${expl}/tx/${id}`} target="_blank" rel="noreferrer">{id}</a> + </div> + <button + class="flex font-bold hover:opacity-80 mb-auto my-auto" + on:click={() => copy(id)} + ><Icon icon="copy" style="ml-2 w-20 my-auto" /> + </button> + </div> + </div> + {/if} - {#if user.hasprinter} - <div> - <button - class="rounded-full border py-3 px-6 hover:opacity-80 flex w-full md:w-60" - on:click={print} - > - <div class="mx-auto flex"> - <Icon icon="printer" style="my-auto h-6 mr-2" /> - <div class="my-auto mt-1 text-base">{$t('payments.print')}</div> - </div> - </button> - </div> - {:else} - <div> - <a href={`/payment/${id}/plain`}> - <button class="rounded-full border py-3 px-6 hover:opacity-80 flex w-full md:w-60"> - <div class="mx-auto flex"> - <Icon icon="printer" style="my-auto h-6 mr-2" /> - <div class="my-auto mt-1 text-base">{$t('payments.print')}</div> - </div> - </button> - </a> - </div> - {/if} + {#if user.hasprinter} + <div> + <button + class="rounded-full border py-3 px-6 hover:opacity-80 flex w-full md:w-60" + on:click={print} + > + <div class="mx-auto flex"> + <Icon icon="printer" style="my-auto h-6 mr-2" /> + <div class="my-auto mt-1 text-base">{$t("payments.print")}</div> + </div> + </button> + </div> + {:else} + <div> + <a href={`/payment/${id}/plain`}> + <button + class="rounded-full border py-3 px-6 hover:opacity-80 flex w-full md:w-60" + > + <div class="mx-auto flex"> + <Icon icon="printer" style="my-auto h-6 mr-2" /> + <div class="my-auto mt-1 text-base">{$t("payments.print")}</div> + </div> + </button> + </a> + </div> + {/if} </div> diff --git a/src/routes/(app)/payment/[id]/plain/+page.server.js b/src/routes/(app)/payment/[id]/plain/+page.server.js index 1c90ab69..5a364c65 100644 --- a/src/routes/(app)/payment/[id]/plain/+page.server.js +++ b/src/routes/(app)/payment/[id]/plain/+page.server.js @@ -1,6 +1,6 @@ -import { auth, get } from '$lib/utils'; +import { auth, get } from "$lib/utils"; export async function load({ cookies, params }) { - let payment = await get(`/payments/${params.id}`, auth(cookies)); - return { payment }; + let payment = await get(`/payments/${params.id}`, auth(cookies)); + return { payment }; } diff --git a/src/routes/(app)/payment/[id]/plain/+page.svelte b/src/routes/(app)/payment/[id]/plain/+page.svelte index 5ffd1656..27e8d0ed 100644 --- a/src/routes/(app)/payment/[id]/plain/+page.svelte +++ b/src/routes/(app)/payment/[id]/plain/+page.svelte @@ -1,77 +1,87 @@ <script> - import { goto } from '$app/navigation'; - import { onMount } from 'svelte'; - import { browser } from '$app/environment'; - import { t } from '$lib/translations'; - import { back, copy, f, s, fiat, post, sats, success, types } from '$lib/utils'; - import { Avatar, Icon } from '$comp'; - import { format } from 'date-fns'; - import { PUBLIC_EXPLORER as expl } from '$env/static/public'; + import { goto } from "$app/navigation"; + import { onMount } from "svelte"; + import { browser } from "$app/environment"; + import { t } from "$lib/translations"; + import { + back, + copy, + f, + s, + fiat, + post, + sats, + success, + types, + } from "$lib/utils"; + import { Avatar, Icon } from "$comp"; + import { format } from "date-fns"; + import { PUBLIC_EXPLORER as expl } from "$env/static/public"; - export let data; - let { user, payment: p } = data; + export let data; + let { user, payment: p } = data; - let { username } = user; - let { id, amount, created, rate, type, ref, tip, ourfee, fee, currency } = p; - let a = Math.abs(amount); + let { username } = user; + let { id, amount, created, rate, type, ref, tip, ourfee, fee, currency } = p; + let a = Math.abs(amount); - onMount(() => { - if (browser) { - let main = document.querySelector('main'); - main.style.paddingBottom = '0'; - window.onfocus = () => goto(`/payment/${id}`); - window.print(); - } - }); + onMount(() => { + if (browser) { + let main = document.querySelector("main"); + main.style.paddingBottom = "0"; + window.onfocus = () => goto(`/payment/${id}`); + window.print(); + } + }); - fee = fee || 0; + fee = fee || 0; </script> <div class="space-y-5"> - <div> - <span class="text-lg text-secondary">Amount</span> - <div> - {f(fiat(a, rate), currency)} - </div> - </div> + <div> + <span class="text-lg text-secondary">Amount</span> + <div> + {f(fiat(a, rate), currency)} + </div> + </div> - {#if tip} - <div> - <span class="text-lg text-secondary">Tip</span> - <div> - {f(fiat(tip, rate), currency)} - ({Math.round((tip * 100) / Math.abs(a))}%) - </div> - </div> + {#if tip} + <div> + <span class="text-lg text-secondary">Tip</span> + <div> + {f(fiat(tip, rate), currency)} + ({Math.round((tip * 100) / Math.abs(a))}%) + </div> + </div> - <div> - <span class="text-lg text-secondary">Total</span> - <div> - {f(fiat(a + (tip || 0), rate), currency)} - </div> - </div> - {/if} + <div> + <span class="text-lg text-secondary">Total</span> + <div> + {f(fiat(a + (tip || 0), rate), currency)} + </div> + </div> + {/if} - <div> - <span class="text-lg text-secondary">Date</span> - <div> - {format(new Date(created), 'MMMM d')}, - {format(new Date(created), 'h:mm aaa')} - </div> - </div> + <div> + <span class="text-lg text-secondary">Date</span> + <div> + {format(new Date(created), "MMMM d")}, + {format(new Date(created), "h:mm aaa")} + </div> + </div> - {#if type === 'bitcoin'} - <div> - <span class="text-lg text-secondary">Txid</span> - <div class="flex"> - <div> - {id} - </div> - </div> - </div> - {/if} + {#if type === "bitcoin"} + <div> + <span class="text-lg text-secondary">Txid</span> + <div class="flex"> + <div> + {id} + </div> + </div> + </div> + {/if} </div> <a href={`/payment/${id}`}> - <div class="opacity-0 w-screen h-screen fixed top-0 left-0 z-50" /> + <div class="opacity-0 w-screen h-screen fixed top-0 left-0 z-50" /> </a> diff --git a/src/routes/(app)/payment/[id]/print/+server.js b/src/routes/(app)/payment/[id]/print/+server.js index fde834d1..2fdfc8c1 100644 --- a/src/routes/(app)/payment/[id]/print/+server.js +++ b/src/routes/(app)/payment/[id]/print/+server.js @@ -1,7 +1,7 @@ -import { auth, post } from '$lib/utils'; -import { json } from '@sveltejs/kit'; +import { auth, post } from "$lib/utils"; +import { json } from "@sveltejs/kit"; export async function POST({ cookies, request }) { - let body = await request.json(); - return json(post('/print', body, auth(cookies))); + let body = await request.json(); + return json(post("/print", body, auth(cookies))); } |
