import React, { useState } from 'react'; import { useForm, router } from '@inertiajs/react'; import { Head } from '@inertiajs/react'; import { LoaderCircle, User, Mail, Phone, Lock, Home, MapPin } from 'lucide-react'; import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog'; interface RegisterProps { package?: { id: number; name: string; description: string; price: number; } | null; privacyHtml: string; } import MarketingLayout from '@/layouts/marketing/MarketingLayout'; export default function Register({ package: initialPackage, privacyHtml }: RegisterProps) { const [privacyOpen, setPrivacyOpen] = useState(false); const { data, setData, post, processing, errors, setError } = useForm({ username: '', email: '', password: '', password_confirmation: '', first_name: '', last_name: '', address: '', phone: '', privacy_consent: false, package_id: initialPackage?.id || null, }); React.useEffect(() => { if (Object.keys(errors).length > 0) { console.log('Validation errors received:', errors); } if (!processing) { console.log('Registration processing completed'); } }, [errors, processing, data]); React.useEffect(() => { if (Object.keys(errors).length > 0) { window.scrollTo({ top: 0, behavior: 'smooth' }); } }, [errors]); React.useEffect(() => { if (Object.keys(errors).length > 0) { // Force re-render or scroll to errors window.scrollTo({ top: 0, behavior: 'smooth' }); } }, [errors]); const submit = (e: React.FormEvent) => { e.preventDefault(); console.log('Submitting registration form with data:', data); router.post('/register', data, { preserveState: true, forceFormData: true, onSuccess: () => { console.log('Registration successful'); }, onError: (errors) => { console.log('Registration errors:', errors); setError(errors); }, }); console.log('POST to /register initiated'); }; return (

Willkommen bei Fotospiel – Erstellen Sie Ihren Account

Registrierung ermöglicht Zugriff auf Events, Galerien und personalisierte Features.

{initialPackage && (

{initialPackage.name}

{initialPackage.description}

{initialPackage.price === 0 ? 'Kostenlos' : `${initialPackage.price} €`}

)}
setData('first_name', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.first_name ? 'border-red-500' : 'border-gray-300'}`} placeholder="Vorname" />
{errors.first_name &&

{errors.first_name}

}
setData('last_name', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.last_name ? 'border-red-500' : 'border-gray-300'}`} placeholder="Nachname" />
{errors.last_name &&

{errors.last_name}

}
setData('email', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.email ? 'border-red-500' : 'border-gray-300'}`} placeholder="email@example.com" />
{errors.email &&

{errors.email}

}
setData('address', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.address ? 'border-red-500' : 'border-gray-300'}`} placeholder="Adresse" />
{errors.address &&

{errors.address}

}
setData('phone', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.phone ? 'border-red-500' : 'border-gray-300'}`} placeholder="Telefonnummer" />
{errors.phone &&

{errors.phone}

}
setData('username', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.username ? 'border-red-500' : 'border-gray-300'}`} placeholder="Benutzername" />
{errors.username &&

{errors.username}

}
setData('password', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.password ? 'border-red-500' : 'border-gray-300'}`} placeholder="Passwort" />
{errors.password &&

{errors.password}

}
setData('password_confirmation', e.target.value)} className={`block w-full pl-10 pr-3 py-3 border rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#FFB6C1] focus:border-[#FFB6C1] sm:text-sm ${errors.password_confirmation ? 'border-red-500' : 'border-gray-300'}`} placeholder="Passwort bestätigen" />
{errors.password_confirmation &&

{errors.password_confirmation}

}
setData('privacy_consent', e.target.checked)} className="h-4 w-4 text-[#FFB6C1] focus:ring-[#FFB6C1] border-gray-300 rounded" /> {errors.privacy_consent &&

{errors.privacy_consent}

}
{Object.keys(errors).length > 0 && (

{Object.entries(errors).map(([key, value]) => ( {value} ))}

)}

Bereits registriert?{' '} Anmelden

); }