diff options
| author | Adam Soltys <[email protected]> | 2022-11-14 02:04:40 -0600 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-11-14 02:04:40 -0600 |
| commit | 08b5677d7b94ac1e0532edb99dccf05b254f59a9 (patch) | |
| tree | 0297153156e3a62087891a472358cd4d5f237e5c /src | |
| parent | fa54e05db105ef941236ad87dcc3944a9903530f (diff) | |
| download | coinos-ui-08b5677d7b94ac1e0532edb99dccf05b254f59a9.tar.gz coinos-ui-08b5677d7b94ac1e0532edb99dccf05b254f59a9.zip | |
fix bug when sending to zero amount invoice
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/send/lightning/[payreq]/+page.server.js | 5 | ||||
| -rw-r--r-- | src/routes/(app)/send/lightning/[payreq]/+page.svelte | 49 |
2 files changed, 34 insertions, 20 deletions
diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.server.js b/src/routes/(app)/send/lightning/[payreq]/+page.server.js index 8d60628b..42b91445 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.server.js +++ b/src/routes/(app)/send/lightning/[payreq]/+page.server.js @@ -6,7 +6,10 @@ export async function load({ params }) { } export const actions = { - default: async ({ cookies, request }) => { + setAmount: async ({ cookies, request }) => { + return Object.fromEntries(await request.formData()); + }, + send: async ({ cookies, request }) => { try { let body = Object.fromEntries(await request.formData()); let { amount, confirmed } = body; diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte index e738c9a3..b6e759f9 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte @@ -13,12 +13,13 @@ let { currency } = data.user; let amount = form?.amount || data.amount; + let a; let loading; let submit = () => (loading = true); $: update(form); let update = () => { - if (form?.message.includes('pin')) $pin = undefined; + if (form?.message?.includes('pin')) $pin = undefined; loading = false; }; </script> @@ -43,28 +44,38 @@ <h1 class="text-xl md:text-2xl text-secondary mb-2">to</h1> <p class="text-6xl break-words">{alias}</p> </div> - {:else} - <Numpad bind:amount {currency} /> - {/if} - <form method="POST" use:enhance on:submit={submit}> - <input name="payreq" value={payreq} type="hidden" /> - <input name="amount" value={amount} type="hidden" /> - <input name="confirmed" value={form?.confirm} type="hidden" /> - <input name="pin" value={$pin} type="hidden" /> + <form method="POST" use:enhance on:submit={submit} action="?/send"> + <input name="payreq" value={payreq} type="hidden" /> + <input name="amount" value={amount} type="hidden" /> + <input name="confirmed" value={form?.confirm} type="hidden" /> + <input name="pin" value={$pin} type="hidden" /> - <div class="flex w-full"> + <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" + disabled={loading} + > + {#if loading} + <Spinner /> + {:else} + Send + {/if} + </button> + </div> + </form> + {:else} + <form method="POST" action="?/setAmount" class="w-[300px]"> + <input type="hidden" value={a} name="amount" /> + <Numpad bind:amount={a} {currency} /> <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" - disabled={loading} + class="bg-black text-white rounded-xl h-[48px] flex w-full justify-center items-center font-semibold + opacity-100 hover:opacity-80" > - {#if loading} - <Spinner /> - {:else} - Send - {/if} + Next </button> - </div> - </form> + </form> + {/if} </div> |
