<commit_before>import Webiny from 'Webiny';
const Ui = Webiny.Ui.Components;

// TODO: maybe create a Webiny.Ui.ModalComponent that will handle show/hide/onHide/onShow methods

class AddCreditsModal extends Webiny.Ui.Component {

    constructor(props) {
        super(props);

        this.state = {
            error: false,
            extraData: {},
            model: {
                credits: 0
            }
        };

        Webiny.Tools.Validator.addValidator('cronFrequency', (val) => {
            const api = new Webiny.Api.Endpoint('/entities/core/users');

            return api.post('call', {mask: val}).then(ar => {
                throw new Error('Message');
            });
        });

        this.bindMethods('addCredits,show,hide,generateSlug');
    }

    /**
     * @param model Submitted form data
     * @param container Form container instance that handled the forms
     * @returns {*}
     */
    addCredits(model) {
        this.setState({model, error: false});
        const api = new Webiny.Api.Endpoint('/entities/core/users');
        return api.post('call', model).then(ar => {
            if (ar.isError() && ar.getCode() === 'WBY-ENTITY-API-METHOD-VALIDATION') {
                return this.setState({error: ar.getData().credits});
            }

            this.hide();
        });
    }

    generateSlug(value) {
        console.log("GENERATE SLUG", value);
        const api = new Webiny.Api.Endpoint('/entities/core/users');

        return api.post('call', {data: value}).then(ar => {
            this.setState({error: 'Neki glupi error!'});<commit_msg>- user categories - just need to resolve one issue<commit_after>import Webiny from 'Webiny';
const Ui = Webiny.Ui.Components;

// TODO: maybe create a Webiny.Ui.ModalComponent that will handle show/hide/onHide/onShow methods

class AddCreditsModal extends Webiny.Ui.Component {

    constructor(props) {
        super(props);

        this.state = {
            error: false,
            extraData: {},
            model: {
                credits: 0
            }
        };

        Webiny.Tools.Validator.addValidator('cronFrequency', (val) => {
            const api = new Webiny.Api.Endpoint('/entities/core/users');

            return api.post('call', {mask: val}).then(() => {
                throw new Error('Message');
            });
        });

        this.bindMethods('addCredits,show,hide,generateSlug');
    }

    /**
     * @param model Submitted form data
     * @param container Form container instance that handled the forms
     * @returns {*}
     */
    addCredits(model) {
        this.setState({model, error: false});
        const api = new Webiny.Api.Endpoint('/entities/core/users');
        return api.post('call', model).then(ar => {
            if (ar.isError() && ar.getCode() === 'WBY-ENTITY-API-METHOD-VALIDATION') {
                return this.setState({error: ar.getData().credits});
            }

            this.hide();
        });
    }

    generateSlug(value) {
        const api = new Webiny.Api.Endpoint('/entities/core/users');

        return api.post('call', {data: value}).then(() => {
            this.setState({error: 'Neki glupi error!'});
{'fraction_non_alphanumeric': 0.14495929868503443, 'fraction_numerical': 0.0006261740763932373, 'mean_word_length': 2.060344827586207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3012082', 'n_tokens_mistral': 915, 'n_tokens_neox': 917, 'n_words': 192}