From 66a6935a7050be9490780102bd80205f7c1ff6c3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 26 Sep 2022 23:56:19 -0700 Subject: tip refactoring --- src/routes/invoice/+server.js | 17 +-- src/routes/invoice/[id]/+page.svelte | 221 +++--------------------------- src/routes/invoice/[id]/paid/+page.svelte | 4 +- 3 files changed, 23 insertions(+), 219 deletions(-) (limited to 'src/routes') diff --git a/src/routes/invoice/+server.js b/src/routes/invoice/+server.js index d9a9739c..759c9315 100644 --- a/src/routes/invoice/+server.js +++ b/src/routes/invoice/+server.js @@ -1,15 +1,7 @@ import { auth, get, post } from '$lib/utils'; export async function POST({ request, parent }) { - let { - amount, - currency, - network = 'lightning', - prompt, - rate, - tip, - username - } = await request.json(); + let { amount, currency, network = 'lightning', prompt, rate, tip, user } = await request.json(); let invoice = { amount, currency, network, prompt, rate, tip }; if (network === 'lightning') { @@ -18,8 +10,7 @@ export async function POST({ request, parent }) { invoice.address = (await get('/address?network=bitcoin&type=bech32')).address; } - return new Response( - JSON.stringify(await post('/invoice', { invoice, user: { username } }, auth(request))), - { headers: { 'content-type': 'application/json' } } - ); + return new Response(JSON.stringify(await post('/invoice', { invoice, user }, auth(request))), { + headers: { 'content-type': 'application/json' } + }); } diff --git a/src/routes/invoice/[id]/+page.svelte b/src/routes/invoice/[id]/+page.svelte index 60257ab7..0fa34430 100644 --- a/src/routes/invoice/[id]/+page.svelte +++ b/src/routes/invoice/[id]/+page.svelte @@ -1,10 +1,9 @@
@@ -160,92 +77,19 @@ class="block lg:flex justify-center items-center space-y-10 lg:space-y-0 space-x-0 lg:space-x-24" > {#if invoice.prompt} -
-
- - -
-

{$t('invoice.addTipq')}

- {#if !showCustomAmount} -
- {f(tipAmount, currency)}{`(${s(tip)} SAT)`} - {Math.round(tipPercent)}% -
- - (showMobileTip = false)} - /> - {/if} -
- {#if !showCustomAmount} - {#each tipAmounts as amount} - - {/each} - {/if} - {#if showCustomAmount} -
- $ - handleCustomTipAmount(e)} - class="pl-10" - placeholder="Other" - /> - - -
- {:else} -
- -
- {/if} -
-
- -