From 7daf3ec4dae68a3a5ae3b7fe0cc8f030aaf3bf4d Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 6 Dec 2024 20:45:07 -0400 Subject: [PATCH] refactor --- .../AddExperience/AddExperience.tsx | 22 +++++++++---- .../PaymentDetails/PaymentDetails.tsx | 33 +++++++++---------- src/components/UserProfile/UserProfile.tsx | 5 +-- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/components/AddExperience/AddExperience.tsx b/src/components/AddExperience/AddExperience.tsx index a931321..9440661 100644 --- a/src/components/AddExperience/AddExperience.tsx +++ b/src/components/AddExperience/AddExperience.tsx @@ -40,7 +40,7 @@ const AddExperience = () => { // Validar texto sin caracteres especiales const isValidText = (text: string): boolean => { - const regex = /^[a-zA-Z0-9áéíóúÁÉÍÓÚñÑ\s]+$/; // Permite letras, números y espacios + const regex = /^[a-zA-Z0-9áéíóúÁÉÍÓÚñÑ.,\s]+$/; // Permite letras, números y espacios return regex.test(text); }; @@ -66,6 +66,12 @@ const AddExperience = () => { ); return false; } + + if(Object.keys(availability).length === 0){ + setErrorMessage("Debe seleccionar al menos una fecha y una hora."); + return false; + } + if (!price || price <= 0) { setErrorMessage("El campo 'Precio' debe ser mayor a 0."); return false; @@ -205,6 +211,7 @@ const AddExperience = () => { coords[1]?.toFixed(4), ]; + const payload = { title, description, @@ -216,6 +223,9 @@ const AddExperience = () => { capacity, }; + + console.log(payload) + try { const response = await experienceServices.addExperience(payload); console.log("Respuesta del backend:", response.data); @@ -267,12 +277,12 @@ const AddExperience = () => { return (
{showModal && ( -
-
-

{errorMessage}

+
+
+

{errorMessage}

@@ -499,7 +509,7 @@ const AddExperience = () => { {/* Etiquetas (Lista desplegable) */}
-
diff --git a/src/components/PaymentDetails/PaymentDetails.tsx b/src/components/PaymentDetails/PaymentDetails.tsx index 3b7a225..270b81a 100644 --- a/src/components/PaymentDetails/PaymentDetails.tsx +++ b/src/components/PaymentDetails/PaymentDetails.tsx @@ -4,7 +4,6 @@ import mastercardLogo from "../../assets/img/iconomastercard.png"; import visaLogo from "../../assets/img/iconovisa.png"; import bookingServices from "../../services/booking.services"; import { ReservationContext } from "../../contexts/reservation.context"; -import { format, parseISO } from "date-fns"; const PaymentDetails: React.FC = () => { const location = useLocation(); @@ -146,18 +145,18 @@ const PaymentDetails: React.FC = () => { expiryDate.length === 8; return ( -
+
-

Confirmar y pagar

+

Confirmar y pagar

@@ -179,7 +178,7 @@ const PaymentDetails: React.FC = () => { style={{ height: "180px" }} >

MARIA VELLER LOPEZ

-

+

{selectedMethod === "mastercard" ? "MasterCard" : selectedMethod === "visa" @@ -197,7 +196,7 @@ const PaymentDetails: React.FC = () => { : visaLogo } alt={selectedMethod} - className="w-17 h-10" + className="h-10 w-17" />

@@ -207,7 +206,7 @@ const PaymentDetails: React.FC = () => {
@@ -218,15 +217,15 @@ const PaymentDetails: React.FC = () => { onChange={handleCardNumberChange} placeholder="1234 5678 1234 5678" maxLength={19} - className="w-full px-4 py-3 text-sm ring-1 ring-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-slate-300" + className="w-full px-4 py-3 text-sm rounded-lg ring-1 ring-slate-200 focus:outline-none focus:ring-2 focus:ring-slate-300" /> - {cardError &&

{cardError}

} + {cardError &&

{cardError}

}
@@ -237,15 +236,15 @@ const PaymentDetails: React.FC = () => { onChange={handleCvvChange} placeholder="123" maxLength={3} - className="w-full px-4 py-3 text-sm ring-1 ring-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-slate-300" + className="w-full px-4 py-3 text-sm rounded-lg ring-1 ring-slate-200 focus:outline-none focus:ring-2 focus:ring-slate-300" /> - {cvvError &&

{cvvError}

} + {cvvError &&

{cvvError}

}
@@ -256,15 +255,15 @@ const PaymentDetails: React.FC = () => { onChange={handleExpiryDateChange} placeholder="MM/DD/AA" maxLength={8} - className="w-full px-4 py-3 text-sm ring-1 ring-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-slate-300" + className="w-full px-4 py-3 text-sm rounded-lg ring-1 ring-slate-200 focus:outline-none focus:ring-2 focus:ring-slate-300" /> - {expiryError &&

{expiryError}

} + {expiryError &&

{expiryError}

}
-
+

{reservation?.totalPrice}€ {/* Itentar resolver la existencia de reservation de otra manera */} diff --git a/src/components/UserProfile/UserProfile.tsx b/src/components/UserProfile/UserProfile.tsx index 18bb9b4..770ff2f 100644 --- a/src/components/UserProfile/UserProfile.tsx +++ b/src/components/UserProfile/UserProfile.tsx @@ -35,14 +35,15 @@ const UserProfile: React.FC = () => { } }, []) - const { email, location, name, phone, role } = userInfo + const { email, avatar , location, name, phone, role } = userInfo + return (

{role.toUpperCase() === 'PROVIDER' && (