tirar o id da url quando entra no ver detalhes ou edit

This commit is contained in:
joao_pedro 2025-11-10 16:10:48 -03:00
parent 251aa95f63
commit 03c32138c6
4 changed files with 25 additions and 20 deletions

View File

@ -7,7 +7,7 @@ import { Link } from "react-router-dom";
import { useAuth } from "../components/utils/AuthProvider";
const Details = () => {
const Details = (DictInfo) => {
const parametros = useParams();
const {getAuthorizationHeader, isAuthenticated} = useAuth();
const [paciente, setPaciente] = useState({});
@ -23,18 +23,18 @@ const Details = () => {
}
useEffect(() => {
if (!patientID) return;
if (!DictInfo) return;
console.log(patientID, 'teu id')
const authHeader = getAuthorizationHeader()
GetPatientByID(patientID, authHeader)
GetPatientByID(DictInfo.DictInfo.id, authHeader)
.then((data) => {
console.log(data, "paciente vindo da API");
setPaciente(data[0]); // supabase retorna array
})
.catch((err) => console.error("Erro ao buscar paciente:", err));
}, [patientID]);
}, [DictInfo]);
const handleDelete = async (anexoId) => {

View File

@ -7,19 +7,23 @@ import { GetPatientByID } from '../components/utils/Functions-Endpoints/Patient'
import API_KEY from '../components/utils/apiKeys'
import {useNavigate, useParams } from 'react-router-dom'
import { useAuth } from '../components/utils/AuthProvider'
const EditPage = () => {
const EditPage = (DictInfo) => {
const navigate = useNavigate()
const Parametros = useParams()
const [PatientToPUT, setPatientPUT] = useState({})
const { getAuthorizationHeader, isAuthenticated } = useAuth();
console.log(DictInfo, "usuario vindo do set")
const PatientID = Parametros.id
useEffect(() => {
const authHeader = getAuthorizationHeader()
console.log(DictInfo.DictInfo.id, "id do cabra")
GetPatientByID(PatientID, authHeader)
GetPatientByID(DictInfo.DictInfo.id, authHeader)
.then((data) => {
console.log(data[0], "paciente vindo da API");
setPatientPUT(data[0]); // supabase retorna array
@ -28,7 +32,8 @@ useEffect(() => {
}, [PatientID])
}, [DictInfo])
const HandlePutPatient = async () => {
const authHeader = getAuthorizationHeader()

View File

@ -6,7 +6,7 @@ import "./style/TablePaciente.css";
import ModalErro from "../components/utils/fetchErros/ModalErro";
import manager from "../components/utils/fetchErros/ManagerFunction";
function TablePaciente({ setCurrentPage, setPatientID }) {
function TablePaciente({ setCurrentPage, setPatientID,setDictInfo }) {
const { getAuthorizationHeader, isAuthenticated } = useAuth();
@ -520,14 +520,14 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
<td>{paciente.email || 'Não informado'}</td>
<td>
<div className="d-flex gap-2">
<Link to={`${paciente.id}`}>
<button className="btn btn-sm btn-view">
<Link to={"details"}>
<button className="btn btn-sm btn-view" onClick={() => setDictInfo(paciente)}>
<i className="bi bi-eye me-1"></i> Ver Detalhes
</button>
</Link>
<Link to={`${paciente.id}/edit`}>
<button className="btn btn-sm btn-edit">
<Link to={"edit"}>
<button className="btn btn-sm btn-edit" onClick={() => setDictInfo(paciente)}>
<i className="bi bi-pencil me-1"></i> Editar
</button>
</Link>

View File

@ -30,10 +30,10 @@ function PerfilSecretaria({ onLogout }) {
<Route path="/" element={<Inicio/>}/>
<Route path="pacientes/cadastro" element={<PatientCadastroManager />} />
<Route path="medicos/cadastro" element={<DoctorCadastroManager />} />
<Route path="pacientes" element={<TablePaciente />} />
<Route path="pacientes" element={<TablePaciente setDictInfo={setDictInfo}/>} />
<Route path="medicos" element={<DoctorTable />} />
<Route path="pacientes/:id" element={<Details />} />
<Route path="pacientes/:id/edit" element={<EditPage />} />
<Route path="pacientes/details" element={<Details DictInfo={DictInfo}/>} />
<Route path="pacientes/edit" element={<EditPage DictInfo={DictInfo}/>} />
<Route path="medicos/:id" element={<DoctorDetails />} />
<Route path="medicos/:id/edit" element={<DoctorEditPage />} />
<Route path="agendamento" element={<Agendamento setDictInfo={setDictInfo}/>} />