aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/launch/purchase/+page.server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-17 11:11:52 -0700
committerAdam Soltys <[email protected]>2022-10-17 11:11:52 -0700
commit44bee42517e70dce187534dac676f52c7b1f327f (patch)
tree78049d1c589dbd09a4cf9eb720e4640f91482950 /src/routes/launch/purchase/+page.server.js
parent87fc33dfa162554b540dfb640ba1c1f66f9132d2 (diff)
downloadcoinos-ui-44bee42517e70dce187534dac676f52c7b1f327f.tar.gz
coinos-ui-44bee42517e70dce187534dac676f52c7b1f327f.zip
tickets wip
Diffstat (limited to 'src/routes/launch/purchase/+page.server.js')
-rw-r--r--src/routes/launch/purchase/+page.server.js31
1 files changed, 28 insertions, 3 deletions
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')
};