From 7e6dd4a3d7bcabbfd3e0a2a31d4b98a04e09e210 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 24 Sep 2023 22:41:54 -0700 Subject: fix shopify qr code --- src/routes/(app)/[username]/shopify.js/+server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/[username]/shopify.js/+server.js b/src/routes/(app)/[username]/shopify.js/+server.js index 963b92a1..7b5c9d41 100644 --- a/src/routes/(app)/[username]/shopify.js/+server.js +++ b/src/routes/(app)/[username]/shopify.js/+server.js @@ -46,8 +46,6 @@ window.addEventListener('load', async () => { let s = (s) => new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(s); - let base64 = drawImg('test', { size: 300 }); - let link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('type', 'text/css'); @@ -92,6 +90,8 @@ window.addEventListener('load', async () => { }) .catch(console.log); + let base64 = drawImg(data.hash, { size: 300 }); + main.innerHTML = \`
-- cgit v1.2.3 From fa8878e0eb910a72033b441c91e1351ae1d877f8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 25 Sep 2023 20:57:09 -0700 Subject: menu update --- src/components/AppHeader.svelte | 2 ++ src/components/LocationsMap.svelte | 41 +++++++++++++++++++------ src/locales/en.json | 2 ++ src/routes/(app)/[username]/map/+page.server.js | 12 ++++++++ src/routes/(app)/[username]/map/+page.svelte | 8 +++++ static/icons/map.svg | 4 +++ static/icons/shirt.svg | 14 +++++++++ 7 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 src/routes/(app)/[username]/map/+page.server.js create mode 100644 src/routes/(app)/[username]/map/+page.svelte create mode 100644 static/icons/map.svg create mode 100644 static/icons/shirt.svg (limited to 'src/routes/(app)') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index ac815211..8f1fe947 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -17,6 +17,8 @@ menuButtons = [ { key: 'nav.settings', icon: 'settings', href: `/${user.username}/settings` }, { key: 'nav.support', icon: 'support', href: `/support` }, + { 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` } ]; diff --git a/src/components/LocationsMap.svelte b/src/components/LocationsMap.svelte index 37dd60ba..b9833c6c 100644 --- a/src/components/LocationsMap.svelte +++ b/src/components/LocationsMap.svelte @@ -34,16 +34,32 @@ let mapElement; let map; + function updateLabelVisibility() { + const zoom = map.getZoom(); + map.eachLayer((layer) => { + if (layer.getTooltip) { + const tooltip = layer.getTooltip(); + if (tooltip) { + if (zoom > 14) { + // Show labels at zoom levels greater than 14 + tooltip.setOpacity(1.0); + } else { + tooltip.setOpacity(0.0); + } + } + } + }); + } + onMount(async () => { if (browser) { const L = await import('leaflet'); map = L.map(mapElement, { - zoomSnap: 0, - attributionControl: false, + zoomSnap: 0, + attributionControl: false }).setView([49.26, -123.05], 12); - const myCustomColour = '#F7931A'; const markerHtmlStyles = ` @@ -178,17 +194,22 @@ marker.addTo(map); }); + updateLabelVisibility(); + map.on('zoomend', updateLabelVisibility); // map.fitBounds(locations.map(({ osm_json: { lat, lon } }) => [lat, lon])); } }); - onDestroy(async () => map && map.remove()); + onDestroy(async () => { + map.off('zoomend', updateLabelVisibility); + map && map.remove(); + });
-
-
-
+
+
+
diff --git a/src/locales/en.json b/src/locales/en.json index dbc8bf3d..7dd7c258 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -145,6 +145,8 @@ "failed": "Login failed" }, "nav": { + "map": "Map", + "merch": "Merch", "profile": "Profile", "startInSeconds": "Start in Seconds", "account": "Account", diff --git a/src/routes/(app)/[username]/map/+page.server.js b/src/routes/(app)/[username]/map/+page.server.js new file mode 100644 index 00000000..7936e88b --- /dev/null +++ b/src/routes/(app)/[username]/map/+page.server.js @@ -0,0 +1,12 @@ +import { get } from '$lib/utils'; + +// export const prerender = true; +export let load = async () => { + let data = { locations: [] }; + + try { + data = await get('/locations'); + } catch (e) {} + + return data; +}; diff --git a/src/routes/(app)/[username]/map/+page.svelte b/src/routes/(app)/[username]/map/+page.svelte new file mode 100644 index 00000000..b5e4dfad --- /dev/null +++ b/src/routes/(app)/[username]/map/+page.svelte @@ -0,0 +1,8 @@ + + + diff --git a/static/icons/map.svg b/static/icons/map.svg new file mode 100644 index 00000000..8f34ff60 --- /dev/null +++ b/static/icons/map.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/static/icons/shirt.svg b/static/icons/shirt.svg new file mode 100644 index 00000000..9bfd4db1 --- /dev/null +++ b/static/icons/shirt.svg @@ -0,0 +1,14 @@ + + + + \ No newline at end of file -- cgit v1.2.3 From 94a4ee99272cbb2a7d6ef2c7ef5cd60bfd059f7b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 26 Sep 2023 11:26:54 -0700 Subject: update shopify instructions --- .../[username]/settings/[...tab]/_shopify.svelte | 57 ++++++++++++++-------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte b/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte index 7b9cc40b..aeecc4d7 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte @@ -4,15 +4,23 @@ import { page } from '$app/stores'; export let user; - $: paymentsUrl = user.shopifyStore && "https://admin.shopify.com/store/" + user.shopifyStore + "/settings/payments"; - $: checkoutUrl = user.shopifyStore && "https://admin.shopify.com/store/" + user.shopifyStore + "/settings/checkout"; - $: appsUrl = user.shopifyStore && "https://admin.shopify.com/store/" + user.shopifyStore + "/settings/apps/development"; + $: paymentsUrl = + user.shopifyStore && + 'https://admin.shopify.com/store/' + user.shopifyStore + '/settings/payments'; + $: checkoutUrl = + user.shopifyStore && + 'https://admin.shopify.com/store/' + user.shopifyStore + '/settings/checkout'; + $: appsUrl = + user.shopifyStore && + 'https://admin.shopify.com/store/' + user.shopifyStore + '/settings/apps/development';
-
admin.shopify.com/store/
+
+ admin.shopify.com/store/ +

- Add Bitcoin under Payments > Manual payment methods with a description like "Pay with Bitcoin". + Add Bitcoin under Payments > Manual payment methods with a description like "Pay with Bitcoin".

- - - -

-Create an app named Coinos under Apps > App Development -

- -

-Edit the Admin API scopes to enable write_orders then -install the app into your store and copy the Admin API access token here. + +

+ Copy this into Checkout -> Additional scripts +

+
- - + +

Coinos can automatically mark orders as Paid if you provide an API token. + + +

+ Create a new app in Apps > App Development +

- Copy this into Checkout -> Additional scripts + Edit the Admin API scopes to enable write_orders permission then install the + app into your store and copy the Admin API access token here.

-- cgit v1.2.3 From 6b7f03fcf87d346f8e25a954220570da5b9a5c3d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 6 Oct 2023 15:17:21 -0700 Subject: fix disable pin bug --- src/routes/(app)/[username]/settings/[...tab]/_security.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte index 40947bda..a08785f6 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte @@ -52,10 +52,12 @@ return true; }; +let disablingPin = false; + let togglePin = async () => { if (user.haspin) { try { - pin = null; + disablingPin = true; await tick(); submit.click(); } catch (e) { @@ -120,7 +122,7 @@ }; - +
-- cgit v1.2.3 From 222bbc9080fbb15861cc5c0802449fcf06a53532 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 7 Oct 2023 23:30:52 -0700 Subject: fix more options invoices --- .../[username]/invoice/[hash]/+layout.server.js | 25 --- .../(app)/[username]/invoice/[hash]/+layout.svelte | 1 - .../[username]/invoice/[hash]/+page.server.js | 5 - .../(app)/[username]/invoice/[hash]/+page.svelte | 217 --------------------- .../[username]/invoice/[hash]/paid/+page.svelte | 65 ------ .../[username]/invoice/[hash]/tip/+page.server.js | 11 -- .../[username]/invoice/[hash]/tip/+page.svelte | 201 ------------------- .../[username]/invoice/[id]/+layout.server.js | 31 +++ .../(app)/[username]/invoice/[id]/+layout.svelte | 1 + .../(app)/[username]/invoice/[id]/+page.server.js | 5 + .../(app)/[username]/invoice/[id]/+page.svelte | 217 +++++++++++++++++++++ .../[username]/invoice/[id]/paid/+page.svelte | 64 ++++++ .../[username]/invoice/[id]/tip/+page.server.js | 11 ++ .../(app)/[username]/invoice/[id]/tip/+page.svelte | 201 +++++++++++++++++++ src/routes/(app)/send/invoice/[id]/+page.svelte | 15 +- 15 files changed, 538 insertions(+), 532 deletions(-) delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/+layout.server.js delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/+layout.svelte delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/+page.server.js delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/+page.svelte delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js delete mode 100644 src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte create mode 100644 src/routes/(app)/[username]/invoice/[id]/+layout.server.js create mode 100644 src/routes/(app)/[username]/invoice/[id]/+layout.svelte create mode 100644 src/routes/(app)/[username]/invoice/[id]/+page.server.js create mode 100644 src/routes/(app)/[username]/invoice/[id]/+page.svelte create mode 100644 src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte create mode 100644 src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js create mode 100644 src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js deleted file mode 100644 index eef24555..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js +++ /dev/null @@ -1,25 +0,0 @@ -import Qr from 'qrcode-base64'; -import { get } from '$lib/utils'; -import { redirect } from '@sveltejs/kit'; - -export async function load({ depends, params, url, parent }) { - depends('app:invoice'); - - let { user } = await parent(); - let { hash } = params; - let invoice = await get(`/invoice/${hash}`); - - if (user && invoice.uid !== user.id && !url.pathname.includes('tip') && !url.searchParams.get('options')) - throw redirect(307, `/send/invoice/${hash}`); - - let { amount, pending, received } = invoice; - amount = parseInt(amount); - - let paid = (!amount && received) || (amount > 0 && (pending >= amount || received >= amount)); - if (paid && !url.pathname.endsWith('paid')) - throw redirect(307, `/${params.username}/invoice/${hash}/paid`); - - let sm = Qr.drawImg(invoice.text || '', { size: 300 }); - - return { hash, invoice, sm, lg: sm }; -} diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.svelte b/src/routes/(app)/[username]/invoice/[hash]/+layout.svelte deleted file mode 100644 index 4fa864ce..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.svelte +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.server.js b/src/routes/(app)/[username]/invoice/[hash]/+page.server.js deleted file mode 100644 index 1068f273..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/+page.server.js +++ /dev/null @@ -1,5 +0,0 @@ -import invoice from '$lib/invoice'; - -export const actions = { - default: invoice -}; diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte deleted file mode 100644 index 508550ba..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte +++ /dev/null @@ -1,217 +0,0 @@ - - -
-
- - - -
- - {#if showQr} -
- - - {/if} - - {#if amount > 0} -
-
- {f(amountFiat, currency)} - - {#if tip} - - +{f(tip * (rate / sats), currency)} - - {/if} -
-
- {`${sat(amount)}`} - - {#if tip} - - +{sat(tip)} - - {/if} -
-
- {/if} - - - -
- - - - - - - -
-
diff --git a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte deleted file mode 100644 index 969fb6c7..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/paid/+page.svelte +++ /dev/null @@ -1,65 +0,0 @@ - - -
-
- -
- {#if received} -

{$t('invoice.paymentSuccessful')}

-

- {f(fiat(received - tip, rate), currency)} - {#if tip} - - + {f(fiat(tip, rate), currency)} - - {/if} -

-

- ⚡️{s(received - tip)} - - {#if tip} - - + ⚡️{s(tip)} - - {/if} -

- {/if} - - {#if pending} -

Payment detected

-

- {f(fiat(pending - tip, rate), currency)} - {#if tip} - + {f(fiat(tip, rate), currency)} - {/if} -

-

- ⚡️{s(pending - tip)} - {#if tip} - - + ⚡️{s(tip)} - - {/if} -

- {/if} -
- - -
- - -
{$t('payments.tapAnywhere')}
diff --git a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js b/src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js deleted file mode 100644 index 814900fb..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.server.js +++ /dev/null @@ -1,11 +0,0 @@ -import invoice from '$lib/invoice'; -import { redirect } from '@sveltejs/kit'; - -export async function load({ parent, params }) { - let { invoice } = await parent(); - if (!invoice.amount) throw redirect(307, `/${params.username}/invoice/${invoice.id}`); -} - -export const actions = { - default: invoice -}; diff --git a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte deleted file mode 100644 index fe6c67be..00000000 --- a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte +++ /dev/null @@ -1,201 +0,0 @@ - - -
-
- - - - - - - - - - -

{$t('invoice.addTipq')}

- {#if !showCustomAmount} -
{Math.round(tipPercent)}%
- - - -
-
- - {f(amountFiat, currency)} - +{f(tipAmount, currency)} - -
- -
- {sat(amount)} - +{sat(tip)} -
-
- - {#if tip} -
- - -
- {:else} - {#each tipAmounts as amount} - - {/each} - {/if} - -
- -
- {/if} - - -
- - {/if} -
- - diff --git a/src/routes/(app)/[username]/invoice/[id]/+layout.server.js b/src/routes/(app)/[username]/invoice/[id]/+layout.server.js new file mode 100644 index 00000000..4d7fd3b8 --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/+layout.server.js @@ -0,0 +1,31 @@ +import Qr from 'qrcode-base64'; +import { get } from '$lib/utils'; +import { redirect } from '@sveltejs/kit'; + +export async function load({ depends, params, url, parent }) { + depends('app:invoice'); + + let { user } = await parent(); + let { id } = params; + let invoice = await get(`/invoice/${id}`); + let options = !!url.searchParams.get('options'); + + if (user && invoice.uid !== user.id && !url.pathname.includes('tip') && !options) { + throw redirect(307, `/send/invoice/${id}`); + } + + let { amount, pending, received } = invoice; + amount = parseInt(amount); + + let paid = (!amount && received) || (amount > 0 && (pending >= amount || received >= amount)); + if (paid && !url.pathname.endsWith('paid')) { + throw redirect( + 307, + `/${params.username}/invoice/${id}/paid` + (options ? '?options=true' : '') + ); + } + + let sm = Qr.drawImg(invoice.text || '', { size: 300 }); + + return { id, invoice, sm, lg: sm }; +} diff --git a/src/routes/(app)/[username]/invoice/[id]/+layout.svelte b/src/routes/(app)/[username]/invoice/[id]/+layout.svelte new file mode 100644 index 00000000..4fa864ce --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/+layout.svelte @@ -0,0 +1 @@ + diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.server.js b/src/routes/(app)/[username]/invoice/[id]/+page.server.js new file mode 100644 index 00000000..1068f273 --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/+page.server.js @@ -0,0 +1,5 @@ +import invoice from '$lib/invoice'; + +export const actions = { + default: invoice +}; diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/+page.svelte new file mode 100644 index 00000000..508550ba --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/+page.svelte @@ -0,0 +1,217 @@ + + +
+
+ + + +
+ + {#if showQr} +
+ + + {/if} + + {#if amount > 0} +
+
+ {f(amountFiat, currency)} + + {#if tip} + + +{f(tip * (rate / sats), currency)} + + {/if} +
+
+ {`${sat(amount)}`} + + {#if tip} + + +{sat(tip)} + + {/if} +
+
+ {/if} + + + +
+ + + + + + + +
+
diff --git a/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte new file mode 100644 index 00000000..84e493d9 --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/paid/+page.svelte @@ -0,0 +1,64 @@ + + +
+
+ +
+ {#if received} +

{$t('invoice.paymentSuccessful')}

+

+ {f(fiat(received - tip, rate), currency)} + {#if tip} + + + {f(fiat(tip, rate), currency)} + + {/if} +

+

+ ⚡️{s(received - tip)} + + {#if tip} + + + ⚡️{s(tip)} + + {/if} +

+ {/if} + + {#if pending} +

Payment detected

+

+ {f(fiat(pending - tip, rate), currency)} + {#if tip} + + {f(fiat(tip, rate), currency)} + {/if} +

+

+ ⚡️{s(pending - tip)} + {#if tip} + + + ⚡️{s(tip)} + + {/if} +

+ {/if} +
+ + +
+ + +
{$t('payments.tapAnywhere')}
diff --git a/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js b/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js new file mode 100644 index 00000000..814900fb --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/tip/+page.server.js @@ -0,0 +1,11 @@ +import invoice from '$lib/invoice'; +import { redirect } from '@sveltejs/kit'; + +export async function load({ parent, params }) { + let { invoice } = await parent(); + if (!invoice.amount) throw redirect(307, `/${params.username}/invoice/${invoice.id}`); +} + +export const actions = { + default: invoice +}; diff --git a/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte new file mode 100644 index 00000000..fe6c67be --- /dev/null +++ b/src/routes/(app)/[username]/invoice/[id]/tip/+page.svelte @@ -0,0 +1,201 @@ + + +
+
+ + + + + + + + + + +

{$t('invoice.addTipq')}

+ {#if !showCustomAmount} +
{Math.round(tipPercent)}%
+ + + +
+
+ + {f(amountFiat, currency)} + +{f(tipAmount, currency)} + +
+ +
+ {sat(amount)} + +{sat(tip)} +
+
+ + {#if tip} +
+ + +
+ {:else} + {#each tipAmounts as amount} + + {/each} + {/if} + +
+ +
+ {/if} + + +
+ + {/if} +
+ + diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 554eef6f..a71c697a 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -28,12 +28,13 @@ let submit = () => (loading = true); let external = async () => { - let invoice = { type: 'lightning', amount }; - let { hash } = await post(`/${recipient.username}/invoice`, { - invoice + let invoice = { type: 'lightning', amount, currency }; + let {id }= await post(`/${recipient.username}/invoice`, { + invoice, + user: { username: recipient.username } }); - goto(`/${recipient.username}/invoice/${hash}`, { invalidateAll: true }); + goto(`/${recipient.username}/invoice/${id}?options=true`, { invalidateAll: true }); }; $: rate = data.rate * (rates[user.currency] / rates[data.currency]); @@ -139,7 +140,7 @@ {/if}
-
- -
+
+ +
-- cgit v1.2.3 From 0212fe0032eb0c5d6bfb74ebaab42543b73d6d6b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 8 Oct 2023 00:17:32 -0700 Subject: payments fixes --- src/components/AppHeader.svelte | 2 +- src/components/Balance.svelte | 4 +- src/components/Code.svelte | 4 +- src/components/Footer.svelte | 2 +- src/components/LocationsMap.svelte | 4 +- src/components/RegisterOrLogin.svelte | 6 ++- src/lib/invoice.js | 8 ++-- src/lib/socket.js | 20 +++------ src/lib/store.js | 1 - .../(app)/[username]/(profile)/+layout.svelte | 20 ++++----- src/routes/(app)/[username]/(profile)/+page.svelte | 8 +++- .../(app)/[username]/card/[serial]/+page.svelte | 50 +++++++++++----------- src/routes/(app)/[username]/generate/+page.svelte | 8 ++-- .../(app)/[username]/invoice/[id]/+page.svelte | 4 +- src/routes/(app)/[username]/map/+page.svelte | 4 +- .../[username]/payments/[...page]/+page.server.js | 4 +- .../[username]/payments/[...page]/+page.svelte | 14 +++--- .../[username]/receive/[...param]/+page.svelte | 1 - .../[username]/settings/[...tab]/+page.svelte | 4 +- .../[username]/settings/[...tab]/_account.svelte | 36 +++++++++------- .../(app)/[username]/settings/[...tab]/_pos.svelte | 4 +- .../[username]/settings/[...tab]/_security.svelte | 6 +-- src/routes/(app)/login/+page.svelte | 2 +- src/routes/(app)/payment/[id]/+page.svelte | 6 +-- src/routes/(app)/pot/[name]/+page.svelte | 20 ++++----- src/routes/(app)/pot/[name]/sweep/+page.svelte | 31 +++++++------- src/routes/(app)/pot/[name]/withdraw/+page.svelte | 4 +- src/routes/(app)/qr/[text]/+page.svelte | 2 +- src/routes/(app)/send/invoice/[id]/+page.svelte | 2 +- src/routes/(static)/bounties/+page.svelte | 27 ++++++------ src/routes/(static)/docs/+page.svelte | 17 +++++--- src/routes/+layout.svelte | 4 +- src/routes/+page.svelte | 8 ++-- src/routes/map/+page.svelte | 4 +- 34 files changed, 173 insertions(+), 168 deletions(-) (limited to 'src/routes/(app)') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index 8f1fe947..798073fb 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -121,7 +121,7 @@
{:else} - + diff --git a/src/components/Balance.svelte b/src/components/Balance.svelte index 96edf630..0e4f2ec2 100644 --- a/src/components/Balance.svelte +++ b/src/components/Balance.svelte @@ -9,14 +9,14 @@ {#if show && user.haspin && $pin?.length !== 6} - (show = false)} /> + (show = false)} /> {/if}
{#if user.haspin && !$pin} (show = true)}>{$t('user.showBalance')} {:else}
diff --git a/src/components/Code.svelte b/src/components/Code.svelte index dd0cecf2..ffca98a4 100644 --- a/src/components/Code.svelte +++ b/src/components/Code.svelte @@ -9,9 +9,7 @@
{samples[sample]}
-
diff --git a/src/components/Footer.svelte b/src/components/Footer.svelte index 9dfbc3de..eda26526 100644 --- a/src/components/Footer.svelte +++ b/src/components/Footer.svelte @@ -10,7 +10,7 @@ const companyLinks = [ { url: '/docs', titleID: 'documentation' }, - { url: '/support', titleID: 'support' }, + { url: '/support', titleID: 'support' } ]; diff --git a/src/components/LocationsMap.svelte b/src/components/LocationsMap.svelte index f927331c..7876659a 100644 --- a/src/components/LocationsMap.svelte +++ b/src/components/LocationsMap.svelte @@ -127,8 +127,8 @@ } :global(.maplibregl-ctrl-attrib) { - display: none; - } + display: none; + } :global(.maplibregl-popup-content) { padding: 0.5em 1em; diff --git a/src/components/RegisterOrLogin.svelte b/src/components/RegisterOrLogin.svelte index d8475340..57e0eeed 100644 --- a/src/components/RegisterOrLogin.svelte +++ b/src/components/RegisterOrLogin.svelte @@ -88,7 +88,11 @@ {/if}
- +
diff --git a/src/lib/invoice.js b/src/lib/invoice.js index 23ce1757..218972c6 100644 --- a/src/lib/invoice.js +++ b/src/lib/invoice.js @@ -21,16 +21,16 @@ export default async ({ cookies, request, url }) => { let user = { username: form.get('username'), currency: form.get('currency') }; invoice = await post('/invoice', { invoice, user }, auth(cookies)); - let { hash } = invoice; + let { id } = invoice; if (request_id) { if (url.pathname.endsWith('tip')) { - throw redirect(307, `/send/invoice/${hash}`); + throw redirect(307, `/send/invoice/${id}`); } throw redirect(307, `/${user.username}/request/${request_id}`); } - if (invoice.prompt) throw redirect(307, `/${user.username}/invoice/${hash}/tip`); - else throw redirect(307, `/${user.username}/invoice/${hash}`); + if (invoice.prompt) throw redirect(307, `/${user.username}/invoice/${id}/tip`); + else throw redirect(307, `/${user.username}/invoice/${id}`); }; diff --git a/src/lib/socket.js b/src/lib/socket.js index e8859fa6..96fde317 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -1,5 +1,5 @@ import { get } from 'svelte/store'; -import { event, invoice, request, newPayment, last, rate, payments, user } from '$lib/store'; +import { event, invoice, request, newPayment, last, rate, user } from '$lib/store'; import { success, sat } from '$lib/utils'; import { PUBLIC_SOCKET } from '$env/static/public'; import { invalidate } from '$app/navigation'; @@ -34,23 +34,13 @@ export const messages = (data) => ({ }, async payment() { - let { amount, invoice } = data; + let { amount, confirmed } = data; + invalidate('app:user'); invalidate('app:invoice'); - - let p = get(payments); - let i = p.findIndex((p) => p.id === data.id); - - if (~i) { - p[i] = data; - payments.set(p); - } else newPayment.set(true); - - invalidate((url) => url.pathname === '/payments'); + invalidate('app:payments'); if (amount > 0) { - success(`${data.confirmed ? 'Received' : 'Detected'} ${sat(amount)}!`); - } else { - // success(`Sent ${sat(amount)}!`); + success(`${confirmed ? 'Received' : 'Detected'} ${sat(amount)}!`); } }, diff --git a/src/lib/store.js b/src/lib/store.js index 923bda52..64cf015e 100644 --- a/src/lib/store.js +++ b/src/lib/store.js @@ -45,7 +45,6 @@ export const decrypted = persistLocal('decrypted', {}); export const newPayment = persistLocal('newPayment'); export const password = persistLocal('password'); export const passwordPrompt = writable(); -export const payments = persistLocal('transactions', []); export const pin = writable(); export const rate = writable(); export const request = writable(); diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index ed8a90f3..331161bb 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -51,16 +51,16 @@
diff --git a/src/routes/(app)/[username]/generate/+page.svelte b/src/routes/(app)/[username]/generate/+page.svelte index 33bf64c4..b9274434 100644 --- a/src/routes/(app)/[username]/generate/+page.svelte +++ b/src/routes/(app)/[username]/generate/+page.svelte @@ -14,10 +14,10 @@ let gen = async () => { if (!browser) return; - if (user.pubkey) { - goto($loginRedirect || `/${user.username}`, { invalidateAll: true }); - return; - } + if (user.pubkey) { + goto($loginRedirect || `/${user.username}`, { invalidateAll: true }); + return; + } if (!$password) $passwordPrompt = true; diff --git a/src/routes/(app)/[username]/invoice/[id]/+page.svelte b/src/routes/(app)/[username]/invoice/[id]/+page.svelte index 508550ba..2d204255 100644 --- a/src/routes/(app)/[username]/invoice/[id]/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[id]/+page.svelte @@ -101,12 +101,12 @@ let toggleType = async () => { invoice.type = invoice.type === types.lightning ? types.bitcoin : types.lightning; - ({ hash } = await post(`/${username}/invoice`, { + ({ id } = await post(`/${username}/invoice`, { invoice, user: { username, currency } })); - goto(`./${hash}`, { invalidateAll: true }); + goto(`./${id}`, { invalidateAll: true }); }; diff --git a/src/routes/(app)/[username]/map/+page.svelte b/src/routes/(app)/[username]/map/+page.svelte index b5e4dfad..99c822d3 100644 --- a/src/routes/(app)/[username]/map/+page.svelte +++ b/src/routes/(app)/[username]/map/+page.svelte @@ -1,6 +1,6 @@ diff --git a/src/routes/(app)/[username]/payments/[...page]/+page.server.js b/src/routes/(app)/[username]/payments/[...page]/+page.server.js index cb94d71d..a3b0ad6f 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+page.server.js +++ b/src/routes/(app)/[username]/payments/[...page]/+page.server.js @@ -2,7 +2,9 @@ import { get, auth } from '$lib/utils'; let limit = 25; -export async function load({ cookies, params, request }) { +export async function load({ cookies, depends, params, request }) { + depends('app:payments'); + let parts = params.page.split('/'); let start, end, page; diff --git a/src/routes/(app)/[username]/payments/[...page]/+page.svelte b/src/routes/(app)/[username]/payments/[...page]/+page.svelte index 69f51f37..2ea225ad 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+page.svelte +++ b/src/routes/(app)/[username]/payments/[...page]/+page.svelte @@ -2,7 +2,7 @@ import { Avatar, Icon } from '$comp'; import { onMount } from 'svelte'; import { format } from 'date-fns'; - import { newPayment, payments } from '$lib/store'; + import { newPayment } from '$lib/store'; import { t } from '$lib/translations'; import { get, f, s, sat, sats, types } from '$lib/utils'; import { page } from '$app/stores'; @@ -11,7 +11,7 @@ export let data; - let { start, end, user, rates } = data; + let { start, end, user, rates, payments } = data; let change = ({ target: { value } }) => goto(value); let link = (p) => { @@ -34,7 +34,7 @@ let p, totals, pages = []; - $: data && ({ page: p, pages, start, end, totals, payments: $payments } = data); + $: data && ({ page: p, pages, start, end, totals, payments } = data); $: $page && ($newPayment = false); $: $newPayment && invalidate(`/users/${user.username}`); @@ -136,7 +136,7 @@
- {#each $payments as p} + {#each payments as p}
@@ -216,7 +216,7 @@
- {$t('payments.total')} + {$t('payments.total')} {$t('payments.presentValue')} {$t('payments.gainLoss')} @@ -226,7 +226,9 @@ {@const gain = (pv * 100) / total - 100} {f(total, c)} {f(pv, c)} - {Math.abs(gain).toFixed(2)}% + {Math.abs(gain).toFixed(2)}% {/each}
diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.svelte b/src/routes/(app)/[username]/receive/[...param]/+page.svelte index a97dc776..d7001079 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.svelte +++ b/src/routes/(app)/[username]/receive/[...param]/+page.svelte @@ -5,7 +5,6 @@ import { page } from '$app/stores'; import { requestRedirect } from '$lib/store'; import { browser } from '$app/environment'; - import { goto } from '$app/navigation'; export let data; let type = 'lightning'; diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte index 842c2eba..762e836e 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte @@ -138,7 +138,9 @@
{#each tabs.filter((t) => t.name !== 'shopify') as { name, key }} - diff --git a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte index 34399ad5..47c4c4c6 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte @@ -64,28 +64,32 @@ $: url = `${$page.url.host}/${user.username}`; $: full = `${$page.url.protocol}//${url}`; - $: addr = `${user.username}@${$page.url.host}`; + $: addr = `${user.username}@${$page.url.host}`;
- -
@{$page.url.host}
-
- - - + +
+ @{$page.url.host} +
+
-
{$page.url.host}/
+
+ {$page.url.host}/ +
diff --git a/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte b/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte index ef5b7869..057d8c20 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte @@ -33,7 +33,9 @@
- diff --git a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte index a08785f6..c01db734 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte @@ -52,12 +52,12 @@ return true; }; -let disablingPin = false; + let disablingPin = false; let togglePin = async () => { if (user.haspin) { try { - disablingPin = true; + disablingPin = true; await tick(); submit.click(); } catch (e) { @@ -122,7 +122,7 @@ let disablingPin = false; }; - + @@ -70,7 +70,7 @@ class="rounded-full border py-3 px-2 font-bold hover:opacity-80 flex gap-1 w-full justify-center" > - {$t('payments.takeFunds')} + {$t('payments.takeFunds')}
@@ -85,10 +85,10 @@
diff --git a/src/routes/(app)/pot/[name]/sweep/+page.svelte b/src/routes/(app)/pot/[name]/sweep/+page.svelte index 17d707cc..9b473af3 100644 --- a/src/routes/(app)/pot/[name]/sweep/+page.svelte +++ b/src/routes/(app)/pot/[name]/sweep/+page.svelte @@ -4,14 +4,13 @@ import { Icon } from '$comp'; import { t } from '$lib/translations'; - export let data; + export let data; - let { amount, name, user, rates } = data; - let { currency } = user; - $: rate = rates[currency]; + let { amount, name, user, rates } = data; + let { currency } = user; + $: rate = rates[currency]; -
-
- -
-

{$t('payments.fundsClaimed')}

-

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

-

- ⚡️{s(amount)} -

-
+
+ +
+

{$t('payments.fundsClaimed')}

+

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

+

+ ⚡️{s(amount)} +

+
diff --git a/src/routes/(app)/pot/[name]/withdraw/+page.svelte b/src/routes/(app)/pot/[name]/withdraw/+page.svelte index da564709..7be643a9 100644 --- a/src/routes/(app)/pot/[name]/withdraw/+page.svelte +++ b/src/routes/(app)/pot/[name]/withdraw/+page.svelte @@ -9,7 +9,7 @@ export let data; export let form; - let { rates } = data; + let { rates } = data; let { amount, name } = $page.params; let { currency } = data.user; let loading; @@ -35,7 +35,7 @@ {/if}
- + diff --git a/src/routes/(app)/qr/[text]/+page.svelte b/src/routes/(app)/qr/[text]/+page.svelte index d903da0e..9e56ab29 100644 --- a/src/routes/(app)/qr/[text]/+page.svelte +++ b/src/routes/(app)/qr/[text]/+page.svelte @@ -7,5 +7,5 @@
- {text} + {text}
diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index a71c697a..a558895c 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -29,7 +29,7 @@ let external = async () => { let invoice = { type: 'lightning', amount, currency }; - let {id }= await post(`/${recipient.username}/invoice`, { + let { id } = await post(`/${recipient.username}/invoice`, { invoice, user: { username: recipient.username } }); diff --git a/src/routes/(static)/bounties/+page.svelte b/src/routes/(static)/bounties/+page.svelte index b2f86964..729cf5dd 100644 --- a/src/routes/(static)/bounties/+page.svelte +++ b/src/routes/(static)/bounties/+page.svelte @@ -2,14 +2,14 @@

Bounties

- We're offering ⚡️1,000,000 to the first 10 people that help us onboard these businesses in Vancouver - to take bitcoin payments. + We're offering ⚡️1,000,000 to the first 10 people that help us onboard these businesses in + Vancouver to take bitcoin payments.

-

- Eligible businesses: -

+

Eligible businesses:

    -
  • Have a physical location in Vancouver, North Vancouver, West Vancouver, Burnaby, New +
  • + Have a physical location in Vancouver, North Vancouver, West Vancouver, Burnaby, New Westminster, or Richmond
  • -
  • Take walk-in customers
  • +
  • Take walk-in customers
  • Have regular hours and a website with contact info
  • Have a 3 star or better rating on Google
  • @@ -53,14 +52,12 @@
  • Use Coinos
-

Each business category can be claimed only once

-

One bounty per person

+

Each business category can be claimed only once

+

One bounty per person

The businesses can expect free ongoing support and promotion from us and our community.

-

- The prize money will be offered to the person who makes the referral. -

+

The prize money will be offered to the person who makes the referral.

⚡️250,000 will be awarded once the business has met with us and is ready to take payments diff --git a/src/routes/(static)/docs/+page.svelte b/src/routes/(static)/docs/+page.svelte index 86be02f0..63173173 100644 --- a/src/routes/(static)/docs/+page.svelte +++ b/src/routes/(static)/docs/+page.svelte @@ -14,7 +14,10 @@

Coinos has a simple REST API that can be used to register accounts and make payments and - queries. The following examples show how you can call the API with curl from your command line. + queries. The following examples show how you can call the API with curl from your command line.

API Base URL

@@ -30,10 +33,11 @@ {#if user && token} This token authorizes you to use the API as {user.username}. {:else} - Sign in to view your auth token here, or get one from the /login endpoint. + Sign in to view your auth token here, or get one from the + /login endpoint. {/if} - Save it in a variable called $token to run the examples. + Save it in a variable called $token to run the examples.

@@ -68,18 +72,17 @@
-

Get a lightning invoice to receive funds

+

Get a lightning invoice to receive funds

-

Get a bitcoin address to receive funds

+

Get a bitcoin address to receive funds

Sample response

You can check the received field to see how much has been paid

- -

Specify a webhook to be called when an invoice is paid

+

Specify a webhook to be called when an invoice is paid

GET /invoice/:hash

diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 6dc84349..7e9cb755 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,8 +1,8 @@ diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ab49f91d..ec9f55b7 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -20,11 +20,11 @@ $: update(data); let howItWorks; - let faq; + let faq; let about; let log = console.log; - let faqs = {}; + let faqs = {}; const howItWorksSteps = [ { image: 'hand', stepID: 'step1' }, @@ -33,7 +33,7 @@ ]; onMount(async () => { - faqs = (await import('../locales/en.json')).default.faq; + faqs = (await import('../locales/en.json')).default.faq; close(); @@ -90,7 +90,7 @@

{$t('faq.header')}

- {#each Object.keys(faqs).filter(f => f !== "header") as faqID} + {#each Object.keys(faqs).filter((f) => f !== 'header') as faqID} {/each}
diff --git a/src/routes/map/+page.svelte b/src/routes/map/+page.svelte index b5e4dfad..99c822d3 100644 --- a/src/routes/map/+page.svelte +++ b/src/routes/map/+page.svelte @@ -1,6 +1,6 @@ -- cgit v1.2.3