<commit_before>// @flow

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { reduxForm, Field } from 'redux-form';
import moment from 'moment';
import { Captcha, TextEditor } from 'app/components/Form';
import Button from 'app/components/Button';
import StripeCheckout from 'react-stripe-checkout';
import logoImage from 'app/assets/kule.png';
import LoadingIndicator from 'app/components/LoadingIndicator';
import Time from 'app/components/Time';
import config from 'app/config';

export type Props = {
  title: string,
  event: Event,
  registration: Object,
  currentUser: Object,
  onSubmit: void,
  onToken: void
};

class JoinEventForm extends Component {
  state = {
    time: null,
    formOpen: false,
    captchaOpen: false,
    buttonOpen: false
  };
  counter = undefined;

  componentWillMount() {
    this.parseEventTimes(this.props.event);
  }

  componentWillUnmount() {
    clearInterval(this.counter);
  }

  parseEventTimes = ({ activationTime, startTime }) => {
    const poolActivationTime = moment(activationTime);
    const currentTime = moment();
    const diffTime = poolActivationTime.diff(currentTime);
    let duration = moment.duration(diffTime, 'milliseconds');
    if (currentTime.isAfter(moment(startTime))) {
      // Do nothing<commit_msg>Fix bug when unregistering and event is not open for registration<commit_after>// @flow

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { reduxForm, Field } from 'redux-form';
import moment from 'moment';
import { Captcha, TextEditor } from 'app/components/Form';
import Button from 'app/components/Button';
import StripeCheckout from 'react-stripe-checkout';
import logoImage from 'app/assets/kule.png';
import LoadingIndicator from 'app/components/LoadingIndicator';
import Time from 'app/components/Time';
import config from 'app/config';

export type Props = {
  title: string,
  event: Event,
  registration: Object,
  currentUser: Object,
  onSubmit: void,
  onToken: void
};

class JoinEventForm extends Component {
  state = {
    time: null,
    formOpen: false,
    captchaOpen: false,
    buttonOpen: false
  };
  counter = undefined;

  componentWillMount() {
    this.parseEventTimes(this.props.event);
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.event.activationTime && !this.props.event.activationTime) {
      this.setState({ formOpen: false });
      this.parseEventTimes(nextProps.event);
    }
  }

  componentWillUnmount() {
    clearInterval(this.counter);
  }

  parseEventTimes = ({ activationTime, startTime }) => {
    const poolActivationTime = moment(activationTime);
    const currentTime = moment();
    const diffTime = poolActivationTime.diff(currentTime);
    let duration = moment.duration(diffTime, 'milliseconds');
    if (currentTime.isAfter(moment(startTime))) {
      // Do nothing
{'fraction_non_alphanumeric': 0.11633412242137302, 'fraction_numerical': 0.0, 'mean_word_length': 4.301075268817204, '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': '11486', 'n_tokens_mistral': 877, 'n_tokens_neox': 863, 'n_words': 231}