diff --git a/src/App.js b/src/App.js index 4f28e3a..931fa27 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import Sidebar from './components/Sidebar'; import Header from './components/Header'; import StatsCard from './components/StatsCard'; @@ -14,22 +14,30 @@ import EmailApp from "./pages/EmailApp"; import ChatApp from "./pages/ChatApp"; import GalleryApp from "./pages/GalleryApp"; import FormLayout from './pages/FormLayout'; +import EditPage from './pages/EditPage'; +import PatientList from './components/patients/PatientList'; +import Details from './pages/Details'; function App() { const [isSidebarActive, setIsSidebarActive] = useState(true); const [currentPage, setCurrentPage] = useState('dashboard'); + const [patientID, setPatientID] = useState(0) + + + + const toggleSidebar = () => { setIsSidebarActive(!isSidebarActive); }; const renderPageContent = () => { if (currentPage === 'form-layout') { - return ; + return ; } else if (currentPage === 'table') { - return ; + return
; } else if (currentPage === 'data-table') { return ; @@ -46,6 +54,13 @@ const renderPageContent = () => { else if (currentPage === 'gallery-app') { return ; } + else if(currentPage === 'edit-page-paciente'){ + + return + } + else if(currentPage === 'details-page-paciente'){ + return
+ } // Dashboard por padrão diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index 6adb5cb..e0af33f 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import InputMask from "react-input-mask"; -function PatientForm({ onSave, onCancel }) { +function PatientForm({ onSave, onCancel, PatientDict }) { const FormatTelefones = (valor) => { @@ -14,8 +14,6 @@ function PatientForm({ onSave, onCancel }) { .replace(/(\d{2})(\d)/, '$1) $2' ) .replace(/(\d)(\d{4})/, '$1 $2') .replace(/(\d{4})(\d{4})/, '$1-$2') - - } @@ -34,31 +32,31 @@ function PatientForm({ onSave, onCancel }) { const [formData, setFormData] = useState({ - nome: '', - nomeSocial: '', - dataNascimento: '', - genero: '', + nome: PatientDict.nome, + nomeSocial: PatientDict.nome_social, + dataNascimento: PatientDict.data_nascimento, + genero: PatientDict.sexo, documento: '', numeroDocumento: '', - cpf: '', - profissao: '', - nomeMae: '', - profissaoMae: '', - nomePai: '', - profissaoPai: '', + cpf: PatientDict.cpf, + profissao: PatientDict.profissao , + nomeMae: PatientDict.nome_mae, + profissaoMae: PatientDict.profissao_mae, + nomePai: PatientDict.nome_pai, + profissaoPai: PatientDict.profissao_pai, nomeResponsavel: '', cpfResponsavel: '', nomeConjuge: '', outroId: '', cep: '', - cidade: '', - estado: '', - bairro: '', - rua: '', + cidade: PatientDict.cidade, + estado: PatientDict.estado, + bairro: PatientDict.bairro, + rua: PatientDict.logradouro, numero: '', complemento: '', - email: '', - telefone1: '', + email: PatientDict.email, + telefone1: PatientDict.celular, telefone2: '', telefone3: '', observacoes: '' diff --git a/src/pages/Details.jsx b/src/pages/Details.jsx new file mode 100644 index 0000000..7db4bc9 --- /dev/null +++ b/src/pages/Details.jsx @@ -0,0 +1,9 @@ +import React from 'react' + +const Details = () => { + return ( +
Details
+ ) +} + +export default Details \ No newline at end of file diff --git a/src/pages/EditPage.jsx b/src/pages/EditPage.jsx new file mode 100644 index 0000000..a64930b --- /dev/null +++ b/src/pages/EditPage.jsx @@ -0,0 +1,52 @@ +import React from 'react' + +import PatientForm from '../components/patients/PatientForm' + +import {useEffect, useState} from 'react' + +const EditPage = ( {id}) => { + + const [PatientToPUT, setPatientPUT] = useState({}) + + var requestOptions = { + method: 'GET', + redirect: 'follow' +}; + +useEffect(() => { + + +fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, requestOptions) + .then(response => response.json()) + .then(result => result.data) + .then(data => console.log(data)) + .catch(error => console.log('error', error)); + +}, []) + const HandlePutPatient = () => { + + console.log('paciente atualizado') + + } + + + return ( + +
+ + + + + + + +
+ ) +} + +export default EditPage \ No newline at end of file diff --git a/src/pages/FormLayout.jsx b/src/pages/FormLayout.jsx index 00dc25f..18d4801 100644 --- a/src/pages/FormLayout.jsx +++ b/src/pages/FormLayout.jsx @@ -4,7 +4,7 @@ import React, { useState } from 'react'; import PatientList from '../components/patients/PatientList'; import PatientForm from '../components/patients/PatientForm'; -function FormLayout() { +function FormLayout( ) { // Este estado vai controlar qual "tela" mostrar: 'list' (lista) ou 'form' (formulário) const [view, setView] = useState('list'); @@ -55,6 +55,8 @@ function FormLayout() { setView('list')} + PatientDict={{}} + /> )} diff --git a/src/pages/Table.jsx b/src/pages/Table.jsx index a39528a..62b4279 100644 --- a/src/pages/Table.jsx +++ b/src/pages/Table.jsx @@ -1,7 +1,8 @@ import React, { useState, useEffect } from 'react'; -function Table() { +function Table( {setCurrentPage, setPatientID}) { + // Função para excluir paciente @@ -27,10 +28,16 @@ function Table() { console.log(e.target.value) - if(value === 'verdetalhes'){} + if(value === 'verdetalhes'){ + setCurrentPage('details-page-paciente') + } if(value === 'editar') - {} + {setCurrentPage('edit-page-paciente') + setPatientID(id) + + + } if(value === 'excluir'){ console.log(`Excluir ${id}`) @@ -130,4 +137,5 @@ useEffect(() => { ); } + export default Table; \ No newline at end of file