aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-06 09:31:54 -0700
committerAdam Soltys <[email protected]>2024-09-06 09:31:54 -0700
commit5135216f5475aa8a0b6badb5feaae2c3b14e625a (patch)
tree5c6cbc0151b0f469b4d6a90dc0b9afa6fb3cc2d4 /src/routes/(app)/send
parente2996ef8d1d3628731e340481d01a5ef07e2abd1 (diff)
downloadcoinos-ui-well.tar.gz
coinos-ui-well.zip
send wellwell
Diffstat (limited to 'src/routes/(app)/send')
-rw-r--r--src/routes/(app)/send/[...text]/+page.svelte11
-rw-r--r--src/routes/(app)/send/well/+page.server.ts27
-rw-r--r--src/routes/(app)/send/well/+page.svelte79
3 files changed, 117 insertions, 0 deletions
diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte
index 780f70c1..8f527beb 100644
--- a/src/routes/(app)/send/[...text]/+page.svelte
+++ b/src/routes/(app)/send/[...text]/+page.svelte
@@ -92,6 +92,17 @@
<div class="my-auto">{$t("user.send.next")}</div>
</button>
+ <a href="/send/well" class="contents">
+ <button
+ type="button"
+ class="flex border rounded-2xl px-6 py-5 w-full font-bold gap-2 justify-center text-xl bg-primary"
+ >
+ <img src="/images/well.svg" class="w-40 my-auto" />
+ <img src="/images/interac.svg" class="w-8 my-auto" />
+ <div class="my-auto">Transfer</div>
+ </button>
+ </a>
+
<a href="/send/ecash" class="contents">
<button
type="button"
diff --git a/src/routes/(app)/send/well/+page.server.ts b/src/routes/(app)/send/well/+page.server.ts
new file mode 100644
index 00000000..dfa41a17
--- /dev/null
+++ b/src/routes/(app)/send/well/+page.server.ts
@@ -0,0 +1,27 @@
+import { error, redirect } from "@sveltejs/kit";
+import { auth, post, fd } from "$lib/utils";
+
+export let load = async ({ fetch }) => {
+ let wellrates = await fetch("https://bitcoinwell.com/api/rate/public").then(
+ (r) => r.json()
+ );
+ console.log(wellrates);
+
+ return { wellrates };
+};
+
+export const actions = {
+ default: async ({ cookies, request }) => {
+ let id;
+ let body = await fd(request);
+
+ try {
+ ({ id } = await post("/mint", body, auth(cookies)));
+ } catch (e: any) {
+ console.log("problem creating ecash", e);
+ error(400, { message: e.message });
+ }
+
+ redirect(307, `/ecash/${id}`);
+ },
+};
diff --git a/src/routes/(app)/send/well/+page.svelte b/src/routes/(app)/send/well/+page.svelte
new file mode 100644
index 00000000..380336d3
--- /dev/null
+++ b/src/routes/(app)/send/well/+page.svelte
@@ -0,0 +1,79 @@
+<script>
+ import { enhance, applyAction } from "$app/forms";
+ import { t } from "$lib/translations";
+ import Icon from "$comp/Icon.svelte";
+ import Numpad from "$comp/Numpad.svelte";
+ import Spinner from "$comp/Spinner.svelte";
+ import { page } from "$app/stores";
+ import { rate } from "$lib/store";
+ import { fail, s } from "$lib/utils";
+ import handler from "$lib/handler";
+
+ export let data;
+
+ let { rates, user, wellrates } = data;
+ let { balance, username } = user;
+ let currency = "CAD";
+ rates["CAD"] = wellrates.sellMarketRate;
+
+ let amount = 0;
+ let submit, fiat;
+
+ $: update(data);
+ let update = () => ($rate = data.rates[currency]);
+
+ let setMax = () => {
+ fiat = false;
+ amount = balance;
+ };
+
+ let submitting;
+ let toggle = () => (submitting = !submitting);
+ let email;
+</script>
+
+<a href="/send">
+ <button type="button" class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80">
+ <Icon icon="arrow-left" style="w-10" />
+ </button>
+</a>
+
+<div class="container px-4 max-w-xl mx-auto space-y-5 text-center">
+ <h1 class="text-3xl md:text-4xl font-semibold mb-2">Send e-Transfer</h1>
+ <img src="/images/well.svg" class="w-72 mx-auto" />
+
+ <input
+ type="text"
+ name="email"
+ bind:value={email}
+ placeholder="Recipient email"
+ />
+
+ <form use:enhance={handler(toggle)} method="POST">
+ <Numpad bind:amount bind:fiat {currency} {submit} bind:rate={$rate} />
+ <input type="hidden" name="amount" bind:value={amount} />
+
+ <div class="flex justify-center gap-2">
+ <button
+ type="button"
+ class="hover:opacity-80 bg-black text-white rounded-2xl py-3 px-4 mt-2 border font-bold"
+ on:click|preventDefault={setMax}
+ disabled={submitting}
+ on:keydown={setMax}>Max ⚡️{s(balance)}</button
+ >
+
+ <button
+ use:focus
+ bind:this={submit}
+ type="submit"
+ class="opacity-100 hover:opacity-80 rounded-2xl border py-3 font-bold mt-2 bg-black text-white px-4 w-24"
+ >
+ {#if submitting}
+ <Spinner />
+ {:else}
+ Send
+ {/if}
+ </button>
+ </div>
+ </form>
+</div>