diff options
| author | Adam Soltys <[email protected]> | 2023-03-20 10:50:36 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-20 10:50:36 -0700 |
| commit | b7b136660b668203ac521707cd511648b687ba22 (patch) | |
| tree | 2866f3c6819f32ca26c94ed8fcf95c4abb33d7fc /src | |
| parent | bf2a0a574e837ffcd8b4e781dac71fac164f5aa5 (diff) | |
| download | coinos-ui-b7b136660b668203ac521707cd511648b687ba22.tar.gz coinos-ui-b7b136660b668203ac521707cd511648b687ba22.zip | |
print function
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/payment/[id]/+page.svelte | 14 | ||||
| -rw-r--r-- | src/routes/(app)/payment/[id]/print/+server.js | 7 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index cf30db35..020efdbb 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -1,6 +1,6 @@ <script> import { t } from '$lib/translations'; - import { back, copy, f, s, fiat, sats } from '$lib/utils'; + import { back, copy, f, s, fiat, post, sats, success } from '$lib/utils'; import { Avatar, Icon } from '$comp'; import { format } from 'date-fns'; import { PUBLIC_EXPLORER as expl } from '$env/static/public'; @@ -12,6 +12,11 @@ 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!'); + }; + fee = fee || 0; </script> @@ -106,4 +111,11 @@ </div> </div> {/if} + + {#if user.username.toLowerCase() === 'laughingbean'} + <button + class="text-sm md:text-lg rounded-full border py-2 px-4 hover:opacity-80 min-w-[72px] bg-black text-white" + on:click={print}>Print Receipt</button + > + {/if} </div> diff --git a/src/routes/(app)/payment/[id]/print/+server.js b/src/routes/(app)/payment/[id]/print/+server.js new file mode 100644 index 00000000..fde834d1 --- /dev/null +++ b/src/routes/(app)/payment/[id]/print/+server.js @@ -0,0 +1,7 @@ +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))); +} |
