Skip to content

Commit

Permalink
fix: CreatePatientView update
Browse files Browse the repository at this point in the history
  • Loading branch information
ElrohirGT committed Nov 15, 2024
1 parent c3a66bb commit 0d31e78
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions sanitas_frontend/src/views/CreatePatientView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

Expand Down Expand Up @@ -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: "",
});
Expand All @@ -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 {
Expand All @@ -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()}.`,
);
Expand All @@ -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",
};

/**
Expand All @@ -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;
Expand All @@ -125,7 +125,7 @@ export function CreatePatientView({
return false;
}

if (!validateBirthDate(patientData.birthDate)) {
if (!validateBirthDate(patientData.birthdate)) {
return false;
}
return true;
Expand Down Expand Up @@ -293,8 +293,8 @@ export function CreatePatientView({
<label style={labelStyles}>Apellidos del paciente:</label>
<BaseInput
type="text"
value={patientData.surnames}
onChange={(e) => handleChange("surnames", e.target.value)}
value={patientData.lastNames}
onChange={(e) => handleChange("lastNames", e.target.value)}
placeholder="Ingresa tu apellido"
style={inputStyles}
/>
Expand All @@ -314,8 +314,8 @@ export function CreatePatientView({
<div style={inputContainerStyles}>
<label style={labelStyles}>Fecha de Nacimiento:</label>
<DateInput
value={patientData.birthDate}
onChange={(e) => handleChange("birthDate", e.target.value)}
value={patientData.birthdate}
onChange={(e) => handleChange("birthdate", e.target.value)}
placeholder="Fecha de nacimiento"
style={inputStyles}
/>
Expand All @@ -324,7 +324,7 @@ export function CreatePatientView({
<div style={inputContainerStyles}>
<label style={labelStyles}>Teléfono:</label>
<BaseInput
value={patientData.birthDate}
value={patientData.phone}
onChange={(e) => handleChange("phone", e.target.value)}
placeholder="Ejemplo: 23438767"
style={inputStyles}
Expand All @@ -334,7 +334,7 @@ export function CreatePatientView({
<div style={inputContainerStyles}>
<label style={labelStyles}>Seguro Médico:</label>
<BaseInput
value={patientData.birthDate}
value={patientData.insurance}
onChange={(e) => handleChange("insurance", e.target.value)}
placeholder="Ejemplo: El Roble o Ninguno"
style={inputStyles}
Expand Down

0 comments on commit 0d31e78

Please sign in to comment.