diff options
| author | Adam Soltys <[email protected]> | 2022-10-17 11:11:52 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-10-17 11:11:52 -0700 |
| commit | 44bee42517e70dce187534dac676f52c7b1f327f (patch) | |
| tree | 78049d1c589dbd09a4cf9eb720e4640f91482950 /src | |
| parent | 87fc33dfa162554b540dfb640ba1c1f66f9132d2 (diff) | |
| download | coinos-ui-44bee42517e70dce187534dac676f52c7b1f327f.tar.gz coinos-ui-44bee42517e70dce187534dac676f52c7b1f327f.zip | |
tickets wip
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/launch/+page.svelte | 5 | ||||
| -rw-r--r-- | src/routes/launch/purchase/+page.server.js | 31 | ||||
| -rw-r--r-- | src/routes/launch/purchase/+page.svelte | 67 | ||||
| -rw-r--r-- | src/routes/launch/purchase/card/+page.server.js (renamed from src/routes/pay/+page.server.js) | 0 | ||||
| -rw-r--r-- | src/routes/launch/purchase/card/+page.svelte (renamed from src/routes/pay/+page.svelte) | 11 | ||||
| -rw-r--r-- | src/routes/launch/ticket/+page.svelte | 5 |
6 files changed, 79 insertions, 40 deletions
diff --git a/src/routes/launch/+page.svelte b/src/routes/launch/+page.svelte index 5e519eff..da1c779c 100644 --- a/src/routes/launch/+page.svelte +++ b/src/routes/launch/+page.svelte @@ -9,8 +9,7 @@ $redirect = '/launch/purchase'; beforeNavigate(({ to }) => { - console.log(link); - if (link === '/register') info('Please sign in so we can get you a ticket'); + if (to.routeId === 'register') info('Please sign in so we can get you a ticket'); }); </script> @@ -30,7 +29,7 @@ </h1> <p class="leading-normal mb-2"> - Come join us at our launch party celebrating 10 years in business! + Come join us at our launch party celebrating our new design and 10 years since our <a href="https://github.com/coinos/coinos-server/commit/b25d11b" class="underline">first commit</a>! </p> <div class="ml-8"> <p><b>When</b></p> diff --git a/src/routes/launch/purchase/+page.server.js b/src/routes/launch/purchase/+page.server.js index 1525034c..03da1e35 100644 --- a/src/routes/launch/purchase/+page.server.js +++ b/src/routes/launch/purchase/+page.server.js @@ -1,10 +1,14 @@ import { auth, get, post } from '$lib/utils'; import tickets from '$lib/tickets'; -export const load = () => get('/ticket'); +export const load = async ({ parent }) => { + let p = await parent(); + let t = await get('/ticket'); + return { ...p, ...t }; +}; export const actions = { - default: async ({ cookies, request }) => { + internal: async ({ cookies, request, parent }) => { let { ticket } = Object.fromEntries(await request.formData()); let r = await post( @@ -22,5 +26,26 @@ export const actions = { ); console.log(r); - } + }, + + lightning: async ({ cookies, request }) => { + let form = await request.formData(); + + let rates = await get('/rates'); + + let invoice = { + amount: parseInt(form.get('amount')), + tip: parseInt(form.get('tip')), + network: 'lightning', + prompt: form.get('prompt') === 'true', + rate: rates[form.get('currency')] + }; + + let user = { username: form.get('username') }; + + let { uuid } = await post('/invoice', { invoice, user }, auth(cookies)); + + throw redirect(307, `/invoice/${uuid}`); + }, + bitcoin: () => console.log('YYEAH') }; diff --git a/src/routes/launch/purchase/+page.svelte b/src/routes/launch/purchase/+page.svelte index ecec51df..68c19076 100644 --- a/src/routes/launch/purchase/+page.svelte +++ b/src/routes/launch/purchase/+page.svelte @@ -9,6 +9,7 @@ let amount = 25000; let { address, + currency, account: { balance }, username } = data.user; @@ -35,17 +36,17 @@ <div class="mx-auto h-screen flex items-center justify-center px-4"> <div class="font-normal text-gray-800 mx-auto mb-8 space-y-8"> - {#if balance > amount} - <h1 class="mb-4 text-4xl font-bold leading-none tracking-tight text-gray-800 text-center"> - Confirm Purchase - </h1> + <h1 class="mb-4 text-4xl font-bold leading-none tracking-tight text-gray-800 text-center"> + Confirm Purchase + </h1> - <img - src={`/tickets/${(ticket + 1).toString().padStart(2, '0')}.png`} - class="w-full max-w-[800px]" - /> + <img + src={`/tickets/${(ticket + 1).toString().padStart(2, '0')}.png`} + class="w-full max-w-[800px]" + /> - <form method="POST" use:enhance> + {#if balance > amount} + <form action="?/internal" method="POST" use:enhance> <input type="hidden" name="ticket" value={ticket} /> <div class="w-full flex"> <button @@ -57,33 +58,35 @@ </form> {:else} <h1 class="mb-4 text-4xl font-bold leading-none tracking-tight text-gray-800 text-center"> - Ticket Price - </h1> - <div class="text-center text-4xl mb-12">{amount} sats</div> - - <h1 class="mb-4 text-4xl font-bold leading-none tracking-tight text-gray-800 text-center"> - Your Balance + Payment Options </h1> - <div class="text-center text-4xl mb-12">{balance} sats</div> - - <h1 class="mb-4 text-4xl font-bold leading-none tracking-tight text-gray-800 text-center"> - Funding Options - </h1> + <form action="?/lightning" method="POST"> + <input type="hidden" name="currency" value={currency} /> + <input type="hidden" name="username" value={username} /> + <button + class="bg-black text-white border rounded-full px-8 py-4 font-bold hover:opacity-80 mx-auto text-2xl" + > + Lightning + </button> + </form> - <button - class="bg-black text-white border rounded-full px-8 py-4 font-bold hover:opacity-80 mx-auto text-2xl" - on:click={lightning} - > - Lightning - </button> + <form action="?/bitcoin" method="POST"> + <button + class="bg-black text-white border rounded-full px-8 py-4 font-bold hover:opacity-80 mx-auto text-2xl" + on:click={bitcoin} + > + Bitcoin + </button> + </form> - <button - class="bg-black text-white border rounded-full px-8 py-4 font-bold hover:opacity-80 mx-auto text-2xl" - on:click={bitcoin} - > - Bitcoin - </button> + <a href={`purchase/card`}> + <button + class="bg-black text-white border rounded-full px-8 py-4 font-bold hover:opacity-80 mx-auto text-2xl" + > + Credit Card + </button> + </a> {/if} </div> </div> diff --git a/src/routes/pay/+page.server.js b/src/routes/launch/purchase/card/+page.server.js index 1393eecc..1393eecc 100644 --- a/src/routes/pay/+page.server.js +++ b/src/routes/launch/purchase/card/+page.server.js diff --git a/src/routes/pay/+page.svelte b/src/routes/launch/purchase/card/+page.svelte index 3b428511..73f2d880 100644 --- a/src/routes/pay/+page.svelte +++ b/src/routes/launch/purchase/card/+page.svelte @@ -1,5 +1,4 @@ <script> - let number; </script> <form method="POST" class="flex flex-wrap gap-3 w-full p-5"> @@ -10,6 +9,7 @@ type="text" name="number" placeholder="0000 0000 0000" + value="4242424242424242" /> <svg xmlns="http://www.w3.org/2000/svg" @@ -34,6 +34,7 @@ type="text" name="expiry" placeholder="MM/YY" + value="0123" /> <svg xmlns="http://www.w3.org/2000/svg" @@ -81,6 +82,7 @@ type="text" name="cvc" placeholder="•••" + value="123" /> <svg xmlns="http://www.w3.org/2000/svg" @@ -98,5 +100,10 @@ </svg> </label> - <button type="submit">Submit</button> + <div class="w-full flex"> + <button + + class="bg-black text-white border rounded-full px-8 py-4 font-bold hover:opacity-80 mx-auto text-2xl" + type="submit">Submit</button> + </div> </form> diff --git a/src/routes/launch/ticket/+page.svelte b/src/routes/launch/ticket/+page.svelte new file mode 100644 index 00000000..acf3b7a5 --- /dev/null +++ b/src/routes/launch/ticket/+page.svelte @@ -0,0 +1,5 @@ + + <img + src={`/tickets/${(ticket + 1).toString().padStart(2, '0')}.png`} + class="w-full max-w-[800px]" + /> |
