From f91f88fa23ef2cd2d8a09b4281a47a41b37db5ae Mon Sep 17 00:00:00 2001 From: jp-lima Date: Wed, 17 Sep 2025 11:45:00 -0300 Subject: [PATCH] =?UTF-8?q?come=C3=A7o=20do=20concerto=20do=20editar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/patients/PatientForm.jsx | 35 ++++++++++++++----------- src/pages/EditPage.jsx | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/components/patients/PatientForm.jsx b/src/components/patients/PatientForm.jsx index 74bb27f..34dcb9a 100644 --- a/src/components/patients/PatientForm.jsx +++ b/src/components/patients/PatientForm.jsx @@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react'; function PatientForm({ onSave, onCancel, PatientDict }) { + PatientDict = PatientDict || {} const FormatTelefones = (valor) => { const digits = String(valor).replace(/\D/g, '').slice(0, 11); @@ -65,9 +66,10 @@ function PatientForm({ onSave, onCancel, PatientDict }) { .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); } + const [formData, setFormData] = useState({ foto: null, - nome: PatientDict.nome, + nome:PatientDict.nome, nomeSocial: PatientDict.nome_social, dataNascimento: PatientDict.data_nascimento, genero: PatientDict.sexo, @@ -80,20 +82,20 @@ function PatientForm({ onSave, onCancel, PatientDict }) { cpfResponsavel: '', nomeConjuge: '', outroId: '', - cep: '', - cidade: PatientDict.cidade, - estado: PatientDict.estado, - bairro: PatientDict.bairro, - rua: PatientDict.logradouro, - numero: '', - complemento: '', - email: PatientDict.email, - telefone1: PatientDict.celular, - telefone2: '', - telefone3: '', - observacoes: '', - rg: '', - documentoTipo: '', + cep:PatientDict.endereco?.cep, + cidade: PatientDict.endereco?.cidade, + estado: PatientDict.endereco?.estado, + bairro: PatientDict.endereco?.bairro, + rua: PatientDict.endereco?.logradouro, + numero: PatientDict.endereco?.numero, + complemento: PatientDict.endereco?.complemento, + email: PatientDict.contato?.email, + telefone1: PatientDict.contato?.telefone1, + telefone2: PatientDict.contato?.telefone2, + telefone3: PatientDict.contato?.telefone3, + observacoes: PatientDict.observacoes, + rg: PatientDict.rg, + documentoTipo: PatientDict.outros_documentos?.tipo, numeroDocumento: '', etniaRaca: '', naturalidade: '', @@ -314,7 +316,7 @@ function PatientForm({ onSave, onCancel, PatientDict }) { {/* CADASTRO */}
- +
@@ -347,6 +349,7 @@ function PatientForm({ onSave, onCancel, PatientDict }) { +
diff --git a/src/pages/EditPage.jsx b/src/pages/EditPage.jsx index a64930b..456aa3f 100644 --- a/src/pages/EditPage.jsx +++ b/src/pages/EditPage.jsx @@ -19,7 +19,7 @@ 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)) + .then(data => setPatientPUT(data)) .catch(error => console.log('error', error)); }, [])