diff options
| author | Adam Soltys <[email protected]> | 2023-12-06 20:33:45 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-12-06 20:33:45 -0800 |
| commit | 6b3ff247e4125941a611369ed9bb74a2ffca57d8 (patch) | |
| tree | 91da939350398188834e5e002bc78011a2a8e5bf /src/routes/(app)/buy | |
| parent | bb59ac3e4e7fcbf7f8a48820eab0ee21558183fc (diff) | |
| parent | d69c34cf389639eac82d24d1f1b02f038ef42399 (diff) | |
| download | coinos-ui-6b3ff247e4125941a611369ed9bb74a2ffca57d8.tar.gz coinos-ui-6b3ff247e4125941a611369ed9bb74a2ffca57d8.zip | |
Merge branch 'master' into swapee
Diffstat (limited to 'src/routes/(app)/buy')
| -rw-r--r-- | src/routes/(app)/buy/+page.server.js | 43 | ||||
| -rw-r--r-- | src/routes/(app)/buy/+page.svelte | 28 |
2 files changed, 41 insertions, 30 deletions
diff --git a/src/routes/(app)/buy/+page.server.js b/src/routes/(app)/buy/+page.server.js index b97ac88b..b6604926 100644 --- a/src/routes/(app)/buy/+page.server.js +++ b/src/routes/(app)/buy/+page.server.js @@ -1,7 +1,7 @@ -import { env } from '$env/dynamic/private'; -import { error, fail, redirect } from '@sveltejs/kit'; -import { post, auth } from '$lib/utils'; -import { createTicket } from '$lib/ticket'; +import { env } from "$env/dynamic/private"; +import { error, fail, redirect } from "@sveltejs/kit"; +import { post, auth } from "$lib/utils"; +import { createTicket } from "$lib/ticket"; export let load = async ({ cookies }) => { let invoice = await post('/invoice', { invoice: { type: 'bitcoin' }}, auth(cookies)); @@ -10,24 +10,25 @@ export let load = async ({ cookies }) => { } export const actions = { - default: async ({ cookies, request }) => { - let form = await request.formData(); + default: async ({ cookies, request }) => { + let form = await request.formData(); - let amount = parseFloat(form.get('amount')); - if (!amount || amount < 0 || amount > 500) return fail(400, { message: 'Invalid amount' }); + let amount = parseFloat(form.get("amount")); + if (!amount || amount < 0 || amount > 500) + return fail(400, { message: "Invalid amount" }); - await post( - '/buy', - { - amount: form.get('amount'), - number: form.get('number').replace(/\s+/g, ''), - month: form.get('expiry').slice(0, 2), - year: form.get('expiry').slice(-2), - cvc: form.get('cvc') - }, - auth(cookies) - ); + await post( + "/buy", + { + amount: form.get("amount"), + number: form.get("number").replace(/\s+/g, ""), + month: form.get("expiry").slice(0, 2), + year: form.get("expiry").slice(-2), + cvc: form.get("cvc"), + }, + auth(cookies) + ); - throw redirect(307, `/${form.get('username')}/payments`); - } + throw redirect(307, `/${form.get("username")}/payments`); + }, }; diff --git a/src/routes/(app)/buy/+page.svelte b/src/routes/(app)/buy/+page.svelte index bf4d3889..04d317ba 100644 --- a/src/routes/(app)/buy/+page.svelte +++ b/src/routes/(app)/buy/+page.svelte @@ -1,17 +1,27 @@ <script> - import { Icon } from '$comp'; - import { copy } from '$lib/utils'; + import { enhance } from "$app/forms"; import { PUBLIC_ONRAMPER } from '$env/static/public'; - export let data; - let { address } = data; + import Icon from "$comp/Icon.svelte"; + import Lock from "$comp/Lock.svelte"; + import Card from "$comp/Card.svelte"; + import Calendar from "$comp/Calendar.svelte"; + import Spinner from "$comp/Spinner.svelte"; + import { f } from "$lib/utils"; + + export let data, form; + + let { username, currency } = data.user; + let loading; + + let amount, n, d, cvc; </script> <div class="container px-4 max-w-xl mx-auto mt-10 space-y-5"> - <div class="w-full flex"> - <a href="/" class="mx-auto"> - <Icon icon="logo" /> - </a> - </div> + <div class="w-full flex"> + <a href="/" class="mx-auto"> + <Icon icon="logo" /> + </a> + </div> <div class="pt-10"> <div class="flex w-full justify-center">Your bitcoin address</div> |
