{"size": 1521, "ext": "js", "max_stars_repo_path": "src/components/form-tcc/Paciente.js", "max_stars_repo_name": "heltonbraga/CO_TCC", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/form-tcc/Paciente.js", "max_issues_repo_name": "heltonbraga/CO_TCC", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/form-tcc/Paciente.js", "max_forks_repo_name": "heltonbraga/CO_TCC", "max_forks_repo_forks_event_min_datetime": "2020-10-18T06:17:51.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-18T06:17:51.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 28.6981132075, "max_line_length": 92, "alphanum_fraction": 0.61078238}
import React from "react";
import { Field, reduxForm } from "redux-form";
import {validate} from "./validate";
import renderField from "./renderField";
import WizButtons from "./WizButtons";

const Paciente = (props) => {
  const { onCancel, reset, handleSubmit } = props;

  React.useEffect(() => {
    if (!props.paciente) {
      return;
    }
    props.change("nome", props.paciente.nome);
    props.change("cpf", props.paciente.cpf);
    props.change("nascimento", props.paciente.nascimento);
    props.change("email", props.paciente.email);
    props.change("tel1", props.paciente.tel1);
  }, [props.paciente]);

  const off = props.readOnly ? "-" : "";

  return (
    <form onSubmit={handleSubmit}>
      <Field name="nome" type={"text-" + off} component={renderField} label="Nome" />
      <Field name="cpf" type={"text-cpf" + off} component={renderField} label="CPF" />
      <Field
        name="nascimento"
        type={"date-" + off}
        component={renderField}
        label="Data de Nascimento"
      />
      <Field name="email" type={"text-email" + off} component={renderField} label="Email" />
      <Field name="tel1" type={"text-cell" + off} component={renderField} label="Celular" />
      <WizButtons
        onCancel={(e) => {
          reset();
          onCancel();
        }}
        resto={props}
      />
    </form>
  );
};

export default reduxForm({
  form: "cad_pac", 
  destroyOnUnmount: false,
  forceUnregisterOnUnmount: true,
  validate,
  enableReinitialize: true,
})(Paciente);
