"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const react_redux_1 = require("react-redux");
const Main_1 = require("@/pages/builder/header/Main");
const components_1 = require("@/pages/components");
const system_1 = require("@/pages/system");
const PAGE_ACTIONS = __importStar(require("@/store/actions/builder/main"));
const mapStateToProps = (store) => ({
    curStep: store.builder.main.curStep,
    stepCount: store.builder.main.stepCount,
    content: store.builder.main.content,
});
const mapDispatchToProps = {
    getSteps: PAGE_ACTIONS.getSteps,
    goLastStep: PAGE_ACTIONS.preStep,
    goNextStep: PAGE_ACTIONS.nextStep,
};
const Steps = (props) => {
    const { curStep, stepCount = 0, content, getSteps, goLastStep, goNextStep } = props;
    const preStepStatus = curStep > 0;
    const nextStepStatus = curStep < stepCount - 1;
    // i18n
    const { locale } = (0, react_1.useContext)(system_1.GlobalContext);
    const { builder } = locale.business;
    (0, react_1.useEffect)(() => {
        if (content.id) {
            getSteps();
        }
    }, [content.id]);
    const handleGoLastStep = () => {
        if (preStepStatus) {
            goLastStep();
        }
    };
    const handleGoNextStep = () => {
        if (nextStepStatus) {
            goNextStep();
        }
    };
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(Main_1.StyledIcon, { className: preStepStatus ? '' : 'disabled', onClick: handleGoLastStep },
            react_1.default.createElement(components_1.BackIcon, { color: preStepStatus ? '' : 'rgb(195, 193, 193)' }),
            react_1.default.createElement(Main_1.IconMsg, null, builder.lastStep)),
        react_1.default.createElement(Main_1.StyledIcon, { className: nextStepStatus ? '' : 'disabled', onClick: handleGoNextStep },
            react_1.default.createElement(components_1.NextIcon, { color: nextStepStatus ? '' : 'rgb(195, 193, 193)' }),
            react_1.default.createElement(Main_1.IconMsg, null, builder.nextStep))));
};
exports.default = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(Steps);
