"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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const react_redux_1 = require("react-redux");
const react_router_dom_1 = require("react-router-dom");
const antd_1 = require("antd");
const styled_components_1 = __importDefault(require("styled-components"));
const ACTIONS = __importStar(require("@/actions/workspace/dynamics/index"));
const index_1 = require("@/components/index");
const index_2 = require("@/constants/index");
const system_1 = require("@/pages/system");
const index_3 = require("@/utils/index");
const { Step: AntdStep } = antd_1.Steps;
const Step = (0, styled_components_1.default)(AntdStep) `
  .ant-steps-item-content {
    .ant-steps-item-title {
      width: 100%;
    }
    .ant-steps-item-subtitle {
      margin-left: 0;
      width: 100%;
      display: flex;
      justify-content: space-between;
    }
  }
`;
const mapStateToProps = (store) => ({
    organizationId: store.system.user.organizationId,
    loading: store.workspace.dynamics.loading,
    pageInfo: store.workspace.dynamics.pageInfo,
    dynamics: store.workspace.dynamics.dynamics,
});
const mapDispatchToProps = {
    searchDynamics: ACTIONS.fetchDynamics,
    clearAll: ACTIONS.clearAll,
};
const Dynamics = (props) => {
    const { organizationId, loading, pageInfo, dynamics, clearAll, searchDynamics } = props;
    // i18n
    const { locale } = (0, react_1.useContext)(system_1.GlobalContext);
    const { global } = locale.business;
    (0, react_1.useEffect)(() => {
        searchDynamics({ organizationId, page: pageInfo.page, size: pageInfo.size, search: '' });
        return () => {
            clearAll();
        };
    }, []);
    return (react_1.default.createElement(index_1.Content, null,
        react_1.default.createElement(index_1.FoxPageContent, { breadcrumb: react_1.default.createElement(index_1.FoxPageBreadcrumb, { breadCrumb: [
                    {
                        name: global.dynamics,
                    },
                ] }) },
            react_1.default.createElement(antd_1.Spin, { spinning: loading },
                react_1.default.createElement(index_1.Content, { style: { maxWidth: index_2.WIDTH_DEFAULT } },
                    react_1.default.createElement(antd_1.Steps, { progressDot: true, current: dynamics.length, direction: "vertical" }, dynamics.map((dynamic) => {
                        const { realMethod, name, user, applicationName, originUrl } = dynamic.content;
                        return (react_1.default.createElement(Step, { key: dynamic.id, title: (0, index_3.periodFormat)(dynamic.createTime, 'unknown'), subTitle: react_1.default.createElement(react_1.default.Fragment, null, name && (react_1.default.createElement(react_1.default.Fragment, null,
                                realMethod === index_2.dynamicType.delete || !originUrl ? (react_1.default.createElement("div", null, name)) : (react_1.default.createElement(react_router_dom_1.Link, { to: originUrl.replace('/#', '') }, name)),
                                react_1.default.createElement("div", null,
                                    global.user,
                                    "\uFF1A",
                                    user)))), description: react_1.default.createElement(react_1.default.Fragment, null,
                                applicationName && (react_1.default.createElement("div", null,
                                    global.application,
                                    "\uFF1A",
                                    applicationName)),
                                react_1.default.createElement("div", null,
                                    global.type,
                                    "\uFF1A",
                                    react_1.default.createElement(antd_1.Tag, { color: index_2.suffixTagColor[realMethod] }, global[index_2.dynamicType[realMethod]]))) }));
                    })),
                    react_1.default.createElement(antd_1.Pagination, { style: { textAlign: 'center' }, current: pageInfo.page, total: pageInfo.total, pageSize: pageInfo.size, hideOnSinglePage: true, onChange: (page, pageSize) => {
                            searchDynamics({ organizationId, page, size: pageSize, search: '' });
                        } }))))));
};
exports.default = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(Dynamics);
