<commit_before>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2016
 */

import React from 'react';
import PropTypes from 'prop-types';
import { Image, StyleSheet, Text, TextInput, View, TouchableOpacity } from 'react-native';
import { Button } from 'react-native-ui-components';
import Modal from 'react-native-modalbox';
import { DemoSiteRequest } from '../../authentication';
import globalStyles, { SUSSOL_ORANGE, GREY, WARM_GREY } from '../../globalStyles';
import { authStrings, generalStrings, demoUserModalStrings } from '../../localization';
import { ConfirmModal } from '../../widgets';
import Icon from 'react-native-vector-icons/FontAwesome';

export class DemoUserModal extends React.Component {
  constructor(props) {
    super(props);
    this.demoSiteRequest = new DemoSiteRequest();
    this.state = {
      status: 'submit', // submit, submitting, submitted, error
      error: '',
      username: '',
      password: '',
      repeatPassword: '',
      email: '',
    };
    this.errorTimeoutId = null;
  }

  componentWillUpdate() {
    if (this.errorTimeoutId) clearTimeout(this.errorTimeoutId);
  }

  onDemoRequestSubmit = async () => {
    if (!this.canAttemptSubmit) return false;
    this.setState({ status: 'submitting' });
    try {
      // TODO: Demo store creation request logic goes here.
      await this.demoSiteRequest.createActivationURL(<commit_msg>Remove TODO comment for feature already done<commit_after>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2016
 */

import React from 'react';
import PropTypes from 'prop-types';
import { Image, StyleSheet, Text, TextInput, View, TouchableOpacity } from 'react-native';
import { Button } from 'react-native-ui-components';
import Modal from 'react-native-modalbox';
import { DemoSiteRequest } from '../../authentication';
import globalStyles, { SUSSOL_ORANGE, GREY, WARM_GREY } from '../../globalStyles';
import { authStrings, generalStrings, demoUserModalStrings } from '../../localization';
import { ConfirmModal } from '../../widgets';
import Icon from 'react-native-vector-icons/FontAwesome';

export class DemoUserModal extends React.Component {
  constructor(props) {
    super(props);
    this.demoSiteRequest = new DemoSiteRequest();
    this.state = {
      status: 'submit', // submit, submitting, submitted, error
      error: '',
      username: '',
      password: '',
      repeatPassword: '',
      email: '',
    };
    this.errorTimeoutId = null;
  }

  componentWillUpdate() {
    if (this.errorTimeoutId) clearTimeout(this.errorTimeoutId);
  }

  onDemoRequestSubmit = async () => {
    if (!this.canAttemptSubmit) return false;
    this.setState({ status: 'submitting' });
    try {
      await this.demoSiteRequest.createActivationURL(
{'fraction_non_alphanumeric': 0.1362812613265676, 'fraction_numerical': 0.002899601304820587, 'mean_word_length': 3.7341337907375642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '803364', 'n_tokens_mistral': 803, 'n_tokens_neox': 787, 'n_words': 209}