sevago-sso-fe 1.0.9 → 1.0.10

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
  };
@@ -31771,6 +31800,217 @@ const routes = [
31771
31800
  ]
31772
31801
  }
31773
31802
  ];
31803
+ const SidebarContext = React.createContext(
31804
+ void 0
31805
+ );
31806
+ const useSidebar = () => {
31807
+ const context = React.useContext(SidebarContext);
31808
+ if (context === void 0) {
31809
+ throw new Error("useSidebar must be used within a SidebarProvider");
31810
+ }
31811
+ return context;
31812
+ };
31813
+ const AppsSidebar = ({
31814
+ isOpen,
31815
+ onClose
31816
+ }) => {
31817
+ const theme = useTheme();
31818
+ const navigate = reactRouterDom.useNavigate();
31819
+ const allApps = useApps();
31820
+ const dispatch = useAppDispatch();
31821
+ const currentApp = useActiveSidebar();
31822
+ const { setActiveExpandMenu } = useSidebar();
31823
+ const { palette } = useTheme();
31824
+ if (!isOpen) return null;
31825
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31826
+ /* @__PURE__ */ jsxRuntime.jsx(
31827
+ material.Box,
31828
+ {
31829
+ onClick: onClose,
31830
+ sx: {
31831
+ position: "fixed",
31832
+ top: 0,
31833
+ left: 0,
31834
+ right: 0,
31835
+ bottom: 0,
31836
+ backgroundColor: palette.action.selected,
31837
+ zIndex: 100
31838
+ }
31839
+ }
31840
+ ),
31841
+ /* @__PURE__ */ jsxRuntime.jsxs(
31842
+ MotionBox,
31843
+ {
31844
+ preset: "fadeInLeft",
31845
+ sx: {
31846
+ position: "fixed",
31847
+ top: 0,
31848
+ left: 0,
31849
+ height: "100vh",
31850
+ backgroundColor: theme.palette.common.white,
31851
+ zIndex: 100,
31852
+ padding: PADDING_GAP_LAYOUT,
31853
+ gap: PADDING_GAP_ITEM,
31854
+ display: "flex",
31855
+ flexDirection: "column"
31856
+ },
31857
+ children: [
31858
+ /* @__PURE__ */ jsxRuntime.jsxs(
31859
+ material.Box,
31860
+ {
31861
+ sx: {
31862
+ display: "flex",
31863
+ justifyContent: "space-between",
31864
+ alignItems: "center"
31865
+ },
31866
+ children: [
31867
+ /* @__PURE__ */ jsxRuntime.jsx(
31868
+ material.IconButton,
31869
+ {
31870
+ onClick: onClose,
31871
+ sx: {
31872
+ color: theme.palette.grey[600],
31873
+ "&:hover": { backgroundColor: theme.palette.grey[100] }
31874
+ },
31875
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconElement, { icon: "close" })
31876
+ }
31877
+ ),
31878
+ /* @__PURE__ */ jsxRuntime.jsx(
31879
+ material.IconButton,
31880
+ {
31881
+ sx: {
31882
+ color: theme.palette.grey[600],
31883
+ "&:hover": { backgroundColor: theme.palette.grey[100] }
31884
+ },
31885
+ children: /* @__PURE__ */ jsxRuntime.jsx(
31886
+ IconElement,
31887
+ {
31888
+ icon: "home",
31889
+ onClick: () => {
31890
+ onClose();
31891
+ navigate(PAGE.DASHBOARD.path);
31892
+ }
31893
+ }
31894
+ )
31895
+ }
31896
+ )
31897
+ ]
31898
+ }
31899
+ ),
31900
+ /* @__PURE__ */ jsxRuntime.jsxs(
31901
+ material.Box,
31902
+ {
31903
+ sx: {
31904
+ gap: PADDING_GAP_ITEM,
31905
+ display: "flex",
31906
+ flexDirection: "column"
31907
+ },
31908
+ children: [
31909
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle2", children: "Workflow Engine" }),
31910
+ /* @__PURE__ */ jsxRuntime.jsx(
31911
+ AppGrid,
31912
+ {
31913
+ apps: allApps.filter(
31914
+ (app2) => app2.category === AppCategory.WORKFLOW
31915
+ ),
31916
+ columns: 4,
31917
+ iconSize: 60,
31918
+ iconRadius: 5.5,
31919
+ gap: PADDING_GAP_ITEM,
31920
+ titleVariant: "body1",
31921
+ captionVariant: "caption",
31922
+ titleColor: theme.palette.grey[800],
31923
+ captionColor: theme.palette.grey[600],
31924
+ selectedAppId: currentApp?.key,
31925
+ onClickItem: async (app2) => {
31926
+ await dispatch(
31927
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
31928
+ ).unwrap();
31929
+ setActiveExpandMenu(null);
31930
+ onClose();
31931
+ }
31932
+ }
31933
+ )
31934
+ ]
31935
+ }
31936
+ ),
31937
+ /* @__PURE__ */ jsxRuntime.jsxs(
31938
+ material.Box,
31939
+ {
31940
+ sx: {
31941
+ gap: PADDING_GAP_ITEM,
31942
+ display: "flex",
31943
+ flexDirection: "column"
31944
+ },
31945
+ children: [
31946
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle2", children: "HRM" }),
31947
+ /* @__PURE__ */ jsxRuntime.jsx(
31948
+ AppGrid,
31949
+ {
31950
+ apps: allApps.filter((app2) => app2.category === AppCategory.HRM),
31951
+ columns: 4,
31952
+ iconSize: 60,
31953
+ iconRadius: 5.5,
31954
+ gap: PADDING_GAP_ITEM,
31955
+ titleVariant: "body1",
31956
+ captionVariant: "caption",
31957
+ titleColor: theme.palette.grey[800],
31958
+ captionColor: theme.palette.grey[600],
31959
+ selectedAppId: currentApp?.key,
31960
+ onClickItem: async (app2) => {
31961
+ await dispatch(
31962
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
31963
+ ).unwrap();
31964
+ setActiveExpandMenu(null);
31965
+ onClose();
31966
+ }
31967
+ }
31968
+ )
31969
+ ]
31970
+ }
31971
+ ),
31972
+ /* @__PURE__ */ jsxRuntime.jsxs(
31973
+ material.Box,
31974
+ {
31975
+ sx: {
31976
+ gap: PADDING_GAP_ITEM,
31977
+ display: "flex",
31978
+ flexDirection: "column"
31979
+ },
31980
+ children: [
31981
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "subtitle2", children: "Platform Info" }),
31982
+ /* @__PURE__ */ jsxRuntime.jsx(
31983
+ AppGrid,
31984
+ {
31985
+ apps: allApps.filter(
31986
+ (app2) => app2.category === AppCategory.PLATFORM_INFO
31987
+ ),
31988
+ columns: 4,
31989
+ iconSize: 60,
31990
+ iconRadius: 5.5,
31991
+ gap: PADDING_GAP_ITEM,
31992
+ titleVariant: "body1",
31993
+ captionVariant: "caption",
31994
+ titleColor: theme.palette.grey[800],
31995
+ captionColor: theme.palette.grey[600],
31996
+ selectedAppId: currentApp?.key,
31997
+ onClickItem: async (app2) => {
31998
+ await dispatch(
31999
+ ACTION_ACCOUNT.updateCurrentAccess(app2.key)
32000
+ ).unwrap();
32001
+ setActiveExpandMenu(null);
32002
+ onClose();
32003
+ }
32004
+ }
32005
+ )
32006
+ ]
32007
+ }
32008
+ )
32009
+ ]
32010
+ }
32011
+ )
32012
+ ] });
32013
+ };
31774
32014
  const TypographyContentCaption = ({
31775
32015
  content,
31776
32016
  caption,
@@ -31817,6 +32057,7 @@ exports.ANIMATION_TIME = ANIMATION_TIME;
31817
32057
  exports.AppCategory = AppCategory;
31818
32058
  exports.AppGrid = AppGrid;
31819
32059
  exports.AppType = AppType;
32060
+ exports.AppsSidebar = AppsSidebar;
31820
32061
  exports.AuthLayout = AuthLayout;
31821
32062
  exports.AuthPage = AuthPage;
31822
32063
  exports.AuthProcess = AuthProcess;
@@ -32020,7 +32261,11 @@ exports.updateAccount = updateAccount$1;
32020
32261
  exports.updateNotification = updateNotification;
32021
32262
  exports.updateNotificationSetting = updateNotificationSetting;
32022
32263
  exports.updateUser = updateUser;
32264
+ exports.useActiveSidebar = useActiveSidebar;
32265
+ exports.useAllApps = useAllApps;
32023
32266
  exports.useApps = useApps;
32267
+ exports.useIsSystemMonitor = useIsSystemMonitor;
32268
+ exports.useSidebarState = useSidebarState;
32024
32269
  exports.useSnackbar = useSnackbar;
32025
32270
  exports.useTagSelector = useTagSelector;
32026
32271
  exports.useUpdateCurrentAccess = useUpdateCurrentAccess;