sevago-sso-fe 1.0.9 → 1.0.11

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.
@@ -7,5 +7,6 @@ export * from './loading';
7
7
  export * from './logo';
8
8
  export * from './motion';
9
9
  export * from './time-ago';
10
+ export * from './sidebar';
10
11
  export * from './elements';
11
12
  export * from './styles';
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface AppsSidebarProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ }
6
+ export declare const AppsSidebar: React.FC<AppsSidebarProps>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export { AppsSidebar } from './apps-sidebar.component';
@@ -1,5 +1,6 @@
1
- export { useApps } from './use-apps.hook';
1
+ export * from './use-apps.hook';
2
2
  export { useSnackbar } from './use-snackbar.hook';
3
3
  export { useTagSelector } from './use-tag-selector.hook';
4
4
  export { useUpdateCurrentAccess } from './use-update-current-access.hook';
5
5
  export { useVersionCheck } from './use-version-check.hook';
6
+ export { useApps, useActiveSidebar, useIsSystemMonitor, useAllApps, useSidebarState, } from './use-apps.hook';
@@ -1,5 +1,5 @@
1
1
  import { AppCategory } from '../common/enums/app-category.enum';
2
- export declare const useApps: (tab: AppCategory) => import('../common/enums/app-category.enum').AppModule[];
2
+ export declare const useApps: (tab?: AppCategory) => import('../common/enums/app-category.enum').AppModule[];
3
3
  export declare const useIsSystemMonitor: () => boolean;
4
4
  export declare const useAllApps: () => import('../common/enums/app-category.enum').AppModule[];
5
5
  export declare const useActiveSidebar: () => import('../common/enums/app-category.enum').AppModule | undefined;
@@ -0,0 +1 @@
1
+ export declare const useSidebar: () => any;
package/dist/index.cjs.js CHANGED
@@ -12806,8 +12806,10 @@ const truncateText = (text, maxLength = 27) => {
12806
12806
  return `${text.substring(0, maxLength)}...`;
12807
12807
  };
12808
12808
  const timeUtils = timeUtilsMethods;
12809
- const useApps = (tab) => {
12810
- const userType = reactRedux.useSelector((state) => state.account.user?.type);
12809
+ const useApps = (tab = AppCategory.ALL) => {
12810
+ const userType = reactRedux.useSelector(
12811
+ (state) => state.account.user?.type
12812
+ );
12811
12813
  const listApp = React.useMemo(() => {
12812
12814
  let filteredApps = SYSTEM_MODULES.filter((app2) => {
12813
12815
  return app2.allowUserTypes.includes(userType);
@@ -12824,8 +12826,21 @@ const useIsSystemMonitor = () => {
12824
12826
  const normalize = (p) => p.replace(/\/+$/, "");
12825
12827
  return normalize(location2.pathname) === normalize(PAGE.DASHBOARD.path);
12826
12828
  };
12829
+ const useAllApps = () => {
12830
+ const userType = reactRedux.useSelector(
12831
+ (state) => state.account.user?.type
12832
+ );
12833
+ const allApps = React.useMemo(() => {
12834
+ return SYSTEM_MODULES.filter((app2) => {
12835
+ return app2.allowUserTypes.includes(userType);
12836
+ });
12837
+ }, [userType]);
12838
+ return allApps;
12839
+ };
12827
12840
  const useActiveSidebar = () => {
12828
- const { user, current_access } = reactRedux.useSelector((state) => state.account);
12841
+ const { user, current_access } = reactRedux.useSelector(
12842
+ (state) => state.account
12843
+ );
12829
12844
  const activeSidebar = React.useMemo(() => {
12830
12845
  return SYSTEM_MODULES.find(
12831
12846
  (it) => it.key === current_access && user && (it.allowUserTypes ? it.allowUserTypes.includes(user?.type) : true)
@@ -12833,6 +12848,18 @@ const useActiveSidebar = () => {
12833
12848
  }, [current_access, user]);
12834
12849
  return activeSidebar;
12835
12850
  };
12851
+ const useSidebarState = () => {
12852
+ const [isSidebarOpen, setIsSidebarOpen] = React.useState(false);
12853
+ const openSidebar = () => setIsSidebarOpen(true);
12854
+ const closeSidebar = () => setIsSidebarOpen(false);
12855
+ const toggleSidebar = () => setIsSidebarOpen((prev) => !prev);
12856
+ return {
12857
+ isSidebarOpen,
12858
+ openSidebar,
12859
+ closeSidebar,
12860
+ toggleSidebar
12861
+ };
12862
+ };
12836
12863
  var propTypes = { exports: {} };
12837
12864
  var reactIs$2 = { exports: {} };
12838
12865
  var reactIs_production_min$1 = {};
@@ -19163,7 +19190,9 @@ const MonitorPart = ({
19163
19190
  }
19164
19191
  );
19165
19192
  };
19166
- const DashboardLayout = ({ children }) => {
19193
+ const DashboardLayout = ({
19194
+ children
19195
+ }) => {
19167
19196
  useUpdateCurrentAccess();
19168
19197
  return /* @__PURE__ */ jsxRuntime.jsx(MonitorPart, { children });
19169
19198
  };
@@ -24142,6 +24171,37 @@ const NotFoundPage = ({}) => {
24142
24171
  /* @__PURE__ */ jsxRuntime.jsx(ButtonElement, { content: "Quay lại trang chủ", fullWidth: false, onClick: () => navigate(PAGE.AUTH.path) })
24143
24172
  ] });
24144
24173
  };
24174
+ const SidebarContext = React.createContext(
24175
+ void 0
24176
+ );
24177
+ const SidebarProvider = ({
24178
+ children
24179
+ }) => {
24180
+ const [isCollapsed, setIsCollapsed] = React.useState(false);
24181
+ const [activeExpandMenu, setActiveExpandMenu] = React.useState(
24182
+ null
24183
+ );
24184
+ const { current_access } = reactRedux.useSelector(
24185
+ (state) => state.account
24186
+ );
24187
+ React.useEffect(() => {
24188
+ setActiveExpandMenu(null);
24189
+ }, [current_access]);
24190
+ const sidebarWidth = activeExpandMenu ? isCollapsed ? STYLE.WIDTH_COLLAPSE + STYLE.WIDTH_SIDEBAR_EXPAND : STYLE.WIDTH_SIDEBAR + STYLE.WIDTH_SIDEBAR_EXPAND : isCollapsed ? STYLE.WIDTH_COLLAPSE : STYLE.WIDTH_SIDEBAR;
24191
+ return /* @__PURE__ */ jsxRuntime.jsx(
24192
+ SidebarContext.Provider,
24193
+ {
24194
+ value: {
24195
+ isCollapsed,
24196
+ setIsCollapsed,
24197
+ activeExpandMenu,
24198
+ setActiveExpandMenu,
24199
+ sidebarWidth: `${sidebarWidth}px`
24200
+ },
24201
+ children
24202
+ }
24203
+ );
24204
+ };
24145
24205
  const LayoutGroupContext = React.createContext({});
24146
24206
  function useConstant(init) {
24147
24207
  const ref = React.useRef(null);
@@ -31771,6 +31831,214 @@ const routes = [
31771
31831
  ]
31772
31832
  }
31773
31833
  ];
31834
+ const useSidebar = () => {
31835
+ const context = React.useContext(SidebarContext);
31836
+ if (context === void 0) {
31837
+ throw new Error("useSidebar must be used within a SidebarProvider");
31838
+ }
31839
+ return context;
31840
+ };
31841
+ const AppsSidebar = ({
31842
+ isOpen,
31843
+ onClose
31844
+ }) => {
31845
+ const theme = useTheme();
31846
+ const navigate = reactRouterDom.useNavigate();
31847
+ const allApps = useApps();
31848
+ const dispatch = useAppDispatch();
31849
+ const currentApp = useActiveSidebar();
31850
+ const { setActiveExpandMenu } = useSidebar();
31851
+ const { palette } = useTheme();
31852
+ if (!isOpen) return null;
31853
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31854
+ /* @__PURE__ */ jsxRuntime.jsx(
31855
+ material.Box,
31856
+ {
31857
+ onClick: onClose,
31858
+ sx: {
31859
+ position: "fixed",
31860
+ top: 0,
31861
+ left: 0,
31862
+ right: 0,
31863
+ bottom: 0,
31864
+ backgroundColor: palette.action.selected,
31865
+ zIndex: 100
31866
+ }
31867
+ }
31868
+ ),
31869
+ /* @__PURE__ */ jsxRuntime.jsxs(
31870
+ MotionBox,
31871
+ {
31872
+ preset: "fadeInLeft",
31873
+ sx: {
31874
+ position: "fixed",
31875
+ top: 0,
31876
+ left: 0,
31877
+ height: "100vh",
31878
+ backgroundColor: theme.palette.common.white,
31879
+ zIndex: 100,
31880
+ padding: PADDING_GAP_LAYOUT,
31881
+ gap: PADDING_GAP_ITEM,
31882
+ display: "flex",
31883
+ flexDirection: "column"
31884
+ },
31885
+ children: [
31886
+ /* @__PURE__ */ jsxRuntime.jsxs(
31887
+ material.Box,
31888
+ {
31889
+ sx: {
31890
+ display: "flex",
31891
+ justifyContent: "space-between",
31892
+ alignItems: "center"
31893
+ },
31894
+ children: [
31895
+ /* @__PURE__ */ jsxRuntime.jsx(
31896
+ material.IconButton,
31897
+ {
31898
+ onClick: onClose,
31899
+ sx: {
31900
+ color: theme.palette.grey[600],
31901
+ "&:hover": { backgroundColor: theme.palette.grey[100] }
31902
+ },
31903
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconElement, { icon: "close" })
31904
+ }
31905
+ ),
31906
+ /* @__PURE__ */ jsxRuntime.jsx(
31907
+ material.IconButton,
31908
+ {
31909
+ sx: {
31910
+ color: theme.palette.grey[600],
31911
+ "&:hover": { backgroundColor: theme.palette.grey[100] }
31912
+ },
31913
+ children: /* @__PURE__ */ jsxRuntime.jsx(
31914
+ IconElement,
31915
+ {
31916
+ icon: "home",
31917
+ onClick: () => {
31918
+ onClose();
31919
+ navigate(PAGE.DASHBOARD.path);
31920
+ }
31921
+ }
31922
+ )
31923
+ }
31924
+ )
31925
+ ]
31926
+ }
31927
+ ),
31928
+ /* @__PURE__ */ jsxRuntime.jsxs(
31929
+ material.Box,
31930
+ {
31931
+ sx: {
31932
+ gap: PADDING_GAP_ITEM,
31933
+ display: "flex",
31934
+ flexDirection: "column"
31935
+ },
31936
+ children: [
31937
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle2", children: "Workflow Engine" }),
31938
+ /* @__PURE__ */ jsxRuntime.jsx(
31939
+ AppGrid,
31940
+ {
31941
+ apps: allApps.filter(
31942
+ (app2) => app2.category === AppCategory.WORKFLOW
31943
+ ),
31944
+ columns: 4,
31945
+ iconSize: 60,
31946
+ iconRadius: 5.5,
31947
+ gap: PADDING_GAP_ITEM,
31948
+ titleVariant: "body1",
31949
+ captionVariant: "caption",
31950
+ titleColor: theme.palette.grey[800],
31951
+ captionColor: theme.palette.grey[600],
31952
+ selectedAppId: currentApp?.key,
31953
+ onClickItem: async (app2) => {
31954
+ await dispatch(
31955
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
31956
+ ).unwrap();
31957
+ setActiveExpandMenu(null);
31958
+ onClose();
31959
+ }
31960
+ }
31961
+ )
31962
+ ]
31963
+ }
31964
+ ),
31965
+ /* @__PURE__ */ jsxRuntime.jsxs(
31966
+ material.Box,
31967
+ {
31968
+ sx: {
31969
+ gap: PADDING_GAP_ITEM,
31970
+ display: "flex",
31971
+ flexDirection: "column"
31972
+ },
31973
+ children: [
31974
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle2", children: "HRM" }),
31975
+ /* @__PURE__ */ jsxRuntime.jsx(
31976
+ AppGrid,
31977
+ {
31978
+ apps: allApps.filter((app2) => app2.category === AppCategory.HRM),
31979
+ columns: 4,
31980
+ iconSize: 60,
31981
+ iconRadius: 5.5,
31982
+ gap: PADDING_GAP_ITEM,
31983
+ titleVariant: "body1",
31984
+ captionVariant: "caption",
31985
+ titleColor: theme.palette.grey[800],
31986
+ captionColor: theme.palette.grey[600],
31987
+ selectedAppId: currentApp?.key,
31988
+ onClickItem: async (app2) => {
31989
+ await dispatch(
31990
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
31991
+ ).unwrap();
31992
+ setActiveExpandMenu(null);
31993
+ onClose();
31994
+ }
31995
+ }
31996
+ )
31997
+ ]
31998
+ }
31999
+ ),
32000
+ /* @__PURE__ */ jsxRuntime.jsxs(
32001
+ material.Box,
32002
+ {
32003
+ sx: {
32004
+ gap: PADDING_GAP_ITEM,
32005
+ display: "flex",
32006
+ flexDirection: "column"
32007
+ },
32008
+ children: [
32009
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle2", children: "Platform Info" }),
32010
+ /* @__PURE__ */ jsxRuntime.jsx(
32011
+ AppGrid,
32012
+ {
32013
+ apps: allApps.filter(
32014
+ (app2) => app2.category === AppCategory.PLATFORM_INFO
32015
+ ),
32016
+ columns: 4,
32017
+ iconSize: 60,
32018
+ iconRadius: 5.5,
32019
+ gap: PADDING_GAP_ITEM,
32020
+ titleVariant: "body1",
32021
+ captionVariant: "caption",
32022
+ titleColor: theme.palette.grey[800],
32023
+ captionColor: theme.palette.grey[600],
32024
+ selectedAppId: currentApp?.key,
32025
+ onClickItem: async (app2) => {
32026
+ await dispatch(
32027
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
32028
+ ).unwrap();
32029
+ setActiveExpandMenu(null);
32030
+ onClose();
32031
+ }
32032
+ }
32033
+ )
32034
+ ]
32035
+ }
32036
+ )
32037
+ ]
32038
+ }
32039
+ )
32040
+ ] });
32041
+ };
31774
32042
  const TypographyContentCaption = ({
31775
32043
  content,
31776
32044
  caption,
@@ -31817,6 +32085,7 @@ exports.ANIMATION_TIME = ANIMATION_TIME;
31817
32085
  exports.AppCategory = AppCategory;
31818
32086
  exports.AppGrid = AppGrid;
31819
32087
  exports.AppType = AppType;
32088
+ exports.AppsSidebar = AppsSidebar;
31820
32089
  exports.AuthLayout = AuthLayout;
31821
32090
  exports.AuthPage = AuthPage;
31822
32091
  exports.AuthProcess = AuthProcess;
@@ -31893,6 +32162,8 @@ exports.RouteType = RouteType;
31893
32162
  exports.SCALE_VALUE = SCALE_VALUE;
31894
32163
  exports.STYLE = STYLE;
31895
32164
  exports.SYSTEM_MODULES = SYSTEM_MODULES;
32165
+ exports.SidebarContext = SidebarContext;
32166
+ exports.SidebarProvider = SidebarProvider;
31896
32167
  exports.SmallIcon = SmallIcon;
31897
32168
  exports.SocketNamespace = SocketNamespace;
31898
32169
  exports.SocketSystemEvent = SocketSystemEvent;
@@ -32020,7 +32291,11 @@ exports.updateAccount = updateAccount$1;
32020
32291
  exports.updateNotification = updateNotification;
32021
32292
  exports.updateNotificationSetting = updateNotificationSetting;
32022
32293
  exports.updateUser = updateUser;
32294
+ exports.useActiveSidebar = useActiveSidebar;
32295
+ exports.useAllApps = useAllApps;
32023
32296
  exports.useApps = useApps;
32297
+ exports.useIsSystemMonitor = useIsSystemMonitor;
32298
+ exports.useSidebarState = useSidebarState;
32024
32299
  exports.useSnackbar = useSnackbar;
32025
32300
  exports.useTagSelector = useTagSelector;
32026
32301
  exports.useUpdateCurrentAccess = useUpdateCurrentAccess;