From b09b29c77daf97f20290ed84ed80431734c07ae1 Mon Sep 17 00:00:00 2001 From: Caio Miguel Lima Nunes Date: Thu, 25 Sep 2025 20:23:34 -0300 Subject: [PATCH] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20no=20codigo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgendarConsulta/FormNovaConsulta.jsx | 27 +++++-- .../style/formagendamentos.css | 17 ++++- src/components/doctors/DoctorForm.jsx | 14 ++-- src/components/patients/PatientForm.jsx | 41 ++++++++--- src/pages/DoctorTable.jsx | 6 +- src/pages/PatientCadastroManager.jsx | 4 +- src/pages/Table.jsx | 72 ++++++++++--------- 7 files changed, 119 insertions(+), 62 deletions(-) diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 53f63c7..435bc8e 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -1,4 +1,3 @@ - import InputMask from "react-input-mask"; import "./style/formagendamentos.css"; import { useState, useEffect } from "react"; @@ -77,6 +76,16 @@ const FormNovaConsulta = ({ onCancel, patientID }) => { .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); } + + const FormatTelefones = (valor) => { + const digits = String(valor).replace(/\D/g, '').slice(0, 11); + return digits + .replace(/(\d)/, '($1') + .replace(/(\d{2})(\d)/, '$1) $2' ) + .replace(/(\d)(\d{4})/, '$1 $2') + .replace(/(\d{4})(\d{4})/, '$1-$2') + } + const BuscarCPFnoBancodeDados = async (cpf) => { @@ -145,7 +154,13 @@ const FormNovaConsulta = ({ onCancel, patientID }) => { email:value }}) - }else{ + } else if(name === 'telefone'){ + setPaciente({...paciente, contato:{ + ...paciente.contato, + telefone1:FormatTelefones(value) + }}) + } + else{ setPaciente({...paciente,[name]:value}) } } @@ -189,9 +204,7 @@ const FormNovaConsulta = ({ onCancel, patientID }) => {
- - {(inputProps) => } - +
@@ -221,7 +234,7 @@ const FormNovaConsulta = ({ onCancel, patientID }) => {

Informações adicionais

- + { ); }; -export default FormNovaConsulta; +export default FormNovaConsulta; \ No newline at end of file diff --git a/src/components/AgendarConsulta/style/formagendamentos.css b/src/components/AgendarConsulta/style/formagendamentos.css index afb1403..4c3fe80 100644 --- a/src/components/AgendarConsulta/style/formagendamentos.css +++ b/src/components/AgendarConsulta/style/formagendamentos.css @@ -140,11 +140,12 @@ svg{ .btn-secondary { margin: 10px 0; - background: #f3f4f6; + background: #4d78cd; padding: 8px 14px; - border: 1px solid #9ca3af; + border: 1px solid #5d739a; border-radius: 6px; cursor: pointer; + max-width: 200px; } .btn-secondary:hover { @@ -208,3 +209,15 @@ select[name=solicitante]{ .campo-de-input{ width:120% } + +.form-container { + width: 100%; + max-width: none; + margin: 0; /* >>> sem espaço para encostar no topo <<< */ + background: #ffffff; + border-radius: 12px; + padding: 24px; + box-shadow: 0 4px 12px rgba(0,0,0,0.08); + border: 10px solid #ffffff; + box-sizing: border-box; +} \ No newline at end of file diff --git a/src/components/doctors/DoctorForm.jsx b/src/components/doctors/DoctorForm.jsx index 0632b7e..6ef87f5 100644 --- a/src/components/doctors/DoctorForm.jsx +++ b/src/components/doctors/DoctorForm.jsx @@ -194,15 +194,15 @@ function DoctorForm({ onSave, onCancel, PatientDict }) { <> {/* Modal de feedback */} {showModal && ( -
-
+
+
-
-
Atenção
- +
+
Atenção
+
-
-

{modalMsg}

+
+

{modalMsg}

diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index cb4121a..4b77f23 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -1,10 +1,12 @@ import React, { useState, useEffect } from 'react'; function PatientForm({ onSave, onCancel, formData, setFormData }) { + const [errorModalMsg, setErrorModalMsg] = useState(""); // Estado para controlar a exibição do modal e os dados do paciente existente const [showModal, setShowModal] = useState(false); const [showModal404, setShowModal404] = useState(false); const [pacienteExistente, setPacienteExistente] = useState(null); + const [showSuccessModal, setShowSuccessModal] = useState(false); const FormatTelefones = (valor) => { const digits = String(valor).replace(/\D/g, '').slice(0, 11); @@ -204,7 +206,8 @@ 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.'); + setErrorModalMsg('Por favor, preencha Nome, CPF, Gênero e data de nascimento.'); + setShowModal404(true); return; } @@ -246,6 +249,7 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) { pacienteVip: formData.pacienteVip, }, }); + setShowSuccessModal(true); }; return ( @@ -313,7 +317,7 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
- +
@@ -665,20 +669,41 @@ function PatientForm({ onSave, onCancel, formData, setFormData }) {
)} - {/* Erro 404 */} + {/* Modal de sucesso ao salvar paciente */} + {showSuccessModal && ( +
+
+
+
+
Paciente salvo com sucesso!
+ +
+
+

O cadastro do paciente foi realizado com sucesso.

+
+
+ +
+
+
+
+ )} + {showModal404 && (
-
-
Erro de validação
- +
+
Atenção
+
-

(Erro 404).Por favor,tente novamente mais tarde

+

{errorModalMsg || '(Erro 404).Por favor, tente novamente mais tarde'}

-
diff --git a/src/pages/DoctorTable.jsx b/src/pages/DoctorTable.jsx index 80774b9..b1cc213 100644 --- a/src/pages/DoctorTable.jsx +++ b/src/pages/DoctorTable.jsx @@ -213,8 +213,8 @@ function TableDoctor({ setCurrentPage, setPatientID }) { >
-
-
Confirmação de Exclusão
+
+
Confirmação de Exclusão
-

+

Tem certeza que deseja excluir este médico?

diff --git a/src/pages/PatientCadastroManager.jsx b/src/pages/PatientCadastroManager.jsx index 8a2fab8..9c5fafb 100644 --- a/src/pages/PatientCadastroManager.jsx +++ b/src/pages/PatientCadastroManager.jsx @@ -24,10 +24,10 @@ function PatientCadastroManager( {setCurrentPage} ) { }; try { - const response = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes", requestOptions); + const response = await fetch("https://mock.apidog.com/m1/1053378-0-dault/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 index 68ca024..ff188fa 100644 --- a/src/pages/Table.jsx +++ b/src/pages/Table.jsx @@ -1,6 +1,8 @@ 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"); @@ -62,24 +64,31 @@ function TablePaciente({ setCurrentPage, setPatientID }) { } } - const deletePatient = async (id) => { - DeleteAnexo(id); + const handleDeleteClick = (id) => { + setDeleteId(id); + setShowDeleteModal(true); + }; + + const confirmDeletePatient = async () => { + if (!deleteId) return; + await DeleteAnexo(deleteId); 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}`, + `https://mock.apidog.com/m1/1053378-0-default/pacientes/${deleteId}`, requestOptionsDelete ) .then((response) => { if (!response.ok) { setShowError404(true); - setTimeout(() => setShowError404(false), 5000); // Esconde a mensagem após 5 segundos + 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) => { @@ -108,33 +117,9 @@ function TablePaciente({ setCurrentPage, setPatientID }) { .catch((error) => console.log("Erro ao atualizar VIP:", error)); }; - 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) => { - 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, convenio } : p)) - ); - }) - .catch((error) => console.log("Erro ao atualizar convênio:", error)); - }; - + useEffect(() => { - fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes") + fetch("https://mock.apidog.com/m1053378-0-det/pacientes") .then((response) => { if (!response.ok) { setShowError404(true); @@ -173,6 +158,28 @@ function TablePaciente({ setCurrentPage, setPatientID }) { return ( <> + {/* Modal de confirmação de exclusão */} + {showDeleteModal && ( +
+
+
+
+
Confirmação de Exclusão
+ +
+
+

+ Tem certeza que deseja excluir este paciente? +

+
+
+ + +
+
+
+
+ )}

Lista de Pacientes

@@ -261,7 +268,6 @@ function TablePaciente({ setCurrentPage, setPatientID }) { CPF Email Telefone - Status Ações @@ -317,7 +323,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) { backgroundColor: "#F8D7DA", color: "#721C24", }} - onClick={() => deletePatient(paciente.id)} + onClick={() => handleDeleteClick(paciente.id)} > Excluir