sevago-sso-fe 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { createAsyncThunk, createSlice, configureStore, combineReducers } from "
3
3
  import { useDispatch, useSelector } from "react-redux";
4
4
  import * as React from "react";
5
5
  import React__default, { useMemo, useState, createContext, useContext, useEffect, useCallback, forwardRef, useImperativeHandle, createElement, Children, useRef, useLayoutEffect, Fragment as Fragment$1, useId, useInsertionEffect, Component as Component$1 } from "react";
6
- import { useLocation, useNavigate, Outlet, Route, Navigate } from "react-router-dom";
6
+ import { useLocation, useNavigate, Outlet, Link, Route, Navigate } from "react-router-dom";
7
7
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
8
8
  import { Alert, Stack as Stack$1, styled as styled$2, TableCell, tableCellClasses, LinearProgress, linearProgressClasses, useTheme as useTheme$2, Skeleton, Box, Icon, Tooltip, tooltipClasses, Avatar, Typography, ClickAwayListener as ClickAwayListener$1, Fade, Badge, List, ListItem, FormControl, InputLabel, RadioGroup, FormControlLabel, Radio, Menu, Divider, MenuItem, Button, IconButton, TextField, InputAdornment } from "@mui/material";
9
9
  import { unstable_createGetCssVar, createSpacing as createSpacing$1, useTheme as useTheme$1, unstable_memoTheme, Stack as Stack$2, css, keyframes as keyframes$1 } from "@mui/system";
@@ -20694,7 +20694,9 @@ const LoadingComponent = ({ color: color2, size = "medium", sx = {} }) => {
20694
20694
  };
20695
20695
  const BellComponent = ({}) => {
20696
20696
  const isSystemMonitor = useIsSystemMonitor();
20697
- const { notificationCount } = useSelector((state) => state.account);
20697
+ const { notificationCount } = useSelector(
20698
+ (state) => state.account
20699
+ );
20698
20700
  const account = useSelector((state) => state.account);
20699
20701
  const dispatch = useAppDispatch();
20700
20702
  const navigate = useNavigate();
@@ -20714,7 +20716,10 @@ const BellComponent = ({}) => {
20714
20716
  setList(res.list);
20715
20717
  dispatch(ACTION_ACCOUNT.changeNotificationCount(res.total));
20716
20718
  } catch (error) {
20717
- showSnackbar({ message: getErrorMessage(error), type: SnackbarType.ERROR });
20719
+ showSnackbar({
20720
+ message: getErrorMessage(error),
20721
+ type: SnackbarType.ERROR
20722
+ });
20718
20723
  } finally {
20719
20724
  setLoading(false);
20720
20725
  }
@@ -20737,7 +20742,10 @@ const BellComponent = ({}) => {
20737
20742
  }
20738
20743
  });
20739
20744
  } catch (error) {
20740
- showSnackbar({ message: getErrorMessage(error), type: SnackbarType.ERROR });
20745
+ showSnackbar({
20746
+ message: getErrorMessage(error),
20747
+ type: SnackbarType.ERROR
20748
+ });
20741
20749
  }
20742
20750
  };
20743
20751
  return /* @__PURE__ */ jsx(
@@ -20789,7 +20797,10 @@ const BellComponent = ({}) => {
20789
20797
  });
20790
20798
  dispatch(ACTION_ACCOUNT.changeNotificationCount(0));
20791
20799
  } catch (error) {
20792
- showSnackbar({ message: getErrorMessage(error), type: SnackbarType.ERROR });
20800
+ showSnackbar({
20801
+ message: getErrorMessage(error),
20802
+ type: SnackbarType.ERROR
20803
+ });
20793
20804
  }
20794
20805
  }
20795
20806
  }
@@ -20860,7 +20871,9 @@ const BellComponent = ({}) => {
20860
20871
  size: "large",
20861
20872
  sx: {
20862
20873
  color: isSystemMonitor ? palette.background.default : palette.primary.main,
20863
- "&:hover": { color: isSystemMonitor ? palette.background.default : palette.primary.main }
20874
+ "&:hover": {
20875
+ color: isSystemMonitor ? palette.background.default : palette.primary.main
20876
+ }
20864
20877
  }
20865
20878
  }
20866
20879
  )
@@ -21244,8 +21257,32 @@ const MonitorPart = ({
21244
21257
  const DashboardLayout = ({
21245
21258
  children
21246
21259
  }) => {
21247
- useUpdateCurrentAccess();
21248
- return /* @__PURE__ */ jsx(MonitorPart, { children });
21260
+ const isSystemMonitor = useIsSystemMonitor();
21261
+ const { sidebarWidth } = useSidebar();
21262
+ if (isSystemMonitor) return /* @__PURE__ */ jsx(MonitorPart, { children });
21263
+ return /* @__PURE__ */ jsx(
21264
+ Stack$1,
21265
+ {
21266
+ sx: {
21267
+ minHeight: "100vh",
21268
+ width: "100%"
21269
+ },
21270
+ children: /* @__PURE__ */ jsx(Stack$1, { p: 0, gap: 0, children: /* @__PURE__ */ jsx(StackRow, { children: /* @__PURE__ */ jsx(
21271
+ Stack$1,
21272
+ {
21273
+ sx: {
21274
+ overflowY: "auto",
21275
+ marginLeft: sidebarWidth,
21276
+ width: "100%",
21277
+ transition: "margin-left 0.3s ease",
21278
+ background: "#F5F6F8",
21279
+ minHeight: `calc(100vh - ${STYLE.HEIGHT_HEADER}px)`
21280
+ },
21281
+ children
21282
+ }
21283
+ ) }) })
21284
+ }
21285
+ );
21249
21286
  };
21250
21287
  const DefaultLayout = ({ children }) => {
21251
21288
  return /* @__PURE__ */ jsx(
@@ -26222,6 +26259,48 @@ const NotFoundPage = ({}) => {
26222
26259
  /* @__PURE__ */ jsx(ButtonElement, { content: "Quay lại trang chủ", fullWidth: false, onClick: () => navigate(PAGE.AUTH.path) })
26223
26260
  ] });
26224
26261
  };
26262
+ const IconLeft = (props) => /* @__PURE__ */ jsx(
26263
+ "svg",
26264
+ {
26265
+ width: "20",
26266
+ height: "16",
26267
+ viewBox: "0 0 20 16",
26268
+ fill: "none",
26269
+ xmlns: "http://www.w3.org/2000/svg",
26270
+ ...props,
26271
+ children: /* @__PURE__ */ jsx(
26272
+ "path",
26273
+ {
26274
+ d: "M8 15L1 8M1 8L8 1M1 8L19 8",
26275
+ stroke: "currentColor",
26276
+ "stroke-width": "2",
26277
+ "stroke-linecap": "round",
26278
+ "stroke-linejoin": "round"
26279
+ }
26280
+ )
26281
+ }
26282
+ );
26283
+ const IconRight = (props) => /* @__PURE__ */ jsx(
26284
+ "svg",
26285
+ {
26286
+ width: "20",
26287
+ height: "16",
26288
+ viewBox: "0 0 20 16",
26289
+ fill: "none",
26290
+ xmlns: "http://www.w3.org/2000/svg",
26291
+ ...props,
26292
+ children: /* @__PURE__ */ jsx(
26293
+ "path",
26294
+ {
26295
+ d: "M12 1L19 8M19 8L12 15M19 8L1 8",
26296
+ stroke: "currentColor",
26297
+ "stroke-width": "2",
26298
+ "stroke-linecap": "round",
26299
+ "stroke-linejoin": "round"
26300
+ }
26301
+ )
26302
+ }
26303
+ );
26225
26304
  const LayoutGroupContext = createContext({});
26226
26305
  function useConstant(init) {
26227
26306
  const ref = useRef(null);
@@ -33497,48 +33576,6 @@ const MotionBox = ({
33497
33576
  } : {};
33498
33577
  return /* @__PURE__ */ jsx(motion.div, { ...motionProps, ...getAnimationProps(), ...hoverProps, onClick, style: { ...sx }, children });
33499
33578
  };
33500
- const IconRight = (props) => /* @__PURE__ */ jsx(
33501
- "svg",
33502
- {
33503
- width: "20",
33504
- height: "16",
33505
- viewBox: "0 0 20 16",
33506
- fill: "none",
33507
- xmlns: "http://www.w3.org/2000/svg",
33508
- ...props,
33509
- children: /* @__PURE__ */ jsx(
33510
- "path",
33511
- {
33512
- d: "M12 1L19 8M19 8L12 15M19 8L1 8",
33513
- stroke: "currentColor",
33514
- "stroke-width": "2",
33515
- "stroke-linecap": "round",
33516
- "stroke-linejoin": "round"
33517
- }
33518
- )
33519
- }
33520
- );
33521
- const IconLeft = (props) => /* @__PURE__ */ jsx(
33522
- "svg",
33523
- {
33524
- width: "20",
33525
- height: "16",
33526
- viewBox: "0 0 20 16",
33527
- fill: "none",
33528
- xmlns: "http://www.w3.org/2000/svg",
33529
- ...props,
33530
- children: /* @__PURE__ */ jsx(
33531
- "path",
33532
- {
33533
- d: "M8 15L1 8M1 8L8 1M1 8L19 8",
33534
- stroke: "currentColor",
33535
- "stroke-width": "2",
33536
- "stroke-linecap": "round",
33537
- "stroke-linejoin": "round"
33538
- }
33539
- )
33540
- }
33541
- );
33542
33579
  const AppGrid = ({
33543
33580
  apps,
33544
33581
  onClickItem,
@@ -33559,12 +33596,25 @@ const AppGrid = ({
33559
33596
  const pageSize = Math.max(1, columns * Math.max(1, rows));
33560
33597
  const totalPages = Math.max(1, Math.ceil(apps.length / pageSize));
33561
33598
  const [page, setPage] = React__default.useState(0);
33599
+ const { user } = useSelector((state) => state.account);
33562
33600
  React__default.useEffect(() => {
33563
33601
  setPage((prev) => prev >= totalPages ? totalPages - 1 : prev);
33564
33602
  }, [totalPages, columns, rows, apps.length]);
33565
33603
  const start = page * pageSize;
33566
33604
  const end = start + pageSize;
33567
33605
  const visibleApps = totalPages > 1 ? apps.slice(start, end) : apps;
33606
+ const findLink = (app2) => {
33607
+ if (!app2.children?.length) {
33608
+ return app2.path;
33609
+ }
33610
+ for (const i of app2.children || []) {
33611
+ if (user?.type && i.allowUserTypes.includes(user?.type)) {
33612
+ if (i.path) {
33613
+ return `${i.path}`;
33614
+ }
33615
+ }
33616
+ }
33617
+ };
33568
33618
  return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
33569
33619
  /* @__PURE__ */ jsx(
33570
33620
  Box,
@@ -33576,62 +33626,73 @@ const AppGrid = ({
33576
33626
  },
33577
33627
  children: visibleApps.map((app2, index) => {
33578
33628
  const isSelected = selectedAppId === app2.key;
33579
- return /* @__PURE__ */ jsxs(
33580
- MotionBox,
33629
+ return /* @__PURE__ */ jsx(
33630
+ Link,
33581
33631
  {
33582
- preset: "staggerItem",
33583
- index,
33584
- hover: true,
33585
- onClick: () => onClickItem?.(app2),
33586
- sx: {
33587
- cursor: "pointer",
33588
- display: "flex",
33589
- flex: 1,
33590
- alignItems: "center",
33591
- flexDirection: "column"
33632
+ to: findLink(app2) || "#",
33633
+ style: {
33634
+ textDecoration: "none",
33635
+ color: "inherit",
33636
+ width: "100%"
33592
33637
  },
33593
- children: [
33594
- /* @__PURE__ */ jsx(
33595
- Box,
33596
- {
33597
- sx: {
33598
- width: iconSize,
33599
- height: iconSize,
33600
- borderRadius: iconRadius,
33601
- mb: 1.5,
33602
- display: "flex",
33603
- alignItems: "center",
33604
- justifyContent: "center",
33605
- background: getAppColor(app2.category),
33606
- boxShadow: isSelected ? `0 0 0 1px ${theme.palette.primary.main}, ${iconShadow}` : iconShadow
33607
- },
33608
- children: app2.icon.startsWith("/") && /* @__PURE__ */ jsx(
33609
- ImageElement,
33638
+ children: /* @__PURE__ */ jsxs(
33639
+ MotionBox,
33640
+ {
33641
+ preset: "staggerItem",
33642
+ index,
33643
+ hover: true,
33644
+ onClick: () => onClickItem?.(app2),
33645
+ sx: {
33646
+ cursor: "pointer",
33647
+ display: "flex",
33648
+ flex: 1,
33649
+ alignItems: "center",
33650
+ flexDirection: "column"
33651
+ },
33652
+ children: [
33653
+ /* @__PURE__ */ jsx(
33654
+ Box,
33655
+ {
33656
+ sx: {
33657
+ width: iconSize,
33658
+ height: iconSize,
33659
+ borderRadius: iconRadius,
33660
+ mb: 1.5,
33661
+ display: "flex",
33662
+ alignItems: "center",
33663
+ justifyContent: "center",
33664
+ background: getAppColor(app2.category),
33665
+ boxShadow: isSelected ? `0 0 0 1px ${theme.palette.primary.main}, ${iconShadow}` : iconShadow
33666
+ },
33667
+ children: app2.icon.startsWith("/") && /* @__PURE__ */ jsx(
33668
+ ImageElement,
33669
+ {
33670
+ sx: { width: iconSize * 0.56, height: iconSize * 0.56 },
33671
+ url: app2.icon,
33672
+ sizeType: ImageSizeType.SQUARE
33673
+ }
33674
+ )
33675
+ }
33676
+ ),
33677
+ /* @__PURE__ */ jsx(
33678
+ Typography,
33610
33679
  {
33611
- sx: { width: iconSize * 0.56, height: iconSize * 0.56 },
33612
- url: app2.icon,
33613
- sizeType: ImageSizeType.SQUARE
33680
+ variant: titleVariant,
33681
+ sx: { color: titleColor ?? theme.palette.common.white },
33682
+ children: app2.title
33683
+ }
33684
+ ),
33685
+ /* @__PURE__ */ jsx(
33686
+ Typography,
33687
+ {
33688
+ variant: captionVariant,
33689
+ sx: { color: captionColor ?? theme.palette.common.white },
33690
+ children: app2.caption
33614
33691
  }
33615
33692
  )
33616
- }
33617
- ),
33618
- /* @__PURE__ */ jsx(
33619
- Typography,
33620
- {
33621
- variant: titleVariant,
33622
- sx: { color: titleColor ?? theme.palette.common.white },
33623
- children: app2.title
33624
- }
33625
- ),
33626
- /* @__PURE__ */ jsx(
33627
- Typography,
33628
- {
33629
- variant: captionVariant,
33630
- sx: { color: captionColor ?? theme.palette.common.white },
33631
- children: app2.caption
33632
- }
33633
- )
33634
- ]
33693
+ ]
33694
+ }
33695
+ )
33635
33696
  },
33636
33697
  app2.key
33637
33698
  );
@@ -33714,143 +33775,6 @@ const AppGrid = ({
33714
33775
  ] })
33715
33776
  ] });
33716
33777
  };
33717
- const SystemMonitorScreen = () => {
33718
- const theme = useTheme();
33719
- useNavigate();
33720
- const dispatch = useAppDispatch();
33721
- const [tab, setTab] = useState(AppCategory.ALL);
33722
- const listApp = useApps(tab);
33723
- const currentApp = useActiveSidebar();
33724
- return /* @__PURE__ */ jsx(
33725
- MotionBox,
33726
- {
33727
- preset: "fadeInUp",
33728
- sx: {
33729
- display: "flex",
33730
- flexDirection: "column",
33731
- alignItems: "center",
33732
- position: "relative",
33733
- top: 150
33734
- },
33735
- children: /* @__PURE__ */ jsxs(
33736
- Box,
33737
- {
33738
- sx: {
33739
- width: 865,
33740
- gap: 6.25,
33741
- display: "flex",
33742
- flexDirection: "column",
33743
- justifyContent: "flex-start"
33744
- },
33745
- children: [
33746
- /* @__PURE__ */ jsx(
33747
- Box,
33748
- {
33749
- sx: {
33750
- display: "flex",
33751
- gap: PADDING_GAP_TAB,
33752
- width: "100%",
33753
- justifyContent: "flex-start"
33754
- },
33755
- children: [
33756
- { key: AppCategory.ALL, label: "Tất Cả" },
33757
- { key: AppCategory.HRM, label: "HRM" },
33758
- { key: AppCategory.WORKFLOW, label: "Workflow Engine" },
33759
- { key: AppCategory.PLATFORM_INFO, label: "Platform & Info" }
33760
- ].map((t) => /* @__PURE__ */ jsxs(
33761
- MotionBox,
33762
- {
33763
- sx: { position: "relative" },
33764
- preset: "tabUnderline",
33765
- children: [
33766
- /* @__PURE__ */ jsx(
33767
- Typography,
33768
- {
33769
- onClick: () => setTab(t.key),
33770
- sx: {
33771
- cursor: "pointer",
33772
- color: tab === t.key ? theme.palette.common.white : theme.palette.grey[300]
33773
- },
33774
- children: t.label
33775
- }
33776
- ),
33777
- tab === t.key && /* @__PURE__ */ jsx(
33778
- MotionBox,
33779
- {
33780
- preset: "tabUnderline",
33781
- sx: {
33782
- position: "absolute",
33783
- left: 0,
33784
- right: 0,
33785
- height: 2,
33786
- backgroundColor: theme.palette.common.white,
33787
- transformOrigin: "left"
33788
- },
33789
- children: /* @__PURE__ */ jsx("div", {})
33790
- }
33791
- )
33792
- ]
33793
- },
33794
- t.key
33795
- ))
33796
- }
33797
- ),
33798
- /* @__PURE__ */ jsx(MotionBox, { preset: "tabContent", children: /* @__PURE__ */ jsx(
33799
- AppGrid,
33800
- {
33801
- apps: listApp,
33802
- columns: 5,
33803
- iconSize: 80,
33804
- iconRadius: 7,
33805
- gap: PADDING_GAP_TAB,
33806
- selectedAppId: currentApp?.key,
33807
- onClickItem: async (app2) => {
33808
- await dispatch(
33809
- ACTION_ACCOUNT.updateCurrentAccess(app2.key)
33810
- ).unwrap();
33811
- }
33812
- }
33813
- ) }, tab)
33814
- ]
33815
- }
33816
- )
33817
- }
33818
- );
33819
- };
33820
- const renderRoutes = (routes2, account) => routes2.map((route) => {
33821
- const { path, layout: layout2, element, type, allowUserTypes = [], children } = route;
33822
- const Layout = layout2 || React__default.Fragment;
33823
- let Element2 = element;
33824
- if (path === PAGE.AUTH.path && account.isLogin) Element2 = () => /* @__PURE__ */ jsx(Navigate, { to: PAGE.DASHBOARD.path });
33825
- if (type === RouteType.PROTECTED) {
33826
- if (!account.isLogin) Element2 = () => /* @__PURE__ */ jsx(Navigate, { to: PAGE.AUTH.path });
33827
- else if (allowUserTypes.length && !allowUserTypes.includes(account.user.type) && account.user.type !== UserType.ROOT)
33828
- Element2 = () => /* @__PURE__ */ jsx(Navigate, { to: PAGE.ERROR.path });
33829
- }
33830
- return /* @__PURE__ */ jsx(
33831
- Route,
33832
- {
33833
- path,
33834
- element: /* @__PURE__ */ jsx(Layout, { children: /* @__PURE__ */ jsx(Element2, {}) }),
33835
- children: children && renderRoutes(children, account)
33836
- },
33837
- path
33838
- );
33839
- });
33840
- const routes = [
33841
- { ...PAGE.AUTH, element: AuthPage, layout: AuthLayout },
33842
- { ...PAGE.NOT_FOUND, element: NotFoundPage, layout: DefaultLayout },
33843
- { ...PAGE.ERROR, element: ErrorPage, layout: DefaultLayout },
33844
- // PROTECTED
33845
- {
33846
- ...PAGE.DASHBOARD,
33847
- element: DashboardPage,
33848
- layout: DashboardLayout,
33849
- children: [
33850
- { ...PAGE.DASHBOARD, element: SystemMonitorScreen }
33851
- ]
33852
- }
33853
- ];
33854
33778
  const AppsSidebar = ({
33855
33779
  isOpen,
33856
33780
  onClose
@@ -34093,6 +34017,217 @@ const TypographyFilter = styled$2(Typography)(({ theme }) => ({
34093
34017
  textWrap: "nowrap",
34094
34018
  padding: `0px ${STYLE.PADDING_GAP_LAYOUT}`
34095
34019
  }));
34020
+ const SystemMonitorScreen = () => {
34021
+ const theme = useTheme();
34022
+ const dispatch = useAppDispatch();
34023
+ const [tab, setTab] = useState(AppCategory.ALL);
34024
+ const user = useSelector((state) => state.account?.user);
34025
+ const listApp = useApps(tab);
34026
+ const currentApp = useActiveSidebar();
34027
+ const checkUserNotOrg = useMemo(
34028
+ () => !user?.userOrgUnitPositions?.length || user.userOrgUnitPositions.some((pos) => !pos.orgUnit || !pos.position),
34029
+ [user]
34030
+ );
34031
+ if (checkUserNotOrg) {
34032
+ return /* @__PURE__ */ jsx(
34033
+ MotionBox,
34034
+ {
34035
+ preset: "fadeInUp",
34036
+ sx: {
34037
+ display: "flex",
34038
+ flexDirection: "column",
34039
+ alignItems: "center",
34040
+ justifyContent: "center",
34041
+ position: "relative",
34042
+ top: 150,
34043
+ minHeight: "400px"
34044
+ },
34045
+ children: /* @__PURE__ */ jsxs(
34046
+ Box,
34047
+ {
34048
+ sx: {
34049
+ display: "flex",
34050
+ flexDirection: "column",
34051
+ alignItems: "center",
34052
+ justifyContent: "center",
34053
+ textAlign: "center",
34054
+ padding: 4,
34055
+ borderRadius: 2,
34056
+ backgroundColor: theme.palette.background.paper,
34057
+ boxShadow: theme.shadows[4],
34058
+ maxWidth: 500
34059
+ },
34060
+ children: [
34061
+ /* @__PURE__ */ jsx(
34062
+ Typography,
34063
+ {
34064
+ variant: "h6",
34065
+ sx: {
34066
+ color: theme.palette.error.main,
34067
+ marginBottom: 2,
34068
+ fontWeight: 600
34069
+ },
34070
+ children: "Thông báo"
34071
+ }
34072
+ ),
34073
+ /* @__PURE__ */ jsx(
34074
+ Typography,
34075
+ {
34076
+ sx: {
34077
+ color: theme.palette.text.secondary,
34078
+ lineHeight: 1.6,
34079
+ marginBottom: 3
34080
+ },
34081
+ children: "Bạn chưa có người quản lý trực tiếp. Vui lòng liên hệ quản trị viên để được hỗ trợ."
34082
+ }
34083
+ ),
34084
+ /* @__PURE__ */ jsx(
34085
+ Typography,
34086
+ {
34087
+ variant: "body2",
34088
+ sx: {
34089
+ color: theme.palette.text.disabled,
34090
+ fontStyle: "italic"
34091
+ },
34092
+ children: "Hệ thống sẽ tự động cập nhật khi bạn được phân quyền."
34093
+ }
34094
+ )
34095
+ ]
34096
+ }
34097
+ )
34098
+ }
34099
+ );
34100
+ }
34101
+ return /* @__PURE__ */ jsx(
34102
+ MotionBox,
34103
+ {
34104
+ preset: "fadeInUp",
34105
+ sx: {
34106
+ display: "flex",
34107
+ flexDirection: "column",
34108
+ alignItems: "center",
34109
+ position: "relative",
34110
+ top: 150
34111
+ },
34112
+ children: /* @__PURE__ */ jsxs(
34113
+ Box,
34114
+ {
34115
+ sx: {
34116
+ width: 865,
34117
+ gap: 6.25,
34118
+ display: "flex",
34119
+ flexDirection: "column",
34120
+ justifyContent: "flex-start"
34121
+ },
34122
+ children: [
34123
+ /* @__PURE__ */ jsx(
34124
+ Box,
34125
+ {
34126
+ sx: {
34127
+ display: "flex",
34128
+ gap: PADDING_GAP_TAB,
34129
+ width: "100%",
34130
+ justifyContent: "flex-start"
34131
+ },
34132
+ children: [
34133
+ { key: AppCategory.ALL, label: "Tất Cả" },
34134
+ { key: AppCategory.HRM, label: "HRM" },
34135
+ { key: AppCategory.WORKFLOW, label: "Workflow Engine" },
34136
+ { key: AppCategory.PLATFORM_INFO, label: "Platform & Info" }
34137
+ ].map((t) => /* @__PURE__ */ jsxs(
34138
+ MotionBox,
34139
+ {
34140
+ sx: { position: "relative" },
34141
+ preset: "tabUnderline",
34142
+ children: [
34143
+ /* @__PURE__ */ jsx(
34144
+ Typography,
34145
+ {
34146
+ onClick: () => setTab(t.key),
34147
+ sx: {
34148
+ cursor: "pointer",
34149
+ color: tab === t.key ? theme.palette.common.white : theme.palette.grey[300]
34150
+ },
34151
+ children: t.label
34152
+ }
34153
+ ),
34154
+ tab === t.key && /* @__PURE__ */ jsx(
34155
+ MotionBox,
34156
+ {
34157
+ preset: "tabUnderline",
34158
+ sx: {
34159
+ position: "absolute",
34160
+ left: 0,
34161
+ right: 0,
34162
+ height: 2,
34163
+ backgroundColor: theme.palette.common.white,
34164
+ transformOrigin: "left"
34165
+ },
34166
+ children: /* @__PURE__ */ jsx("div", {})
34167
+ }
34168
+ )
34169
+ ]
34170
+ },
34171
+ t.key
34172
+ ))
34173
+ }
34174
+ ),
34175
+ /* @__PURE__ */ jsx(MotionBox, { preset: "tabContent", children: /* @__PURE__ */ jsx(
34176
+ AppGrid,
34177
+ {
34178
+ apps: listApp,
34179
+ columns: 5,
34180
+ iconSize: 80,
34181
+ iconRadius: 7,
34182
+ gap: PADDING_GAP_TAB,
34183
+ selectedAppId: currentApp?.key,
34184
+ onClickItem: async (app2) => {
34185
+ await dispatch(
34186
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
34187
+ ).unwrap();
34188
+ }
34189
+ }
34190
+ ) }, tab)
34191
+ ]
34192
+ }
34193
+ )
34194
+ }
34195
+ );
34196
+ };
34197
+ const renderRoutes = (routes2, account) => routes2.map((route) => {
34198
+ const { path, layout: layout2, element, type, allowUserTypes = [], children } = route;
34199
+ const Layout = layout2 || React__default.Fragment;
34200
+ let Element2 = element;
34201
+ if (path === PAGE.AUTH.path && account.isLogin) Element2 = () => /* @__PURE__ */ jsx(Navigate, { to: PAGE.DASHBOARD.path });
34202
+ if (type === RouteType.PROTECTED) {
34203
+ if (!account.isLogin) Element2 = () => /* @__PURE__ */ jsx(Navigate, { to: PAGE.AUTH.path });
34204
+ else if (allowUserTypes.length && !allowUserTypes.includes(account.user.type) && account.user.type !== UserType.ROOT)
34205
+ Element2 = () => /* @__PURE__ */ jsx(Navigate, { to: PAGE.ERROR.path });
34206
+ }
34207
+ return /* @__PURE__ */ jsx(
34208
+ Route,
34209
+ {
34210
+ path,
34211
+ element: /* @__PURE__ */ jsx(Layout, { children: /* @__PURE__ */ jsx(Element2, {}) }),
34212
+ children: children && renderRoutes(children, account)
34213
+ },
34214
+ path
34215
+ );
34216
+ });
34217
+ const routes = [
34218
+ { ...PAGE.AUTH, element: AuthPage, layout: AuthLayout },
34219
+ { ...PAGE.NOT_FOUND, element: NotFoundPage, layout: DefaultLayout },
34220
+ { ...PAGE.ERROR, element: ErrorPage, layout: DefaultLayout },
34221
+ // PROTECTED
34222
+ {
34223
+ ...PAGE.DASHBOARD,
34224
+ element: DashboardPage,
34225
+ layout: DashboardLayout,
34226
+ children: [
34227
+ { ...PAGE.DASHBOARD, element: SystemMonitorScreen }
34228
+ ]
34229
+ }
34230
+ ];
34096
34231
  export {
34097
34232
  ALLOW_USER_TYPES,
34098
34233
  ANIMATION_TIME,