Alteração modal CPF
This commit is contained in:
parent
612f0c51a0
commit
17c4259bbc
@ -35,4 +35,4 @@
|
|||||||
to {
|
to {
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,18 +105,17 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
|
|||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!formData.full_name || !formData.cpf || !formData.sex || !formData.birth_date){
|
if (!formData.full_name || !formData.cpf || !formData.sex || !formData.birth_date){
|
||||||
|
console.log(formData.full_name, formData.cpf, formData.sex, formData.birth_date)
|
||||||
setErrorModalMsg('Por favor, preencha Nome, CPF, Gênero e data de nascimento.');
|
setErrorModalMsg('Por favor, preencha Nome, CPF, Gênero e data de nascimento.');
|
||||||
setShowModal404(true);
|
setShowModal404(true);
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onSave({
|
onSave({
|
||||||
...formData,bmi:12.0
|
...formData,bmi:12.0
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card p-3">
|
<div className="card p-3">
|
||||||
<h3 className="mb-4 text-center" style={{ fontSize: '2.5rem' }}>MediConnect</h3>
|
<h3 className="mb-4 text-center" style={{ fontSize: '2.5rem' }}>MediConnect</h3>
|
||||||
|
|||||||
@ -3,9 +3,12 @@ import PatientForm from '../components/patients/PatientForm';
|
|||||||
import API_KEY from '../components/utils/apiKeys';
|
import API_KEY from '../components/utils/apiKeys';
|
||||||
import { useAuth } from '../components/utils/AuthProvider';
|
import { useAuth } from '../components/utils/AuthProvider';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
function PatientCadastroManager( {setCurrentPage} ) {
|
function PatientCadastroManager( {setCurrentPage} ) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
const [infosModal, setInfosModal] = useState({title:'', message:''});
|
||||||
|
|
||||||
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
||||||
const [formData, setFormData] = useState({})
|
const [formData, setFormData] = useState({})
|
||||||
|
|
||||||
@ -43,10 +46,13 @@ function PatientCadastroManager( {setCurrentPage} ) {
|
|||||||
console.log("Erro ao salvar paciente:", data);
|
console.log("Erro ao salvar paciente:", data);
|
||||||
if (data.code === "23505") {
|
if (data.code === "23505") {
|
||||||
setShowModal(true);
|
setShowModal(true);
|
||||||
|
setInfosModal({
|
||||||
|
title: 'Erro ao salvar paciente',
|
||||||
|
message: 'CPF já cadastrado. Por favor, verifique o CPF informado.'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
console.log("ATUALIZADO COM SUCESSO");
|
console.log("ATUALIZADO COM SUCESSO");
|
||||||
navigate('/pacientes')
|
navigate('/pacientes')
|
||||||
}
|
}
|
||||||
@ -56,24 +62,19 @@ function PatientCadastroManager( {setCurrentPage} ) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="page-heading">
|
<div className="page-heading">
|
||||||
|
|
||||||
{showModal &&(
|
{showModal &&(
|
||||||
<div className="modal" style={{ display: 'block', backgroundColor: 'rgba(0,0,0,0.5)' }}>
|
<div className="modal" style={{ display: 'block', backgroundColor: 'rgba(0,0,0,0.5)' }}>
|
||||||
<div className="modal-dialog">
|
<div className="modal-dialog">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-header">
|
<div className="modal-header bg-danger text-white">
|
||||||
<h5 className="modal-title">Ops! Este CPF já está cadastrado</h5>
|
<h5 className="modal-title">{infosModal.title}</h5>
|
||||||
<button type="button" className="btn-close" onClick={() => setShowModal(false)}></button>
|
<button type="button" className="btn-close" onClick={() => setShowModal(false)}></button>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<div className="text-center mb-3">
|
<p>{infosModal.message}</p>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button
|
<button
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user