import { Tabs } from "antd"; import queryString from "query-string"; import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { useLocation, useNavigate } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import ShopCsiConfig from "../../components/shop-csi-config/shop-csi-config.component"; import ShopEmployeesContainer from "../../components/shop-employees/shop-employees.container"; import ShopInfoContainer from "../../components/shop-info/shop-info.container"; import ShopInfoUsersComponent from "../../components/shop-users/shop-users.component"; import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; import { HasFeatureAccess } from "../../components/feature-wrapper/feature-wrapper.component"; import ShopTeamsContainer from "../../components/shop-teams/shop-teams.container"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop }); const mapDispatchToProps = (dispatch) => ({ setSelectedHeader: (key) => dispatch(setSelectedHeader(key)), setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)) }); export function ShopPage({ bodyshop, setSelectedHeader, setBreadcrumbs }) { const { t } = useTranslation(); const history = useNavigate(); const search = queryString.parse(useLocation().search); useEffect(() => { document.title = t("titles.shop", { app: InstanceRenderManager({ imex: "$t(titles.imexonline)", rome: "$t(titles.romeonline)", promanager: "$t(titles.promanager)" }) }); setSelectedHeader("shop"); setBreadcrumbs([ { link: "/manage/shop", label: t("titles.bc.shop", { shopname: bodyshop.shopname }) } ]); }, [t, setSelectedHeader, setBreadcrumbs, bodyshop.shopname]); useEffect(() => { if (!search.tab) history({ search: "?tab=info" }); }, [history, search]); const items = [ { key: "info", label: t("bodyshop.labels.shopinfo"), children: }, { key: "employees", label: t("bodyshop.labels.employees"), children: } ]; if (bodyshop.md_tasks_presets.enable_tasks) { items.push({ key: "teams", label: t("bodyshop.labels.employee_teams"), children: }); } InstanceRenderManager({ executeFunction: true, args: [], imex: () => { items.push({ key: "licensing", label: t("bodyshop.labels.licensing"), children: }); }, rome: "USE_IMEX" }); if (HasFeatureAccess({ featureName: "csi", bodyshop })) { items.push({ key: "csiq", label: t("bodyshop.labels.csiq"), children: }); } return ( history({ search: `?tab=${key}` })} items={items} /> ); } export default connect(mapStateToProps, mapDispatchToProps)(ShopPage);