Advertisement
danine1

Mutations: (edit.jsx)

Mar 21st, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint camelcase:0 */
  2. import React from "react";
  3. import PropTypes from "prop-types";
  4. import classnames from "classnames";
  5.  
  6. import { translate, Trans } from "react-i18next";
  7.  
  8. import {
  9.   Form,
  10.   Input,
  11.   Radio,
  12.   Content,
  13. } from "@ematix/tesseract-component-library";
  14.  
  15. import {
  16.   DynamicIdentificationDocument,
  17.   SelectQueryCountry,
  18. } from "@ematix/inputSets";
  19.  
  20. import cls from "./styles.scss";
  21.  
  22. @translate("FormBasic")
  23. class BasicFormEdit extends React.PureComponent {
  24.   static propTypes = {
  25.     t: PropTypes.func.isRequired,
  26.     basicInfo: PropTypes.instanceOf(Object).isRequired,
  27.     readOnly: PropTypes.bool,
  28.     updatePerson: PropTypes.func.isRequired,
  29.     className: PropTypes.string,
  30.   };
  31.  
  32.   static defaultProps = {
  33.     readOnly: true,
  34.     className: "",
  35.   };
  36.  
  37.   render() {
  38.     const {
  39.       className, t, basicInfo, updatePerson,
  40.     } = this.props;
  41.     const {
  42.       first_name,
  43.       middle_name,
  44.       last_name,
  45.       date_of_birth,
  46.       gender,
  47.       place_of_birth,
  48.     } = basicInfo;
  49.     return (
  50.       <Content>
  51.         <Form
  52.           className={classnames(className)}
  53.           readOnly={this.props.readOnly}
  54.           onSubmit={() => {}}
  55.         >
  56.           <div className={cls.twoColumnsWrapper}>
  57.             <div className={cls.gridCol1}>
  58.               <Input
  59.                 label={t("Name")}
  60.                 name="name"
  61.                 onBlur={(e) => {
  62.                   const { target: { value } } = e;
  63.                   updatePerson("firstName", value);
  64.                 }}
  65.                 defaultValue={first_name}
  66.               />
  67.               <Input
  68.                 label={t("Middle Name")}
  69.                 name="middle_name"
  70.                 defaultValue={middle_name}
  71.                 onBlur={(e) => {
  72.                   const { target: { value } } = e;
  73.                   updatePerson("middleName", value);
  74.                 }}
  75.               />
  76.               <Input
  77.                 label={t("Surname")}
  78.                 name="surname"
  79.                 defaultValue={last_name}
  80.                 onBlur={(e) => {
  81.                   const { target: { value } } = e;
  82.                   updatePerson("lastName", value);
  83.                 }}
  84.               />
  85.               <Input
  86.                 label={t("Date Of Birth")}
  87.                 name="date_of_birth"
  88.                 defaultValue={date_of_birth}
  89.                 onBlur={(e) => {
  90.                   const { target: { value } } = e;
  91.                   updatePerson("dateOfBirth", value);
  92.                 }}
  93.               />
  94.               <label className={cls.genderLabel}>
  95.                 <Trans>Gender</Trans>
  96.               </label>
  97.               <div className={cls.radiobtns}>
  98.                 <Radio
  99.                   id="r1"
  100.                   type="radio"
  101.                   value="male"
  102.                   defaultChecked={gender === "male"}
  103.                   name="sex"
  104.                   label={t("Male")}
  105.                   onBlur={() => {
  106.                     const maleGlobalId = "RW51bToyNg==";
  107.                     updatePerson("genderGlobalId", maleGlobalId);
  108.                   }}
  109.                 />
  110.                 <Radio
  111.                   id="r2"
  112.                   type="radio"
  113.                   value="female"
  114.                   defaultChecked={gender === "female"}
  115.                   name="sex"
  116.                   label={t("Female")}
  117.                   onBlur={() => {
  118.                     const femaleGlobalId = "RW51bToyNw==";
  119.                     updatePerson("genderGlobalId", femaleGlobalId);
  120.                   }}
  121.                 />
  122.                 <Radio
  123.                   id="r3"
  124.                   type="radio"
  125.                   value="other"
  126.                   defaultChecked={gender === "other"}
  127.                   name="sex"
  128.                   label={t("Other")}
  129.                   onBlur={() => {
  130.                     const otherGlobalId = "RW51bToyOA==";
  131.                     updatePerson("genderGlobalId", otherGlobalId);
  132.                   }}
  133.                 />
  134.               </div>
  135.               {/* TODO: Appropriate place of birth code */}
  136.               {/* needs to be received in order to set */}
  137.               {/* a correct default value */}
  138.             </div>
  139.             <div className={cls.gridCol2}>
  140.               <SelectQueryCountry defaultValue={place_of_birth} />
  141.               <DynamicIdentificationDocument />
  142.             </div>
  143.           </div>
  144.         </Form>
  145.       </Content>
  146.     );
  147.   }
  148. }
  149.  
  150. export default BasicFormEdit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement