-
-
-
- {renderPageContent()}
+
+
+
+
+
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ Página não encontrada} />
+
+
-
+
);
}
-export default App;
\ No newline at end of file
+export default App;
diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js
deleted file mode 100644
index 095b41e..0000000
--- a/src/components/Sidebar.js
+++ /dev/null
@@ -1,131 +0,0 @@
-import React, { useState } from 'react';
-// ADIÇÃO 1: Importar o arquivo JSON com os itens do menu
-import menuItems from '../data/sidebar-items.json'; // <-- ATENÇÃO: ajuste o caminho para o seu arquivo!
-
-// ADIÇÃO 2: A função agora precisa receber 'props' para ter acesso ao setCurrentPage
-function Sidebar(props) {
- const [isActive, setIsActive] = useState(true);
- const [openSubmenu, setOpenSubmenu] = useState(null);
-
- const toggleSidebar = () => {
- setIsActive(!isActive);
- };
-
- const handleSubmenuClick = (submenuName) => {
- setOpenSubmenu(openSubmenu === submenuName ? null : submenuName);
- };
-
- // =====================================================
- // renderLink atualizado para suportar Table.jsx
- // =====================================================
- const renderLink = (item) => {
- if (item.url && !item.url.includes('.html') && !item.url.startsWith('http')) {
- return (
-
{
- e.preventDefault();
- props.setCurrentPage(item.url); // agora passa "table" corretamente
- }}
- >
- {item.icon && }
- {item.name}
-
- );
- }
- return (
-
- {item.icon && }
- {item.name}
-
- );
- };
-
- return (
-
- );
-}
-
-export default Sidebar;
diff --git a/src/components/doctors/DoctorForm.jsx b/src/components/doctors/DoctorForm.jsx
index 6ef87f5..5254aa2 100644
--- a/src/components/doctors/DoctorForm.jsx
+++ b/src/components/doctors/DoctorForm.jsx
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
-
+import {Link} from 'react-router-dom'
function DoctorForm({ onSave, onCancel, PatientDict }) {
@@ -458,9 +458,11 @@ function DoctorForm({ onSave, onCancel, PatientDict }) {
-
+
+
+
diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx
index 4b77f23..74f6659 100644
--- a/src/components/patients/PatientForm.jsx
+++ b/src/components/patients/PatientForm.jsx
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
+import {Link} from 'react-router-dom'
function PatientForm({ onSave, onCancel, formData, setFormData }) {
const [errorModalMsg, setErrorModalMsg] = useState("");
@@ -615,11 +616,15 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
@@ -703,6 +708,8 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
{errorModalMsg || '(Erro 404).Por favor, tente novamente mais tarde'}
+
+
diff --git a/src/data/sidebar-items.json b/src/data/sidebar-items.json
index 64efcad..81762b6 100644
--- a/src/data/sidebar-items.json
+++ b/src/data/sidebar-items.json
@@ -6,43 +6,43 @@
{
"name":"Início",
- "url": "Inicio",
+ "url": "/",
"icon": "house"
},
{
"name": "Cadastro de Pacientes",
- "url": "form-layout",
+ "url": "/pacientes/cadastro",
"icon": "heart-pulse-fill"
},
{
"name": "Cadastro do Médico",
- "url": "doctor-form-layout",
+ "url": "/medicos/cadastro",
"icon": "capsule"
},
{
"name": "Lista de Pacientes",
"icon": "clipboard-heart-fill",
- "url": "table"
+ "url": "/pacientes"
},
{
"name": "Lista de Médico",
"icon": "hospital-fill",
- "url": "doctor-table"
+ "url": "/medicos"
},
{
"name": "Agendar consulta",
"icon": "calendar-plus-fill",
- "url": "agendamento"
+ "url": "/agendamento"
},
{
"name": "Laudo do Paciente",
"icon": "table",
- "url": "laudo-manager"
+ "url": "/laudo"
}
]
\ No newline at end of file
diff --git a/src/pages/DoctorTable.jsx b/src/pages/DoctorTable.jsx
index b1cc213..549c37e 100644
--- a/src/pages/DoctorTable.jsx
+++ b/src/pages/DoctorTable.jsx
@@ -42,7 +42,7 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
useEffect(() => {
fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes")
.then((response) => response.json())
- .then((result) => setMedicos(result["data"]))
+ .then((result) => console.log('nada'))
.catch((error) =>
console.log("Erro para encontrar médicos no banco de dados", error)
);
diff --git a/src/pages/Inicio.jsx b/src/pages/Inicio.jsx
index 2edcfe0..dc47fae 100644
--- a/src/pages/Inicio.jsx
+++ b/src/pages/Inicio.jsx
@@ -11,7 +11,8 @@ function Inicio({ setCurrentPage }) {
try {
const res = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes");
const data = await res.json();
- setPacientes(data.data);
+ console.log(data)
+ //setPacientes(data.data);
} catch (error) {
console.error("Erro ao buscar pacientes:", error);
}
diff --git a/src/pages/Table.jsx b/src/pages/Table.jsx
deleted file mode 100644
index ff188fa..0000000
--- a/src/pages/Table.jsx
+++ /dev/null
@@ -1,353 +0,0 @@
-import React, { useState, useEffect } from "react";
-
-function TablePaciente({ setCurrentPage, setPatientID }) {
- const [showDeleteModal, setShowDeleteModal] = useState(false);
- const [deleteId, setDeleteId] = useState(null);
- const [pacientes, setPacientes] = useState([]);
- const [search, setSearch] = useState("");
- const [filtroConvenio, setFiltroConvenio] = useState("Todos");
- const [filtroVIP, setFiltroVIP] = useState(false);
- const [filtroAniversariante, setFiltroAniversariante] = useState(false);
-
- // Estado para controlar a exibição do erro 404
- const [showError404, setShowError404] = useState(false);
-
- const GetAnexos = async (id) => {
- var myHeaders = new Headers();
- myHeaders.append("Authorization", "Bearer
");
-
- var requestOptions = {
- method: 'GET',
- headers: myHeaders,
- redirect: 'follow'
- };
- try {
- const response = await fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}/anexos`, requestOptions);
- if (!response.ok) {
- setShowError404(true);
- setTimeout(() => setShowError404(false), 5000); // Esconde a mensagem após 5 segundos
- throw new Error('Erro 404');
- }
- const result = await response.json();
- return result.data;
- } catch (error) {
- console.log('error', error);
- return [];
- }
- }
-
- const DeleteAnexo = async (patientID) => {
- const RespostaGetAnexos = await GetAnexos(patientID);
- for (let i = 0; i < RespostaGetAnexos.length; i++) {
- const idAnexo = RespostaGetAnexos[i].id;
-
- var myHeaders = new Headers();
- myHeaders.append("Authorization", "Bearer ");
-
- var requestOptions = {
- method: 'DELETE',
- headers: myHeaders,
- redirect: 'follow'
- };
-
- fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos/${idAnexo}`, requestOptions)
- .then(response => {
- if (!response.ok) {
- setShowError404(true);
- setTimeout(() => setShowError404(false), 5000); // Esconde a mensagem após 5 segundos
- throw new Error('Erro 404');
- }
- return response.text();
- })
- .then(result => console.log('anexo excluido com sucesso', result))
- .catch(error => console.log('error', error));
- }
- }
-
- const handleDeleteClick = (id) => {
- setDeleteId(id);
- setShowDeleteModal(true);
- };
-
- const confirmDeletePatient = async () => {
- if (!deleteId) return;
- await DeleteAnexo(deleteId);
- const requestOptionsDelete = { method: "DELETE", redirect: "follow" };
- await fetch(
- `https://mock.apidog.com/m1/1053378-0-default/pacientes/${deleteId}`,
- requestOptionsDelete
- )
- .then((response) => {
- if (!response.ok) {
- setShowError404(true);
- setTimeout(() => setShowError404(false), 5000);
- throw new Error('Erro 404');
- }
- return response.text();
- })
- .then((mensage) => console.log(mensage))
- .catch((error) => console.log("Deu problema", error));
- setShowDeleteModal(false);
- setDeleteId(null);
- };
-
- const toggleVIP = async (id, atual) => {
- const novoStatus = atual === true ? false : true;
- await fetch(
- `https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`,
- {
- method: "PUT",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ vip: novoStatus }),
- }
- )
- .then((response) => {
- if (!response.ok) {
- setShowError404(true);
- setTimeout(() => setShowError404(false), 5000);
- throw new Error('Erro 404');
- }
- return response.json();
- })
- .then(() => {
- setPacientes((prev) =>
- prev.map((p) => (p.id === id ? { ...p, vip: novoStatus } : p))
- );
- })
- .catch((error) => console.log("Erro ao atualizar VIP:", error));
- };
-
-
- useEffect(() => {
- fetch("https://mock.apidog.com/m1053378-0-det/pacientes")
- .then((response) => {
- if (!response.ok) {
- setShowError404(true);
- setTimeout(() => setShowError404(false), 5000);
- throw new Error('Erro 404');
- }
- return response.json();
- })
- .then((result) => setPacientes(result["data"]))
- .catch((error) =>
- console.log("Erro para encontrar pacientes no banco de dados", error)
- );
- }, []);
-
- const ehAniversariante = (dataNascimento) => {
- if (!dataNascimento) return false;
- const hoje = new Date();
- const nascimento = new Date(dataNascimento);
- return (
- hoje.getDate() === nascimento.getDate() &&
- hoje.getMonth() === nascimento.getMonth()
- );
- };
-
- const pacientesFiltrados = pacientes.filter((paciente) => {
- const texto = `${paciente.nome}`.toLowerCase();
- const passaBusca = texto.includes(search.toLowerCase());
- const passaVIP = filtroVIP ? paciente.vip === true : true;
- const passaConvenio =
- filtroConvenio === "Todos" || paciente.convenio === filtroConvenio;
- const passaAniversario = filtroAniversariante
- ? ehAniversariante(paciente.data_nascimento)
- : true;
- return passaBusca && passaVIP && passaConvenio && passaAniversario;
- });
-
- return (
- <>
- {/* Modal de confirmação de exclusão */}
- {showDeleteModal && (
-
-
-
-
-
Confirmação de Exclusão
-
-
-
-
- Tem certeza que deseja excluir este paciente?
-
-
-
-
-
-
-
-
-
- )}
-
-
Lista de Pacientes
-
-
-
-
-
-
-
Pacientes Cadastrados
-
-
-
-
- {showError404 && (
-
- (Erro 404). Por favor, tente novamente mais tarde.
-
- )}
-
-
- Filtros
-
-
- setSearch(e.target.value)}
- style={{
- minWidth: 250,
- maxWidth: 300,
- width: 260,
- flex: "0 0 auto",
- }}
- />
-
-
-
-
-
-
-
-
-
- | Nome |
- CPF |
- Email |
- Telefone |
- Ações |
-
-
-
- {pacientesFiltrados.length > 0 ? (
- pacientesFiltrados.map((paciente) => (
-
- | {paciente.nome} |
- {paciente.cpf} |
- {paciente.email} |
- {paciente.telefone} |
-
-
- {paciente.ativo}
-
- |
-
-
-
-
-
-
- |
-
- ))
- ) : (
-
- |
- Nenhum paciente encontrado.
- |
-
- )}
-
-
-
-
-
-
-
-
- >
- );
-}
-
-export default TablePaciente;
\ No newline at end of file