diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index c5540205..ddb76e45 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -52,6 +52,8 @@ function PatientForm({ onSave, onCancel, formData, setFormData, isLoading }) { })); }; + + useEffect(() => { const peso = parseFloat(formData.weight_kg); const altura = parseFloat(formData.height_m); @@ -63,9 +65,20 @@ function PatientForm({ onSave, onCancel, formData, setFormData, isLoading }) { } }, [formData.weight_kg, formData.height_m, setFormData]); + const handleCep = (value) => { + if(value.length === 8){ + fetch(`https://viacep.com.br/ws/${value}/json/`) + .then(response => response.json()) + .then(result => {setFormData(prev => ({...prev, street:result.logradouro,neighborhood:result.bairro,city:result.localidade, + state:result.estado + + }))}) + } + } + const handleChange = (e) => { const { name, value, type, checked, files } = e.target; - + console.log(name, value) if (value && emptyFields.includes(name)) { setEmptyFields(prev => prev.filter(field => field !== name)); } @@ -101,8 +114,11 @@ function PatientForm({ onSave, onCancel, formData, setFormData, isLoading }) { } else if (name.includes('weight_kg') || name.includes('height_m')) { setFormData(prev => ({ ...prev, [name]: FormatPeso(value) })); } else if (name === 'rn_in_insurance' || name === 'vip' || name === 'validadeIndeterminada') { - setFormData(prev => ({ ...prev, [name]: checked })); - } else { + setFormData(prev => ({ ...prev, [name]: checked })); + } else if(name === 'cep'){ + handleCep(value) + setFormData(prev => ({...prev, [name]: value})) + }else { setFormData(prev => ({ ...prev, [name]: value })); } }; @@ -189,9 +205,6 @@ function PatientForm({ onSave, onCancel, formData, setFormData, isLoading }) { } const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; - if (!emailRegex.test(formData.email)) { - throw new Error('Email inválido. Por favor, verifique o email digitado.'); - } await onSave({ ...formData, bmi: parseFloat(formData.bmi) || null }); }; @@ -647,4 +660,4 @@ function PatientForm({ onSave, onCancel, formData, setFormData, isLoading }) { ); } -export default PatientForm; \ No newline at end of file +export default PatientForm; diff --git a/src/pages/DoctorDetails.jsx b/src/pages/DoctorDetails.jsx index e426f751..23e59d48 100644 --- a/src/pages/DoctorDetails.jsx +++ b/src/pages/DoctorDetails.jsx @@ -4,11 +4,12 @@ import { useParams,Link, useNavigate, useLocation } from "react-router-dom"; import { GetDoctorByID } from "../components/utils/Functions-Endpoints/Doctor"; import { useAuth } from "../components/utils/AuthProvider"; -const DoctorDetails = ({doctor}) => { +const DoctorDetails = ({DictInfo}) => { const {getAuthorizationHeader} = useAuth(); const Parametros = useParams() const navigate = useNavigate(); const location = useLocation(); + const Voltar = () => { @@ -16,11 +17,6 @@ const Voltar = () => { navigate(`/${prefixo}/medicos`); } - - - - - return ( <>
{doctor.cpf || "CPF"}
+ {DictInfo.full_name || "Nome Completo"} +{DictInfo.cpf || "CPF"}