<commit_before>import React, {Component} from "react";
import {
  Row,
  Col,
  Button,
  ButtonDropdown,
  DropdownToggle,
  DropdownMenu,
  DropdownItem,
  Card,
  CardHeader,
  CardFooter,
  CardBlock,
  Form,
  FormGroup,
  FormText,
  Label,
  Input,
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  Modal,
  ModalHeader,
  ModalBody,
  ModalFooter
} from "reactstrap";
import axios from 'axios';

class Forms extends Component {
  constructor(props) {
    super(props);
    this.state = {
      first_name:'',
      last_name:'',
      email:'',
      password:'',
      diagnosis:'',
      care_giver:'',
      doctor:'',
      gender:'',
      mobile:'',
      street:'',
      city:'',
      sector:'',
      state:'',
      country:'',
      modal:false
    };
    this.onSubmit = this.onSubmit.bind(this);
    this.onChange = this.onChange.bind(this);
    this.onReset = this.onReset.bind(this);
    this.toggle = this.toggle.bind(this);
  }
  componentWillMount(){
    const token = localStorage.getItem('jwtToken');
    if (!token){
      this.props.history.push('/login');
    }
  }
  onChange(e){
    this.setState({
      [e.target.name]: e.target.value
    });
  }
  onSubmit(e) {
    e.preventDefault();
    var data = {
      first_name:this.state.first_name,
      last_name:this.state.last_name,
      username:this.state.email,
      password:<PASSWORD>,
      diagnosis:this.state.diagnosis,
      care_giver:this.state.care_giver,
      doctor:this.state.doctor,
      gender:this.state.gender,
      mobile:this.state.mobile,
      street:this.state.street,
      city:this.state.city,
      sector:this.state.sector,
      state:this.state.state,
      country:this.state.country
    }
    var headers = {
      'Content-Type':'application/json'
    }
    axios.post('api/register', data, headers).then(
      this.setState({
        modal:!this.state.modal
      })
    );
  }
  onReset(){
    this.setState({
      first_name:'',
      last_name:'',
      email:'',
      password:'',
      diagnosis:'',
      care_giver:'',
      doctor:'',
      gender:'',
      mobile:'',
      street:'',
      city:'',
      sector:'',
      state:'',
      country:''
    });
  }
  toggle() {
    this.setState({
      modal: !this.state.modal
    });
  }
  render() {
    const {first_name, last_name, password, email, diagnosis, care_giver, doctor, gender, mobile, street, city, sector, state, country} = this.state;

    return (
      <div className="animated fadeIn">

        <Row>
          <Col xs="12" md="12">
            <Card>
              <CardHeader>
                <strong>Patient Info</strong>
              </CardHeader>
              <CardBlock className="card-body">
                <Form action="" method="post" encType="multipart/form-data" className="form-horizontal">
                  <FormGroup row>
                    <Col md="3">
                      <Label>Firstname</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input
                            type="first_name"
                            id="first_name-input"
                            name="first_name"
                            placeholder="Enter firstname"
                            value={first_name}
                            onChange={this.onChange}
                            />
                      <FormText color="muted">Please enter firstname</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label>Lastname</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input
                            type="last_name"
                            id="last_name-input"
                            name="last_name"
                            placeholder="Enter lastname"
                            value={last_name}
                            onChange={this.onChange}/>
                      <FormText color="muted">Please enter lastname</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="email-input">Email Address</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="email"
                             id="email-input"
                             name="email"
                             placeholder="Enter Email"
                             value={email}
                             onChange={this.onChange}/>
                      <FormText className="help-block">Please enter patient email</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="password-input">Password</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="password"
                             id="password-input"
                             name="password"
                             placeholder="Password"
                             value={name}
                             onChange={this.onChange}
                             />
                      <FormText className="help-block">Please enter a complex password</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="address-input">Diagnosis</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="diagnosis"
                             id="diagnosis"
                             name="diagnosis"
                             placeholder="Enter patient diagnosis"
                             value={diagnosis}
                             onChange={this.onChange}/>
                      <FormText className="help-block">Please enter diagnosis</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="care_giver-input">Care giver</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="care_giver"
                             id="care_giver-input"
                             name="care_giver"
                             placeholder="Enter care giver"<commit_msg>change patient form to accept password.<commit_after>import React, {Component} from "react";
import {
  Row,
  Col,
  Button,
  ButtonDropdown,
  DropdownToggle,
  DropdownMenu,
  DropdownItem,
  Card,
  CardHeader,
  CardFooter,
  CardBlock,
  Form,
  FormGroup,
  FormText,
  Label,
  Input,
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  Modal,
  ModalHeader,
  ModalBody,
  ModalFooter
} from "reactstrap";
import axios from 'axios';

class Forms extends Component {
  constructor(props) {
    super(props);
    this.state = {
      first_name:'',
      last_name:'',
      email:'',
      password:'',
      diagnosis:'',
      care_giver:'',
      doctor:'',
      gender:'',
      mobile:'',
      street:'',
      city:'',
      sector:'',
      state:'',
      country:'',
      modal:false
    };
    this.onSubmit = this.onSubmit.bind(this);
    this.onChange = this.onChange.bind(this);
    this.onReset = this.onReset.bind(this);
    this.toggle = this.toggle.bind(this);
  }
  componentWillMount(){
    const token = localStorage.getItem('jwtToken');
    if (!token){
      this.props.history.push('/login');
    }
  }
  onChange(e){
    this.setState({
      [e.target.name]: e.target.value
    });
  }
  onSubmit(e) {
    e.preventDefault();
    var data = {
      first_name:this.state.first_name,
      last_name:this.state.last_name,
      username:this.state.email,
      password:<PASSWORD>,
      email:this.state.email,
      patient: {
        diagnosis:this.state.diagnosis,
        care_giver:this.state.care_giver,
        doctor:this.state.doctor,
        gender:this.state.gender,
        mobile:this.state.mobile,
        street:this.state.street,
        city:this.state.city,
        sector:this.state.sector,
        state:this.state.state,
        country:this.state.country
      }
    }
    var headers = {
      'Content-Type':'application/json'
    }
    axios.post('api/register', data, headers).then(
      this.setState({
        modal:!this.state.modal
      })
    );
  }
  onReset(){
    this.setState({
      first_name:'',
      last_name:'',
      email:'',
      password:'',
      diagnosis:'',
      care_giver:'',
      doctor:'',
      gender:'',
      mobile:'',
      street:'',
      city:'',
      sector:'',
      state:'',
      country:''
    });
  }
  toggle() {
    this.setState({
      modal: !this.state.modal
    });
  }
  render() {
    const {first_name, last_name, password, email, diagnosis, care_giver, doctor, gender, mobile, street, city, sector, state, country} = this.state;

    return (
      <div className="animated fadeIn">

        <Row>
          <Col xs="12" md="12">
            <Card>
              <CardHeader>
                <strong>Patient Info</strong>
              </CardHeader>
              <CardBlock className="card-body">
                <Form action="" method="post" encType="multipart/form-data" className="form-horizontal">
                  <FormGroup row>
                    <Col md="3">
                      <Label>Firstname</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input
                            type="first_name"
                            id="first_name-input"
                            name="first_name"
                            placeholder="Enter firstname"
                            value={first_name}
                            onChange={this.onChange}
                            />
                      <FormText color="muted">Please enter firstname</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label>Lastname</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input
                            type="last_name"
                            id="last_name-input"
                            name="last_name"
                            placeholder="Enter lastname"
                            value={last_name}
                            onChange={this.onChange}/>
                      <FormText color="muted">Please enter lastname</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="email-input">Email Address</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="email"
                             id="email-input"
                             name="email"
                             placeholder="Enter Email"
                             value={email}
                             onChange={this.onChange}/>
                      <FormText className="help-block">Please enter patient email</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="password-input">Password</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="password"
                             id="password-input"
                             name="password"
                             placeholder="Password"
                             value={password}
                             onChange={this.onChange}
                             />
                      <FormText className="help-block">Please enter a complex password</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="address-input">Diagnosis</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="diagnosis"
                             id="diagnosis"
                             name="diagnosis"
                             placeholder="Enter patient diagnosis"
                             value={diagnosis}
                             onChange={this.onChange}/>
                      <FormText className="help-block">Please enter diagnosis</FormText>
                    </Col>
                  </FormGroup>

                  <FormGroup row>
                    <Col md="3">
                      <Label htmlFor="care_giver-input">Care giver</Label>
                    </Col>
                    <Col xs="12" md="9">
                      <Input type="care_giver"
                             id="care_giver-input"
                             name="care_giver"
                             placeholder="Enter care giver"
{'fraction_non_alphanumeric': 0.11893773170916244, 'fraction_numerical': 0.004236967541802224, 'mean_word_length': 1.1902236951118474, 'pattern_counts': {'":': 0, '<': 149, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3831767', 'n_tokens_mistral': 3528, 'n_tokens_neox': 3373, 'n_words': 604}