From 0bf19ab6f2342e8bea165818e2bda7e29cea2f32 Mon Sep 17 00:00:00 2001 From: jp-lima Date: Fri, 3 Oct 2025 20:35:55 -0300 Subject: [PATCH] Concerto das linkagens --- src/PagesMedico/InicioMedico.jsx | 44 ++----- src/components/patients/PatientForm.jsx | 79 ++----------- src/data/sidebar-items-adm.json | 13 +-- src/data/sidebar-items-financeiro.json | 19 --- src/data/sidebar-items-medico.json | 6 - src/pages/Details.jsx | 110 +++--------------- src/pages/DoctorDetails.jsx | 26 +++-- src/pages/DoctorEditPage.jsx | 9 +- src/pages/EditPage.jsx | 8 +- src/pages/PatientCadastroManager.jsx | 4 +- src/perfis/Perfil_adm/Perfiladm.jsx | 4 +- src/perfis/Perfil_medico/PerfilMedico.jsx | 5 +- .../perfil_financeiro/PerfilFinanceiro.jsx | 12 +- 13 files changed, 69 insertions(+), 270 deletions(-) diff --git a/src/PagesMedico/InicioMedico.jsx b/src/PagesMedico/InicioMedico.jsx index dc47fae1..b488798c 100644 --- a/src/PagesMedico/InicioMedico.jsx +++ b/src/PagesMedico/InicioMedico.jsx @@ -1,37 +1,11 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState } from 'react'; import { FaUser, FaUserPlus, FaCalendarAlt, FaCalendarCheck } from 'react-icons/fa'; import './style/Inicio.css'; - -function Inicio({ setCurrentPage }) { +import { useNavigate } from 'react-router-dom'; +function Inicio() { const [pacientes, setPacientes] = useState([]); const [agendamentos, setAgendamentos] = useState([]); - - useEffect(() => { - const fetchPacientes = async () => { - try { - const res = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes"); - const data = await res.json(); - console.log(data) - //setPacientes(data.data); - } catch (error) { - console.error("Erro ao buscar pacientes:", error); - } - }; - - const fetchAgendamentos = async () => { - return; // <===serve para que nao cause erro - // try { - // const res = await fetch(); - // const data = await res.json(); - // setAgendamentos(data.data); - // } catch (error) { - // console.error("Erro ao buscar agendamentos:", error); - // } - }; - - fetchPacientes(); - fetchAgendamentos(); - }, []); + const navigate = useNavigate(); const totalPacientes = pacientes.length; const novosEsseMes = pacientes.filter(p => p.createdAt && new Date(p.createdAt).getMonth() === new Date().getMonth()).length; @@ -87,21 +61,21 @@ function Inicio({ setCurrentPage }) {

Ações Rápidas

-
setCurrentPage('form-layout')}> +
navigate('/form-layout')}>
- Novo Paciente + Novo Pacient Cadastrar um novo paciente
-
setCurrentPage('table')}> +
navigate('/table')}>
Lista de Pacientes Ver todos os pacientes
-
setCurrentPage('agendamento')}> +
navigate('agendamento')}>
Agendamentos @@ -126,7 +100,7 @@ function Inicio({ setCurrentPage }) {

Nenhum agendamento para hoje

-
diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index eacf08fa..656a0b10 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -281,21 +281,20 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
- - {/* CAMPOS MOVIDOS */}
- - -
-
- -
- - - {formData.anexos ? formData.anexos.name : 'Nenhum arquivo escolhido'} +
+ +
+
+ + +
+
@@ -332,68 +331,12 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
-
- - -
+
- {/* INFORMAÇÕES DE CONVÊNIO */} -
-

handleToggleCollapse('infoConvenio')} style={{ fontSize: '1.8rem' }}> - Informações de convênio - - {collapsedSections.infoConvenio ? '▲' : '▼'} - -

-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- {/* PACIENTE VIP */} -
-
- - -
-
-
-
-
- {/* ENDEREÇO */}

handleToggleCollapse('endereco')} style={{ fontSize: '1.8rem' }}> diff --git a/src/data/sidebar-items-adm.json b/src/data/sidebar-items-adm.json index 410a133a..2d77c70e 100644 --- a/src/data/sidebar-items-adm.json +++ b/src/data/sidebar-items-adm.json @@ -3,12 +3,6 @@ "name": "Menu", "isTitle": true }, - - { - "name":"Início", - "url": "/admin/", - "icon": "house" - }, { "name": "Lista de Pacientes", "icon": "clipboard-heart-fill", @@ -20,12 +14,7 @@ "icon": "hospital-fill", "url": "/admin/medicos" }, - { - "name": "Agendar consulta", - "icon": "calendar-plus-fill", - "url": "/admin/agendamento" - }, - + { "name": "Gestão de Usuários", "icon": "person-badge-fill", diff --git a/src/data/sidebar-items-financeiro.json b/src/data/sidebar-items-financeiro.json index 8183087d..dfce9bcf 100644 --- a/src/data/sidebar-items-financeiro.json +++ b/src/data/sidebar-items-financeiro.json @@ -3,25 +3,6 @@ "name": "Menu-Financeiro", "isTitle": true }, - - { - "name":"Início", - "url": "/financeiro/inicio", - "icon": "house" - }, - - { - "name": "Lista de Pacientes", - "icon": "clipboard-heart-fill", - "url": "/financeiro/pacientes" - }, - - { - "name": "Lista de Médico", - "icon": "hospital-fill", - "url": "/financeiro/medicos" - }, - { "name": "Controle Financeiro", "icon": "cash-coin", diff --git a/src/data/sidebar-items-medico.json b/src/data/sidebar-items-medico.json index 4a6717da..0d2a4393 100644 --- a/src/data/sidebar-items-medico.json +++ b/src/data/sidebar-items-medico.json @@ -3,12 +3,6 @@ "name": "Menu", "isTitle": true }, - - { - "name":"Início", - "url": "/medico/", - "icon": "house" - }, { "name": "Prontuário", diff --git a/src/pages/Details.jsx b/src/pages/Details.jsx index 21d640dd..70cba433 100644 --- a/src/pages/Details.jsx +++ b/src/pages/Details.jsx @@ -1,22 +1,26 @@ import React, { useEffect, useState } from "react"; import avatarPlaceholder from '../assets/images/avatar_placeholder.png'; -import { useParams } from "react-router-dom"; +import { useParams, useNavigate, useLocation, Navigate } from "react-router-dom"; import API_KEY from "../components/utils/apiKeys"; import {GetByID} from "../components/utils/Functions-Endpoints/Patient" import { Link } from "react-router-dom"; import { useAuth } from "../components/utils/AuthProvider"; - const Details = () => { const parametros = useParams(); const {getAuthorizationHeader, isAuthenticated} = useAuth(); const [paciente, setPaciente] = useState({}); const [anexos, setAnexos] = useState([]); const [selectedFile, setSelectedFile] = useState(null); - + const location = useLocation(); + const navigate = useNavigate(); const patientID = parametros.id + const Voltar = () => { + const prefixo = location.pathname.split("/")[1]; + navigate(`/${prefixo}/pacientes`); + } useEffect(() => { if (!patientID) return; @@ -30,36 +34,8 @@ const Details = () => { }) .catch((err) => console.error("Erro ao buscar paciente:", err)); - /*fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos`) - .then(res => res.json()) - .then(data => setAnexos(data.data || [])) - .catch(err => console.error("Erro ao buscar anexos:", err)); -*/ - }, [patientID]); + }, [patientID]); - const handleUpload = async () => { - if (!selectedFile) return; - - const formData = new FormData(); - formData.append('file', selectedFile); - - try { - const response = await fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos`, { - method: 'POST', - body: formData, - }); - - if (response.ok) { - const newAnexo = await response.json(); - setAnexos(prev => [...prev, newAnexo]); - setSelectedFile(null); - } else { - console.error('Erro ao enviar anexo'); - } - } catch (err) { - console.error('Erro ao enviar anexo:', err); - } - }; const handleDelete = async (anexoId) => { try { @@ -89,11 +65,10 @@ const Details = () => {

MediConnect


- - - +
@@ -197,10 +172,7 @@ const Details = () => {

{paciente.marital_status || "-"}

-
- -

{paciente.nome_conjuge || "-"}

-
+

{paciente.legacy_code || "-"}

@@ -210,28 +182,18 @@ const Details = () => {
+
+
+
+ + +

{paciente.notes || "-"}

-
- - {anexos.length > 0 ?( -
    - {anexos.map((anexo) => ( -
  • - - {anexo.nome} - - -
  • - ))} -
- ) : ( -

-

- )} -
+
@@ -260,42 +222,6 @@ const Details = () => { - {/* ------------------ INFORMAÇÕES DE CONVÊNIO ------------------ */} -
-
Informações de Convênio
-
-
-
- -

{paciente.convenio || "-"}

-
-
- -

{paciente.plano || "-"}

-
-
- -

{paciente.numeroMatricula || "-"}

-
-
- -

{paciente.validadeCarteira || "-"}

-
-
-
- - -
-
-
-
- - -
-
-
-
- {/* ------------------ ENDEREÇO ------------------ */}
Endereço
diff --git a/src/pages/DoctorDetails.jsx b/src/pages/DoctorDetails.jsx index ee270c92..9a6a179b 100644 --- a/src/pages/DoctorDetails.jsx +++ b/src/pages/DoctorDetails.jsx @@ -1,13 +1,20 @@ import React, { useEffect, useState } from "react"; import avatarPlaceholder from '../assets/images/avatar_placeholder.png'; -import { useParams,Link } from "react-router-dom"; +import { useParams,Link, useNavigate, useLocation } from "react-router-dom"; import { GetDoctorByID } from "../components/utils/Functions-Endpoints/Doctor"; import { useAuth } from "../components/utils/AuthProvider"; - -const Details = ({setCurrentPage }) => { - const {getAuthorizationHeader, isAuthenticated} = useAuth(); + +const Details = () => { + const {getAuthorizationHeader} = useAuth(); const [doctor, setDoctor] = useState({}); const Parametros = useParams() + const navigate = useNavigate(); + const location = useLocation(); + + const Voltar = () => { + const prefixo = location.pathname.split("/")[1]; + navigate(`/${prefixo}/medicos`); + } const doctorID = Parametros.id useEffect(() => { @@ -34,11 +41,10 @@ const Details = ({setCurrentPage }) => {

MediConnect


- - - + +
@@ -48,7 +54,7 @@ const Details = ({setCurrentPage }) => {

{doctor.cpf || "CPF"}

- + diff --git a/src/pages/DoctorEditPage.jsx b/src/pages/DoctorEditPage.jsx index fd934a73..513481a3 100644 --- a/src/pages/DoctorEditPage.jsx +++ b/src/pages/DoctorEditPage.jsx @@ -48,13 +48,8 @@ const authHeader = getAuthorizationHeader() }; try { - const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors?id=eq.${DoctorID}`,requestOptions); - - // se o backend retorna JSON - const result = await response.json(); - console.log("ATUALIZADO COM SUCESSO", result); - - return result; + const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/doctors?id=eq.${DoctorID}`,requestOptions); + } catch (error) { console.error("Erro ao atualizar paciente:", error); throw error; diff --git a/src/pages/EditPage.jsx b/src/pages/EditPage.jsx index 982f592c..0402ebc0 100644 --- a/src/pages/EditPage.jsx +++ b/src/pages/EditPage.jsx @@ -53,11 +53,11 @@ const HandlePutPatient = async () => { try { const response = await fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients?id=eq.${PatientID}`,requestOptions); - // se o backend retorna JSON - console.log("Resposta do servidor:", response.ok); + + if(response.ok === false){ - const errorText = await response.text(); - console.error("Erro ao atualizar paciente:", errorText); + + console.error("Erro ao atualizar paciente:"); } else{ diff --git a/src/pages/PatientCadastroManager.jsx b/src/pages/PatientCadastroManager.jsx index a321c849..73e0007a 100644 --- a/src/pages/PatientCadastroManager.jsx +++ b/src/pages/PatientCadastroManager.jsx @@ -37,8 +37,6 @@ function PatientCadastroManager( {} ) { }; - // 23505 - cpf duplicadoo - // 23514 - cpf invalido try { const response = await fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients", requestOptions); console.log(response.ok, 'aqui') @@ -55,7 +53,7 @@ function PatientCadastroManager( {} ) { } } else{ - console.log("ATUALIZADO COM SUCESSO"); + console.log("Salvo com sucesso"); navigate('/pacientes') } } catch (error) { diff --git a/src/perfis/Perfil_adm/Perfiladm.jsx b/src/perfis/Perfil_adm/Perfiladm.jsx index a3c72bb0..0b5ee13f 100644 --- a/src/perfis/Perfil_adm/Perfiladm.jsx +++ b/src/perfis/Perfil_adm/Perfiladm.jsx @@ -22,7 +22,7 @@ function Perfiladm() {
- } /> + } /> } /> } /> } /> @@ -33,7 +33,7 @@ function Perfiladm() { } /> } /> } /> - } /> + } /> } /> Página não encontrada} /> diff --git a/src/perfis/Perfil_medico/PerfilMedico.jsx b/src/perfis/Perfil_medico/PerfilMedico.jsx index a3407fd7..77983104 100644 --- a/src/perfis/Perfil_medico/PerfilMedico.jsx +++ b/src/perfis/Perfil_medico/PerfilMedico.jsx @@ -1,7 +1,6 @@ -import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import { Routes, Route } from "react-router-dom"; import Sidebar from "../../components/Sidebar"; -import Inicio from "../../pages/Inicio"; import LaudoManager from "../../pages/LaudoManager"; import Prontuario from "../../PagesMedico/prontuario"; import Relatorio from "../../PagesMedico/relatorio"; @@ -17,7 +16,7 @@ function PerfilMedico() {
- } /> + } /> } /> } /> } /> diff --git a/src/perfis/perfil_financeiro/PerfilFinanceiro.jsx b/src/perfis/perfil_financeiro/PerfilFinanceiro.jsx index 7e8040c6..36bb2f16 100644 --- a/src/perfis/perfil_financeiro/PerfilFinanceiro.jsx +++ b/src/perfis/perfil_financeiro/PerfilFinanceiro.jsx @@ -2,11 +2,8 @@ import { Routes, Route } from "react-router-dom"; import Sidebar from "../../components/Sidebar"; import FinanceiroItems from "../../data/sidebar-items-financeiro.json"; import Inicio from "../../pages/Inicio"; -import TablePaciente from "../../pages/TablePaciente"; import FinanceiroDashboard from "../../pages/FinanceiroDashboard"; -import DoctorTable from "../../pages/DoctorTable"; -import Details from "../../pages/Details"; -import DoctorDetails from "../../pages/DoctorDetails"; + function PerfilFinanceiro({ onLogout }) { return ( @@ -15,12 +12,9 @@ function PerfilFinanceiro({ onLogout }) {
}/> - } /> + }/> - } /> - } /> - } /> - } /> + Página não encontrada} />