forked from RiseUP/riseup-squad23
tirar o id da url quando entra no ver detalhes ou edit
This commit is contained in:
parent
251aa95f63
commit
03c32138c6
@ -7,7 +7,7 @@ import { Link } from "react-router-dom";
|
|||||||
import { useAuth } from "../components/utils/AuthProvider";
|
import { useAuth } from "../components/utils/AuthProvider";
|
||||||
|
|
||||||
|
|
||||||
const Details = () => {
|
const Details = (DictInfo) => {
|
||||||
const parametros = useParams();
|
const parametros = useParams();
|
||||||
const {getAuthorizationHeader, isAuthenticated} = useAuth();
|
const {getAuthorizationHeader, isAuthenticated} = useAuth();
|
||||||
const [paciente, setPaciente] = useState({});
|
const [paciente, setPaciente] = useState({});
|
||||||
@ -23,18 +23,18 @@ const Details = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!patientID) return;
|
if (!DictInfo) return;
|
||||||
console.log(patientID, 'teu id')
|
console.log(patientID, 'teu id')
|
||||||
const authHeader = getAuthorizationHeader()
|
const authHeader = getAuthorizationHeader()
|
||||||
|
|
||||||
GetPatientByID(patientID, authHeader)
|
GetPatientByID(DictInfo.DictInfo.id, authHeader)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data, "paciente vindo da API");
|
console.log(data, "paciente vindo da API");
|
||||||
setPaciente(data[0]); // supabase retorna array
|
setPaciente(data[0]); // supabase retorna array
|
||||||
})
|
})
|
||||||
.catch((err) => console.error("Erro ao buscar paciente:", err));
|
.catch((err) => console.error("Erro ao buscar paciente:", err));
|
||||||
|
|
||||||
}, [patientID]);
|
}, [DictInfo]);
|
||||||
|
|
||||||
|
|
||||||
const handleDelete = async (anexoId) => {
|
const handleDelete = async (anexoId) => {
|
||||||
|
|||||||
@ -7,19 +7,23 @@ import { GetPatientByID } from '../components/utils/Functions-Endpoints/Patient'
|
|||||||
import API_KEY from '../components/utils/apiKeys'
|
import API_KEY from '../components/utils/apiKeys'
|
||||||
import {useNavigate, useParams } from 'react-router-dom'
|
import {useNavigate, useParams } from 'react-router-dom'
|
||||||
import { useAuth } from '../components/utils/AuthProvider'
|
import { useAuth } from '../components/utils/AuthProvider'
|
||||||
const EditPage = () => {
|
|
||||||
|
const EditPage = (DictInfo) => {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const Parametros = useParams()
|
const Parametros = useParams()
|
||||||
const [PatientToPUT, setPatientPUT] = useState({})
|
const [PatientToPUT, setPatientPUT] = useState({})
|
||||||
|
|
||||||
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
||||||
|
console.log(DictInfo, "usuario vindo do set")
|
||||||
const PatientID = Parametros.id
|
const PatientID = Parametros.id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const authHeader = getAuthorizationHeader()
|
const authHeader = getAuthorizationHeader()
|
||||||
|
console.log(DictInfo.DictInfo.id, "id do cabra")
|
||||||
|
|
||||||
GetPatientByID(PatientID, authHeader)
|
GetPatientByID(DictInfo.DictInfo.id, authHeader)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data[0], "paciente vindo da API");
|
console.log(data[0], "paciente vindo da API");
|
||||||
setPatientPUT(data[0]); // supabase retorna array
|
setPatientPUT(data[0]); // supabase retorna array
|
||||||
@ -28,7 +32,8 @@ useEffect(() => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, [PatientID])
|
}, [DictInfo])
|
||||||
|
|
||||||
|
|
||||||
const HandlePutPatient = async () => {
|
const HandlePutPatient = async () => {
|
||||||
const authHeader = getAuthorizationHeader()
|
const authHeader = getAuthorizationHeader()
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import "./style/TablePaciente.css";
|
|||||||
import ModalErro from "../components/utils/fetchErros/ModalErro";
|
import ModalErro from "../components/utils/fetchErros/ModalErro";
|
||||||
import manager from "../components/utils/fetchErros/ManagerFunction";
|
import manager from "../components/utils/fetchErros/ManagerFunction";
|
||||||
|
|
||||||
function TablePaciente({ setCurrentPage, setPatientID }) {
|
function TablePaciente({ setCurrentPage, setPatientID,setDictInfo }) {
|
||||||
|
|
||||||
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
const { getAuthorizationHeader, isAuthenticated } = useAuth();
|
||||||
|
|
||||||
@ -520,14 +520,14 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
|||||||
<td>{paciente.email || 'Não informado'}</td>
|
<td>{paciente.email || 'Não informado'}</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="d-flex gap-2">
|
<div className="d-flex gap-2">
|
||||||
<Link to={`${paciente.id}`}>
|
<Link to={"details"}>
|
||||||
<button className="btn btn-sm btn-view">
|
<button className="btn btn-sm btn-view" onClick={() => setDictInfo(paciente)}>
|
||||||
<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={`${paciente.id}/edit`}>
|
<Link to={"edit"}>
|
||||||
<button className="btn btn-sm btn-edit">
|
<button className="btn btn-sm btn-edit" onClick={() => setDictInfo(paciente)}>
|
||||||
<i className="bi bi-pencil me-1"></i> Editar
|
<i className="bi bi-pencil me-1"></i> Editar
|
||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@ -30,10 +30,10 @@ function PerfilSecretaria({ onLogout }) {
|
|||||||
<Route path="/" element={<Inicio/>}/>
|
<Route path="/" element={<Inicio/>}/>
|
||||||
<Route path="pacientes/cadastro" element={<PatientCadastroManager />} />
|
<Route path="pacientes/cadastro" element={<PatientCadastroManager />} />
|
||||||
<Route path="medicos/cadastro" element={<DoctorCadastroManager />} />
|
<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="medicos" element={<DoctorTable />} />
|
||||||
<Route path="pacientes/:id" element={<Details />} />
|
<Route path="pacientes/details" element={<Details DictInfo={DictInfo}/>} />
|
||||||
<Route path="pacientes/:id/edit" element={<EditPage />} />
|
<Route path="pacientes/edit" element={<EditPage DictInfo={DictInfo}/>} />
|
||||||
<Route path="medicos/:id" element={<DoctorDetails />} />
|
<Route path="medicos/:id" element={<DoctorDetails />} />
|
||||||
<Route path="medicos/:id/edit" element={<DoctorEditPage />} />
|
<Route path="medicos/:id/edit" element={<DoctorEditPage />} />
|
||||||
<Route path="agendamento" element={<Agendamento setDictInfo={setDictInfo}/>} />
|
<Route path="agendamento" element={<Agendamento setDictInfo={setDictInfo}/>} />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user