Add home page

This commit is contained in:
Alexis Sellier
2021-05-18 13:52:45 +02:00
parent a54b0eb975
commit e6f8edc3f6
10 changed files with 104 additions and 27 deletions
+17
View File
@@ -0,0 +1,17 @@
<script lang="typescript">
import { navigate } from 'svelte-routing';
let input: string = "";
const search = () => {
navigate(`/resolve?${
new URLSearchParams({ q: input })
}`);
};
</script>
<main>
<input size="40" type="text" bind:value={input} placeholder="Enter a name, address or domain..." />
<button class="primary" on:click={search} disabled={!input}>
Search
</button>
</main>
+5 -5
View File
@@ -7,23 +7,23 @@
import Error from '@app/Error.svelte';
import type { Config } from '@app/config';
import type { Session } from '@app/session';
import { getSearchParam } from '@app/utils';
export let session: Session | null;
export let config: Config;
export let query: Record<string, any>;
</script>
<Route path="register">
<Register {config} />
</Route>
<Route path="register/:name" let:params>
<Begin {config} subdomain={params.name} {query} />
<Route path="register/:name" let:params let:location>
<Begin {config} subdomain={params.name} owner={getSearchParam("owner", location)} />
</Route>
<Route path="register/:name/submit" let:params>
<Route path="register/:name/submit" let:params let:location>
{#if session}
<Submit {config} subdomain={params.name} {query} {session} />
<Submit {config} subdomain={params.name} owner={getSearchParam("owner", location)} {session} />
{:else}
<Error
message={"You must connect your wallet to register"}
+2 -2
View File
@@ -18,10 +18,10 @@
export let config: Config;
export let subdomain: string;
export let query: Record<string, any>;
export let owner: string | null;
let state = State.Initial;
$: registrationOwner = query.get("owner") || ($session && $session.address);
$: registrationOwner = owner || ($session && $session.address);
async function begin() {
state = State.CheckingAvailability;
+3 -9
View File
@@ -3,8 +3,7 @@
// TODO: When transfering name, warn about transfering to org.
import { onMount } from 'svelte';
import { navigate } from 'svelte-routing';
import { ethers } from 'ethers';
import { registerName, registrationFee } from '../registrar';
import { registerName } from '../registrar';
import { State, state } from '../state';
import type { Session } from '@app/session';
import type { Config } from '@app/config';
@@ -14,16 +13,11 @@
export let config: Config;
export let subdomain: string;
export let query: Record<string, any>;
export let owner: string | null;
export let session: Session;
let error: Error | null = null;
let registrationOwner = query.get("owner") || session.address;
async function getFee(cfg: Config) {
let fee = await registrationFee(cfg);
return ethers.utils.formatUnits(fee);
}
let registrationOwner = owner || session.address;
const done = () => navigate(`/registrations/${subdomain}`)
+27
View File
@@ -0,0 +1,27 @@
<script lang="typescript">
import { onMount } from 'svelte';
import { ethers } from 'ethers';
import { navigate } from 'svelte-routing';
import type { Config } from '@app/config';
import * as utils from '@app/utils';
export let config: Config;
export let query: string | null;
onMount(() => {
if (query) {
if (ethers.utils.isAddress(query)) {
// Go to org.
navigate(`/orgs/${query}`, { replace: true });
} else if (utils.isRadicleId(query)) {
// Go to Radicle entity.
alert("Radicle IDs are not yet supported");
} else {
let label = utils.parseEnsLabel(query, config);
navigate(`/registrations/${label}`, { replace: true });
}
} else {
navigate('/');
}
});
</script>
+12
View File
@@ -0,0 +1,12 @@
<script lang="typescript">
import { Route } from "svelte-routing";
import Resolve from '@app/base/resolve/Resolve.svelte';
import type { Config } from '@app/config';
import * as utils from '@app/utils';
export let config: Config;
</script>
<Route path="/resolve" let:location>
<Resolve {config} query={utils.getSearchParam("q", location)} />
</Route>