<commit_before>import { Meteor } from 'meteor/meteor';
import React, { Component, PropTypes } from 'react';
import { Grid, Button, Icon } from 'semantic-ui-react';

import AdminUserEdit from './admin-user-edit';
import Actions from './actions';

class AdminUser extends Component {
  constructor(props) {
    super(props);
    this.state = {
      editMode: false
    };
  }

  render() {
    return (
      <Grid.Row>
        <Grid.Column computer={3} mobile={16}>
          <Actions
            onEdit={() => console.log(`edit: ${this.props.user.name}`)}
            onPasswordReset={() => console.log(`password reset: ${this.props.user.name}`)}
            onEmailResend={() => console.log(`email resend: ${this.props.user.name}`)}
            onDelete={() => console.log(`delete: ${this.props.user.name}`)}
          />
        </Grid.Column>
      </Grid.Row>
    )
  }

  enableEdit(user) {
    this.setState({ editMode: true });
  }

  saveUser(event) {
    const firstname = this.refs.firstname.value;
    const lastname = this.refs.lastname.value;
    const username = this.refs.username.value;
    const email = this.refs.email.value;

    console.log(`Tryin to save \nfirst:${firstname}\nlast:${lastname}\nUsername:${username} \nEmail:${email} `);

    const btn = $(event.target);

    Meteor.call('userAdminUpdate', {
        _id: this.props.user._id,
      firstname: firstname,
      lastname: lastname,
      username: username,
      email: email
    }, (err, result) => {
      if (err) {
        console.log(err);
        btn.attr('data-content', 'Failed to save user! 😰');
      } else {
        btn.attr('data-content', `${firstname} saved! 😀`);
      }<commit_msg>connect edit mode to action<commit_after>import { Meteor } from 'meteor/meteor';
import React, { Component, PropTypes } from 'react';
import { Grid, Button, Icon } from 'semantic-ui-react';

import AdminUserEdit from './admin-user-edit';
import Actions from './actions';

class AdminUser extends Component {
  constructor(props) {
    super(props);
    this.state = {
      editMode: false
    };
  }

  render() {
    return (
      <Grid.Row>
        <Grid.Column computer={3} mobile={16}>
          <Actions
            onEdit={() => this._toggleEdit()}
            onPasswordReset={() => console.log(`password reset: ${this.props.user.name}`)}
            onEmailResend={() => console.log(`email resend: ${this.props.user.name}`)}
            onDelete={() => console.log(`delete: ${this.props.user.name}`)}
          />
        </Grid.Column>
      </Grid.Row>
    );
  }

  _toggleEdit() {
    this.setState({ editMode: !this.state.editMode });
  }

  saveUser(event) {
    const firstname = this.refs.firstname.value;
    const lastname = this.refs.lastname.value;
    const username = this.refs.username.value;
    const email = this.refs.email.value;

    console.log(`Tryin to save \nfirst:${firstname}\nlast:${lastname}\nUsername:${username} \nEmail:${email} `);

    const btn = $(event.target);

    Meteor.call('userAdminUpdate', {
        _id: this.props.user._id,
      firstname: firstname,
      lastname: lastname,
      username: username,
      email: email
    }, (err, result) => {
      if (err) {
        console.log(err);
        btn.attr('data-content', 'Failed to save user! 😰');
      } else {
        btn.attr('data-content', `${firstname} saved! 😀`);
      }
{'fraction_non_alphanumeric': 0.16745702430349732, 'fraction_numerical': 0.0017783046828689982, 'mean_word_length': 2.6486486486486487, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, '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': '4818465', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1067, 'n_words': 219}