import * as React from 'react';
import { AdaptablePopover } from '../../AdaptablePopover';
import WizardPanel from '../../../components/WizardPanel';
import HelpBlock from '../../../components/HelpBlock';
import { CheckBox } from '../../../components/CheckBox';
import { Flex } from 'rebass';
import StringExtensions from '../../../Utilities/Extensions/StringExtensions';
export class AlertSelectQueryWizard extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            HasExpression: StringExtensions.IsNotNullOrEmpty(this.props.data.Rule.BooleanExpression),
        };
    }
    render() {
        return (React.createElement("div", { "data-name": 'alert-query' },
            React.createElement(WizardPanel, null,
                React.createElement(HelpBlock, null,
                    "A Query is used if the alert triggering is dependent on value in other columns in the row.",
                    React.createElement("br", null),
                    React.createElement("br", null),
                    "If so, then alert will only be triggered if the Query evaluates as true."),
                React.createElement(Flex, { alignItems: "center", flexDirection: "row", marginTop: 2 },
                    React.createElement(CheckBox, { marginRight: 3, marginLeft: 2, onChange: (checked) => this.onOtherExpressionOptionChanged(checked), checked: this.state.HasExpression }, "Use Query"),
                    ' ',
                    React.createElement(AdaptablePopover, { headerText: 'Alert: Query', bodyText: [
                            'Create a query (in next step) which will stipulate other cell values required for the Alert to be triggered.',
                        ] })))));
    }
    onOtherExpressionOptionChanged(checked) {
        this.setState({ HasExpression: checked }, () => this.props.updateGoBackState());
    }
    canNext() {
        return true;
    }
    canBack() {
        return true;
    }
    next() {
        // if we have an expression and its null then create an empty one
        if (!this.state.HasExpression) {
            this.props.data.Rule.BooleanExpression = undefined;
        }
    }
    back() {
        /* no implementation */
    }
    getIndexStepIncrement() {
        return this.state.HasExpression ? 1 : 2;
    }
    getIndexStepDecrement() {
        return 1;
    }
}
