"use client"; import { useState } from "react"; import { Button } from "@kandev/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@kandev/ui/card"; import { Input } from "@kandev/ui/input"; import { IconShieldLock } from "@tabler/icons-react"; import { ApiError } from "@/lib/api/client"; import { setup } from "@/lib/api/domains/auth-api"; type SetupFormProps = { email: string; setEmail: (v: string) => void; password: string; setPassword: (v: string) => void; displayName: string; setDisplayName: (v: string) => void; error: string | null; submitting: boolean; onSubmit: (e: React.FormEvent) => void; }; function SetupForm({ email, setEmail, password, setPassword, displayName, setDisplayName, error, submitting, onSubmit, }: SetupFormProps) { return (
setDisplayName(e.target.value)} />
setEmail(e.target.value)} />
setPassword(e.target.value)} />

At least 8 characters.

{error && (

{error}

)}
); } export function SetupWizard() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [displayName, setDisplayName] = useState(""); const [error, setError] = useState(null); const [submitting, setSubmitting] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setSubmitting(true); try { await setup({ email, password, display_name: displayName }); // Full reload re-fetches the boot payload with the new session cookie. window.location.assign("/"); } catch (err) { setSubmitting(false); if (err instanceof ApiError) { setError( err.status === 409 ? "Setup is no longer available — an account already exists." : (err.message ?? "Setup failed. Please try again."), ); return; } setError("Something went wrong. Please try again."); } } return (
Set up Kandev Authentication is enabled for this deployment. Create the first account below — it becomes the admin and can invite additional users. void onSubmit(e)} />
); }