<commit_before>import * as React from "react";
import { Map } from 'immutable';
import { Action } from 'redux';

import { User } from '../../Immutable'
import { PendingUser } from '../../Immutable';

import { Modal, Form, FormGroup, ControlLabel, FormControl, Row, Button, Alert } from 'react-bootstrap';
import { BusyButton } from '../BusyButton';
import { ClientStack } from '../..';
import { ReduxStore } from '../../Redux';

interface props {
  show: boolean
  cancel: () => void
  user: PendingUser
  store: ReduxStore
}

interface state {
  reason?: string,
  error?: string
}

export class ReviewPendingModal extends React.Component<props, state> {

  constructor(props: props) {
    super(props);
    this.state = {
      reason: '',
      error: ''
    }
  }

  componentWillReceiveProps(nextProps: props) {
    if (!nextProps.show) {
      this.setState({
        reason: '',
        error: ''
      })
    }
  }

  onReason(e: { target: { value: string } }) {
    this.setState({ reason: e.target.value })
  }

  onApprove(): Promise<void> {
    return ClientStack.PendingUser.Approve(this.props.user).then((uuid) => {
      // place user into redux
      let u = new User();
      u = u.set('name', this.props.user.name)
        .set('email', this.props.user.email)
        .set('uuid', uuid)
        .set('godLevel', 1);
      this.props.store.User.Update(u);
      // remove pending user from redux
      this.props.store.PendingUser.Destroy(this.props.user);
      this.props.cancel();
    }).catch((err: Error) => {
      this.setState({
        error: 'Error approving user: ' + err.message<commit_msg>incorrect fields in user approval.  They need to match the Immutable Record<commit_after>import * as React from "react";
import { Map } from 'immutable';
import { Action } from 'redux';

import { User } from '../../Immutable'
import { PendingUser } from '../../Immutable';

import { Modal, Form, FormGroup, ControlLabel, FormControl, Row, Button, Alert } from 'react-bootstrap';
import { BusyButton } from '../BusyButton';
import { ClientStack } from '../..';
import { ReduxStore } from '../../Redux';

interface props {
  show: boolean
  cancel: () => void
  user: PendingUser
  store: ReduxStore
}

interface state {
  reason?: string,
  error?: string
}

export class ReviewPendingModal extends React.Component<props, state> {

  constructor(props: props) {
    super(props);
    this.state = {
      reason: '',
      error: ''
    }
  }

  componentWillReceiveProps(nextProps: props) {
    if (!nextProps.show) {
      this.setState({
        reason: '',
        error: ''
      })
    }
  }

  onReason(e: { target: { value: string } }) {
    this.setState({ reason: e.target.value })
  }

  onApprove(): Promise<void> {
    return ClientStack.PendingUser.Approve(this.props.user).then((uuid) => {
      // place user into redux
      let names = this.props.user.name.split(' ');
      let u = new User();
      u = u.set('username', names[0])
        .set('lastname', names[1])
        .set('email', this.props.user.email)
        .set('UUID', uuid)
        .set('godLevel', 1);
      this.props.store.User.Update(u);
      // remove pending user from redux
      this.props.store.PendingUser.Destroy(this.props.user);
      this.props.cancel();
    }).catch((err: Error) => {
      this.setState({
        error: 'Error approving user: ' + err.message
{'fraction_non_alphanumeric': 0.16044997039668443, 'fraction_numerical': 0.0011841326228537595, 'mean_word_length': 2.741971207087486, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '6076403', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1056, 'n_words': 259}