import { useState } from 'react' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' import { z } from 'zod' import { useAuth } from '@/hooks/useAuth' import { useTheme } from '@/hooks/useTheme' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Alert, AlertDescription } from '@/components/ui/alert' import { Loader2, UserPlus, AlertCircle } from 'lucide-react' const setupSchema = z.object({ name: z.string().min(2, 'Name must be at least 2 characters'), email: z.string().email('Invalid email address'), password: z.string().min(8, 'Password must be at least 8 characters'), }) type SetupFormData = z.infer export function Setup() { const { signUpWithEmail } = useAuth() const theme = useTheme() const [error, setError] = useState(null) const [isSubmitting, setIsSubmitting] = useState(false) const { register, handleSubmit, formState: { errors }, } = useForm({ resolver: zodResolver(setupSchema), }) const onSubmit = async (data: SetupFormData) => { setError(null) setIsSubmitting(true) try { const result = await signUpWithEmail(data.email, data.password, data.name) if (result.error) { setError(result.error) } } finally { setIsSubmitting(false) } } return (
OpenCode

Create Admin Account

{error && ( {error} )}
{errors.name && (

{errors.name.message}

)}
{errors.email && (

{errors.email.message}

)}
{errors.password && (

{errors.password.message}

)}
) }