forked from RiseUP/riseup-squad23
Inicio de detalhes e atualização do paciente
This commit is contained in:
parent
06ff7d5324
commit
5534568e20
21
src/App.js
21
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 <FormLayout />;
|
||||
return <FormLayout/>;
|
||||
}
|
||||
else if (currentPage === 'table') {
|
||||
return <Table />;
|
||||
return <Table setCurrentPage={setCurrentPage} setPatientID={setPatientID}/>;
|
||||
}
|
||||
else if (currentPage === 'data-table') {
|
||||
return <DataTable />;
|
||||
@ -46,6 +54,13 @@ const renderPageContent = () => {
|
||||
else if (currentPage === 'gallery-app') {
|
||||
return <GalleryApp />;
|
||||
}
|
||||
else if(currentPage === 'edit-page-paciente'){
|
||||
|
||||
return <EditPage id={patientID} />
|
||||
}
|
||||
else if(currentPage === 'details-page-paciente'){
|
||||
return <Details/>
|
||||
}
|
||||
|
||||
|
||||
// Dashboard por padrão
|
||||
|
||||
@ -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: ''
|
||||
|
||||
9
src/pages/Details.jsx
Normal file
9
src/pages/Details.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
const Details = () => {
|
||||
return (
|
||||
<div>Details</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Details
|
||||
52
src/pages/EditPage.jsx
Normal file
52
src/pages/EditPage.jsx
Normal file
@ -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 (
|
||||
|
||||
<div>
|
||||
|
||||
<button>Voltar para lista sem salvar</button>
|
||||
|
||||
|
||||
|
||||
<PatientForm
|
||||
onSave={HandlePutPatient}
|
||||
onCancel={console.log('Não atualizar')}
|
||||
PatientDict={PatientToPUT}
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default EditPage
|
||||
@ -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() {
|
||||
<PatientForm
|
||||
onSave={handleSavePatient}
|
||||
onCancel={() => setView('list')}
|
||||
PatientDict={{}}
|
||||
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -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;
|
||||
Loading…
x
Reference in New Issue
Block a user