From 0d31e783a783b32537ce9323abe5afec85b1c8e5 Mon Sep 17 00:00:00 2001 From: ElrohirGT Date: Fri, 15 Nov 2024 15:19:33 -0600 Subject: [PATCH] fix: CreatePatientView update --- .../src/views/CreatePatientView/index.jsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sanitas_frontend/src/views/CreatePatientView/index.jsx b/sanitas_frontend/src/views/CreatePatientView/index.jsx index a36c53be..39d8a5d8 100644 --- a/sanitas_frontend/src/views/CreatePatientView/index.jsx +++ b/sanitas_frontend/src/views/CreatePatientView/index.jsx @@ -14,9 +14,9 @@ import { getErrorMessage } from "src/utils/errorhandlerstoasts"; * @typedef {Object} PatientData * @property {string} cui - Unique identifier for the patient. * @property {string} names - First and middle names of the patient. - * @property {string} surnames - Last names of the patient. + * @property {string} lastNames - Last names of the patient. * @property {boolean} isWoman - Gender of the patient. - * @property {string} birthDate - Birthdate of the patient. + * @property {string} birthdate - Birthdate of the patient. * @property {boolean} isNew - Indicates if the patient data is new or existing. */ @@ -45,11 +45,11 @@ export function CreatePatientView({ const navigate = useNavigate(); const [patientData, setPatientData] = useState({ - cui: location.state?.cui ?? "", + cui: location.state?.cui ?? "2987944380101", names: "", - surnames: "", + lastNames: "", isWoman: true, - birthDate: "", + birthdate: "", phone: "", insurance: "", }); @@ -61,7 +61,7 @@ export function CreatePatientView({ * @param {string} value - The new value for the field. */ const handleChange = (field, value) => { - if (field === "names" || field === "surnames") { + if (field === "names" || field === "lastNames") { const filteredValue = value.replace(/[^a-zA-ZáéíóúÁÉÍÓÚñÑ\s]/g, ""); setPatientData({ ...patientData, [field]: filteredValue }); } else { @@ -80,9 +80,9 @@ export function CreatePatientView({ currentDate.getMonth(), currentDate.getDate(), ); - const birthDate = new Date(date); + const birthdate = new Date(date); - if (birthDate > currentDate || birthDate < minDate) { + if (birthdate > currentDate || birthdate < minDate) { toast.error( `La fecha de nacimiento es inválida. Debe estar entre ${minDate.toLocaleDateString()} y ${currentDate.toLocaleDateString()}.`, ); @@ -97,8 +97,8 @@ export function CreatePatientView({ const fieldLabels = { names: "nombres del paciente", - surnames: "apellidos del paciente", - birthDate: "fecha de nacimiento", + lastNames: "apellidos del paciente", + birthdate: "fecha de nacimiento", }; /** @@ -107,7 +107,7 @@ export function CreatePatientView({ * @returns {boolean} True if the form is valid, false otherwise. */ const validateFormData = () => { - const fields = ["names", "surnames", "birthDate"]; + const fields = ["names", "lastNames", "birthdate"]; if (patientData.cui.length !== 13) { toast.error("El CUI debe contener exactamente 13 caracteres."); return false; @@ -125,7 +125,7 @@ export function CreatePatientView({ return false; } - if (!validateBirthDate(patientData.birthDate)) { + if (!validateBirthDate(patientData.birthdate)) { return false; } return true; @@ -293,8 +293,8 @@ export function CreatePatientView({ handleChange("surnames", e.target.value)} + value={patientData.lastNames} + onChange={(e) => handleChange("lastNames", e.target.value)} placeholder="Ingresa tu apellido" style={inputStyles} /> @@ -314,8 +314,8 @@ export function CreatePatientView({
handleChange("birthDate", e.target.value)} + value={patientData.birthdate} + onChange={(e) => handleChange("birthdate", e.target.value)} placeholder="Fecha de nacimiento" style={inputStyles} /> @@ -324,7 +324,7 @@ export function CreatePatientView({
handleChange("phone", e.target.value)} placeholder="Ejemplo: 23438767" style={inputStyles} @@ -334,7 +334,7 @@ export function CreatePatientView({
handleChange("insurance", e.target.value)} placeholder="Ejemplo: El Roble o Ninguno" style={inputStyles}