<commit_before>import React, { Component } from 'react';
import PropTypes, { connect } from '../PropTypes.js';

import { displayFormat } from '../controls/Telephone.js';
import * as loginActions from '../../actions/userActions.js';

import RaisedButton from 'material-ui/RaisedButton';
import TabbedContainer from '../controls/TabbedContainer.js';

import ChangePassword from '../users/ChangePassword.js';
import ChangePlayerDetails from '../users/ChangePlayerDetails.js';
import ProfilePhotoForm, { ProfilePhotoAvatarForm } from '../users/ProfilePhotoForm.js';
import PlayerLineup from './PlayerLineup.js';

const tabEventKeys = {
  main: 1,
  editDetails: 2,
  editPicture: 3,
  editAvatar: 4,
  editPassword: 5,
  editHolidays: 6,
};

@connect(state => {
  return {
    //config: state.config,
    user: state.user,
  };
}, loginActions)
export default class Profile extends Component {
  static contextTypes = PropTypes.contextTypes;
  static propTypes = {
    user: PropTypes.UserModel.isRequired,
    logout: PropTypes.func.isRequired,
  }

  constructor(props) {
    super(props);
  }

  _renderTabContent(eventKey) {
    const player = this.props.user.getPlayer();
    switch (eventKey) {
    case tabEventKeys.main:
      return <ProfilePlayerDetails t={this.context.t} player={player} logout={this.props.logout} />;
    case tabEventKeys.editDetails:
      return <ChangePlayerDetails player={player} />;
    case tabEventKeys.editPicture:
      return <ProfilePhotoForm />;
    case tabEventKeys.editAvatar:
      return <ProfilePhotoAvatarForm />;
    case tabEventKeys.editPassword:
      return <ChangePassword />;
    case tabEventKeys.editHolidays:
      return <PlayerLineup user={this.props.user} />;
    }
  }

  render() {
    const t = this.context.t;
    const tabConfig = [{
      key: tabEventKeys.main,
      title: t('profile.main'),
    }, {
      key: tabEventKeys.editHolidays,
      title: t('profile.editHolidays'),
    }, {
      key: tabEventKeys.editPassword,
      title: t('profile.editPassword'),
    }, {
      key: tabEventKeys.editDetails,
      title: t('profile.editDetails'),
    }, {
      key: tabEventKeys.editPicture,
      title: t('profile.editPicture'),
    }, {
      key: tabEventKeys.editAvatar,
      title: t('profile.editAvatar'),
    }];

    return (
      <div style={{marginTop: 15, marginBottom: 20}}>
        <TabbedContainer
          openTabKey={tabEventKeys.main}
          tabKeys={tabConfig}
          tabRenderer={::this._renderTabContent} />
      </div>
    );
  }
}

const ProfilePlayerDetails = ({player, t, logout}) => (
  <div style={{padding: 10}}>
    <h3>{player.name}</h3>
    <p>
      <strong>{t('player.email')}</strong>&nbsp;{player.contact.email}
      <br />
      <strong>{t('player.gsm')}</strong>&nbsp;{displayFormat(player.contact.mobile)}
      <br />
      <strong>{t('player.address')}</strong>&nbsp;{player.contact.address}
      <br />
      <strong>{t('player.city')}</strong>&nbsp;{player.contact.city}
    </p>

    <RaisedButton
      label={t('login.logoutButton')}
      secondary={true}
      style={{marginTop: 15}}<commit_msg>don't crash when landing on profile page<commit_after>import React, { Component } from 'react';
import PropTypes, { connect } from '../PropTypes.js';

import { displayFormat } from '../controls/Telephone.js';
import * as loginActions from '../../actions/userActions.js';

import RaisedButton from 'material-ui/RaisedButton';
import TabbedContainer from '../controls/TabbedContainer.js';

import ChangePassword from '../users/ChangePassword.js';
import ChangePlayerDetails from '../users/ChangePlayerDetails.js';
import ProfilePhotoForm, { ProfilePhotoAvatarForm } from '../users/ProfilePhotoForm.js';
import PlayerLineup from './PlayerLineup.js';

const tabEventKeys = {
  main: 1,
  editDetails: 2,
  editPicture: 3,
  editAvatar: 4,
  editPassword: 5,
  editHolidays: 6,
};

@connect(state => {
  return {
    //config: state.config,
    user: state.user,
  };
}, loginActions)
export default class Profile extends Component {
  static contextTypes = PropTypes.contextTypes;
  static propTypes = {
    user: PropTypes.UserModel.isRequired,
    logout: PropTypes.func.isRequired,
  }

  constructor(props) {
    super(props);
  }

  _renderTabContent(eventKey) {
    const player = this.props.user.getPlayer();
    switch (eventKey) {
    case tabEventKeys.main:
      return <ProfilePlayerDetails t={this.context.t} player={player} logout={this.props.logout} />;
    case tabEventKeys.editDetails:
      return <ChangePlayerDetails player={player} />;
    case tabEventKeys.editPicture:
      return <ProfilePhotoForm />;
    case tabEventKeys.editAvatar:
      return <ProfilePhotoAvatarForm />;
    case tabEventKeys.editPassword:
      return <ChangePassword />;
    case tabEventKeys.editHolidays:
      return <PlayerLineup user={this.props.user} />;
    }
  }

  render() {
    const t = this.context.t;
    const tabConfig = [{
      key: tabEventKeys.main,
      title: t('profile.main'),
    }, {
      key: tabEventKeys.editHolidays,
      title: t('profile.editHolidays'),
    }, {
      key: tabEventKeys.editPassword,
      title: t('profile.editPassword'),
    }, {
      key: tabEventKeys.editDetails,
      title: t('profile.editDetails'),
    }, {
      key: tabEventKeys.editPicture,
      title: t('profile.editPicture'),
    }, {
      key: tabEventKeys.editAvatar,
      title: t('profile.editAvatar'),
    }];

    if (!this.props.user.playerId) {
      return <div />;
    }

    return (
      <div style={{marginTop: 15, marginBottom: 20}}>
        <TabbedContainer
          openTabKey={tabEventKeys.main}
          tabKeys={tabConfig}
          tabRenderer={::this._renderTabContent} />
      </div>
    );
  }
}

const ProfilePlayerDetails = ({player, t, logout}) => (
  <div style={{padding: 10}}>
    <h3>{player.name}</h3>
    <p>
      <strong>{t('player.email')}</strong>&nbsp;{player.contact.email}
      <br />
      <strong>{t('player.gsm')}</strong>&nbsp;{displayFormat(player.contact.mobile)}
      <br />
      <strong>{t('player.address')}</strong>&nbsp;{player.contact.address}
      <br />
      <strong>{t('player.city')}</strong>&nbsp;{player.contact.city}
    </p>

    <RaisedButton
      label={t('login.logoutButton')}
      secondary={true}
      style={{marginTop: 15}}
{'fraction_non_alphanumeric': 0.15010237832729564, 'fraction_numerical': 0.005040163805323673, 'mean_word_length': 3.2474916387959865, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 58, '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': '6063370', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1977, 'n_words': 371}