<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import AutocompleteInput from 'app/components/elements/AutocompleteInput';

import Unicode from 'app/utils/Unicode';
import tt from 'counterpart';
import { throws } from 'assert';

const languageOptions = [
    { abbr: 'en', name: 'English' },
    { abbr: 'kr', name: 'Korean' },
    { abbr: 'zh', name: 'Chinese' },
    { abbr: 'ms', name: 'Malay' },
    { abbr: 'pl', name: 'Polish' },
    { abbr: 'pt', name: 'Portuguese' },
    { abbr: 'ru', name: 'Russian' },
    { abbr: 'it', name: 'Italian' },
    { abbr: 'de', name: 'German' },
    { abbr: 'es', name: 'Spanish' },
    { abbr: 'sv', name: 'Swedish' },
];

class CommunitySettings extends Component {
    constructor(props) {
        super(props);
        this.state = {
            title: this.props.title,
            about: this.props.about,
            is_nsfw: this.props.is_nsfw,
            lang: this.props.lang,
            description: this.props.description,
            flag_text: this.props.flag_text,
        };
    }

    onInput = event => {
        const el = event.target;
        const field = el.name;
        const value = el.hasOwnProperty('checked') ? el.checked : el.value;
        this.setState({ [field]: value });

        if (field == 'title') {
            let formError = null;
            const rx = new RegExp('^[' + Unicode.L + ']');
            if (value && !rx.test(value))
                formError = 'Must start with a letter.';
            this.setState({ formError });
        }
    };

    onSubmit = e => {
        e.preventDefault();
        // Trim leading and trailing whitespace before submission.
        const payload = {};
        Object.keys(this.state).forEach(k => {
            if (k == 'formError') return;
            if (typeof this.state[k] === 'string')
                payload[k] = this.state[k].trim();
            else payload[k] = this.state[k];
        });
        this.props.onSubmit(payload);
    };

    render() {
        const {
            title,
            about,
            is_nsfw,
            lang,
            description,
            flag_text,
            formError,
        } = this.state;
        return (
            <span>
                <div>
                    <h4>{tt('g.community_settings_header')}</h4>
                    <p>{tt('g.community_settings_description')}</p>
                </div>
                <form onSubmit={this.onSubmit}>
                    {formError && <span className="error">{formError}</span>}
                    <label className="input-group">
                        <span className="input-group-label">Title </span>
                        <input
                            className="input-group-field"
                            type="text"
                            maxLength={20}
                            minLength={3}
                            name="title"
                            value={title}
                            onChange={e => this.onInput(e)}
                            required
                        />
                    </label>
                    <label className="input-group">
                        <span className="input-group-label">About </span>
                        <input
                            className="input-group-field"
                            type="text"
                            maxLength={120}
                            name="about"
                            value={about}
                            onChange={e => this.onInput(e)}
                        />
                    </label>
                    <AutocompleteInput
                        label={'Select a language'}
                        values={languageOptions}
                        initialValue="English"
                        onSelect={v => {
                            const selectedLanguage = languageOptions.filter(
                                l => l.name === v
                            )[0];
                            debugger;
                            this.setState({
                                lang: selectedLanguage.abbr,
                            });
                        }}
                    />
                    <label style={{ margin: '0 0 1rem' }}>
                        Description<br />
                        <textarea
                            style={{ whiteSpace: 'normal' }}
                            type="text"
                            maxLength={1000}
                            rows="10"
                            onChange={e => this.onInput(e)}
                            name="description"
                            value={description}
                        />
                    </label>
                    <label style={{ margin: '0 0 0.5rem' }}>
                        Rules (one per line)<br />
                        <textarea
                            style={{ whiteSpace: 'normal' }}
                            type="text"
                            maxLength={1000}
                            rows="7"
                            onChange={e => this.onInput(e)}
                            name="flag_text"
                            value={flag_text}
                        />
                    </label>
                    <label>
                        <input
                            type="checkbox"
                            name="is_nsfw"
                            checked={is_nsfw}
                            onChange={e => this.onInput(e)}
                        />{' '}
                        NSFW
                    </label>
                    <div className="text-right">
                        <input className="button" type="submit" value="Save" />
                    </div>
                </form>
            </span>
        );
    }
}

CommunitySettings.propTypes = {
    onSubmit: PropTypes.func.isRequired,
    title: PropTypes.string.isRequired,
    about: PropTypes.string.isRequired,
    is_nsfw: PropTypes.bool.isRequired,
    lang: PropTypes.string,
    description: PropTypes.string.isRequired,
    flag_text: PropTypes.string.isRequired,
};

export default connect()(CommunitySettings);
<commit_msg>remove debugger statement<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import AutocompleteInput from 'app/components/elements/AutocompleteInput';

import Unicode from 'app/utils/Unicode';
import tt from 'counterpart';
import { throws } from 'assert';

const languageOptions = [
    { abbr: 'en', name: 'English' },
    { abbr: 'kr', name: 'Korean' },
    { abbr: 'zh', name: 'Chinese' },
    { abbr: 'ms', name: 'Malay' },
    { abbr: 'pl', name: 'Polish' },
    { abbr: 'pt', name: 'Portuguese' },
    { abbr: 'ru', name: 'Russian' },
    { abbr: 'it', name: 'Italian' },
    { abbr: 'de', name: 'German' },
    { abbr: 'es', name: 'Spanish' },
    { abbr: 'sv', name: 'Swedish' },
];

class CommunitySettings extends Component {
    constructor(props) {
        super(props);
        this.state = {
            title: this.props.title,
            about: this.props.about,
            is_nsfw: this.props.is_nsfw,
            lang: this.props.lang,
            description: this.props.description,
            flag_text: this.props.flag_text,
        };
    }

    onInput = event => {
        const el = event.target;
        const field = el.name;
        const value = el.hasOwnProperty('checked') ? el.checked : el.value;
        this.setState({ [field]: value });

        if (field == 'title') {
            let formError = null;
            const rx = new RegExp('^[' + Unicode.L + ']');
            if (value && !rx.test(value))
                formError = 'Must start with a letter.';
            this.setState({ formError });
        }
    };

    onSubmit = e => {
        e.preventDefault();
        // Trim leading and trailing whitespace before submission.
        const payload = {};
        Object.keys(this.state).forEach(k => {
            if (k == 'formError') return;
            if (typeof this.state[k] === 'string')
                payload[k] = this.state[k].trim();
            else payload[k] = this.state[k];
        });
        this.props.onSubmit(payload);
    };

    render() {
        const {
            title,
            about,
            is_nsfw,
            lang,
            description,
            flag_text,
            formError,
        } = this.state;
        return (
            <span>
                <div>
                    <h4>{tt('g.community_settings_header')}</h4>
                    <p>{tt('g.community_settings_description')}</p>
                </div>
                <form onSubmit={this.onSubmit}>
                    {formError && <span className="error">{formError}</span>}
                    <label className="input-group">
                        <span className="input-group-label">Title </span>
                        <input
                            className="input-group-field"
                            type="text"
                            maxLength={20}
                            minLength={3}
                            name="title"
                            value={title}
                            onChange={e => this.onInput(e)}
                            required
                        />
                    </label>
                    <label className="input-group">
                        <span className="input-group-label">About </span>
                        <input
                            className="input-group-field"
                            type="text"
                            maxLength={120}
                            name="about"
                            value={about}
                            onChange={e => this.onInput(e)}
                        />
                    </label>
                    <AutocompleteInput
                        label={'Select a language'}
                        values={languageOptions}
                        initialValue="English"
                        onSelect={v => {
                            const selectedLanguage = languageOptions.filter(
                                l => l.name === v
                            )[0];
                            this.setState({
                                lang: selectedLanguage.abbr,
                            });
                        }}
                    />
                    <label style={{ margin: '0 0 1rem' }}>
                        Description<br />
                        <textarea
                            style={{ whiteSpace: 'normal' }}
                            type="text"
                            maxLength={1000}
                            rows="10"
                            onChange={e => this.onInput(e)}
                            name="description"
                            value={description}
                        />
                    </label>
                    <label style={{ margin: '0 0 0.5rem' }}>
                        Rules (one per line)<br />
                        <textarea
                            style={{ whiteSpace: 'normal' }}
                            type="text"
                            maxLength={1000}
                            rows="7"
                            onChange={e => this.onInput(e)}
                            name="flag_text"
                            value={flag_text}
                        />
                    </label>
                    <label>
                        <input
                            type="checkbox"
                            name="is_nsfw"
                            checked={is_nsfw}
                            onChange={e => this.onInput(e)}
                        />{' '}
                        NSFW
                    </label>
                    <div className="text-right">
                        <input className="button" type="submit" value="Save" />
                    </div>
                </form>
            </span>
        );
    }
}

CommunitySettings.propTypes = {
    onSubmit: PropTypes.func.isRequired,
    title: PropTypes.string.isRequired,
    about: PropTypes.string.isRequired,
    is_nsfw: PropTypes.bool.isRequired,
    lang: PropTypes.string,
    description: PropTypes.string.isRequired,
    flag_text: PropTypes.string.isRequired,
};

export default connect()(CommunitySettings);

{'fraction_non_alphanumeric': 0.11786738922537456, 'fraction_numerical': 0.004303474657315907, 'mean_word_length': 1.0398244473342002, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1078638', 'n_tokens_mistral': 3122, 'n_tokens_neox': 3001, 'n_words': 611}