From ca1f5409e057d90afa59634fc036396b46ed8bbd Mon Sep 17 00:00:00 2001 From: jp-lima Date: Fri, 19 Sep 2025 15:19:01 -0300 Subject: [PATCH 1/8] =?UTF-8?q?come=C3=A7o=20da=20estiliza=C3=A7=C3=A3o=20?= =?UTF-8?q?do=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgendarConsulta/FormNovaConsulta.jsx | 188 +++++++++++------- ...eagendamentos.css => formagendamentos.css} | 39 +++- .../style/styleTabelas/tabelasemana.css | 4 + src/pages/DoctorDetails.jsx | 2 +- 4 files changed, 154 insertions(+), 79 deletions(-) rename src/components/AgendarConsulta/style/{styleagendamentos.css => formagendamentos.css} (74%) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 6723e6c..1ce6f12 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -1,6 +1,6 @@ import React from "react"; import InputMask from "react-input-mask"; -import "./style/styleagendamentos.css"; +import "./style/formagendamentos.css"; const FormNovaConsulta = ({ onCancel }) => { const handleSubmit = (e) => { @@ -15,98 +15,132 @@ const FormNovaConsulta = ({ onCancel }) => {

Informações do paciente

-
- - +
+
+ + +
- - - {(inputProps) => } - +
+ + + {(inputProps) => } + +
- - +
+ + +
- - +
+
+ + +
- - - {(inputProps) => } - +
+ + + {(inputProps) => } + +
- - - - - - - - +
+ + +
+
+
+ +
+ + +
+
+ + +
+ +
- - {(inputProps) => } - + +
+

Informações adicionais

Informações do atendimento

+ +
+
+ + +
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Acessibilidade

-
- - - - +
+ + +
-
- +
+
+ +
+
+ + +
+ + + +
+ + +
+
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+
diff --git a/src/components/AgendarConsulta/style/styleagendamentos.css b/src/components/AgendarConsulta/style/formagendamentos.css similarity index 74% rename from src/components/AgendarConsulta/style/styleagendamentos.css rename to src/components/AgendarConsulta/style/formagendamentos.css index bcdc8db..d41eb61 100644 --- a/src/components/AgendarConsulta/style/styleagendamentos.css +++ b/src/components/AgendarConsulta/style/formagendamentos.css @@ -1,5 +1,5 @@ .form-container { - max-width: 800px; + /*max-width: 800px;*/ margin: 20px auto; padding: 25px; background: #f5f8ff; @@ -106,3 +106,40 @@ font-size: small; } +.campos-informacoes-paciente,.campo-informacoes-atendimento{ + display: flex; + gap: 10px; + flex-direction: row; +} + +.campo-de-input{ + display: flex; + flex-direction: column; + +} + + +#informacoes-atendimento-segunda-linha{ + margin-top: 10px; + display: flex; + flex-direction: row; + gap: rem; +} + +textarea{ + width: 30px; + resize: both; + +} + +#informacoes-atendimento-segunda-linha-esquerda input{ + width: 200px; +} + +input[type='text']{ + width: 600px; +} + +select[name='solicitante']{ + width: 300px; +} \ No newline at end of file diff --git a/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css b/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css index d2692d3..e890b6f 100644 --- a/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css +++ b/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css @@ -80,3 +80,7 @@ .tabelasemanal tr:hover { background-color: #f1f1f1 !important; } + +tr{ + width: 1000px; +} \ No newline at end of file diff --git a/src/pages/DoctorDetails.jsx b/src/pages/DoctorDetails.jsx index 25a26e4..c8b7726 100644 --- a/src/pages/DoctorDetails.jsx +++ b/src/pages/DoctorDetails.jsx @@ -111,7 +111,7 @@ const Details = ({ patientID, setCurrentPage }) => {
-

{paciente.anexos || "-"}

+

{ "-"}

From 8866ebedbf34b8c051d9d2ade921108edeac3ffd Mon Sep 17 00:00:00 2001 From: jp-lima Date: Sat, 20 Sep 2025 11:10:13 -0300 Subject: [PATCH 2/8] =?UTF-8?q?Final=20estiliza=C3=A7=C3=A3o=20do=20form?= =?UTF-8?q?=20de=20agendamento?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgendarConsulta/FormNovaConsulta.jsx | 1 + .../style/formagendamentos.css | 29 ++++++++--- src/pages/Agendamento.jsx | 51 ++++++++++++------- src/pages/style/Agendamento.css | 11 +++- 4 files changed, 67 insertions(+), 25 deletions(-) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 1ce6f12..120aa56 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -98,6 +98,7 @@ const FormNovaConsulta = ({ onCancel }) => {
diff --git a/src/components/AgendarConsulta/style/formagendamentos.css b/src/components/AgendarConsulta/style/formagendamentos.css index d41eb61..3684f90 100644 --- a/src/components/AgendarConsulta/style/formagendamentos.css +++ b/src/components/AgendarConsulta/style/formagendamentos.css @@ -123,7 +123,8 @@ margin-top: 10px; display: flex; flex-direction: row; - gap: rem; + gap: 4rem; + } textarea{ @@ -132,14 +133,30 @@ textarea{ } -#informacoes-atendimento-segunda-linha-esquerda input{ - width: 200px; +.campos-informacoes-paciente, +.campo-informacoes-atendimento { + display: flex; + gap: 16px; /* espaço entre campos */ } -input[type='text']{ - width: 600px; +.campo-de-input { + flex: 1; /* todos os filhos ocupam mesmo espaço */ + display: flex; + flex-direction: column; /* mantém label em cima do input */ } -select[name='solicitante']{ +#informacoes-atendimento-segunda-linha-esquerda select[name="unidade"]{ width: 300px; +} + +input[type="time"]{ + width: 150px; +} + +select[name=solicitante]{ + width: 190px; +} + +.campo-de-input{ + width:120% } \ No newline at end of file diff --git a/src/pages/Agendamento.jsx b/src/pages/Agendamento.jsx index 66349fd..0f68825 100644 --- a/src/pages/Agendamento.jsx +++ b/src/pages/Agendamento.jsx @@ -10,6 +10,11 @@ import "./style/Agendamento.css"; const Agendamento = () => { + const [FiladeEspera, setFiladeEspera] = useState(false) + const [tabela, setTabela] = useState('diario') + const [PageNovaConsulta, setPageConsulta] = useState(false) + + const ListarDiasdoMes = (ano, mes) => { let segundas = []; let tercas = []; let quartas = []; let quintas = []; let sextas = [] @@ -54,8 +59,6 @@ const Agendamento = () => { return ListaDiasDatas } - const [tabela, setTabela] = useState('diario') - const [PageNovaConsulta, setPageConsulta] = useState(false) const handleClickAgendamento = (agendamento) => { @@ -76,6 +79,7 @@ const Agendamento = () => {

Agendar nova consulta

+ {!PageNovaConsulta? (
@@ -106,25 +110,36 @@ const Agendamento = () => { -
+
+ + +
- - - +
+ +
+ + + +
+
+ +
+
@@ -142,6 +157,8 @@ const Agendamento = () => { Cancelado
+ + {tabela === "diario" && ( Date: Wed, 24 Sep 2025 10:35:37 -0300 Subject: [PATCH 3/8] =?UTF-8?q?Come=C3=A7o=20da=20fila=20de=20espera=20e?= =?UTF-8?q?=20icones=20de=20formulario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgendarConsulta/FormNovaConsulta.jsx | 51 +++++++++++++++++-- .../AgendarConsulta/TabelaAgendamentoMes.jsx | 10 ++-- .../style/formagendamentos.css | 25 ++++++++- .../style/styleTabelas/tabeladia.css | 7 +-- .../style/styleTabelas/tabelames.css | 6 +++ .../style/styleTabelas/tabelasemana.css | 12 +---- src/components/ProfileCard.js | 4 +- src/pages/Agendamento.jsx | 29 ++++++++--- src/pages/Table.jsx | 6 --- src/pages/style/Agendamento.css | 47 ++++++++++++++++- 10 files changed, 156 insertions(+), 41 deletions(-) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 120aa56..2dbd572 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -3,6 +3,40 @@ import InputMask from "react-input-mask"; import "./style/formagendamentos.css"; const FormNovaConsulta = ({ onCancel }) => { + + const BuscarCPFnoBancodeDados = (cpf) => { + + var myHeaders = new Headers(); + myHeaders.append("Authorization", "Bearer "); + myHeaders.append("Content-Type", "application/json"); + + var raw = JSON.stringify({ + "cpf": cpf + }); + + var requestOptions = { + method: 'POST', + headers: myHeaders, + body: raw, + redirect: 'follow' + }; + +fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requestOptions) + .then(response => response.text()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); + } + + const BuscarPacienteExistentePeloCPF = (value) => { + + if(isNaN(value[13]) === false){ + BuscarCPFnoBancodeDados(value) + } + //BuscarCPFnoBancodeDados(value) + + + } + const handleSubmit = (e) => { e.preventDefault(); alert("Agendamento salvo!"); @@ -23,8 +57,8 @@ const FormNovaConsulta = ({ onCancel }) => {
- - {(inputProps) => } + BuscarPacienteExistentePeloCPF(e.target.value)}> + {(inputProps) => }
@@ -98,7 +132,7 @@ const FormNovaConsulta = ({ onCancel }) => {
@@ -133,7 +167,15 @@ const FormNovaConsulta = ({ onCancel }) => {
- + +
+ accessible + elderly + pregnant_woman + child_care + accessibility_new +
+
@@ -145,6 +187,7 @@ const FormNovaConsulta = ({ onCancel }) => {
+
); }; diff --git a/src/components/AgendarConsulta/TabelaAgendamentoMes.jsx b/src/components/AgendarConsulta/TabelaAgendamentoMes.jsx index 924332f..55d8cf9 100644 --- a/src/components/AgendarConsulta/TabelaAgendamentoMes.jsx +++ b/src/components/AgendarConsulta/TabelaAgendamentoMes.jsx @@ -47,7 +47,7 @@ const TabelaAgendamentoMes = ({ListarDiasdoMes}) => { ))}
{dias.segunda.length > 3 ? -

+ {dias.segunda.length - 3}

+

+ {dias.segunda.length - 3}

: null}
@@ -65,7 +65,7 @@ const TabelaAgendamentoMes = ({ListarDiasdoMes}) => { ))} {dias.terca.length > 3 ? -

+ {dias.terca.length - 3}

+

+ {dias.terca.length - 3}

: null} @@ -83,7 +83,7 @@ const TabelaAgendamentoMes = ({ListarDiasdoMes}) => { ))} {dias.quarta.length > 3 ? -

+ {dias.quarta.length - 3}

+

+ {dias.quarta.length - 3}

: null} @@ -101,7 +101,7 @@ const TabelaAgendamentoMes = ({ListarDiasdoMes}) => { ))} {dias.quinta.length > 3 ? -

+ {dias.quinta.length - 3}

+

+ {dias.quinta.length - 3}

: null} @@ -119,7 +119,7 @@ const TabelaAgendamentoMes = ({ListarDiasdoMes}) => { ))} {dias.sexta.length > 3 ? -

+ {dias.sexta.length - 3}

+

+ {dias.sexta.length - 3}

: null} diff --git a/src/components/AgendarConsulta/style/formagendamentos.css b/src/components/AgendarConsulta/style/formagendamentos.css index 3684f90..7bb5276 100644 --- a/src/components/AgendarConsulta/style/formagendamentos.css +++ b/src/components/AgendarConsulta/style/formagendamentos.css @@ -1,3 +1,26 @@ +@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined'); + +.icons-container { + display: flex; + gap: 10px; +} + +.icon { + font-family: 'Material Symbols Outlined'; + font-size: 36px; + padding: 12px; + border: 1px solid #d1d5db; + border-radius: 12px; + display: flex; + align-items: center; + justify-content: center; + width: 56px; + height: 56px; + cursor: default; +} + + + .form-container { /*max-width: 800px;*/ margin: 20px auto; @@ -124,13 +147,11 @@ display: flex; flex-direction: row; gap: 4rem; - } textarea{ width: 30px; resize: both; - } .campos-informacoes-paciente, diff --git a/src/components/AgendarConsulta/style/styleTabelas/tabeladia.css b/src/components/AgendarConsulta/style/styleTabelas/tabeladia.css index bc1a179..a242ba0 100644 --- a/src/components/AgendarConsulta/style/styleTabelas/tabeladia.css +++ b/src/components/AgendarConsulta/style/styleTabelas/tabeladia.css @@ -51,8 +51,9 @@ font-weight: 600; padding: 8px; } -/* Ajuste para a classe .diadia, se for usada */ -.diadia { +/* Ajuste para a classe calendario, se for usada */ +/* +.calendario { margin-top: 20px; border-collapse: collapse; width: 100%; @@ -61,7 +62,7 @@ font-weight: 600; box-shadow: 0 4px 12px rgb(255, 255, 255); border: 10px solid #ffffffc5; background-color: rgb(253, 253, 253); -} +}*/ .mostrar-horario td, .mostrar-horario th { diff --git a/src/components/AgendarConsulta/style/styleTabelas/tabelames.css b/src/components/AgendarConsulta/style/styleTabelas/tabelames.css index 6df085d..fbce17b 100644 --- a/src/components/AgendarConsulta/style/styleTabelas/tabelames.css +++ b/src/components/AgendarConsulta/style/styleTabelas/tabelames.css @@ -147,4 +147,10 @@ padding: 4px 8px; margin-bottom: 5px; border-radius: 4px; +} + +.cards-que-faltam{ + color: #005a9e; + font-weight: bold; + font-size: larger; } \ No newline at end of file diff --git a/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css b/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css index e890b6f..70cdeef 100644 --- a/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css +++ b/src/components/AgendarConsulta/style/styleTabelas/tabelasemana.css @@ -56,17 +56,7 @@ padding: 12px; } -/* Ajuste para a classe .diadia, se for usada */ -.diadia { - margin-top: 20px; - border-collapse: collapse; - width: 100%; - border-radius: 10px; - overflow: hidden; - box-shadow: 0 4px 12px rgb(255, 255, 255); - border: 10px solid #ffffffc5; - background-color: rgb(253, 253, 253); -} +/* Ajuste para a classe .calendario, se for usada */ .tabelasemanal tr:nth-child(even) { background-color: #e7e7e7a6 !important; diff --git a/src/components/ProfileCard.js b/src/components/ProfileCard.js index 64b88b2..7a5b181 100644 --- a/src/components/ProfileCard.js +++ b/src/components/ProfileCard.js @@ -1,4 +1,4 @@ -import React from 'react'; +/*import React from 'react'; function ProfileCard() { return ( @@ -18,4 +18,4 @@ function ProfileCard() { ); } -export default ProfileCard; \ No newline at end of file +export default ProfileCard;*/ \ No newline at end of file diff --git a/src/pages/Agendamento.jsx b/src/pages/Agendamento.jsx index 0f68825..b008dc0 100644 --- a/src/pages/Agendamento.jsx +++ b/src/pages/Agendamento.jsx @@ -112,13 +112,20 @@ const Agendamento = () => { +
+ + +
+ +
+ {FiladeEspera ===false ? -
+
-
+
-
- -
-
-
+
Realizado @@ -157,6 +160,10 @@ const Agendamento = () => { Cancelado
+ +
+ + @@ -179,7 +186,15 @@ const Agendamento = () => { )}
+
: + +
+
+
+ + } +
) : ( diff --git a/src/pages/Table.jsx b/src/pages/Table.jsx index 1ad96dd..a5eb050 100644 --- a/src/pages/Table.jsx +++ b/src/pages/Table.jsx @@ -29,8 +29,6 @@ function TablePaciente({ setCurrentPage, setPatientID }) { } - - const DeleteAnexo = async (patientID) => { @@ -66,12 +64,8 @@ function TablePaciente({ setCurrentPage, setPatientID }) { // Função para excluir paciente const deletePatient = async (id) => { - DeleteAnexo(id) - - - const requestOptionsDelete = { method: "DELETE", redirect: "follow" }; if (!window.confirm("Tem certeza que deseja excluir este paciente?")) return; diff --git a/src/pages/style/Agendamento.css b/src/pages/style/Agendamento.css index 06fb555..3bb469a 100644 --- a/src/pages/style/Agendamento.css +++ b/src/pages/style/Agendamento.css @@ -93,6 +93,7 @@ margin-top: 30px; margin-bottom: 10px; gap: 15px; + justify-content: flex-end; } .legenda-item-realizado{ @@ -143,9 +144,53 @@ border-radius: 10px; } -.botões-container{ +.btns-e-legenda-container{ display: flex; justify-content: space-between; + flex-direction: row; + margin-top: 10px; +} + + +.calendario { + + border-collapse: collapse; + width: 100%; + border-radius: 10px; + overflow: hidden; + box-shadow: 0 4px 12px rgb(255, 255, 255); + border: 10px solid #ffffffc5; + background-color: rgb(253, 253, 253); +} + + + +.calendario-ou-filaespera{ + margin-top: 0; +} + +.container-btns-agenda-fila_esepera{ + margin-top: 30px; + display: flex; + flex-direction: row; + gap: 20px; + margin-left:20px ; + +} + +.btn-fila-espera, .btn-agenda{ + background-color: transparent; + border: 0px ; + border-bottom: 3px solid rgb(253, 253, 253); + padding: 8px; + border-radius: 10px 10px 0px 0px; + font-weight: bold; + +} + +.opc-filaespera-ativo, .opc-agenda-ativo{ + color: white; + background-color: #5980fd; } \ No newline at end of file From f37865d251102608b8e0b16efbe51a030f5bfc22 Mon Sep 17 00:00:00 2001 From: jp-lima Date: Wed, 24 Sep 2025 14:59:57 -0300 Subject: [PATCH 4/8] Icones acessibilidade --- .../AgendarConsulta/FormNovaConsulta.jsx | 68 +++++++++++++++---- .../style/formagendamentos.css | 47 ++++++++++--- 2 files changed, 92 insertions(+), 23 deletions(-) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 2dbd572..6a0e5dd 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -1,8 +1,26 @@ import React from "react"; import InputMask from "react-input-mask"; import "./style/formagendamentos.css"; +import { useState } from "react"; + const FormNovaConsulta = ({ onCancel }) => { + + const [acessibilidade, setAcessibilidade] = useState({cadeirante:false,idoso:false,gravida:false,bebe:false, autista:false }) + const handleclickAcessibilidade = (id) => { + let resultado = acessibilidade[id] + + if(resultado === false){ setAcessibilidade({...acessibilidade, [id]:true}); console.log('mudou')} + + else if(resultado === true){ setAcessibilidade({...acessibilidade, [id]:false})} + + + + + + console.log(id) + + } const BuscarCPFnoBancodeDados = (cpf) => { @@ -112,7 +130,35 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requ

Informações do atendimento

+ +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + + accessible +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + elderly +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + pregnant_woman +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + + +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + +
+ +
+
+
@@ -167,19 +213,15 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requ
- -
- accessible - elderly - pregnant_woman - child_care - accessibility_new -
- -
- - -
+ +
+ + +
+ + +
+
diff --git a/src/components/AgendarConsulta/style/formagendamentos.css b/src/components/AgendarConsulta/style/formagendamentos.css index 7bb5276..afb1403 100644 --- a/src/components/AgendarConsulta/style/formagendamentos.css +++ b/src/components/AgendarConsulta/style/formagendamentos.css @@ -3,23 +3,50 @@ .icons-container { display: flex; gap: 10px; + justify-content: flex-end; + margin-bottom: -7px; } -.icon { - font-family: 'Material Symbols Outlined'; - font-size: 36px; - padding: 12px; - border: 1px solid #d1d5db; - border-radius: 12px; +.acessibilidade-ativado{ + background-color: #1e3a8a; + border: none; +} +.acessibilidade-ativado svg, .acessibilidade-ativado .icon{ + color: white; +} + + +.icons-div{ + border: 1px solid #607080; + padding: 10px; display: flex; align-items: center; justify-content: center; - width: 56px; - height: 56px; - cursor: default; + height: 40px; + width: 40px; + border-radius: 10px; + cursor: pointer; + transition: 0.3s; } +.icons-div:hover{ + background-color: #1e3a8a; + } + .icons-div:hover svg, .icons-div:hover .icon{ + color:white; + } +svg{ + color:black; + +} +.icon { + font-family: 'Material Symbols Outlined'; + font-size: 20px; + color:black + + +} .form-container { /*max-width: 800px;*/ @@ -180,4 +207,4 @@ select[name=solicitante]{ .campo-de-input{ width:120% -} \ No newline at end of file +} From cdc6d39f779b5a89fc5cf79dc6038c3747cefdec Mon Sep 17 00:00:00 2001 From: jp-lima Date: Wed, 24 Sep 2025 16:25:38 -0300 Subject: [PATCH 5/8] =?UTF-8?q?Come=C3=A7o=20da=20funcionalidade=20de=20CP?= =?UTF-8?q?F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgendarConsulta/FormNovaConsulta.jsx | 113 ++++++++++++------ src/pages/PatientCadastroManager.jsx | 2 +- src/pages/Table.jsx | 43 +------ 3 files changed, 76 insertions(+), 82 deletions(-) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 6a0e5dd..7d9f116 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -13,16 +13,27 @@ const FormNovaConsulta = ({ onCancel }) => { if(resultado === false){ setAcessibilidade({...acessibilidade, [id]:true}); console.log('mudou')} else if(resultado === true){ setAcessibilidade({...acessibilidade, [id]:false})} - - - - - console.log(id) - } - const BuscarCPFnoBancodeDados = (cpf) => { + + const FormatCPF = (valor) => { + + + console.log(valor) + + const digits = String(valor).replace(/\D/g, '').slice(0, 11); + BuscarPacienteExistentePeloCPF(valor) + + return digits + .replace(/(\d{3})(\d)/, '$1.$2') + .replace(/(\d{3})(\d)/, '$1.$2') + .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); + + } + + + const BuscarCPFnoBancodeDados = async (cpf) => { var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer "); @@ -39,17 +50,41 @@ const FormNovaConsulta = ({ onCancel }) => { redirect: 'follow' }; -fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requestOptions) - .then(response => response.text()) - .then(result => console.log(result)) - .catch(error => console.log('error', error)); + const response = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requestOptions); + const result = await response.json(); + return result + + } - const BuscarPacienteExistentePeloCPF = (value) => { + const BuscarPacienteExistentePeloCPF = async (value) => { - if(isNaN(value[13]) === false){ - BuscarCPFnoBancodeDados(value) - } + if(isNaN(value[13]) === false && value.length === 14)try { + const result = await BuscarCPFnoBancodeDados(value); + console.log("Resultado:", result); + + if (result.data.existe === true){ + + var myHeaders = new Headers(); + myHeaders.append("Authorization", "Bearer "); + + var requestOptions = { + method: 'GET', + headers: myHeaders, + redirect: 'follow' + }; + + fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions) + .then(response => response.json()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); + } + + + + } catch (error) { + console.log("error", error); + } //BuscarCPFnoBancodeDados(value) @@ -75,9 +110,9 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requ
- BuscarPacienteExistentePeloCPF(e.target.value)}> - {(inputProps) => } - + + e.target.value = FormatCPF(e.target.value)} /> +
@@ -132,30 +167,30 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requ
- -
handleclickAcessibilidade(e.currentTarget.id)}> + +
handleclickAcessibilidade(e.currentTarget.id)}> + + accessible +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + elderly +
- accessible -
+
handleclickAcessibilidade(e.currentTarget.id)}> + pregnant_woman +
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + -
handleclickAcessibilidade(e.currentTarget.id)}> - elderly -
- -
handleclickAcessibilidade(e.currentTarget.id)}> - pregnant_woman -
+
+ +
handleclickAcessibilidade(e.currentTarget.id)}> + +
-
handleclickAcessibilidade(e.currentTarget.id)}> - - -
- -
handleclickAcessibilidade(e.currentTarget.id)}> - -
- -
+
diff --git a/src/pages/PatientCadastroManager.jsx b/src/pages/PatientCadastroManager.jsx index 7653975..05d14be 100644 --- a/src/pages/PatientCadastroManager.jsx +++ b/src/pages/PatientCadastroManager.jsx @@ -31,7 +31,7 @@ function PatientCadastroManager( {setCurrentPage} ) { .then(result => console.log(result)) .catch(error => console.log('error', error)); - alert(`Paciente "${patientData.nome}" salvo com sucesso!`); //altere isso para integração com backend + alert(`Paciente "${patientData.nome}" !`); //altere isso para integração com backend // Após salvar, voltamos para a tela de lista }; diff --git a/src/pages/Table.jsx b/src/pages/Table.jsx index a5eb050..bfc0e06 100644 --- a/src/pages/Table.jsx +++ b/src/pages/Table.jsx @@ -59,9 +59,6 @@ function TablePaciente({ setCurrentPage, setPatientID }) { } - - - // Função para excluir paciente const deletePatient = async (id) => { DeleteAnexo(id) @@ -79,45 +76,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) { .catch((error) => console.log("Deu problema", error)); }; - // Função para marcar/desmarcar VIP - 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) => response.json()) - .then(() => { - setPacientes((prev) => - prev.map((p) => (p.id === id ? { ...p, vip: novoStatus } : p)) - ); - }) - .catch((error) => console.log("Erro ao atualizar VIP:", error)); - }; - - // Função para atualizar convênio/particular - const updateConvenio = async (id, convenio) => { - await fetch( - `https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, - { - method: "PUT", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ convenio }), - } - ) - .then((response) => response.json()) - .then(() => { - setPacientes((prev) => - prev.map((p) => (p.id === id ? { ...p, convenio } : p)) - ); - }) - .catch((error) => console.log("Erro ao atualizar convênio:", error)); - }; + // Requisição inicial para buscar pacientes useEffect(() => { From 7115012c4b97572518273b3a61df78eb079158ac Mon Sep 17 00:00:00 2001 From: jp-lima Date: Wed, 24 Sep 2025 18:54:26 -0300 Subject: [PATCH 6/8] =?UTF-8?q?Finaliza=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgendarConsulta/FormNovaConsulta.jsx | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 7d9f116..a3eb650 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -5,7 +5,7 @@ import { useState } from "react"; const FormNovaConsulta = ({ onCancel }) => { - + const [paciente, setPaciente] = useState({}) const [acessibilidade, setAcessibilidade] = useState({cadeirante:false,idoso:false,gravida:false,bebe:false, autista:false }) const handleclickAcessibilidade = (id) => { let resultado = acessibilidade[id] @@ -18,8 +18,6 @@ const FormNovaConsulta = ({ onCancel }) => { const FormatCPF = (valor) => { - - console.log(valor) const digits = String(valor).replace(/\D/g, '').slice(0, 11); @@ -29,7 +27,6 @@ const FormNovaConsulta = ({ onCancel }) => { .replace(/(\d{3})(\d)/, '$1.$2') .replace(/(\d{3})(\d)/, '$1.$2') .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); - } @@ -76,7 +73,7 @@ const FormNovaConsulta = ({ onCancel }) => { fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions) .then(response => response.json()) - .then(result => console.log(result)) + .then(result => setPaciente(result.data)) .catch(error => console.log('error', error)); } @@ -86,8 +83,23 @@ const FormNovaConsulta = ({ onCancel }) => { console.log("error", error); } //BuscarCPFnoBancodeDados(value) + } - + const handleChange = (e) => { + + const {value, name} = e.target; + + console.log(value, name) + + if(name === 'email'){ + setPaciente({...paciente, contato:{ + ...paciente.contato, + email:value + }}) + + }else{ + setPaciente({...paciente,[name]:value}) + } } const handleSubmit = (e) => { @@ -105,13 +117,13 @@ const FormNovaConsulta = ({ onCancel }) => {
- +
- e.target.value = FormatCPF(e.target.value)} /> + e.target.value = FormatCPF(e.target.value)} />
@@ -124,7 +136,7 @@ const FormNovaConsulta = ({ onCancel }) => {
- +
@@ -136,7 +148,7 @@ const FormNovaConsulta = ({ onCancel }) => {
- +
@@ -213,7 +225,7 @@ const FormNovaConsulta = ({ onCancel }) => {
@@ -241,7 +253,7 @@ const FormNovaConsulta = ({ onCancel }) => {
From ae5988997e38c688cb0e0d6bd9a3d90f9e457d48 Mon Sep 17 00:00:00 2001 From: Caio Miguel Lima Nunes Date: Wed, 24 Sep 2025 18:57:18 -0300 Subject: [PATCH 7/8] Adicionado o modal no codigo --- src/components/doctors/DoctorForm.jsx | 173 +++++------------------- src/components/patients/PatientForm.jsx | 51 +++++-- src/pages/DoctorCadastroManager.jsx | 42 ++++-- src/pages/PatientCadastroManager.jsx | 3 +- 4 files changed, 110 insertions(+), 159 deletions(-) diff --git a/src/components/doctors/DoctorForm.jsx b/src/components/doctors/DoctorForm.jsx index 7255942..c7e8242 100644 --- a/src/components/doctors/DoctorForm.jsx +++ b/src/components/doctors/DoctorForm.jsx @@ -124,6 +124,9 @@ function DoctorForm({ onSave, onCancel, PatientDict }) { }; // Função para buscar endereço pelo CEP + const [showModal, setShowModal] = useState(false); + const [modalMsg, setModalMsg] = useState(''); + const handleCepBlur = async () => { const cep = formData.cep.replace(/\D/g, ''); if (cep.length === 8) { @@ -139,17 +142,20 @@ function DoctorForm({ onSave, onCancel, PatientDict }) { estado: data.uf || '' })); } else { - alert('CEP não encontrado!'); + setModalMsg('CEP não encontrado!'); + setShowModal(true); } } catch (error) { - alert('Erro ao buscar o CEP.'); + setModalMsg('Erro ao buscar o CEP.'); + setShowModal(true); } } }; const handleSubmit = () => { - if (!formData.nome || !formData.cpf || !formData.genero || !formData.dataNascimento || !formData.email) { - alert('Por favor, preencha: Nome ,CPF, Gênero, Data de Nascimento e Email.'); + if (!formData.nome || !formData.cpf || !formData.genero || !formData.dataNascimento ) { + setModalMsg('Por favor, preencha: Nome, CPF, Gênero, Data de Nascimento.'); + setShowModal(true); return; } @@ -180,9 +186,31 @@ function DoctorForm({ onSave, onCancel, PatientDict }) { } } ); + setModalMsg('Médico salvo com sucesso!'); + setShowModal(true); }; return ( + <> + {/* Modal de feedback */} + {showModal && ( +
+
+
+
+
Atenção
+ +
+
+

{modalMsg}

+
+
+ +
+
+
+
+ )}

MediConnect

@@ -247,7 +275,7 @@ function DoctorForm({ onSave, onCancel, PatientDict }) {
- +
@@ -406,11 +434,11 @@ function DoctorForm({ onSave, onCancel, PatientDict }) {
- +
- +
@@ -434,137 +462,10 @@ function DoctorForm({ onSave, onCancel, PatientDict }) { Cancelar
+
- //
- //

MediConnect

- - // {/* ------------------ DADOS PESSOAIS ------------------ */} - //
Dados Pessoais
- //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- - // {/* ------------------ ENDEREÇO ------------------ */} - //
Endereço
- //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- - // {/* ------------------ CONTATO ------------------ */} - //
Contato
- //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- // - // - //
- //
- - // {/* ------------------ INFORMAÇÕES ADICIONAIS ------------------ */} - //
Informações Adicionais
- //
- // - // - //
- - // {/* Botões */} - //
- // - // - //
- //
+ ); } - export default DoctorForm; diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index 673a405..58352a8 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -2,6 +2,10 @@ import React, { useState, useEffect } from 'react'; function PatientForm({ onSave, onCancel,formData, setFormData }) { + // Estado para controlar modal de feedback + const [showMessage, setShowMessage] = useState(false); + const [message, setMessage] = useState(''); + const [messageType, setMessageType] = useState('success'); // 'success' ou 'danger' const FormatTelefones = (valor) => { const digits = String(valor).replace(/\D/g, '').slice(0, 11); @@ -169,18 +173,20 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) { const handleSubmit = async () => { if (!formData.nome || !formData.cpf || !formData.sexo || !formData.data_nascimento){ - alert('Por favor, preencha Nome ,CPF, Gênero e data de nascimento.'); + setMessage('Por favor, preencha: Nome, CPF, Gênero, Data de Nascimento .'); + setMessageType('danger'); + setShowMessage(true); return; } - const CPFinvalido = await ValidarCPF(formData.cpf) - console.log(CPFinvalido) + const CPFinvalido = await ValidarCPF(formData.cpf); if(CPFinvalido[0] === true){ - alert(CPFinvalido[1]) - return + setMessage(CPFinvalido[1]); + setMessageType('danger'); + setShowMessage(true); + return; } - onSave({ ...formData, endereco: { @@ -214,10 +220,39 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) { pacienteVip: formData.pacienteVip, }, }); + setMessage('Paciente salvo com sucesso!'); + setMessageType('success'); + setShowMessage(true); }; return ( -
+
+ {/* Modal de feedback */} + {showMessage && ( +
+ )} + {showMessage && ( +
+
+
+
+
+ {messageType === 'danger' ? 'Atenção' : 'Sucesso'} +
+ +
+
+ {message} +
+
+ +
+
+
+
+ )}

MediConnect

{/* DADOS PESSOAIS */} @@ -281,7 +316,7 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
- +
diff --git a/src/pages/DoctorCadastroManager.jsx b/src/pages/DoctorCadastroManager.jsx index 3a928c4..3976e53 100644 --- a/src/pages/DoctorCadastroManager.jsx +++ b/src/pages/DoctorCadastroManager.jsx @@ -12,6 +12,10 @@ function DoctorCadastroManager( ) { var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); + // Estado do modal de sucesso + const [showModal, setShowModal] = useState(false); + const [modalMsg, setModalMsg] = useState(''); + // Função que será chamada para "salvar" o paciente const handleSavePatient = (patientData) => { console.log('Salvando médico:', patientData); @@ -23,32 +27,45 @@ function DoctorCadastroManager( ) { header: myHeaders, body:raw, redirect:'follow' - } + fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes", requestOptions) + .then(response => response.text()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); - fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes", requestOptions) - .then(response => response.text()) - .then(result => console.log(result)) - .catch(error => console.log('error', error)); - - alert(`Médico "${patientData.nome}" salvo com sucesso!`); //altere isso para integração com backend - // Após salvar, voltamos para a tela de lista + setModalMsg(`Médico "${patientData.nome}" salvo com sucesso!`); + setShowModal(true); setView('list'); }; return ( <> + {/* Modal de feedback */} + {showModal && ( +
+
+
+
+
Sucesso
+ +
+
+

{modalMsg}

+
+
+ +
+
+
+
+ )}

Cadastro de Médicos

- {/* Aqui está a lógica principal: */} - {/* Se a view for 'list', mostramos a lista com o botão. */} - {/* Se for 'form', mostramos o formulário de cadastro. */} - {view === 'list' ? ( setView('form')} /> ) : ( @@ -56,7 +73,6 @@ function DoctorCadastroManager( ) { onSave={handleSavePatient} onCancel={() => setView('list')} PatientDict={{}} - /> )}
diff --git a/src/pages/PatientCadastroManager.jsx b/src/pages/PatientCadastroManager.jsx index 7653975..832eb93 100644 --- a/src/pages/PatientCadastroManager.jsx +++ b/src/pages/PatientCadastroManager.jsx @@ -30,8 +30,7 @@ function PatientCadastroManager( {setCurrentPage} ) { .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); - - alert(`Paciente "${patientData.nome}" salvo com sucesso!`); //altere isso para integração com backend + ; //altere isso para integração com backend // Após salvar, voltamos para a tela de lista }; From 54625235d5a93f215e4219126c36a81faafecc67 Mon Sep 17 00:00:00 2001 From: jp-lima Date: Thu, 25 Sep 2025 10:47:18 -0300 Subject: [PATCH 8/8] =?UTF-8?q?melhorar=20organiza=C3=A7=C3=A3o=20e=20adi?= =?UTF-8?q?=C3=A7=C3=A3o=20de=20modal=20para=20excluir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 6 +- src/components/doctors/DoctorList.jsx | 20 -- src/components/patients/PatientForm.jsx | 4 +- src/components/patients/PatientList.jsx | 20 -- src/pages/DoctorCadastroManager.jsx | 14 +- src/pages/DoctorTable.jsx | 87 +++++-- src/pages/EditPage.jsx | 22 +- src/pages/PatientCadastroManager.jsx | 6 +- src/pages/Table.jsx | 295 ------------------------ 9 files changed, 95 insertions(+), 379 deletions(-) delete mode 100644 src/components/doctors/DoctorList.jsx delete mode 100644 src/components/patients/PatientList.jsx delete mode 100644 src/pages/Table.jsx diff --git a/src/App.js b/src/App.js index 3d45098..8d5862b 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import Sidebar from './components/Sidebar'; //import Header from './components/Header'; -import Table from "./pages/Table"; +import TablePaciente from "./pages/TablePaciente"; import Inicio from './pages/Inicio'; import PatientCadastroManager from './pages/PatientCadastroManager'; @@ -34,7 +34,7 @@ function App() { case 'doctor-form-layout': return ; case 'table': - return ; + return ; case 'doctor-table': return ; case 'details-page-paciente': @@ -42,7 +42,7 @@ function App() { case 'details-page-doctor': return ; case 'edit-page-paciente': - return ; + return ; case 'edit-page-doctor': return ; case 'laudo-manager': diff --git a/src/components/doctors/DoctorList.jsx b/src/components/doctors/DoctorList.jsx deleted file mode 100644 index 570e598..0000000 --- a/src/components/doctors/DoctorList.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; - -// Este componente recebe uma função 'onAddDoctor' para avisar que o botão foi clicado -function DoctorList({ onAddPatient }) { - return ( -
-
-

Médicos

-
-
-

Gerencie os médicos cadastrados no sistema.

- -
-
- ); -} - -export default DoctorList; \ No newline at end of file diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index 04cf897..6f23523 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; -function PatientForm({ onSave, onCancel,formData, setFormData }) { +function PatientForm({ onSave, onCancel,formData, setFormData,setCurrentPage }) { // Estado para controlar modal de feedback const [showMessage, setShowMessage] = useState(false); @@ -296,7 +296,7 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) { {message}
-
diff --git a/src/components/patients/PatientList.jsx b/src/components/patients/PatientList.jsx deleted file mode 100644 index 1619828..0000000 --- a/src/components/patients/PatientList.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; - -// Este componente recebe uma função 'onAddPatient' para avisar que o botão foi clicado -function PatientList({ onAddPatient }) { - return ( -
-
-

Pacientes

-
-
-

Gerencie os pacientes cadastrados no sistema.

- -
-
- ); -} - -export default PatientList; \ No newline at end of file diff --git a/src/pages/DoctorCadastroManager.jsx b/src/pages/DoctorCadastroManager.jsx index 3976e53..5c9d802 100644 --- a/src/pages/DoctorCadastroManager.jsx +++ b/src/pages/DoctorCadastroManager.jsx @@ -1,12 +1,12 @@ import React, { useState } from 'react'; // Importamos os dois novos componentes que criamos -import DoctorList from '../components/doctors/DoctorList'; + import DoctorForm from '../components/doctors/DoctorForm'; function DoctorCadastroManager( ) { // Este estado vai controlar qual "tela" mostrar: 'list' (lista) ou 'form' (formulário) - const [view, setView] = useState('form'); + var myHeaders = new Headers(); @@ -36,7 +36,7 @@ function DoctorCadastroManager( ) { setModalMsg(`Médico "${patientData.nome}" salvo com sucesso!`); setShowModal(true); - setView('list'); + }; return ( @@ -66,15 +66,13 @@ function DoctorCadastroManager( ) {
- {view === 'list' ? ( - setView('form')} /> - ) : ( + setView('list')} + onCancel={console.log('hsh')} PatientDict={{}} /> - )} +
diff --git a/src/pages/DoctorTable.jsx b/src/pages/DoctorTable.jsx index b834137..80774b9 100644 --- a/src/pages/DoctorTable.jsx +++ b/src/pages/DoctorTable.jsx @@ -5,19 +5,25 @@ function TableDoctor({ setCurrentPage, setPatientID }) { const [search, setSearch] = useState(""); const [filtroAniversariante, setFiltroAniversariante] = useState(false); + // estados do modal + const [showDeleteModal, setShowDeleteModal] = useState(false); + const [selectedDoctorId, setSelectedDoctorId] = useState(null); + // Função para excluir médicos const deleteDoctor = async (id) => { const requestOptionsDelete = { method: "DELETE", redirect: "follow" }; - if (!window.confirm("Tem certeza que deseja excluir este médico?")) return; - - await fetch( - `https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, - requestOptionsDelete - ) - .then((response) => response.text()) - .then((mensage) => console.log(mensage)) - .catch((error) => console.log("Deu problema", error)); + try { + await fetch( + `https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, + requestOptionsDelete + ); + setMedicos((prev) => prev.filter((m) => m.id !== id)); + } catch (error) { + console.log("Deu problema", error); + } finally { + setShowDeleteModal(false); + } }; // Função para verificar se hoje é aniversário @@ -60,7 +66,6 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
-

Médicos Cadastrados

@@ -105,7 +108,7 @@ function TableDoctor({ setCurrentPage, setPatientID }) { - + @@ -130,7 +133,7 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
Email Telefone Ações
- + {/* Ver Detalhes */} + @@ -189,6 +197,55 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
+ + {/* Modal de confirmação de exclusão */} + {showDeleteModal && ( +
+ e.target.classList.contains("modal") && setShowDeleteModal(false) + } + > +
+
+
+
Confirmação de Exclusão
+ +
+
+

+ Tem certeza que deseja excluir este médico? +

+
+
+ + +
+
+
+
+ )} ); } diff --git a/src/pages/EditPage.jsx b/src/pages/EditPage.jsx index b706ef9..1b94620 100644 --- a/src/pages/EditPage.jsx +++ b/src/pages/EditPage.jsx @@ -4,7 +4,7 @@ import PatientForm from '../components/patients/PatientForm' import {useEffect, useState} from 'react' -const EditPage = ( {id}) => { +const EditPage = ( {id, setCurrentPage}) => { const [PatientToPUT, setPatientPUT] = useState({}) @@ -22,9 +22,10 @@ fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, requestOpt .then(data => setPatientPUT(data)) .catch(error => console.log('error', error)); -}, []) +}, [id,requestOptions]) + const HandlePutPatient = async () => { - //alert(`Atualizando paciente "${PatientToPUT.nome}" com sucesso`); + var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer "); @@ -50,26 +51,23 @@ const HandlePutPatient = async () => { // se o backend retorna JSON const result = await response.json(); console.log("ATUALIZADO COM SUCESSO", result); - - return result; // <- importante! + + return result; } catch (error) { console.error("Erro ao atualizar paciente:", error); throw error; } + + }; - - return ( -
- - {setCurrentPage('table')}} + setCurrentPage={setCurrentPage} formData={PatientToPUT} setFormData={setPatientPUT} /> diff --git a/src/pages/PatientCadastroManager.jsx b/src/pages/PatientCadastroManager.jsx index 339d3b9..8a2fab8 100644 --- a/src/pages/PatientCadastroManager.jsx +++ b/src/pages/PatientCadastroManager.jsx @@ -1,11 +1,8 @@ -import { useState } from 'react'; - - +import {useState} from 'react'; import PatientForm from '../components/patients/PatientForm'; function PatientCadastroManager( {setCurrentPage} ) { - const [formData, setFormData] = useState({}) var myHeaders = new Headers(); @@ -30,6 +27,7 @@ function PatientCadastroManager( {setCurrentPage} ) { const response = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes", requestOptions); const result = await response.json(); console.log("Paciente salvo no backend:", result); + setCurrentPage('table') return result; } catch (error) { console.error("Erro ao salvar paciente:", error); diff --git a/src/pages/Table.jsx b/src/pages/Table.jsx deleted file mode 100644 index bfc0e06..0000000 --- a/src/pages/Table.jsx +++ /dev/null @@ -1,295 +0,0 @@ -import React, { useState, useEffect } from "react"; - -function TablePaciente({ setCurrentPage, setPatientID }) { - const [pacientes, setPacientes] = useState([]); - const [search, setSearch] = useState(""); - const [filtroConvenio, setFiltroConvenio] = useState("Todos"); - const [filtroVIP, setFiltroVIP] = useState(false); - const [filtroAniversariante, setFiltroAniversariante] = 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); - const result = await response.json(); - - return result.data; // agora retorna corretamente - } 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; - - console.log('anexos',RespostaGetAnexos) - - - 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 => response.text()) - .then(result => console.log('anexo excluido com sucesso',result)) - .catch(error => console.log('error', error)); - - } - - } - - // Função para excluir paciente - const deletePatient = async (id) => { - DeleteAnexo(id) - - const requestOptionsDelete = { method: "DELETE", redirect: "follow" }; - - if (!window.confirm("Tem certeza que deseja excluir este paciente?")) return; - - await fetch( - `https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, - requestOptionsDelete - ) - .then((response) => response.text()) - .then((mensage) => console.log(mensage)) - .catch((error) => console.log("Deu problema", error)); - }; - - - - // Requisição inicial para buscar pacientes - useEffect(() => { - fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes") - .then((response) => response.json()) - .then((result) => setPacientes(result["data"])) - .catch((error) => - console.log("Erro para encontrar pacientes no banco de dados", error) - ); - }, []); - - // Função para verificar se hoje é aniversário do paciente - 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 ( - <> -
-

Lista de Pacientes

-
-
-
-
-
-
-

Pacientes Cadastrados

- -
- -
-
-
- Filtros -
- -
- setSearch(e.target.value)} - style={{ - minWidth: 250, - maxWidth: 300, - width: 260, - flex: "0 0 auto", - }} - /> - - - - - - -
-
- - -
- - - - - - - - - - - {pacientesFiltrados.length > 0 ? ( - pacientesFiltrados.map((paciente) => ( - - - - - - - - - )) - ) : ( - - - - )} - -
NomeCPFEmailTelefone
{paciente.nome}{paciente.cpf}{paciente.email}{paciente.telefone} - - {paciente.ativo} - - -
- - - - - - - -
-
- Nenhum paciente encontrado. -
-
-
-
-
-
-
- - ); -} - -export default TablePaciente;