@@ -130,7 +133,7 @@ function TableDoctor({ setCurrentPage, setPatientID }) {
|
-
+ {/* Ver Detalhes */}
+
+ {/* Modal de confirmação de exclusão */}
+ {showDeleteModal && (
+
+ e.target.classList.contains("modal") && setShowDeleteModal(false)
+ }
+ >
+
+
+
+ Confirmação de Exclusão
+ setShowDeleteModal(false)}
+ >
+
+
+
+ Tem certeza que deseja excluir este médico?
+
+
+
+ setShowDeleteModal(false)}
+ >
+ Cancelar
+
+ deleteDoctor(selectedDoctorId)}
+ >
+ Excluir
+
+
+
+
+
+ )}
>
);
}
diff --git a/src/pages/EditPage.jsx b/src/pages/EditPage.jsx
index b204fd95..1b946208 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,43 +22,52 @@ 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 = () => {
- alert(`Atualizando paciente "${PatientToPUT.nome}" com sucesso`)
- var myHeaders = new Headers();
-myHeaders.append("Authorization", "Bearer ");
-myHeaders.append("Content-Type", "application/json");
+const HandlePutPatient = async () => {
+
-var raw = JSON.stringify(PatientToPUT)
+ var myHeaders = new Headers();
+ myHeaders.append("Authorization", "Bearer ");
+ myHeaders.append("Content-Type", "application/json");
-console.log(PatientToPUT)
+ var raw = JSON.stringify(PatientToPUT);
-var requestOptions = {
- method: 'PUT',
- headers: myHeaders,
- body: raw,
- redirect: 'follow'
-};
+ console.log("Enviando paciente para atualização:", PatientToPUT);
-fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions)
- .then(response => response.text())
- .then(result => console.log('ATUALIZADO COM SUCESSO',result))
- .catch(error => console.log('error', error));
+ var requestOptions = {
+ method: 'PUT',
+ headers: myHeaders,
+ body: raw,
+ redirect: 'follow'
+ };
+ try {
+ const response = await fetch(
+ "https://mock.apidog.com/m1/1053378-0-default/pacientes/" + PatientToPUT.id,
+ requestOptions
+ );
+
+ // se o backend retorna JSON
+ const result = await response.json();
+ console.log("ATUALIZADO COM SUCESSO", result);
+
+ 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 7653975a..8a2fab83 100644
--- a/src/pages/PatientCadastroManager.jsx
+++ b/src/pages/PatientCadastroManager.jsx
@@ -1,11 +1,7 @@
-import React, { useState } from 'react';
-
-// Importamos os dois novos componentes que criamos
-
+import {useState} from 'react';
import PatientForm from '../components/patients/PatientForm';
function PatientCadastroManager( {setCurrentPage} ) {
- // Este estado vai controlar qual "tela" mostrar: 'list' (lista) ou 'form' (formulário)
const [formData, setFormData] = useState({})
@@ -13,29 +9,33 @@ function PatientCadastroManager( {setCurrentPage} ) {
myHeaders.append("Content-Type", "application/json");
// Função que será chamada para "salvar" o paciente
- const handleSavePatient = (patientData) => {
- console.log('Salvando paciente:', patientData);
+ const handleSavePatient = async (patientData) => {
+ console.log('Salvando paciente:', patientData);
- var raw = JSON.stringify(patientData)
+ var raw = JSON.stringify(patientData);
- var requestOptions = {
- method:'POST',
- 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));
-
- alert(`Paciente "${patientData.nome}" salvo com sucesso!`); //altere isso para integração com backend
- // Após salvar, voltamos para a tela de lista
-
+ var requestOptions = {
+ method: 'POST',
+ headers: {
+ "Content-Type": "application/json"
+ },
+ body: raw,
+ redirect: 'follow'
};
+ try {
+ 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);
+ throw error;
+ }
+};
+
+
return (
<>
diff --git a/src/pages/style/Agendamento.css b/src/pages/style/Agendamento.css
index d7f34d51..3bb469aa 100644
--- a/src/pages/style/Agendamento.css
+++ b/src/pages/style/Agendamento.css
@@ -89,10 +89,11 @@
.legenda-tabela{
display: flex;
- justify-content: flex-end;
- margin-top: 10px;
+
+ margin-top: 30px;
margin-bottom: 10px;
gap: 15px;
+ justify-content: flex-end;
}
.legenda-item-realizado{
@@ -141,4 +142,55 @@
padding: 5px;
font-weight: bold;
border-radius: 10px;
+}
+
+.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
|