diff --git a/src/components/AgendarConsulta/FormNovaConsulta.jsx b/src/components/AgendarConsulta/FormNovaConsulta.jsx index 7d9f116..a3eb650 100644 --- a/src/components/AgendarConsulta/FormNovaConsulta.jsx +++ b/src/components/AgendarConsulta/FormNovaConsulta.jsx @@ -5,7 +5,7 @@ import { useState } from "react"; const FormNovaConsulta = ({ onCancel }) => { - + const [paciente, setPaciente] = useState({}) const [acessibilidade, setAcessibilidade] = useState({cadeirante:false,idoso:false,gravida:false,bebe:false, autista:false }) const handleclickAcessibilidade = (id) => { let resultado = acessibilidade[id] @@ -18,8 +18,6 @@ const FormNovaConsulta = ({ onCancel }) => { const FormatCPF = (valor) => { - - console.log(valor) const digits = String(valor).replace(/\D/g, '').slice(0, 11); @@ -29,7 +27,6 @@ const FormNovaConsulta = ({ onCancel }) => { .replace(/(\d{3})(\d)/, '$1.$2') .replace(/(\d{3})(\d)/, '$1.$2') .replace(/(\d{3})(\d{1,2})$/, '$1-$2'); - } @@ -76,7 +73,7 @@ const FormNovaConsulta = ({ onCancel }) => { fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions) .then(response => response.json()) - .then(result => console.log(result)) + .then(result => setPaciente(result.data)) .catch(error => console.log('error', error)); } @@ -86,8 +83,23 @@ const FormNovaConsulta = ({ onCancel }) => { console.log("error", error); } //BuscarCPFnoBancodeDados(value) + } - + const handleChange = (e) => { + + const {value, name} = e.target; + + console.log(value, name) + + if(name === 'email'){ + setPaciente({...paciente, contato:{ + ...paciente.contato, + email:value + }}) + + }else{ + setPaciente({...paciente,[name]:value}) + } } const handleSubmit = (e) => { @@ -105,13 +117,13 @@ const FormNovaConsulta = ({ onCancel }) => {
- +
- e.target.value = FormatCPF(e.target.value)} /> + e.target.value = FormatCPF(e.target.value)} />
@@ -124,7 +136,7 @@ const FormNovaConsulta = ({ onCancel }) => {
- +
@@ -136,7 +148,7 @@ const FormNovaConsulta = ({ onCancel }) => {
- +
@@ -213,7 +225,7 @@ const FormNovaConsulta = ({ onCancel }) => {
@@ -241,7 +253,7 @@ const FormNovaConsulta = ({ onCancel }) => {