feat: integrate login/registration into PurchaseWizard

This commit is contained in:
Codex Agent
2025-10-04 21:38:03 +02:00
parent 3c0bbb688b
commit fdaa2bec62
52 changed files with 1477 additions and 732 deletions

View File

@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useForm } from '@inertiajs/react';
import { useForm, usePage } from '@inertiajs/react';
import { useTranslation } from 'react-i18next';
import toast from 'react-hot-toast';
import { LoaderCircle, User, Mail, Phone, Lock, MapPin } from 'lucide-react';
import { Dialog, DialogContent, DialogTitle, DialogDescription } from '@/components/ui/dialog';
@@ -14,6 +15,7 @@ export default function RegisterForm({ packageId, onSuccess, privacyHtml }: Regi
const [privacyOpen, setPrivacyOpen] = useState(false);
const [hasTriedSubmit, setHasTriedSubmit] = useState(false);
const { t } = useTranslation(['auth', 'common']);
const { props } = usePage<{ errors: Record<string, string> }>();
const { data, setData, post, processing, errors, clearErrors, reset } = useForm({
username: '',
@@ -28,6 +30,12 @@ export default function RegisterForm({ packageId, onSuccess, privacyHtml }: Regi
package_id: packageId || null,
});
useEffect(() => {
if (hasTriedSubmit && Object.keys(errors).length > 0) {
toast.error(Object.values(errors).join(' '));
}
}, [errors, hasTriedSubmit]);
const submit = (e: React.FormEvent) => {
e.preventDefault();
setHasTriedSubmit(true);