bug:linkagem para ver detalhes e editar a lista de médicos
This commit is contained in:
parent
be160327fb
commit
91a4193512
@ -780,4 +780,4 @@ const handleAvailabilityUpdate = useCallback((newAvailability) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DoctorForm;
|
export default DoctorForm;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ const Voltar = () => {
|
|||||||
navigate(`/${prefixo}/medicos`);
|
navigate(`/${prefixo}/medicos`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(DictInfo)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="card p-3 shadow-sm">
|
<div className="card p-3 shadow-sm">
|
||||||
@ -142,4 +143,4 @@ const Voltar = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DoctorDetails;
|
export default DoctorDetails;
|
||||||
|
|||||||
@ -24,13 +24,13 @@ const weekdayStrToNum = Object.fromEntries(
|
|||||||
Object.entries(weekdayNumToStr).map(([num, str]) => [str, Number(num)])
|
Object.entries(weekdayNumToStr).map(([num, str]) => [str, Number(num)])
|
||||||
);
|
);
|
||||||
|
|
||||||
const EditDoctorPage = () => {
|
const EditDoctorPage = ({DictInfo}) => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { getAuthorizationHeader } = useAuth();
|
const { getAuthorizationHeader } = useAuth();
|
||||||
|
|
||||||
const [doctor, setDoctor] = useState(null);
|
const [doctor, setDoctor] = useState({});
|
||||||
const [availability, setAvailability] = useState([]);
|
const [availability, setAvailability] = useState([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
@ -194,6 +194,9 @@ const EditDoctorPage = () => {
|
|||||||
}, [availability, effectiveId]);
|
}, [availability, effectiveId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
|
console.log("teste")
|
||||||
|
setDoctor({...DictInfo})
|
||||||
const fetchDoctorData = async () => {
|
const fetchDoctorData = async () => {
|
||||||
if (!effectiveId || effectiveId === "edit") {
|
if (!effectiveId || effectiveId === "edit") {
|
||||||
alert("ID do médico não encontrado");
|
alert("ID do médico não encontrado");
|
||||||
@ -216,7 +219,7 @@ const EditDoctorPage = () => {
|
|||||||
throw new Error("Médico não encontrado");
|
throw new Error("Médico não encontrado");
|
||||||
}
|
}
|
||||||
|
|
||||||
setDoctor(doctorData[0]);
|
// setDoctor(doctorData[0]);
|
||||||
|
|
||||||
const availabilityResponse = await fetch(
|
const availabilityResponse = await fetch(
|
||||||
`${ENDPOINT_AVAILABILITY}?doctor_id=eq.${effectiveId}&order=weekday.asc,start_time.asc`,
|
`${ENDPOINT_AVAILABILITY}?doctor_id=eq.${effectiveId}&order=weekday.asc,start_time.asc`,
|
||||||
@ -281,38 +284,11 @@ const EditDoctorPage = () => {
|
|||||||
navigate("/secretaria/medicos");
|
navigate("/secretaria/medicos");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="container mt-4">
|
|
||||||
<div className="d-flex justify-content-center">
|
|
||||||
<div className="spinner-border" role="status">
|
|
||||||
<span className="visually-hidden">Carregando...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p className="text-center mt-2">
|
|
||||||
Carregando dados do médico ID: {effectiveId || "..."}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doctor) {
|
|
||||||
if (!isLoading) {
|
|
||||||
return (
|
|
||||||
<div className="container mt-4">
|
|
||||||
<div className="alert alert-danger">
|
|
||||||
Médico não encontrado
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formData = {
|
const formData = {
|
||||||
...doctor,
|
...doctor,
|
||||||
availability: (doctor && doctor.availability) ? doctor.availability : availabilityFormatted,
|
availability: (doctor && doctor.availability) ? doctor.availability : availabilityFormatted,
|
||||||
};
|
};
|
||||||
|
console.log(doctor, "Informações do médico")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mt-4">
|
<div className="container mt-4">
|
||||||
@ -320,7 +296,7 @@ const EditDoctorPage = () => {
|
|||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<h1>Editar Médico</h1>
|
<h1>Editar Médico</h1>
|
||||||
<DoctorForm
|
<DoctorForm
|
||||||
formData={formData}
|
formData={doctor}
|
||||||
setFormData={setDoctor}
|
setFormData={setDoctor}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
@ -333,4 +309,4 @@ const EditDoctorPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EditDoctorPage;
|
export default EditDoctorPage;
|
||||||
|
|||||||
@ -438,13 +438,13 @@ function TableDoctor({setDictInfo}) {
|
|||||||
<td>{medico.email || 'Não informado'}</td>
|
<td>{medico.email || 'Não informado'}</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="d-flex gap-2">
|
<div className="d-flex gap-2">
|
||||||
<Link to={`details/${medico.id}`}>
|
<Link to={`details`}>
|
||||||
<button className="btn btn-sm btn-view" onClick={() => setDictInfo({...medico})}>
|
<button className="btn btn-sm btn-view" onClick={() => setDictInfo({...medico})}>
|
||||||
<i className="bi bi-eye me-1"></i> Ver Detalhes
|
<i className="bi bi-eye me-1"></i> Ver Detalhes
|
||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link to={`edit/${medico.id}`}>
|
<Link to={`edit`}>
|
||||||
<button className="btn btn-sm btn-edit" onClick={() => setDictInfo({...medico})}>
|
<button className="btn btn-sm btn-edit" onClick={() => setDictInfo({...medico})}>
|
||||||
<i className="bi bi-pencil me-1"></i> Editar
|
<i className="bi bi-pencil me-1"></i> Editar
|
||||||
</button>
|
</button>
|
||||||
@ -591,4 +591,4 @@ function TableDoctor({setDictInfo}) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TableDoctor;
|
export default TableDoctor;
|
||||||
|
|||||||
@ -41,8 +41,8 @@ function PerfilSecretaria({ onLogout }) {
|
|||||||
<Route path="medicos" element={<DoctorTable setDictInfo={setDictInfo} />} />
|
<Route path="medicos" element={<DoctorTable setDictInfo={setDictInfo} />} />
|
||||||
<Route path="pacientes/details" element={<Details DictInfo={DictInfo}/>} />
|
<Route path="pacientes/details" element={<Details DictInfo={DictInfo}/>} />
|
||||||
<Route path="pacientes/edit" element={<EditPage DictInfo={DictInfo}/>} />
|
<Route path="pacientes/edit" element={<EditPage DictInfo={DictInfo}/>} />
|
||||||
<Route path="medicos/details/:id" element={<DoctorDetails doctor={DictInfo} />} />
|
<Route path="medicos/details" element={<DoctorDetails DictInfo={DictInfo} />} />
|
||||||
<Route path="medicos/edit/:id" element={<DoctorEditPage DictInfo={DictInfo} />} />
|
<Route path="medicos/edit" element={<DoctorEditPage DictInfo={DictInfo} />} />
|
||||||
<Route path="agendamento" element={<Agendamento setDictInfo={setDictInfo}/>} />
|
<Route path="agendamento" element={<Agendamento setDictInfo={setDictInfo}/>} />
|
||||||
<Route path="agendamento/edit" element={<AgendamentoEditPage setDictInfo={setDictInfo} DictInfo={DictInfo}/>} />
|
<Route path="agendamento/edit" element={<AgendamentoEditPage setDictInfo={setDictInfo} DictInfo={DictInfo}/>} />
|
||||||
<Route path="laudo" element={<LaudoManager />} />
|
<Route path="laudo" element={<LaudoManager />} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user