<commit_before>import React from 'react';
import HoodieApi from '../services/hoodie.services.js';
import WarningMessage from './warning-message.components.jsx';
import LocalClient from '../stores/local-client.stores.jsx';
import Log from '../services/log.services.js';

export default class Account extends React.Component {
	constructor(props) {
		super(props);
		this.state = {};
	}
	async changePassword(e) {
		e.preventDefault();
		const password = React.findDOMNode(this.refs.password).value;
		if (password.length < 6) {
			this.setState({
				passwordTooShort:true,
			});

			return;
		}

		const result = await HoodieApi.changePassword(password);

		this.setState({
			passwordChanged:true,
		});

		return;
	}

	componentWillMount() {
		this.client = LocalClient.instance();
	}

	componentWillUnmount() {
		this.setState({
			passwordChanged:false,
			passwordTooShort:false,
		});
	}

	logout() {
		this.client.dispatchAction('/logout');
		Log.ui('Account.logout');
	}

	render() {
		if (process.env.__SHOW_RENDER__) {
			console.log('[RENDER] account');
		}

		const accountInfos = (
			<div className="account-block">
				<h2 className="account-block-title side-tab-h2">My subscription</h2>
				<div className="account-block-plan">
					{(() => {
						if ( HoodieApi.instance.plan.indexOf('annual') > -1 ) {
							return 'Professional annual plan';
						}
						else if ( HoodieApi.instance.plan.indexOf('monthly') > -1 ) {
							return 'Professional monthly plan';
						}
						else {
							return 'All privileges)';
						}
					})()}
				</div>
				<a className="account-block-button" href="https://www.prototypo.io/account#/account">Update my account</a>
			</div>
		);

		let passwordTooShort = false;

		if (this.state.passwordTooShort) {
			passwordTooShort = `You're password is too short (must be 6 characters long at least)`;
		}

		let changePassContent = false;

		if (!this.state.passwordChanged) {
			changePassContent = (
				<div className="account-block">
					<h2 className="account-block-title side-tab-h2">Change password</h2>
					<form className="account-block-form" onSubmit={(e) => { this.changePassword(e) }}><commit_msg>Add free plan in account panel<commit_after>import React from 'react';
import HoodieApi from '../services/hoodie.services.js';
import WarningMessage from './warning-message.components.jsx';
import LocalClient from '../stores/local-client.stores.jsx';
import Log from '../services/log.services.js';

export default class Account extends React.Component {
	constructor(props) {
		super(props);
		this.state = {};
	}
	async changePassword(e) {
		e.preventDefault();
		const password = React.findDOMNode(this.refs.password).value;
		if (password.length < 6) {
			this.setState({
				passwordTooShort:true,
			});

			return;
		}

		const result = await HoodieApi.changePassword(password);

		this.setState({
			passwordChanged:true,
		});

		return;
	}

	componentWillMount() {
		this.client = LocalClient.instance();
	}

	componentWillUnmount() {
		this.setState({
			passwordChanged:false,
			passwordTooShort:false,
		});
	}

	logout() {
		this.client.dispatchAction('/logout');
		Log.ui('Account.logout');
	}

	render() {
		if (process.env.__SHOW_RENDER__) {
			console.log('[RENDER] account');
		}

		const accountInfos = (
			<div className="account-block">
				<h2 className="account-block-title side-tab-h2">My subscription</h2>
				<div className="account-block-plan">
					{(() => {
						if ( HoodieApi.instance.plan.indexOf('free_') > -1 ) {
							return 'Free plan';
						}
						else if ( HoodieApi.instance.plan.indexOf('annual_') > -1 ) {
							return 'Professional annual plan';
						}
						else if ( HoodieApi.instance.plan.indexOf('monthly_') > -1 ) {
							return 'Professional monthly plan';
						}
						else {
							return 'All privileges)';
						}
					})()}
				</div>
				<a className="account-block-button" href="https://www.prototypo.io/account#/account">Update my account</a>
			</div>
		);

		let passwordTooShort = false;

		if (this.state.passwordTooShort) {
			passwordTooShort = `You're password is too short (must be 6 characters long at least)`;
		}

		let changePassContent = false;

		if (!this.state.passwordChanged) {
			changePassContent = (
				<div className="account-block">
					<h2 className="account-block-title side-tab-h2">Change password</h2>
					<form className="account-block-form" onSubmit={(e) => { this.changePassword(e) }}>
{'fraction_non_alphanumeric': 0.15146067415730338, 'fraction_numerical': 0.004719101123595505, 'mean_word_length': 3.4465534465534464, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 36, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4143603', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1407, 'n_words': 278}