diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index 4177d27..0dad967 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -56,7 +56,7 @@ function Sidebar(props) { props.setCurrentPage('Inicio'); }} > - MediConnect +

MediConnect

diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index 9844b80..3cdeb13 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import InputMask from "react-input-mask"; -function PatientForm({ onSave, onCancel, PatientDict }) { +function PatientForm({ onSave, onCancel, PatientDict, patientID }) { const FormatTelefones = (valor) => { const digits = String(valor).replace(/\D/g, '').slice(0, 11); @@ -87,13 +87,18 @@ function PatientForm({ onSave, onCancel, PatientDict }) { contato: false, }); - // Função para alternar o estado de colapso de uma seção - const handleToggleCollapse = (section) => { - setCollapsedSections(prevState => ({ - ...prevState, - [section]: !prevState[section] - })); - }; + // Estado para anexos existentes + const [anexos, setAnexos] = useState([]); + + // GET dos anexos existentes + useEffect(() => { + if (!PatientDict?.id) return; + + fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${PatientDict.id}/anexos`) + .then(res => res.json()) + .then(data => setAnexos(data)) + .catch(err => console.error("Erro ao buscar anexos:", err)); + }, [PatientDict]); // Lógica para calcular o IMC useEffect(() => { @@ -107,6 +112,13 @@ function PatientForm({ onSave, onCancel, PatientDict }) { } }, [formData.peso, formData.altura]); + // Função para alternar o estado de colapso de uma seção + const handleToggleCollapse = (section) => { + setCollapsedSections(prevState => ({ + ...prevState, + [section]: !prevState[section] + })); + }; const handleChange = (e) => { const { name, value, type, checked, files } = e.target; @@ -163,6 +175,25 @@ function PatientForm({ onSave, onCancel, PatientDict }) { } }; + // Enviar anexos + const uploadAnexo = () => { + if (!formData.anexos) return alert("Selecione um arquivo para enviar."); + + const form = new FormData(); + form.append("file", formData.anexos); + + fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${PatientDict.id}/anexos`, { + method: "POST", + body: form + }) + .then(res => res.json()) + .then(data => { + setAnexos(prev => [...prev, data]); + setFormData(prev => ({ ...prev, anexos: null })); + }) + .catch(err => console.error("Erro ao enviar anexo:", err)); + }; + const handleSubmit = () => { if (!formData.nome || !formData.cpf || !formData.genero || !formData.dataNascimento){ alert('Por favor, preencha Nome ,CPF, Gênero e data de nascimento.'); @@ -375,17 +406,20 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
{/* CAMPOS MOVIDOS */} -
- - -
+
- -
- - - {formData.anexos ? formData.anexos.name : 'Nenhum arquivo escolhido'} -
+ + + + +
diff --git a/src/index.js b/src/index.js index a98e326..e0e017b 100644 --- a/src/index.js +++ b/src/index.js @@ -4,9 +4,9 @@ import './assets/scss/bootstrap.scss'; import './assets/scss/app.scss'; import App from './App'; -ReactDOM.render( +const root = ReactDOM.createRoot(document.getElementById("root")); +root.render( - , - document.getElementById('root') -); + +); \ No newline at end of file