'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import Link from 'next/link' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useToast } from '@/components/ui/use-toast' import { ArrowLeft, Building2, User, Mail, Lock, Loader2, Check } from 'lucide-react' import { LogoRound } from '@/components/ui/logo' export default function RegisterPage() { const [organizationName, setOrganizationName] = useState('') const [name, setName] = useState('') const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') const [privacyAccepted, setPrivacyAccepted] = useState(false) const [isLoading, setIsLoading] = useState(false) const [isSuccess, setIsSuccess] = useState(false) const router = useRouter() const { toast } = useToast() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (password !== confirmPassword) { toast({ title: 'Passwörter stimmen nicht überein', variant: 'destructive' }) return } if (password.length < 8) { toast({ title: 'Passwort muss mindestens 8 Zeichen haben', variant: 'destructive' }) return } setIsLoading(true) try { const res = await fetch('/api/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ organizationName, name, email, password, privacyAccepted }), }) const data = await res.json() if (res.ok) { setIsSuccess(true) } else { toast({ title: 'Registrierung fehlgeschlagen', description: data.error || 'Bitte versuchen Sie es erneut.', variant: 'destructive', }) } } catch { toast({ title: 'Fehler', description: 'Verbindung zum Server fehlgeschlagen.', variant: 'destructive' }) } finally { setIsLoading(false) } } if (isSuccess) { return (

Fast geschafft!

Ihr Konto und Ihre Organisation wurden erfolgreich erstellt.

E-Mail bestätigen

Wir haben Ihnen eine E-Mail mit einem Bestätigungslink gesendet. Bitte klicken Sie auf den Link, um Ihr Konto zu aktivieren.

) } return (
{/* Header */}

Konto erstellen

Erstellen Sie Ihr Konto für die Feuerwehr Krokier-App

{/* Organization */}
setOrganizationName(e.target.value)} required disabled={isLoading} />
{/* Name */}
setName(e.target.value)} required disabled={isLoading} />
{/* Email */}
setEmail(e.target.value)} required disabled={isLoading} />
{/* Password */}
setPassword(e.target.value)} required disabled={isLoading} />
{/* Confirm Password */}
setConfirmPassword(e.target.value)} required disabled={isLoading} />
{/* Privacy Policy Checkbox */}
Bereits registriert?{' '} Anmelden
{/* Back to landing */}
Zurück zur Startseite
) }