diff options
| author | Adam Soltys <[email protected]> | 2023-02-08 16:46:10 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-02-08 16:46:10 -0800 |
| commit | d309ab34c550912b5d1b31762eed23bb69f83f82 (patch) | |
| tree | 9519f379d8f05f095a2098d40c20f1e274ee3445 /src | |
| parent | fc2f98b42fbe8bc76140d44c172b4c93c53d9e70 (diff) | |
| download | coinos-ui-d309ab34c550912b5d1b31762eed23bb69f83f82.tar.gz coinos-ui-d309ab34c550912b5d1b31762eed23bb69f83f82.zip | |
invoice requests and btc deposits
Diffstat (limited to 'src')
5 files changed, 73 insertions, 46 deletions
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index af191a2b..baab8ba1 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -1,9 +1,11 @@ <script> import { Avatar, Balance, Feed } from '$comp'; import { t } from '$lib/translations'; + import { f, sat, sats } from '$lib/utils'; export let data; let { events, invoices, sent, received, subject, user } = data; + console.log(invoices); </script> <div class="flex justify-center lg:justify-start"> @@ -13,28 +15,41 @@ </div> <div> - <!-- {#each invoice} --> - <!-- <a href={`/${user.username}/receive/${id}`}> --> - <!-- <div class="border-b p-2 last:border-b-0 hover:bg-gray-100"> --> - <!-- <div class="flex"> --> - <!-- <div> --> - <!-- <div class="flex"> --> - <!-- <Avatar user={r} size={20} /> --> - <!-- <div class="my-auto text-left"> --> - <!-- <p class="ml-1 text-lg break-words">{r.username}</p> --> - <!-- <p class="ml-1 text-secondary">{memo}</p> --> - <!-- </div> --> - <!-- </div> --> - <!-- </div> --> - <!-- <div class="whitespace-nowrap my-auto ml-auto flex gap-2"> --> - <!-- <button class="rounded-full border py-2 px-4 font-bold hover:opacity-80 w-full" --> - <!-- >Invoice</button --> - <!-- > --> - <!-- </div> --> - <!-- </div> --> - <!-- </div> --> - <!-- </a> --> - <!-- {/each} --> + {#each invoices as { amount, currency, rate, request: { requester, recipient }, hash }} + {@const requested = user.username === requester?.username} + <a href={`/${recipient.username}/invoice/${hash}` + (requested ? '/tip' : '')}> + <div class="border-b p-2 last:border-b-0 hover:bg-gray-100"> + <div class="flex gap-2"> + <div> + {#if requested} + <div class="flex"> + <Avatar user={recipient} size={20} /> + <div class="my-auto text-left"> + <p class="text-secondary">{$t('payments.invoiceFrom')}</p> + <p class="ml-1 text-lg break-words">{recipient.username}</p> + </div> + </div> + {:else} + <div class="flex"> + <Avatar user={requester} size={20} /> + <div class="my-auto text-left"> + <p class="text-secondary">{$t('payments.awaiting')}</p> + <p class="ml-1 text-lg break-words">{requester.username}</p> + </div> + </div> + {/if} + </div> + <div class="whitespace-nowrap my-auto ml-auto flex gap-2"> + <div class="font-bold"> + {f(amount * (rate / sats), currency)} + </div> + + <div class="text-secondary">{sat(amount)}</div> + </div> + </div> + </div> + </a> + {/each} {#each received as { id, invoice, memo, requester: r }} <a href={`/${user.username}/receive/${id}`}> diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js index 0f6168e3..b5323d3f 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js +++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js @@ -2,11 +2,16 @@ import Qr from 'qrcode-base64'; import { get } from '$lib/utils'; import { redirect } from '@sveltejs/kit'; -export async function load({ depends, params, url }) { +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')) + throw redirect(307, `/send/invoice/${hash}`); + let { amount, received } = invoice; amount = parseInt(amount); diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte index 6d7e1dda..ad9721e7 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte @@ -13,8 +13,8 @@ $: refresh(data); let { invoice, id, user, sm, lg } = data; let { - address, amount, + hash, type, rate, received, @@ -34,8 +34,8 @@ let refresh = (data) => { ({ invoice, id } = data); ({ - address, amount, + hash, type, rate, received, @@ -61,8 +61,8 @@ }); }); - $: link = address ? text : `lightning:${text}`; - $: txt = address || text; + $: link = type === 'bitcoin' ? text : `lightning:${text}`; + $: txt = type === 'bitcoin' ? hash : text; let full; let toggle = () => { @@ -115,8 +115,8 @@ {/if} <div class="w-full flex justify-center"> - <button class="flex rounded-full border py-2 px-5 hover:opacity-80" on:click={() => copy(txt)} - ><Icon icon="copy" style="mr-1" /> + <button class="flex rounded-full border py-2 px-5 hover:opacity-80" on:click={() => copy(txt)}> + <Icon icon="copy" style="mr-1" /> <div class="text-secondary">{txt.substr(0, 10)}..{txt.substr(-6)}</div></button > </div> diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.svelte b/src/routes/(app)/[username]/receive/[...param]/+page.svelte index 29a0f7a5..99d95be0 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.svelte +++ b/src/routes/(app)/[username]/receive/[...param]/+page.svelte @@ -1,5 +1,5 @@ <script> - import { Icon, Numpad } from '$comp'; + import { Icon, Numpad, Toggle } from '$comp'; import { t } from '$lib/translations'; import { enhance } from '$app/forms'; import { page } from '$app/stores'; @@ -16,9 +16,12 @@ let amount; + let lightning = true; let { currency, username, prompt } = data.subject; let { user } = data; let submit; + + $: type = lightning ? 'lightning' : 'bitcoin'; </script> <form method="POST" class="flex justify-center items-center mt-24 mb-3 px-3" use:enhance> @@ -43,5 +46,10 @@ > {amount ? $t('payments.next') : $t('payments.sendersChoice')} </button> + + <div class="w-full flex justify-center"> + <span class="font-bold mr-2">{type[0].toUpperCase() + type.substring(1, type.length)}</span> + <Toggle id="prompt" checked={lightning} bind:value={lightning} /> + </div> </div> </form> diff --git a/src/routes/(static)/bounties/+page.svelte b/src/routes/(static)/bounties/+page.svelte index 22d4283e..140b9c16 100644 --- a/src/routes/(static)/bounties/+page.svelte +++ b/src/routes/(static)/bounties/+page.svelte @@ -2,9 +2,8 @@ <h1 class="text-3xl mb-6 pt-20">Bounties</h1> <p class="text-secondary"> - We'd like to see more on-the-ground merchant adoption in our hometown of Vancouver so we're - offering <b>⚡️1,000,000</b> to the first 10 people that help us onboard businesses in the following - categories: + We're offering <b>⚡️1,000,000</b> to the first <b>10 people</b> that help us onboard businesses + in the following categories to take bitcoin payments: </p> <ul class="text-xl ml-20"> @@ -20,27 +19,27 @@ <li>Bubble Tea or Ice Cream Parlour</li> </ul> - <p> - The business owners can expect free ongoing support and promotion from us and our community. - We'll consult with them and make sure they're all trained up and ready to go then we'll help get - the word out. - </p> - <h2 class="text-2xl">Terms and Conditions</h2> - <ul class="text-xl ml-20"> + <ul class="ml-20"> <li>The business must have a physical location that takes walk-in customers</li> - <li>They must be located in Metro Vancouver</li> + <li> + They must be located within Vancouver, North Vancouver, West Vancouver, Burnaby, New + Westminster, or Richmond + </li> <li>They must have regular hours and a website with contact info</li> <li>They must have a 3+ star rating on Google Maps</li> <li> It must be possible to pay for any of their usual goods/services with bitcoin at any time - during their posted hours without needing to make any special arrangements, regardless of who - is on staff that day. + during their posted hours without needing to make any special arrangements </li> <li>They must use Coinos and accept lightning payments</li> + <li>Each business category can be claimed only once</li> + <li>One bounty per person</li> </ul> + <p>The businesses can expect free ongoing support and promotion from us and our community.</p> + <p> The prize money will be offered to the person who makes the referral/introduction. Whether you choose to split some with the business owner is up to you. @@ -58,11 +57,11 @@ </p> <p> - Bounties will be awarded solely at our discretion, we reserve the right to refuse any applicants - without cause + Bounties will be awarded solely at our discretion and we reserve the right to refuse any + applicants without cause </p> - <h2 class="text-2xl">Let's go!</h2> + <h2 class="text-2xl">Ready to begin!?</h2> <p> To make a referral, reach out on one of our socials or email us at <a |
