From ae87f1d43c6d2cf34bd2ea6fd7b4d28af6d2aa91 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 10 Nov 2023 21:33:49 -0800 Subject: nav update --- src/components/AppHeader.svelte | 9 +- src/locales/en.json | 30 ++--- .../(app)/[username]/(profile)/+layout.svelte | 32 ++--- src/routes/(app)/[username]/(profile)/+page.svelte | 20 ++- src/routes/(app)/[username]/funds/+page.server.js | 0 src/routes/(app)/[username]/funds/+page.svelte | 56 +++++++++ src/routes/(app)/fund/[id]/+page.server.js | 23 ++++ src/routes/(app)/fund/[id]/+page.svelte | 138 +++++++++++++++++++++ src/routes/(app)/fund/[id]/sweep/+page.server.js | 14 +++ src/routes/(app)/fund/[id]/sweep/+page.svelte | 37 ++++++ .../(app)/fund/[id]/withdraw/+page.server.js | 20 +++ src/routes/(app)/fund/[id]/withdraw/+page.svelte | 58 +++++++++ src/routes/(app)/fund/[id]/withdraw/+server.js | 6 + src/routes/(app)/funds/[id]/+page.server.js | 23 ---- src/routes/(app)/funds/[id]/+page.svelte | 138 --------------------- src/routes/(app)/funds/[id]/sweep/+page.server.js | 14 --- src/routes/(app)/funds/[id]/sweep/+page.svelte | 37 ------ .../(app)/funds/[id]/withdraw/+page.server.js | 20 --- src/routes/(app)/funds/[id]/withdraw/+page.svelte | 58 --------- src/routes/(app)/funds/[id]/withdraw/+server.js | 6 - src/routes/(app)/send/[...text]/+page.svelte | 2 +- src/routes/+page.svelte | 2 +- 22 files changed, 388 insertions(+), 355 deletions(-) create mode 100644 src/routes/(app)/[username]/funds/+page.server.js create mode 100644 src/routes/(app)/[username]/funds/+page.svelte create mode 100644 src/routes/(app)/fund/[id]/+page.server.js create mode 100644 src/routes/(app)/fund/[id]/+page.svelte create mode 100644 src/routes/(app)/fund/[id]/sweep/+page.server.js create mode 100644 src/routes/(app)/fund/[id]/sweep/+page.svelte create mode 100644 src/routes/(app)/fund/[id]/withdraw/+page.server.js create mode 100644 src/routes/(app)/fund/[id]/withdraw/+page.svelte create mode 100644 src/routes/(app)/fund/[id]/withdraw/+server.js delete mode 100644 src/routes/(app)/funds/[id]/+page.server.js delete mode 100644 src/routes/(app)/funds/[id]/+page.svelte delete mode 100644 src/routes/(app)/funds/[id]/sweep/+page.server.js delete mode 100644 src/routes/(app)/funds/[id]/sweep/+page.svelte delete mode 100644 src/routes/(app)/funds/[id]/withdraw/+page.server.js delete mode 100644 src/routes/(app)/funds/[id]/withdraw/+page.svelte delete mode 100644 src/routes/(app)/funds/[id]/withdraw/+server.js (limited to 'src') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index 4ee0c4a7..4ccd2d03 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -17,10 +17,7 @@ menuButtons = [ { key: 'nav.settings', icon: 'settings', href: `/${user.username}/settings` }, { key: 'nav.support', icon: 'support', href: `/support` }, - { key: 'nav.funds', icon: 'fund', href: `/${user.username}/funds` }, - { key: 'nav.map', icon: 'map', href: `/${user.username}/map` }, - { key: 'nav.merch', icon: 'shirt', href: `https://coinosmerch.com` }, - { key: 'nav.signOut', icon: 'logout', href: `/logout` } + { key: 'nav.signOut', icon: 'logout', href: `/logout` }, ]; let showMenu = false; @@ -56,7 +53,7 @@ .url.pathname === `/${user.username}/receive` ? 'opacity-100' : 'opacity-70 hover:opacity-80'}" - > + > @@ -116,8 +113,6 @@ {/each} -
-
Coinos diff --git a/src/locales/en.json b/src/locales/en.json index 7aa157d1..9ecd3702 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -31,21 +31,13 @@ }, "faq": { "header": "FAQ", - "why": { - "question": "Why accept Bitcoin?", - "answer": "With Bitcoin, merchants save on fees, consumers gain privacy and savers gain purchasing power. We'll promote your business to an enthusiastic community that prefers to shop at places that take Bitcoin." - }, "cost": { "question": "What does it cost?", - "answer": "Receiving payments into your account is free. Withdrawals to external wallets incur a small fee that varies depending on network conditions. We charge 0.1% to convert between lightning and on-chain Bitcoin. Sending to other Coinos accounts is free." - }, - "individuals": { - "question": "Who can use it?", - "answer": "Anyone, anywhere in the world. Coinos is suitable for individuals and businesses." + "answer": "Receiving payments into your account is free. Withdrawals to external wallets incur a small fee that varies depending on network conditions." }, "compatibility": { "question": "Do I need any special device or software?", - "answer": "No, Coinos is a web app that works anywhere that has Internet. Merchants might use it on a tablet or put up a QR code for customers to scan with their phone." + "answer": "No, Coinos works anywhere that has Internet. Merchants might use it on a tablet or put up a QR code for customers to scan with their phone." }, "safety": { "question": "When do my funds settle?", @@ -55,14 +47,6 @@ "question": "Can Coinos integrate with my existing PoS?", "answer": "We recommend entering sales into your existing PoS as cash transactions." }, - "accounting": { - "question": "What about accounting?", - "answer": "We display all payments in terms of your local currency and let you filter by date so you can report your income as normal. You can export your account history to a csv file. If you sell Bitcoin for a profit you may wish to report capital gains." - }, - "offramp": { - "question": "Can I convert the Bitcoin I receive to my local currency?", - "answer": "You can withdraw your funds at any time to an exchange or brokerage to sell your Bitcoin and receive a bank transfer. We may be willing to provide direct settlement via e-transfer to select Canadian merchants." - }, "bitcoin": { "question": "What can I do with Bitcoin?", "answer": "Spend it at other merchants or pay your expenses with it by getting your staff, suppliers and landlord to take it." @@ -146,14 +130,17 @@ "failed": "Login failed" }, "nav": { + "about": "About", + "docs": "Docs", + "messages": "Messages", "funds": "Funds", "map": "Map", - "merch": "Merch", + "merch": "Shop", "profile": "Profile", "startInSeconds": "Start in Seconds", "account": "Account", "signIn": "Sign In", - "signOut": "Sign Out", + "signOut": "Sign out", "dashboard": "Dashboard", "settings": "Settings", "support": "Support" @@ -203,7 +190,7 @@ }, "send": { "contacts": "Contacts", - "scan": "Scan QR", + "scan": "Scan", "paste": "Paste", "next": "Next", "placeholder": "Paste a bitcoin address, lightning invoice or coinos username" @@ -265,6 +252,7 @@ } }, "payments": { + "create": "Create", "fund": "Fund", "addFunds": "Add Funds", "takeFunds": "Take Funds", diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index 35c316bb..8790aaf2 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -17,7 +17,7 @@ $: ({ currency, username: n, display } = subject); $: username = n.length > 60 ? n.substr(0, 6) : display || n; - $: npub = bech32m.encode('npub', toWords(hexToUint8Array(user.pubkey)), 180); + $: npub = bech32m.encode('npub', toWords(hexToUint8Array(subject.pubkey)), 180); $: lnaddr = `${n}@${$page.url.host}`; $: profile = `${$page.url.host}/${n}`; @@ -147,7 +147,7 @@ {#if following}
{/if} - {#if user && user.username !== subject.username && subject.pubkey} + {#if !subject.anon && subject.username !== user?.username}
-
+
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index 84aa4425..180b12bd 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -96,21 +96,21 @@ {/if}
- - diff --git a/src/routes/(app)/[username]/funds/+page.server.js b/src/routes/(app)/[username]/funds/+page.server.js new file mode 100644 index 00000000..e69de29b diff --git a/src/routes/(app)/[username]/funds/+page.svelte b/src/routes/(app)/[username]/funds/+page.svelte new file mode 100644 index 00000000..6479fb8b --- /dev/null +++ b/src/routes/(app)/[username]/funds/+page.svelte @@ -0,0 +1,56 @@ + + +
+

+ Funds +

+ +
+
+
+
+ +
+ +
+
+ +
+
+
+ Pot +
+ +
Pot
+
+
+ +
+
+ +
+
+
+
+ + +
+
+ + diff --git a/src/routes/(app)/fund/[id]/+page.server.js b/src/routes/(app)/fund/[id]/+page.server.js new file mode 100644 index 00000000..4194deed --- /dev/null +++ b/src/routes/(app)/fund/[id]/+page.server.js @@ -0,0 +1,23 @@ +import { error, redirect } from '@sveltejs/kit'; +import { auth, get, post } from '$lib/utils'; +import Qr from 'qrcode-base64'; + +export let load = async ({ params: { id }, url }) => { + let { amount, payments } = await get(`/fund/${id}`); + + let src = Qr.drawImg(url.href, { size: 300 }); + return { amount, payments, src }; +}; + +export const actions = { + default: async ({ cookies, locals, params, request }) => { + let { user } = locals; + + if (user) { + await post('/redeem', params, auth(cookies)); + throw redirect(307, `/${user.username}/payments`); + } + + throw redirect(307, '/register'); + } +}; diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte new file mode 100644 index 00000000..d2d3079c --- /dev/null +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -0,0 +1,138 @@ + + +
+
+
+
+ + {#if id.split('-').length === 4} +

Card {id}

+ {:else} + Fund +
+

{$t('payments.fund')}

+

{id}

+
+ {/if} +
+ {#if show} + {id} + {/if} +
+
+

+ {f(amountFiat, currency)} +

+

+ {sat(amount)} +

+
+
+ +
+ + +
+ +
+
+
diff --git a/src/routes/(app)/fund/[id]/sweep/+page.server.js b/src/routes/(app)/fund/[id]/sweep/+page.server.js new file mode 100644 index 00000000..9fd244a3 --- /dev/null +++ b/src/routes/(app)/fund/[id]/sweep/+page.server.js @@ -0,0 +1,14 @@ +import { get, auth, post } from '$lib/utils'; +import { redirect } from '@sveltejs/kit'; + +export async function load({ cookies, params, parent }) { + let { user } = await parent(); + let { id } = params; + let { amount } = await get(`/fund/${id}`); + + + if (!amount) throw redirect(307, `/fund/${id}`); + if (!user) throw redirect(307, `/register?redirect=/fund/${id}/sweep`); + await post('/take', { amount, id }, auth(cookies)); + return { amount, id }; +} diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/+page.svelte new file mode 100644 index 00000000..64bed4dd --- /dev/null +++ b/src/routes/(app)/fund/[id]/sweep/+page.svelte @@ -0,0 +1,37 @@ + + +
+
+ + + +
+ +
+ +
+

{$t('payments.fundsClaimed')}

+

+ {f(fiat(amount, rate), currency)} +

+

+ ⚡️{s(amount)} +

+
+ + +
+ + +
{$t('payments.tapAnywhere')}
diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.server.js b/src/routes/(app)/fund/[id]/withdraw/+page.server.js new file mode 100644 index 00000000..476149f2 --- /dev/null +++ b/src/routes/(app)/fund/[id]/withdraw/+page.server.js @@ -0,0 +1,20 @@ +import { fail, json, redirect } from '@sveltejs/kit'; +import { fd, auth, post } from '$lib/utils'; + +export async function load({ parent }) { + let { user } = await parent(); + if (!user) throw redirect(307, '/register'); +} + +export const actions = { + default: async ({ cookies, request }) => { + let body = await fd(request); + try { + await post('/take', body, auth(cookies)); + } catch (e) { + return fail(400, { message: e.message }); + } + + throw redirect(307, `/fund/${body.id}`); + } +}; diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.svelte b/src/routes/(app)/fund/[id]/withdraw/+page.svelte new file mode 100644 index 00000000..9cad945a --- /dev/null +++ b/src/routes/(app)/fund/[id]/withdraw/+page.svelte @@ -0,0 +1,58 @@ + + + + +{#if form?.message} +
+ {form.message} +
+{/if} + +
+ + +
+ + + + +
+ +
+
+
diff --git a/src/routes/(app)/fund/[id]/withdraw/+server.js b/src/routes/(app)/fund/[id]/withdraw/+server.js new file mode 100644 index 00000000..0f9a23f3 --- /dev/null +++ b/src/routes/(app)/fund/[id]/withdraw/+server.js @@ -0,0 +1,6 @@ +import { json } from '@sveltejs/kit'; +import { auth, post } from '$lib/utils'; + +export async function POST({ cookies, request }) { + return json(await post('/take', await request.json(), auth(cookies))); +} diff --git a/src/routes/(app)/funds/[id]/+page.server.js b/src/routes/(app)/funds/[id]/+page.server.js deleted file mode 100644 index 4194deed..00000000 --- a/src/routes/(app)/funds/[id]/+page.server.js +++ /dev/null @@ -1,23 +0,0 @@ -import { error, redirect } from '@sveltejs/kit'; -import { auth, get, post } from '$lib/utils'; -import Qr from 'qrcode-base64'; - -export let load = async ({ params: { id }, url }) => { - let { amount, payments } = await get(`/fund/${id}`); - - let src = Qr.drawImg(url.href, { size: 300 }); - return { amount, payments, src }; -}; - -export const actions = { - default: async ({ cookies, locals, params, request }) => { - let { user } = locals; - - if (user) { - await post('/redeem', params, auth(cookies)); - throw redirect(307, `/${user.username}/payments`); - } - - throw redirect(307, '/register'); - } -}; diff --git a/src/routes/(app)/funds/[id]/+page.svelte b/src/routes/(app)/funds/[id]/+page.svelte deleted file mode 100644 index d2d3079c..00000000 --- a/src/routes/(app)/funds/[id]/+page.svelte +++ /dev/null @@ -1,138 +0,0 @@ - - -
-
-
-
- - {#if id.split('-').length === 4} -

Card {id}

- {:else} - Fund -
-

{$t('payments.fund')}

-

{id}

-
- {/if} -
- {#if show} - {id} - {/if} -
-
-

- {f(amountFiat, currency)} -

-

- {sat(amount)} -

-
-
- -
- - -
- -
-
-
diff --git a/src/routes/(app)/funds/[id]/sweep/+page.server.js b/src/routes/(app)/funds/[id]/sweep/+page.server.js deleted file mode 100644 index 9fd244a3..00000000 --- a/src/routes/(app)/funds/[id]/sweep/+page.server.js +++ /dev/null @@ -1,14 +0,0 @@ -import { get, auth, post } from '$lib/utils'; -import { redirect } from '@sveltejs/kit'; - -export async function load({ cookies, params, parent }) { - let { user } = await parent(); - let { id } = params; - let { amount } = await get(`/fund/${id}`); - - - if (!amount) throw redirect(307, `/fund/${id}`); - if (!user) throw redirect(307, `/register?redirect=/fund/${id}/sweep`); - await post('/take', { amount, id }, auth(cookies)); - return { amount, id }; -} diff --git a/src/routes/(app)/funds/[id]/sweep/+page.svelte b/src/routes/(app)/funds/[id]/sweep/+page.svelte deleted file mode 100644 index 64bed4dd..00000000 --- a/src/routes/(app)/funds/[id]/sweep/+page.svelte +++ /dev/null @@ -1,37 +0,0 @@ - - -
-
- - - -
- -
- -
-

{$t('payments.fundsClaimed')}

-

- {f(fiat(amount, rate), currency)} -

-

- ⚡️{s(amount)} -

-
- - -
- - -
{$t('payments.tapAnywhere')}
diff --git a/src/routes/(app)/funds/[id]/withdraw/+page.server.js b/src/routes/(app)/funds/[id]/withdraw/+page.server.js deleted file mode 100644 index 476149f2..00000000 --- a/src/routes/(app)/funds/[id]/withdraw/+page.server.js +++ /dev/null @@ -1,20 +0,0 @@ -import { fail, json, redirect } from '@sveltejs/kit'; -import { fd, auth, post } from '$lib/utils'; - -export async function load({ parent }) { - let { user } = await parent(); - if (!user) throw redirect(307, '/register'); -} - -export const actions = { - default: async ({ cookies, request }) => { - let body = await fd(request); - try { - await post('/take', body, auth(cookies)); - } catch (e) { - return fail(400, { message: e.message }); - } - - throw redirect(307, `/fund/${body.id}`); - } -}; diff --git a/src/routes/(app)/funds/[id]/withdraw/+page.svelte b/src/routes/(app)/funds/[id]/withdraw/+page.svelte deleted file mode 100644 index 9cad945a..00000000 --- a/src/routes/(app)/funds/[id]/withdraw/+page.svelte +++ /dev/null @@ -1,58 +0,0 @@ - - - - -{#if form?.message} -
- {form.message} -
-{/if} - -
- - -
- - - - -
- -
-
-
diff --git a/src/routes/(app)/funds/[id]/withdraw/+server.js b/src/routes/(app)/funds/[id]/withdraw/+server.js deleted file mode 100644 index 0f9a23f3..00000000 --- a/src/routes/(app)/funds/[id]/withdraw/+server.js +++ /dev/null @@ -1,6 +0,0 @@ -import { json } from '@sveltejs/kit'; -import { auth, post } from '$lib/utils'; - -export async function POST({ cookies, request }) { - return json(await post('/take', await request.json(), auth(cookies))); -} diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index de84c287..b2c9616c 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -61,7 +61,7 @@ type="button" class="flex border rounded-full px-6 py-2 font-bold hover:opacity-80 mr-1" > - +
{$t('user.send.scan')}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ec9f55b7..0aaf887d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -89,7 +89,7 @@
-

{$t('faq.header')}

+

{$t('faq.header')}

{#each Object.keys(faqs).filter((f) => f !== 'header') as faqID} {/each} -- cgit v1.2.3