aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/voucher
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-08-23 23:53:29 -0700
committerAdam Soltys <[email protected]>2024-08-23 23:53:29 -0700
commit243f2b2f0f2da9735885978a6773b77a7bd139eb (patch)
tree7ee9ed6e90dd1417cb87f091c03148b7eb06011f /src/routes/(app)/voucher
parent8d3fb861ef2a9e56fee6a0ab9c4c0e3c935305dc (diff)
downloadcoinos-ui-243f2b2f0f2da9735885978a6773b77a7bd139eb.tar.gz
coinos-ui-243f2b2f0f2da9735885978a6773b77a7bd139eb.zip
rename ecash routes
Diffstat (limited to 'src/routes/(app)/voucher')
-rw-r--r--src/routes/(app)/voucher/[...token]/+page.server.js32
-rw-r--r--src/routes/(app)/voucher/[...token]/+page.svelte92
2 files changed, 0 insertions, 124 deletions
diff --git a/src/routes/(app)/voucher/[...token]/+page.server.js b/src/routes/(app)/voucher/[...token]/+page.server.js
deleted file mode 100644
index cb04224e..00000000
--- a/src/routes/(app)/voucher/[...token]/+page.server.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { validate } from "bitcoin-address-validation";
-import bip21 from "bip21";
-import { auth, get, isLiquid, post } from "$lib/utils";
-import { error, fail, redirect } from "@sveltejs/kit";
-import { PUBLIC_DOMAIN } from "$env/static/public";
-import parse from "$lib/parse";
-import { test } from "$lib/parse";
-
-export async function load({ cookies, params, parent, request, url }) {
- let { user } = await parent();
- if (!user) redirect(307, `/register?redirect=${url.pathname}`);
-
- let { token } = params;
- if (token && !token.startsWith("cashu"))
- ({ token } = await get(`/cash/${token}`));
- await parse(token, url.host, cookies);
-
- if (token) error(409, "Token could not be redeemed. Was it already spent?");
-}
-
-export const actions = {
- default: async ({ cookies, request, url }) => {
- const form = await request.formData();
- let t = form.get("text");
- if (t.startsWith("cashu")) {
- let { id } = await post("/cash", { token: t }, auth);
- redirect(307, `/ecash/${id}`);
- }
- let msg = await parse(t, url.host, cookies);
- return fail(400, { error: msg || "default" });
- },
-};
diff --git a/src/routes/(app)/voucher/[...token]/+page.svelte b/src/routes/(app)/voucher/[...token]/+page.svelte
deleted file mode 100644
index 2fd4b879..00000000
--- a/src/routes/(app)/voucher/[...token]/+page.svelte
+++ /dev/null
@@ -1,92 +0,0 @@
-<script>
- import { page } from "$app/stores";
- import { fly } from "svelte/transition";
- import { enhance } from "$app/forms";
- import { tick } from "svelte";
- import { browser } from "$app/environment";
- import { t } from "$lib/translations";
- import AppHeader from "$comp/AppHeader.svelte";
- import Avatar from "$comp/Avatar.svelte";
- import Icon from "$comp/Icon.svelte";
- import Spinner from "$comp/Spinner.svelte";
- import { back, fail, focus } from "$lib/utils";
-
- export let data;
- export let form;
-
- let { token } = data;
- data.subject = data.user;
-
- let el, text, pasted, w;
-
- let keypress = (e) => e.key === "Enter" && (e.preventDefault() || el.click());
-
- let paste = async () => {
- text = await navigator.clipboard.readText();
- };
-
- $: if (browser && pasted && text) el.click() && (pasted = false);
-</script>
-
-<svelte:window bind:innerWidth={w} />
-
-<AppHeader {data} />
-<div class="container px-4 max-w-lg mx-auto space-y-5 mt-20">
- <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
- {$t("payments.voucher")}
- </h1>
-
- <form method="POST" use:enhance class="space-y-2 text-xl">
- {#if form?.error}
- <div class="mb-5">
- <div class="text-red-600">
- {form.error === "default"
- ? $t("error.unrecognizedInput")
- : form.error}
- </div>
- </div>
- {/if}
-
- <div class="mb-2">
- <textarea
- use:focus
- name="text"
- placeholder={$t("payments.voucherText")}
- on:keypress={keypress}
- class="w-full p-4 border rounded-xl h-48 text-xl"
- bind:value={text}
- on:paste={() => (pasted = true)}
- autocapitalize="none"
- />
- </div>
-
- <div class="flex gap-2">
- <a href="/scan" class="w-full">
- <button
- type="button"
- class="flex border rounded-2xl px-6 py-5 font-bold hover:opacity-80 w-full bg-primary justify-center"
- >
- <Icon icon="camera" style="mr-2 w-6 my-auto" />
- <div class="my-auto">{$t("user.send.scan")}</div>
- </button>
- </a>
-
- <button
- type="button"
- class="flex border rounded-2xl px-6 py-5 font-bold hover:opacity-80 w-full bg-primary justify-center"
- on:click={paste}
- >
- <Icon icon="paste" style="mr-2 w-6 my-auto" />
- <div class="my-auto">{$t("user.send.paste")}</div>
- </button>
- </div>
-
- <button
- bind:this={el}
- type="submit"
- class="bg-black text-white border rounded-2xl px-6 py-5 w-full font-bold"
- >
- {$t("user.send.next")}
- </button>
- </form>
-</div>