fe9a95c60d
Replaces the centered single-column of full-width cards with a proper application layout: a persistent left sidebar (Trees, and per-tree People/Sources/Media, with the tree name and sign-out) and a constrained content column. Marketing landing and auth pages are split out (own header/footer; centered auth with the logo). Adds a Media gallery (upload + image thumbnails / file tiles, served via the backend content endpoint). Events are no longer free-text: a curated event-type list (+ custom) and a structured date (qualifier + day/month/year) that composes a proper genealogical date. Regenerated the OpenAPI client. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Justin Paul <justin@jpaul.me>
91 lines
3.0 KiB
TypeScript
91 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
|
|
import { api } from "@/lib/api/client";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
export default function RegisterPage() {
|
|
const router = useRouter();
|
|
const [email, setEmail] = useState("");
|
|
const [displayName, setDisplayName] = useState("");
|
|
const [password, setPassword] = useState("");
|
|
const [error, setError] = useState<string | null>(null);
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
async function onSubmit(e: React.FormEvent) {
|
|
e.preventDefault();
|
|
setLoading(true);
|
|
setError(null);
|
|
const { error } = await api.POST("/api/v1/auth/register", {
|
|
body: { email, password, display_name: displayName || null },
|
|
});
|
|
setLoading(false);
|
|
if (error) {
|
|
setError("Could not register. The email may already be in use, or the password is too short (min 8).");
|
|
return;
|
|
}
|
|
router.push("/trees");
|
|
}
|
|
|
|
return (
|
|
<div className="grid min-h-screen place-items-center px-4 py-10">
|
|
<div className="w-full max-w-md space-y-6">
|
|
<Link href="/" className="flex justify-center" aria-label="Provenance — home">
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
<img src="/provenance-logo-plain.svg" alt="Provenance" className="h-8 w-auto" />
|
|
</Link>
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle>Create your account</CardTitle>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<form onSubmit={onSubmit} className="space-y-4">
|
|
<div className="space-y-1">
|
|
<Label htmlFor="name">Name</Label>
|
|
<Input id="name" value={displayName} onChange={(e) => setDisplayName(e.target.value)} />
|
|
</div>
|
|
<div className="space-y-1">
|
|
<Label htmlFor="email">Email</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
required
|
|
/>
|
|
</div>
|
|
<div className="space-y-1">
|
|
<Label htmlFor="password">Password</Label>
|
|
<Input
|
|
id="password"
|
|
type="password"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
minLength={8}
|
|
required
|
|
/>
|
|
</div>
|
|
{error && <p className="text-sm text-red-600">{error}</p>}
|
|
<Button type="submit" disabled={loading} className="w-full">
|
|
{loading ? "Creating…" : "Create account"}
|
|
</Button>
|
|
</form>
|
|
<p className="mt-4 text-sm text-[var(--muted)]">
|
|
Already have an account?{" "}
|
|
<Link href="/login" className="text-bronze underline">
|
|
Sign in
|
|
</Link>
|
|
</p>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|