diff --git a/src/App.css b/src/App.css index fe8e2a0..d9bf5ef 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,33 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; +.form-buttons { display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); + gap: 10px; /* Espaço entre os botões */ + justify-content: flex-start; /* Alinha os botões à esquerda */ + margin-top: 20px; +} + +.btn-save { + background-color: #28a745; color: white; + border: none; + padding: 8px 16px; + border-radius: 6px; + cursor: pointer; } -.App-link { - color: #61dafb; +.btn-cancel { + background-color: #ccc; + color: black; + border: none; + padding: 8px 16px; + border-radius: 6px; + cursor: pointer; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +.btn-back { + background-color: #007bff; + color: white; + border: none; + padding: 8px 16px; + border-radius: 6px; + cursor: pointer; } diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index f4eb448..2f2d399 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -1,43 +1,31 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import InputMask from "react-input-mask"; function PatientForm({ onSave, onCancel, PatientDict }) { - const FormatTelefones = (valor) => { - - const digits = String(valor).replace(/\D/g, '').slice(0, 11); - - - return digits - .replace(/(\d)/, '($1') // 123 -> 123. - .replace(/(\d{2})(\d)/, '$1) $2' ) - .replace(/(\d)(\d{4})/, '$1 $2') - .replace(/(\d{4})(\d{4})/, '$1-$2') + 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 FormatCPF = (valor) => { - - const digits = String(valor).replace(/\D/g, '').slice(0, 11); - - - - return digits - .replace(/(\d{3})(\d)/, '$1.$2') // 123 -> 123. - .replace(/(\d{3})(\d)/, '$1.$2') // 123.456 -> 123.456. - .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); // 123.456.789 -> 123.456.789-01 - + const digits = String(valor).replace(/\D/g, '').slice(0, 11); + return digits + .replace(/(\d{3})(\d)/, '$1.$2') + .replace(/(\d{3})(\d)/, '$1.$2') + .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); } - const [formData, setFormData] = useState({ + foto: null, nome: PatientDict.nome, nomeSocial: PatientDict.nome_social, dataNascimento: PatientDict.data_nascimento, genero: PatientDict.sexo, - documento: '', - numeroDocumento: '', cpf: PatientDict.cpf, profissao: PatientDict.profissao , nomeMae: PatientDict.nome_mae, @@ -59,50 +47,82 @@ function PatientForm({ onSave, onCancel, PatientDict }) { telefone1: PatientDict.celular, telefone2: '', telefone3: '', - observacoes: '' + observacoes: '', + rg: '', + documentoTipo: '', + numeroDocumento: '', + etniaRaca: '', + naturalidade: '', + nacionalidade: '', + estadoCivil: '', + rnConvenio: false, + + // INFORMAÇÕES MÉDICAS + tipoSanguineo: '', + peso: '', + altura: '', + imc: '', + alergias: '', + + // INFORMAÇÕES DE CONVÊNIO + convenio: '', + plano: '', + numeroMatricula: '', + validadeCarteira: '', + validadeIndeterminada: false, + + // ANEXO + anexos: null, }); + // armazenar a URL da foto do avatar + const [avatarUrl, setAvatarUrl] = useState(null); + + // Lógica para calcular o IMC + useEffect(() => { + const peso = parseFloat(formData.peso); + const altura = parseFloat(formData.altura); + if (peso > 0 && altura > 0) { + const imcCalculado = peso / (altura * altura); + setFormData(prev => ({ ...prev, imc: imcCalculado.toFixed(2) })); + } else { + setFormData(prev => ({ ...prev, imc: '' })); + } + }, [formData.peso, formData.altura]); + + const handleChange = (e) => { - const { name, value } = e.target; - setFormData({ - ...formData, - [name]: value - }); + const { name, value, type, checked, files } = e.target; + + if (type === 'checkbox') { + setFormData({ ...formData, [name]: checked }); + } else if (type === 'file') { + setFormData({ ...formData, [name]: files[0] }); + // Lógica para pré-visualizar a imagem no avatar + if (name === 'foto' && files[0]) { + const reader = new FileReader(); + reader.onloadend = () => { + setAvatarUrl(reader.result); + }; + reader.readAsDataURL(files[0]); + } else if (name === 'foto' && !files[0]) { + setAvatarUrl(null); // Limpa o avatar se nenhum arquivo for selecionado + } - if(name.includes('cpf')){ - - let cpfFormatado = FormatCPF(e.target.value) - - setFormData({...formData, - [name]: cpfFormatado,} - )} - - else if(name.includes('telefone')){ - let telefoneFormatado = FormatTelefones(value) - - console.log(telefoneFormatado) - - - - setFormData({...formData, - [name]: telefoneFormatado - }) + } else { + setFormData({ ...formData, [name]: value }); } - else if(name.includes('cep')){ - const digitsCep = String(value).replace(/\D/g, '').slice(0, 8); - setFormData({...formData, - [name]: digitsCep - }) - } - - - - }; - + if (name.includes('cpf')) { + let cpfFormatado = FormatCPF(value); + setFormData(prev => ({ ...prev, [name]: cpfFormatado })); + } else if (name.includes('telefone')) { + let telefoneFormatado = FormatTelefones(value); + setFormData(prev => ({ ...prev, [name]: telefoneFormatado })); + } + }; - // Função para buscar endereço pelo CEP const handleCepBlur = async () => { const cep = formData.cep.replace(/\D/g, ''); if (cep.length === 8) { @@ -127,59 +147,95 @@ function PatientForm({ onSave, onCancel, PatientDict }) { }; const handleSubmit = () => { - if (!formData.nome || !formData.cpf || !formData.genero || !formData.dataNascimento || !formData.email||!formData.telefone1){ - alert('Por favor, preencha: Nome ,CPF, Gênero, Data de nascimento, telefone e Email.'); + if (!formData.nome || !formData.cpf || !formData.genero || !formData.dataNascimento){ + alert('Por favor, preencha Nome ,CPF, Gênero e data de nascimento.'); return; } - onSave( - {nome: formData.nome, - nomeSocial: formData.nomeSocial, - dataNascimento: formData.dataNascimento, - genero: formData.genero, - documento: formData.documento, - numeroDocumento: formData.numeroDocumento, - cpf: formData.cpf, - profissao: formData.profissao, - nomeMae: formData.nomeMae, - profissaoMae: formData.profissaoMae, - nomePai: formData.nomePai, - profissaoPai: formData.profissaoPai, - nomeResponsavel: formData.nomeResponsavel, - cpfResponsavel: formData.cpfResponsavel, - nomeConjuge: formData.nomeConjuge, - outroId: formData.outroId, - endereco: { - cep: formData.cep, - cidade: formData.cidade, - estado: formData.estado, - bairro: formData.bairro, - logradouro: formData.rua, - numero: formData.numero, - complemento: formData.complemento, - }, - - contato: { - email: formData.email, - telefone1: formData.telefone1, - telefone2: formData.telefone2, - telefone3: formData.telefone3, - }, - - observacoes: formData.observacoes, -} - - - ); + onSave({ + ...formData, + endereco: { + cep: formData.cep, + cidade: formData.cidade, + estado: formData.estado, + bairro: formData.bairro, + logradouro: formData.rua, + numero: formData.numero, + complemento: formData.complemento, + }, + contato: { + email: formData.email, + telefone1: formData.telefone1, + telefone2: formData.telefone2, + telefone3: formData.telefone3, + }, + infoMedicas: { + tipoSanguineo: formData.tipoSanguineo, + peso: formData.peso, + altura: formData.altura, + imc: formData.imc, + alergias: formData.alergias, + }, + infoConvenio: { + convenio: formData.convenio, + plano: formData.plano, + numeroMatricula: formData.numeroMatricula, + validadeCarteira: formData.validadeCarteira, + validadeIndeterminada: formData.validadeIndeterminada, + }, + }); }; return (
-

MediConnect

+

MedicoConnect

- {/* ------------------ DADOS PESSOAIS ------------------ */} + {/* DADOS PESSOAIS */}
Dados Pessoais
+ {/* AVATAR E INPUT DE FOTO */} +
+
+ {avatarUrl ? ( + Avatar do Paciente + ) : ( +
+ {/* Ícone de usuário simples ou suas iniciais */} + ☤ +
+ )} +
+
+ + + {formData.foto && {formData.foto.name}} +
+
+ {/* CADASTRO */} +
@@ -202,21 +258,58 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
- - + + +
+
+ + +
+
+ +
- - + + +
+
+ + +
+
+ +
+
+ + +
@@ -249,9 +342,87 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
+
+
+ + +
+
- {/* ------------------ ENDEREÇO ------------------ */} + {/* INFORMAÇÕES MÉDICAS */} +
Informações Médicas
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + {/* INFORMAÇÕES DE CONVÊNIO */} +
Informações de convênio
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + {/* ENDEREÇO */}
Endereço
@@ -284,7 +455,7 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
- {/* ------------------ CONTATO ------------------ */} + {/* CONTATO */}
Contato
@@ -305,12 +476,20 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
- {/* ------------------ INFORMAÇÕES ADICIONAIS ------------------ */} -
Informações Adicionais
+ {/* INFORMAÇÕES ADICIONAIS */} +
Informações Adicionais
+ + {/* ANEXOS DO PACIENTE */} +
Anexos do Paciente
+
+ + + {formData.anexos ? formData.anexos.name : 'Nenhum arquivo escolhido'} +
{/* Botões */}
@@ -325,4 +504,4 @@ function PatientForm({ onSave, onCancel, PatientDict }) { ); } -export default PatientForm; +export default PatientForm; \ No newline at end of file diff --git a/src/pages/EditPage.jsx b/src/pages/EditPage.jsx index a64930b..c659cfe 100644 --- a/src/pages/EditPage.jsx +++ b/src/pages/EditPage.jsx @@ -1,52 +1,50 @@ -import React from 'react' - +import React, { useEffect, useState } from 'react' import PatientForm from '../components/patients/PatientForm' -import {useEffect, useState} from 'react' - -const EditPage = ( {id}) => { - +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') - + 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 => setPatientPUT(data)) + .catch(error => console.log('error', error)) + }, [id]) + + const HandlePutPatient = () => { + console.log('paciente atualizado') + } + + const handleBack = () => { + console.log('voltando para lista sem salvar') + // aqui você pode usar react-router-dom, ex: + // navigate('/lista-pacientes') + } return ( -
- - - - - - - + console.log('Não atualizar')} + PatientDict={PatientToPUT} + extraButton={ + + } + />
) } -export default EditPage \ No newline at end of file +export default EditPage