<commit_before>import * as React from 'react';
const { Fragment } = require('react');
import { connect } from 'react-redux';
import { trackDataset } from '../../../services/tracker';
import StateTree from '../../../stores/tree';
import { User } from '../../../stores/user';
import Modal from '../../modal/modal';
import { SuccessIcon } from '../../ui/icons';
import { Button, LabeledInput } from '../../ui/ui';

const AUTO_HIDE_TIME_MS = 5000;

interface PropsFromState {
  user: User.State;
}

interface PropsFromDispatch {
  updateUser: typeof User.actions.update;
}

interface Props extends PropsFromState, PropsFromDispatch {
  onRequestClose: () => void;
  titleOnly: boolean;
}

interface State {
  email: string;
  isSubmitted: boolean;
}

class AfterDownloadModal extends React.Component<Props, State> {
  state = { email: this.props.user.email, isSubmitted: false };
  timeout: any;

  componentDidMount() {
    const { onRequestClose, titleOnly } = this.props;
    if (titleOnly) {
      this.timeout = setTimeout(onRequestClose, AUTO_HIDE_TIME_MS);
    }
  }

  componentWillUnmount() {
    clearTimeout(this.timeout);
  }

  handleSubmit = (event: React.FormEvent<any>) => {
    event.preventDefault();
    trackDataset('post-download-signup');
    this.props.updateUser({
      email: this.state.email,
      sendEmails: true,
    });
    this.setState({ isSubmitted: true });
  };

  render() {
    const { onRequestClose, titleOnly } = this.props;
    const { email, isSubmitted } = this.state;
    return (
      <Modal
        {...{ onRequestClose }}
        innerClassName={'email-modal ' + (titleOnly ? 'compact' : '')}>
        <div className="head">
          <SuccessIcon />
          <h2>Your download has started.</h2>
        </div>

        {!titleOnly && (
          <Fragment>
            <form onSubmit={this.handleSubmit}>
              <p>
                Help us build a community around voice technology, stay in touch
                via email.
              </p>

              <LabeledInput
                label={isSubmitted ? '' : 'Enter your email'}
                type="email"
                value={isSubmitted ? "Thank you, we'll be in touch." : email}
                disabled={isSubmitted}
                onChange={(event: any) =>
                  this.setState({ email: event.target.value })}
              />

              {!isSubmitted && (
                <Button type="submit" outline>
                  Submit<commit_msg>set after download modal input to text when it just shows a message<commit_after>import * as React from 'react';
const { Fragment } = require('react');
import { connect } from 'react-redux';
import { trackDataset } from '../../../services/tracker';
import StateTree from '../../../stores/tree';
import { User } from '../../../stores/user';
import Modal from '../../modal/modal';
import { SuccessIcon } from '../../ui/icons';
import { Button, LabeledInput } from '../../ui/ui';

const AUTO_HIDE_TIME_MS = 5000;

interface PropsFromState {
  user: User.State;
}

interface PropsFromDispatch {
  updateUser: typeof User.actions.update;
}

interface Props extends PropsFromState, PropsFromDispatch {
  onRequestClose: () => void;
  titleOnly: boolean;
}

interface State {
  email: string;
  isSubmitted: boolean;
}

class AfterDownloadModal extends React.Component<Props, State> {
  state = { email: this.props.user.email, isSubmitted: false };
  timeout: any;

  componentDidMount() {
    const { onRequestClose, titleOnly } = this.props;
    if (titleOnly) {
      this.timeout = setTimeout(onRequestClose, AUTO_HIDE_TIME_MS);
    }
  }

  componentWillUnmount() {
    clearTimeout(this.timeout);
  }

  handleSubmit = (event: React.FormEvent<any>) => {
    event.preventDefault();
    trackDataset('post-download-signup');
    this.props.updateUser({
      email: this.state.email,
      sendEmails: true,
    });
    this.setState({ isSubmitted: true });
  };

  render() {
    const { onRequestClose, titleOnly } = this.props;
    const { email, isSubmitted } = this.state;
    return (
      <Modal
        {...{ onRequestClose }}
        innerClassName={'email-modal ' + (titleOnly ? 'compact' : '')}>
        <div className="head">
          <SuccessIcon />
          <h2>Your download has started.</h2>
        </div>

        {!titleOnly && (
          <Fragment>
            <form onSubmit={this.handleSubmit}>
              <p>
                Help us build a community around voice technology, stay in touch
                via email.
              </p>

              <LabeledInput
                label={isSubmitted ? '' : 'Enter your email'}
                type={isSubmitted ? 'text' : 'email'}
                value={isSubmitted ? "Thank you, we'll be in touch." : email}
                disabled={isSubmitted}
                onChange={(event: any) =>
                  this.setState({ email: event.target.value })}
              />

              {!isSubmitted && (
                <Button type="submit" outline>
                  Submit
{'fraction_non_alphanumeric': 0.13959037582024258, 'fraction_numerical': 0.0023861602704314975, 'mean_word_length': 2.272608978529603, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008266', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1420, 'n_words': 349}