import React, { useEffect, useState } from "react"; import avatarPlaceholder from '../assets/images/avatar_placeholder.png'; const Details = ({ patientID, setCurrentPage }) => { const [paciente, setPaciente] = useState({}); const [anexos, setAnexos] = useState([]); const [selectedFile, setSelectedFile] = useState(null); useEffect(() => { if (!patientID) return; fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}`) .then(res => res.json()) .then(result => {setPaciente(result.data)}) .catch(err => console.error("Erro ao buscar paciente:", err)); fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos`) .then(res => res.json()) .then(data => setAnexos(data.data || [])) .catch(err => console.error("Erro ao buscar anexos:", err)); }, [patientID]); const handleUpload = async () => { if (!selectedFile) return; const formData = new FormData(); formData.append('file', selectedFile); try { const response = await fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos`, { method: 'POST', body: formData, }); if (response.ok) { const newAnexo = await response.json(); setAnexos(prev => [...prev, newAnexo]); setSelectedFile(null); } else { console.error('Erro ao enviar anexo'); } } catch (err) { console.error('Erro ao enviar anexo:', err); } }; const handleDelete = async (anexoId) => { try { const response = await fetch( `https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos/${anexoId}`, { method: "DELETE", } ); if (response.ok) { setAnexos((prev) => prev.filter((a) => a.id !== anexoId)); } else { console.error("Erro ao deletar anexo"); } } catch (err) { console.error("Erro ao deletar anexo:", err); } }; return ( <>

MediConnect


{paciente.nome || "Nome Completo"}

{paciente.cpf || "CPF"}

{/* ------------------ DADOS PESSOAIS ------------------ */}
Dados Pessoais

{paciente.nome || "-"}

{paciente.nome_social || "-"}

{paciente.data_nascimento || "-"}

{paciente.sexo || "-"}

{paciente.cpf || "-"}

{paciente.rg || "-"}

{paciente.outros_documentos?.tipo || "-"}

{paciente.outros_documentos?.numero || "-"}

{paciente.etnia || "-"}

{paciente.raca || "-"}

{paciente.etniaRaca || "-"}

{paciente.profissao || "-"}

{paciente.nome_mae || "-"}

{paciente.profissao_mae || "-"}

{paciente.nome_pai || "-"}

{paciente.profissao_pai || "-"}

{paciente.nome_responsavel || "-"}

{paciente.cpf_responsavel || "-"}

{paciente.estado_civil || "-"}

{paciente.nome_conjuge || "-"}

{paciente.outro_id || "-"}

{paciente.observacoes || "-"}

{anexos.length > 0 ?(
    {anexos.map((anexo) => (
  • {anexo.nome}
  • ))}
) : (

-

)}
setSelectedFile(e.target.files[0])} accept="image/*"/> {selectedFile && {selectedFile.name}}
{/* ------------------ INFORMAÇÕES MÉDICAS ------------------ */}
Informações Médicas

{paciente.tipoSanguineo || "-"}

{paciente.peso || "-"}

{paciente.altura || "-"}

{paciente.imc || "-"}

{paciente.alergias || "-"}

{/* ------------------ INFORMAÇÕES DE CONVÊNIO ------------------ */}
Informações de Convênio

{paciente.convenio || "-"}

{paciente.plano || "-"}

{paciente.numeroMatricula || "-"}

{paciente.validadeCarteira || "-"}

{/* ------------------ ENDEREÇO ------------------ */}
Endereço

{paciente.endereco?.cep || "-"}

{paciente.endereco?.logradouro || "-"}

{paciente.endereco?.bairro || "-"}

{paciente.endereco?.cidade || "-"}

{paciente.endereco?.estado || "-"}

{paciente.endereco?.numero || "-"}

{paciente.endereco?.complemento || "-"}

{/* ------------------ CONTATO ------------------ */}
Contato

{paciente.contato?.email || "-"}

{paciente.contato?.celular || "-"}

{paciente.contato?.telefone2 || "-"}

{paciente.contato?.telefone3 || "-"}

); }; export default Details;