aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-08 10:13:03 -0800
committerAdam Soltys <[email protected]>2023-02-08 10:13:03 -0800
commit3b7e5e3492684b3d08f37cb078d6eec3fa4da0b2 (patch)
treee22c32c9948e4bacfc14bdc8f95a16c557a916e5
parent38a1046a92a8f6e3168c5054dc7de2cb3fd8e726 (diff)
downloadcoinos-ui-3b7e5e3492684b3d08f37cb078d6eec3fa4da0b2.tar.gz
coinos-ui-3b7e5e3492684b3d08f37cb078d6eec3fa4da0b2.zip
rm uuid route
-rw-r--r--src/components/LandingHeader.svelte5
-rw-r--r--src/lib/invoice.js6
-rw-r--r--src/lib/utils.js6
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.server.js4
-rw-r--r--src/routes/(app)/[username]/(profile)/+page.svelte27
-rw-r--r--src/routes/(app)/send/[...text]/+page.server.js1
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.server.js (renamed from src/routes/(app)/send/[uuid=uuid]/+page.server.js)6
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.svelte (renamed from src/routes/(app)/send/[uuid=uuid]/+page.svelte)0
-rw-r--r--src/routes/(static)/+layout.svelte8
-rw-r--r--src/routes/(static)/bounties/+page.svelte1
10 files changed, 52 insertions, 12 deletions
diff --git a/src/components/LandingHeader.svelte b/src/components/LandingHeader.svelte
index 04ec1dca..f7317a58 100644
--- a/src/components/LandingHeader.svelte
+++ b/src/components/LandingHeader.svelte
@@ -3,6 +3,7 @@
import { scroll } from '$lib/utils';
import { Icon } from '$comp';
import { t } from '$lib/translations';
+ import { page } from '$app/stores';
export let howItWorks;
export let faq;
@@ -23,7 +24,7 @@
>
<nav class="block xl:flex flex-wrap justify-between items-center">
<div class="flex justify-start md:justify-center items-center md:space-x-10">
- <a href="/" on:click={(() => console.log('HMM'), scroll(header))}>
+ <a href="/" on:click={() => scroll(header)}>
<Icon icon="logo" style="hidden md:block mb-5 xl:mb-0" />
<Icon icon="logo" style="block md:hidden ml-5 w-48" />
</a>
@@ -31,11 +32,13 @@
<!-- desktop nav -->
<div class="hidden space-x-10 md:flex flex-wrap justify-center items-center font-bold">
+ {#if $page.url.pathname === "/"}
<button class="hover:opacity-80" on:click={() => scroll(howItWorks)}
>{$t('howItWorks.header')}</button
>
<button class="hover:opacity-80" on:click={() => scroll(faq)}>{$t('faq.header')}</button>
<button class="hover:opacity-80" on:click={() => scroll(about)}>{$t('about.header')}</button>
+ {/if}
{#if !user}
<button
class="border rounded-full px-6 py-2 font-bold hover:opacity-80"
diff --git a/src/lib/invoice.js b/src/lib/invoice.js
index 5b939079..bb75d4cb 100644
--- a/src/lib/invoice.js
+++ b/src/lib/invoice.js
@@ -7,6 +7,7 @@ export default async ({ cookies, request, url }) => {
let rates = await get('/rates');
let amount = parseInt(form.get('amount'));
let request_id = form.get('request_id');
+ if (request_id === 'undefined') request_id = undefined;
let invoice = {
amount,
@@ -19,11 +20,12 @@ export default async ({ cookies, request, url }) => {
let user = { username: form.get('username'), currency: form.get('currency') };
- let { hash } = await post('/invoice', { invoice, user }, auth(cookies));
+ invoice = await post('/invoice', { invoice, user }, auth(cookies));
+ let { hash } = invoice;
if (request_id) {
if (url.pathname.endsWith('tip')) {
- throw redirect(307, `/send/${hash}`);
+ throw redirect(307, `/send/invoice/${hash}`);
}
throw redirect(307, `/${user.username}/request/${request_id}`);
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 24991100..ef1e997b 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -4,9 +4,13 @@ import { browser } from '$app/environment';
import { toast } from '@zerodevx/svelte-toast';
import { goto } from '$app/navigation';
import { PUBLIC_COINOS_URL } from '$env/static/public';
+import { page } from '$app/stores';
+import { get as getStore } from 'svelte/store';
export function scroll(section) {
- section.scrollIntoView({ behavior: 'smooth' });
+ if (getStore(page).url.pathname !== '/') goto('/');
+ console.log("section", section);
+ setTimeout(() => section.scrollIntoView({ behavior: 'smooth' }), 500);
}
const base = browser ? '' : PUBLIC_COINOS_URL;
diff --git a/src/routes/(app)/[username]/(profile)/+page.server.js b/src/routes/(app)/[username]/(profile)/+page.server.js
index 553e2559..c68cfecc 100644
--- a/src/routes/(app)/[username]/(profile)/+page.server.js
+++ b/src/routes/(app)/[username]/(profile)/+page.server.js
@@ -16,7 +16,7 @@ export async function load({ cookies, params, parent, url }) {
e.seen = e.created_at;
});
- let { requests } = await get('/requests', auth(cookies));
+ let { invoices, sent, received } = await get('/requests', auth(cookies));
- return { events, requests };
+ return { invoices, events, sent, received };
}
diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte
index ae8add63..557ac9b4 100644
--- a/src/routes/(app)/[username]/(profile)/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/+page.svelte
@@ -3,7 +3,7 @@
import { t } from '$lib/translations';
export let data;
- let { events, requests, subject, user } = data;
+ let { events, invoices, sent, received, subject, user } = data;
</script>
<div class="flex justify-center lg:justify-start">
@@ -13,7 +13,30 @@
</div>
<div>
- {#each requests as { id, invoice, memo, requester: r }}
+ {#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 received as { id, invoice, memo, requester: r }}
<a href={`/${user.username}/receive/${id}`}>
<div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
<div class="flex">
diff --git a/src/routes/(app)/send/[...text]/+page.server.js b/src/routes/(app)/send/[...text]/+page.server.js
index c64361ff..096c60e9 100644
--- a/src/routes/(app)/send/[...text]/+page.server.js
+++ b/src/routes/(app)/send/[...text]/+page.server.js
@@ -58,6 +58,7 @@ let parse = async (t, host) => {
// user
try {
user = await get(`/users/${t}`);
+ if (user.anon) user = null;
} catch (e) {}
if (user) throw redirect(307, `/send/user/${t}`);
diff --git a/src/routes/(app)/send/[uuid=uuid]/+page.server.js b/src/routes/(app)/send/invoice/[id]/+page.server.js
index a59853d3..6b7823ce 100644
--- a/src/routes/(app)/send/[uuid=uuid]/+page.server.js
+++ b/src/routes/(app)/send/invoice/[id]/+page.server.js
@@ -1,17 +1,17 @@
import { error, fail, redirect } from '@sveltejs/kit';
import { btc as asset, auth, get, post } from '$lib/utils';
-export async function load({ params, parent }) {
+export async function load({ params: { id }, parent }) {
let { user } = await parent();
- let { amount, address, tip, text, user: recipient } = await get(`/invoice/${params.uuid}`);
+ let { amount, address, tip, text, user: recipient } = await get(`/invoice/${id}`);
if (recipient.username === user.username) throw error(500, { message: 'Cannot send to self' });
if (tip) amount += tip;
return { amount, address, payreq: text, recipient };
}
export const actions = {
- default: async ({ cookies, params, request }) => {
+ default: async ({ cookies, request }) => {
try {
let body = Object.fromEntries(await request.formData());
let { confirmed } = body;
diff --git a/src/routes/(app)/send/[uuid=uuid]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte
index 27837bca..27837bca 100644
--- a/src/routes/(app)/send/[uuid=uuid]/+page.svelte
+++ b/src/routes/(app)/send/invoice/[id]/+page.svelte
diff --git a/src/routes/(static)/+layout.svelte b/src/routes/(static)/+layout.svelte
index a7a1ab22..dde9fd11 100644
--- a/src/routes/(static)/+layout.svelte
+++ b/src/routes/(static)/+layout.svelte
@@ -1,3 +1,9 @@
-<main class="container flex px-10 md:px-40 mx-auto">
+<script>
+ import { Footer, LandingHeader } from "$comp";
+</script>
+
+<LandingHeader />
+<main class="container flex px-10 md:px-40 mx-auto min-h-[600px]">
<slot />
</main>
+<Footer />
diff --git a/src/routes/(static)/bounties/+page.svelte b/src/routes/(static)/bounties/+page.svelte
new file mode 100644
index 00000000..45b983be
--- /dev/null
+++ b/src/routes/(static)/bounties/+page.svelte
@@ -0,0 +1 @@
+hi