começo do concerto do editar

This commit is contained in:
jp-lima 2025-09-17 11:45:00 -03:00
parent 82469bccf9
commit b9a35be8ee
2 changed files with 20 additions and 17 deletions

View File

@ -3,6 +3,7 @@ import React, { useState, useEffect } from 'react';
function PatientForm({ onSave, onCancel, PatientDict }) { function PatientForm({ onSave, onCancel, PatientDict }) {
PatientDict = PatientDict || {}
const FormatTelefones = (valor) => { const FormatTelefones = (valor) => {
const digits = String(valor).replace(/\D/g, '').slice(0, 11); 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'); .replace(/(\d{3})(\d{1,2})$/, '$1-$2');
} }
const [formData, setFormData] = useState({ const [formData, setFormData] = useState({
foto: null, foto: null,
nome: PatientDict.nome, nome:PatientDict.nome,
nomeSocial: PatientDict.nome_social, nomeSocial: PatientDict.nome_social,
dataNascimento: PatientDict.data_nascimento, dataNascimento: PatientDict.data_nascimento,
genero: PatientDict.sexo, genero: PatientDict.sexo,
@ -80,20 +82,20 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
cpfResponsavel: '', cpfResponsavel: '',
nomeConjuge: '', nomeConjuge: '',
outroId: '', outroId: '',
cep: '', cep:PatientDict.endereco?.cep,
cidade: PatientDict.cidade, cidade: PatientDict.endereco?.cidade,
estado: PatientDict.estado, estado: PatientDict.endereco?.estado,
bairro: PatientDict.bairro, bairro: PatientDict.endereco?.bairro,
rua: PatientDict.logradouro, rua: PatientDict.endereco?.logradouro,
numero: '', numero: PatientDict.endereco?.numero,
complemento: '', complemento: PatientDict.endereco?.complemento,
email: PatientDict.email, email: PatientDict.contato?.email,
telefone1: PatientDict.celular, telefone1: PatientDict.contato?.telefone1,
telefone2: '', telefone2: PatientDict.contato?.telefone2,
telefone3: '', telefone3: PatientDict.contato?.telefone3,
observacoes: '', observacoes: PatientDict.observacoes,
rg: '', rg: PatientDict.rg,
documentoTipo: '', documentoTipo: PatientDict.outros_documentos?.tipo,
numeroDocumento: '', numeroDocumento: '',
etniaRaca: '', etniaRaca: '',
naturalidade: '', naturalidade: '',
@ -314,7 +316,7 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
{/* CADASTRO */} {/* CADASTRO */}
<div className="col-md-6 mb-3"> <div className="col-md-6 mb-3">
<label style={{ fontSize: '1.1rem' }}>Nome: *</label> <label style={{ fontSize: '1.1rem' }}>Nome: *</label>
<input type="text" className="form-control" name="nome" value={formData.nome} onChange={handleChange} style={{ fontSize: '1.1rem' }} /> <input type="text" className="form-control" name="nome" value={PatientDict.nome} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
</div> </div>
<div className="col-md-6 mb-3"> <div className="col-md-6 mb-3">
<label style={{ fontSize: '1.1rem' }}>Nome social:</label> <label style={{ fontSize: '1.1rem' }}>Nome social:</label>
@ -347,6 +349,7 @@ function PatientForm({ onSave, onCancel, PatientDict }) {
<option value="">Selecione</option> <option value="">Selecione</option>
<option value="CNH">CNH</option> <option value="CNH">CNH</option>
<option value="Passaporte">Passaporte</option> <option value="Passaporte">Passaporte</option>
<option value="carteira de trabalho">Carteira de Trabalho</option>
</select> </select>
</div> </div>
<div className="col-md-6 mb-3"> <div className="col-md-6 mb-3">

View File

@ -19,7 +19,7 @@ useEffect(() => {
fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, requestOptions) fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, requestOptions)
.then(response => response.json()) .then(response => response.json())
.then(result => result.data) .then(result => result.data)
.then(data => console.log(data)) .then(data => setPatientPUT(data))
.catch(error => console.log('error', error)); .catch(error => console.log('error', error));
}, []) }, [])