"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const defaultData = require("../chunks/default-data-Cm5qCRh7.js");
const jsxRuntime = require("../chunks/jsx-runtime-B6vEU3CM.js");
const reactI18next = require("react-i18next");
const android12Switch = require("../chunks/android-12-switch-DTQN8nM7.js");
const useAuth = require("../chunks/useAuth-vPRkzGjO.js");
const fullScreen = require("../chunks/fullScreen-DI2vh8T2.js");
const React = require("react");
const modules = require("../chunks/modules-BKRTgB3s.js");
const images = require("../chunks/images-CY-_BlWh.js");
;/* empty css                            */
const common = require("../chunks/common-B47boGYI.js");
const api = require("../chunks/api-BygscvSz.js");
const appbar = require("../chunks/appbar-BjvK6O9Q.js");
const CssBaseline = require("../chunks/CssBaseline-Ba0wbudi.js");
const reducer = require("../chunks/reducer-D43h_jCk.js");
const routePageMap = require("../chunks/route-page-map-CPeFCmDL.js");
const Dashboard = () => {
  var _a, _b;
  const { t } = reactI18next.useTranslation();
  const [erp_modules, setModules] = React.useState([]);
  const u_data = localStorage.getItem("_u_data") || void 0;
  const userData = React.useMemo(() => u_data ? JSON.parse(u_data) : "", [u_data]);
  const access_modules = (userData == null ? void 0 : userData.module_access) && ((_a = userData == null ? void 0 : userData.module_access) == null ? void 0 : _a.length) > 0 ? userData == null ? void 0 : userData.module_access : [{ "module_name": "user" }];
  const display_modules = erp_modules == null ? void 0 : erp_modules.filter((item1) => access_modules == null ? void 0 : access_modules.some((item2) => item2.module_name == item1.beModuleName || item1.beModuleName === "rbac"));
  const rolePermission = localStorage.getItem("role-permission") || void 0;
  const permissions = rolePermission && ((_b = JSON.parse(rolePermission)) == null ? void 0 : _b.modules) ? JSON.parse(rolePermission).modules : [];
  let matchedModules = display_modules;
  if (permissions.length) {
    matchedModules = display_modules.filter((module2) => permissions.includes(module2.beModuleName));
  }
  React.useEffect(() => {
    setModules(modules.modules(t));
  }, [t]);
  const getAndSetUserRoleAndPermissions = async (userId) => {
    const response = await api.getV1RoleUserId({
      id: userId,
      ...common.getToken()
    });
    const data = response == null ? void 0 : response.data.role;
    localStorage.setItem("role-permission", JSON.stringify(data));
  };
  React.useEffect(() => {
    if (userData == null ? void 0 : userData.id) {
      getAndSetUserRoleAndPermissions(userData.id);
    }
  }, [userData == null ? void 0 : userData.id]);
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(appbar.Box, { children: [
    /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(CssBaseline.CssBaseline, {}),
    /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(fullScreen.FullscreenLayout, { children: /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(appbar.Box, { className: "dashboard-container", children: [
      /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(appbar.Box, { className: "dashboard-heading", children: [
        /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useAuth.Typography, { type: "h2", className: "dashboard-title", children: t("dashboard.title") }),
        /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useAuth.Typography, { type: "s3", className: "dashboard-subtitle", children: t("dashboard.subtitle") })
      ] }),
      /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(appbar.Box, { className: "module-container", children: [
        matchedModules == null ? void 0 : matchedModules.map((module2, index) => {
          return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(android12Switch.ModuleTile, { module: module2 }, index);
        }),
        userData && (userData == null ? void 0 : userData.role_name) == "Admin" && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
          android12Switch.ModuleTile,
          {
            module: {
              label: "Add New Module",
              link: "",
              sidebar: images.images.addModule,
              icon: images.images.addModule,
              permission: "",
              bg: "transparent"
            }
          },
          0
        )
      ] })
    ] }) })
  ] });
};
const ganttData = [
  {
    start: new Date(2024, 0, 1, 7, 0, 0),
    end: new Date(2024, 1, 6, 10, 30, 0),
    name: "ERP Force Project",
    id: "sample",
    type: "project",
    progress: 30,
    isDisabled: false,
    hideChildren: false
  },
  {
    start: new Date(2024, 0, 4, 7, 0, 0),
    end: new Date(2024, 0, 7, 10, 30, 0),
    name: "task 2",
    id: "Task 2",
    type: "task",
    progress: 70,
    isDisabled: false,
    project: "sample"
  },
  {
    start: new Date(2024, 0, 12, 7, 0, 0),
    end: new Date(2024, 0, 14, 10, 30, 0),
    name: "task 3",
    id: "Task 3",
    type: "task",
    progress: 60,
    dependencies: ["Task 2"],
    isDisabled: false,
    project: "sample"
  },
  {
    start: new Date(2024, 0, 14, 7, 0, 0),
    end: new Date(2024, 0, 16, 10, 30, 0),
    name: "task 4",
    id: "Task 4",
    type: "task",
    progress: 100,
    isDisabled: false
  },
  {
    start: new Date(2024, 1, 4, 7, 0, 0),
    end: new Date(2024, 1, 6, 10, 30, 0),
    name: "completed",
    id: "Task 5",
    type: "milestone",
    dependencies: ["Task 2"],
    progress: 100,
    isDisabled: false,
    project: "sample"
  }
];
exports.AddTemplate = defaultData.AddTemplate;
exports.AlignmentControl = defaultData.AlignmentControl;
exports.BorderControl = defaultData.BorderControl;
exports.ButtonControls = defaultData.ButtonControls;
exports.ChangePassword = defaultData.ChangePassword;
exports.CheckboxEditForm = defaultData.CheckboxEditForm;
exports.CodeControls = defaultData.CodeControls;
exports.ColumnWidth = defaultData.ColumnWidth;
exports.CompanySelectionModal = defaultData.CompanySelectionModal;
exports.CustomForm = defaultData.CustomForm;
exports.DividerControls = defaultData.DividerControls;
exports.EditSectionModal = defaultData.EditSectionModal;
exports.EditorCanvas = defaultData.EditorCanvas;
exports.EditorHeader = defaultData.EditorHeader;
exports.EditorSection = defaultData.MemoizedEditorSection;
exports.EditorSidebar = defaultData.EditorSidebar;
exports.FieldSelect = defaultData.FieldSelect;
exports.ForgotPassword = defaultData.ForgotPassword;
exports.FormField = defaultData.FormField;
exports.FormFields = defaultData.FormFields;
exports.HtmlThumbnailPreview = defaultData.HtmlThumbnailPreview;
exports.ImageControls = defaultData.ImageControls;
exports.Landing = defaultData.Landing;
exports.NotFound = defaultData.NotFound;
exports.PageView = defaultData.PageView;
exports.PrivateRoute = defaultData.PrivateRoute;
exports.React = defaultData.TextControls;
exports.ResetPassword = defaultData.ResetPassword;
exports.SectionEditForm = defaultData.SectionEditForm;
exports.SectionFlowEditor = defaultData.SectionFlowEditor;
exports.SectionFormatPanel = defaultData.SectionFormatPanel;
exports.SelectEditForm = defaultData.SelectEditForm;
exports.SignatureControls = defaultData.SignatureControls;
exports.TableControls = defaultData.TableControls;
exports.TableEditForm = defaultData.TableEditForm;
exports.TemplateModal = defaultData.TemplateModal;
exports.TemplateNameModal = defaultData.TemplateNameModal;
exports.Templates = defaultData.Templates;
exports.TextEditForm = defaultData.TextEditForm;
exports.activityTag = defaultData.activityTag;
exports.board = defaultData.board;
exports.calendarData = defaultData.calendarData;
exports.column = defaultData.column;
exports.createDefaultTableColumns = defaultData.createDefaultTableColumns;
exports.data = defaultData.data;
exports.defaultData = defaultData.defaultData;
exports.element = defaultData.element;
exports.emailColumns = defaultData.emailColumns;
exports.extractSections = defaultData.extractSections;
exports.extractStyles = defaultData.extractStyles;
exports.fetchPage = defaultData.fetchPage;
exports.formatText = defaultData.formatText;
exports.generateCustomFormPath = defaultData.generateCustomFormPath;
exports.generateEmailPreview = defaultData.generateEmailPreview;
exports.generateHeaderFooterPreview = defaultData.generateHeaderFooterPreview;
exports.generateInlineStyles = defaultData.generateInlineStyles;
exports.generateModulePath = defaultData.generateModulePath;
exports.getInitialSectionData = defaultData.getInitialSectionData;
exports.local = defaultData.local;
exports.multilineData = defaultData.multilineData;
exports.pageViewChangeCurrentPage = defaultData.pageViewChangeCurrentPage;
exports.pageViewSlice = defaultData.reducer;
exports.processMembers = defaultData.processMembers;
exports.processTableColumns = defaultData.processTableColumns;
exports.setColumnOrder = defaultData.setColumnOrder;
exports.setPageViewPages = defaultData.setPageViewPages;
exports.setPageViewPaginationModel = defaultData.setPageViewPaginationModel;
exports.setRowData = defaultData.setRowData;
exports.tableData = defaultData.tableData;
exports.tabsData = defaultData.tabsData;
exports.templateEditorRoutes = defaultData.templateEditorRoutes;
exports.templateRoutes = defaultData.templateRoutes;
exports.textOptions = defaultData.textOptions;
exports.useCKEditorStyleExtractor = defaultData.useCKEditorStyleExtractor;
exports.useFormDataEffect = defaultData.useFormDataEffect;
exports.useFormDataProcessor = defaultData.useFormDataProcessor;
exports.userData = defaultData.userData;
exports.userRoles = android12Switch.userRoles;
exports.UsersFetchAction = reducer.UsersFetchAction;
exports.changeCurrentPage = reducer.changeCurrentPage;
exports.dashBoardDrive = reducer.dashBoardDrive;
exports.dashboardSlice = reducer.reducer;
exports.formBuilderListSlice = reducer.reducer$1;
exports.getFieldsByFormId = reducer.getFieldsByFormId;
exports.getFormDataById = reducer.getFormDataById;
exports.patchFormDataById = reducer.patchFormDataById;
exports.pinToDashboardAction = reducer.pinToDashboardAction;
exports.pinToDashboardList = reducer.pinToDashboardList;
exports.setFormData = reducer.setFormData;
exports.setGrid = reducer.setGrid;
exports.setPages = reducer.setPages;
exports.setPagesAction = reducer.setPagesAction;
exports.setSharedPage = reducer.setSharedPage;
exports.setSharedPageAction = reducer.setSharedPageAction;
exports.setUserName = reducer.setUserName;
exports.setUserNameAction = reducer.setUserNameAction;
exports.setdashboardDriveData = reducer.setdashboardDriveData;
exports.sharedPagesData = reducer.sharedPagesData;
exports.state = reducer.state;
exports.TEMPLATE_EDITOR_PATHS = routePageMap.TEMPLATE_EDITOR_PATHS;
exports.initialStyles = routePageMap.initialStyles;
exports.Dashboard = Dashboard;
exports.ganttData = ganttData;
//# sourceMappingURL=index.js.map
