import { A, a, B, b, C, c, d, e, f, g, D, E, h, i, M, j, F, k, l, m, H, I, L, N, P, n, T, R, S, o, p, q, r, s, t, u, v, w, x, y, z, G, J, K, O, Q, U, al, V, W, X, am, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak } from "../chunks/default-data-B3Yz3w99.esm.js";
import { j as jsxRuntimeExports } from "../chunks/jsx-runtime-ClFauRgV.esm.js";
import { useTranslation } from "react-i18next";
import { $ as ModuleTile } from "../chunks/android-12-switch-DbuvTT7x.esm.js";
import { ap } from "../chunks/android-12-switch-DbuvTT7x.esm.js";
import { T as Typography } from "../chunks/useAuth-CEQTm2rv.esm.js";
import { F as FullscreenLayout } from "../chunks/fullScreen-D72H_EwG.esm.js";
import { useState, useMemo, useEffect } from "react";
import { m as modules } from "../chunks/modules-Bpg0vTA2.esm.js";
import { i as images } from "../chunks/images-DvZ6-RV8.esm.js";
/* empty css                               */
import { at as getToken } from "../chunks/common-B0qL-cCR.esm.js";
import { u as getV1RoleUserId } from "../chunks/api-BQ_tS-9F.esm.js";
import { f as Box } from "../chunks/appbar-CF_DgfSS.esm.js";
import { C as CssBaseline } from "../chunks/CssBaseline-qnbPrAjr.esm.js";
import { U as U2, c as c2, d as d2, r as r2, f as f2, g as g2, h as h2, i as i2, j as j2, p as p2, k as k2, e as e2, s as s2, l as l2, b as b2, m as m2, n as n2, o as o2, q as q2, t as t2, u as u2 } from "../chunks/reducer-C2CFWu_w.esm.js";
import { bA, bB } from "../chunks/route-page-map-BV-t2IDw.esm.js";
const Dashboard = () => {
  var _a, _b;
  const { t: t3 } = useTranslation();
  const [erp_modules, setModules] = useState([]);
  const u_data = localStorage.getItem("_u_data") || void 0;
  const userData = 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((module) => permissions.includes(module.beModuleName));
  }
  useEffect(() => {
    setModules(modules(t3));
  }, [t3]);
  const getAndSetUserRoleAndPermissions = async (userId) => {
    const response = await getV1RoleUserId({
      id: userId,
      ...getToken()
    });
    const data = response == null ? void 0 : response.data.role;
    localStorage.setItem("role-permission", JSON.stringify(data));
  };
  useEffect(() => {
    if (userData == null ? void 0 : userData.id) {
      getAndSetUserRoleAndPermissions(userData.id);
    }
  }, [userData == null ? void 0 : userData.id]);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(CssBaseline, {}),
    /* @__PURE__ */ jsxRuntimeExports.jsx(FullscreenLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: "dashboard-container", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: "dashboard-heading", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { type: "h2", className: "dashboard-title", children: t3("dashboard.title") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { type: "s3", className: "dashboard-subtitle", children: t3("dashboard.subtitle") })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: "module-container", children: [
        matchedModules == null ? void 0 : matchedModules.map((module, index) => {
          return /* @__PURE__ */ jsxRuntimeExports.jsx(ModuleTile, { module }, index);
        }),
        userData && (userData == null ? void 0 : userData.role_name) == "Admin" && /* @__PURE__ */ jsxRuntimeExports.jsx(
          ModuleTile,
          {
            module: {
              label: "Add New Module",
              link: "",
              sidebar: images.addModule,
              icon: 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"
  }
];
export {
  A as AddTemplate,
  a as AlignmentControl,
  B as BorderControl,
  b as ButtonControls,
  C as ChangePassword,
  c as CheckboxEditForm,
  d as CodeControls,
  e as ColumnWidth,
  f as CompanySelectionModal,
  g as CustomForm,
  Dashboard,
  D as DividerControls,
  E as EditSectionModal,
  h as EditorCanvas,
  i as EditorHeader,
  M as EditorSection,
  j as EditorSidebar,
  F as FieldSelect,
  k as ForgotPassword,
  l as FormField,
  m as FormFields,
  H as HtmlThumbnailPreview,
  I as ImageControls,
  L as Landing,
  N as NotFound,
  P as PageView,
  n as PrivateRoute,
  T as React,
  R as ResetPassword,
  S as SectionEditForm,
  o as SectionFlowEditor,
  p as SectionFormatPanel,
  q as SelectEditForm,
  r as SignatureControls,
  bA as TEMPLATE_EDITOR_PATHS,
  s as TableControls,
  t as TableEditForm,
  u as TemplateModal,
  v as TemplateNameModal,
  w as Templates,
  x as TextEditForm,
  U2 as UsersFetchAction,
  y as activityTag,
  z as board,
  G as calendarData,
  c2 as changeCurrentPage,
  J as column,
  K as createDefaultTableColumns,
  d2 as dashBoardDrive,
  r2 as dashboardSlice,
  O as data,
  Q as defaultData,
  U as element,
  al as emailColumns,
  V as extractSections,
  W as extractStyles,
  X as fetchPage,
  f2 as formBuilderListSlice,
  am as formatText,
  ganttData,
  Y as generateCustomFormPath,
  Z as generateEmailPreview,
  _ as generateHeaderFooterPreview,
  $ as generateInlineStyles,
  a0 as generateModulePath,
  g2 as getFieldsByFormId,
  h2 as getFormDataById,
  a1 as getInitialSectionData,
  bB as initialStyles,
  a2 as local,
  a3 as multilineData,
  a4 as pageViewChangeCurrentPage,
  a5 as pageViewSlice,
  i2 as patchFormDataById,
  j2 as pinToDashboardAction,
  p2 as pinToDashboardList,
  a6 as processMembers,
  a7 as processTableColumns,
  a8 as setColumnOrder,
  k2 as setFormData,
  e2 as setGrid,
  a9 as setPageViewPages,
  aa as setPageViewPaginationModel,
  s2 as setPages,
  l2 as setPagesAction,
  ab as setRowData,
  b2 as setSharedPage,
  m2 as setSharedPageAction,
  n2 as setUserName,
  o2 as setUserNameAction,
  q2 as setdashboardDriveData,
  t2 as sharedPagesData,
  u2 as state,
  ac as tableData,
  ad as tabsData,
  ae as templateEditorRoutes,
  af as templateRoutes,
  ag as textOptions,
  ah as useCKEditorStyleExtractor,
  ai as useFormDataEffect,
  aj as useFormDataProcessor,
  ak as userData,
  ap as userRoles
};
//# sourceMappingURL=index.esm.js.map
