Fix: Slot reservation only after successful email validation
- Move email validation before slot reservation in backend - Remove duplicate frontend email validation - Slots are no longer blocked by failed booking attempts - Clean up unused email error UI components - Ensure slots remain available if email validation fails
This commit is contained in:
@@ -138,7 +138,8 @@ export function BookingForm() {
|
||||
if (fileInput) fileInput.value = '';
|
||||
};
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setErrorMessage(""); // Clear any previous error messages
|
||||
|
||||
@@ -160,6 +161,8 @@ export function BookingForm() {
|
||||
setErrorMessage("Bitte bestätige die Kenntnisnahme der Allgemeinen Geschäftsbedingungen.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Email validation now handled in backend before slot reservation
|
||||
const slot = availableSlots.find((s) => s.id === selectedSlotId);
|
||||
const appointmentTime = slot?.time || "";
|
||||
// console.log("Creating booking with data:", {
|
||||
@@ -206,19 +209,13 @@ export function BookingForm() {
|
||||
onError: (error: any) => {
|
||||
console.error("Booking error:", error);
|
||||
|
||||
// Extract error message from oRPC error structure
|
||||
// Simple error handling for oRPC errors
|
||||
let errorText = "Ein unbekannter Fehler ist aufgetreten.";
|
||||
|
||||
if (error?.message) {
|
||||
if (error?.cause?.message) {
|
||||
errorText = error.cause.message;
|
||||
} else if (error?.message && error.message !== "Internal server error") {
|
||||
errorText = error.message;
|
||||
} else if (error?.data?.message) {
|
||||
errorText = error.data.message;
|
||||
} else if (error?.data?.error) {
|
||||
errorText = error.data.error;
|
||||
} else if (typeof error === 'string') {
|
||||
errorText = error;
|
||||
} else if (error?.toString) {
|
||||
errorText = error.toString();
|
||||
}
|
||||
|
||||
setErrorMessage(errorText);
|
||||
|
Reference in New Issue
Block a user