@campxdev/shared 0.5.21 → 0.5.22

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.
Files changed (69) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +34 -0
  3. package/.prettierrc +10 -0
  4. package/exports.ts +7 -6
  5. package/package.json +64 -50
  6. package/publish.sh +2 -0
  7. package/src/assets/images/index.ts +8 -8
  8. package/src/components/Breadcrumbs.tsx +3 -3
  9. package/src/components/ChangePassword.tsx +147 -147
  10. package/src/components/DropDownButton.tsx +167 -163
  11. package/src/components/ErrorBoundary/ErrorBoundary.tsx +22 -22
  12. package/src/components/ErrorBoundary/ErrorFallback.tsx +215 -215
  13. package/src/components/ErrorBoundary/GlobalNetworkLoadingIndicator.tsx +6 -6
  14. package/src/components/ErrorBoundary/index.tsx +1 -1
  15. package/src/components/FullScreenLoader.tsx +15 -15
  16. package/src/components/HookForm/AutoCompleteSearch.tsx +0 -30
  17. package/src/components/HookForm/RadioGroup.tsx +1 -1
  18. package/src/components/IconButtons/Icons.tsx +1 -2
  19. package/src/components/Input/AutoCompleteSearch.tsx +0 -30
  20. package/src/components/Input/SingleSelect.tsx +0 -15
  21. package/src/components/Layout/Header/AppHeader.tsx +89 -89
  22. package/src/components/Layout/Header/AppsMenu.tsx +79 -79
  23. package/src/components/Layout/Header/CogWheelMenu.tsx +27 -27
  24. package/src/components/Layout/Header/UserBox.tsx +25 -25
  25. package/src/components/Layout/Header/applications.ts +79 -79
  26. package/src/components/Layout/Header/assets/index.ts +10 -10
  27. package/src/components/Layout/Header/styles.tsx +72 -72
  28. package/src/components/LayoutWrapper.tsx +6 -6
  29. package/src/components/LinearProgress.tsx +14 -14
  30. package/src/components/ListItemButton.tsx +79 -79
  31. package/src/components/LoginForm.tsx +86 -86
  32. package/src/components/MenuButton.tsx +88 -88
  33. package/src/components/ModalButtons/DialogButton.tsx +66 -66
  34. package/src/components/PageContent.tsx +10 -10
  35. package/src/components/PageNotFound.tsx +12 -12
  36. package/src/components/PopupConfirm/ConfirmContextProvider.tsx +28 -28
  37. package/src/components/PopupConfirm/PopupConfirm.tsx +27 -27
  38. package/src/components/PopupConfirm/useConfirm.ts +41 -41
  39. package/src/components/SideMenuHeader.tsx +15 -15
  40. package/src/components/SideNav.tsx +119 -119
  41. package/src/components/Spinner.tsx +14 -14
  42. package/src/components/TableComponent/ReactTable.tsx +256 -256
  43. package/src/components/TableComponent/RenderTableBody.tsx +56 -56
  44. package/src/components/TableComponent/index.tsx +171 -171
  45. package/src/components/TableComponent/react-table-config.d.ts +2 -3
  46. package/src/components/index.ts +54 -54
  47. package/src/config/axios.ts +50 -50
  48. package/src/config/axiosXTenant.ts +57 -0
  49. package/src/constants/isDevelopment.ts +2 -2
  50. package/src/contexts/LoginFormProvider.tsx +28 -28
  51. package/src/contexts/Providers.tsx +40 -40
  52. package/src/contexts/QueryClientProvider.tsx +15 -15
  53. package/src/hooks/index.ts +2 -2
  54. package/src/hooks/useAppInit.ts +23 -23
  55. package/src/hooks/useAuth.ts +78 -77
  56. package/src/layouts/Components/DashBoardMenu.tsx +77 -77
  57. package/src/layouts/Components/icons/index.tsx +32 -32
  58. package/src/layouts/Components/styles.tsx +23 -23
  59. package/src/permissions/PageWithPermission.tsx +9 -9
  60. package/src/permissions/PermissionDeniedPage.tsx +13 -13
  61. package/src/permissions/PermissionsStore.ts +303 -303
  62. package/src/shared-state/index.ts +3 -3
  63. package/src/theme/MuiThemeProvider.tsx +9 -9
  64. package/src/theme/theme.d.ts +72 -72
  65. package/src/utils/index.ts +7 -7
  66. package/src/utils/logout.ts +19 -19
  67. package/src/utils/withLocalization.tsx +8 -8
  68. package/src/utils/withRouteWrapper.tsx +20 -20
  69. package/src/utils/withSuspense.tsx +3 -3
@@ -1,40 +1,40 @@
1
- import {createContext, ReactNode, useState} from 'react'
1
+ import { createContext, ReactNode, useState } from 'react'
2
2
  import PopupConfirm from './PopupConfirm'
3
3
 
4
4
  interface ConfirmContextProps {
5
- confirm: {
6
- prompt: ReactNode
7
- isOpen: boolean
8
- proceed: () => void
9
- cancel: () => void
10
- }
11
- setConfirm: any
5
+ confirm: {
6
+ prompt: ReactNode
7
+ isOpen: boolean
8
+ proceed: () => void
9
+ cancel: () => void
10
+ }
11
+ setConfirm: any
12
12
  }
13
13
 
14
14
  export const ConfirmContext = createContext<ConfirmContextProps>({
15
- confirm: {
16
- cancel: () => {},
17
- proceed: () => {},
18
- prompt: 'Are you sure?',
19
- isOpen: false,
20
- },
21
- setConfirm: () => {},
15
+ confirm: {
16
+ cancel: () => {},
17
+ proceed: () => {},
18
+ prompt: 'Are you sure?',
19
+ isOpen: false,
20
+ },
21
+ setConfirm: () => {},
22
22
  })
23
23
 
24
- const ConfirmContextProvider = ({children}) => {
25
- const [confirm, setConfirm] = useState({
26
- prompt: '',
27
- isOpen: false,
28
- proceed: null,
29
- cancel: null,
30
- })
24
+ const ConfirmContextProvider = ({ children }) => {
25
+ const [confirm, setConfirm] = useState({
26
+ prompt: '',
27
+ isOpen: false,
28
+ proceed: null,
29
+ cancel: null,
30
+ })
31
31
 
32
- return (
33
- <ConfirmContext.Provider value={{confirm, setConfirm}}>
34
- {children}
35
- <PopupConfirm />
36
- </ConfirmContext.Provider>
37
- )
32
+ return (
33
+ <ConfirmContext.Provider value={{ confirm, setConfirm }}>
34
+ {children}
35
+ <PopupConfirm />
36
+ </ConfirmContext.Provider>
37
+ )
38
38
  }
39
39
 
40
40
  export default ConfirmContextProvider
@@ -1,34 +1,34 @@
1
1
  import {
2
- Button,
3
- Dialog,
4
- DialogActions,
5
- DialogContent,
6
- DialogTitle,
2
+ Button,
3
+ Dialog,
4
+ DialogActions,
5
+ DialogContent,
6
+ DialogTitle,
7
7
  } from '@mui/material'
8
8
  import useConfirm from './useConfirm'
9
9
 
10
10
  const PopupConfirm = () => {
11
- const {prompt = '', isOpen = false, proceed, cancel} = useConfirm()
12
- return (
13
- <Dialog
14
- sx={{zIndex: 1600}}
15
- keepMounted
16
- maxWidth='sm'
17
- fullWidth
18
- open={isOpen}
19
- transitionDuration={150}
20
- >
21
- <DialogTitle>Confirm</DialogTitle>
22
- <DialogContent sx={{minHeight: '40px'}}>{prompt}</DialogContent>
23
- <DialogActions>
24
- <Button variant='contained' color='primary' onClick={proceed}>
25
- Ok
26
- </Button>
27
- <Button color='secondary' variant='outlined' onClick={cancel}>
28
- Cancel
29
- </Button>
30
- </DialogActions>
31
- </Dialog>
32
- )
11
+ const { prompt = '', isOpen = false, proceed, cancel } = useConfirm()
12
+ return (
13
+ <Dialog
14
+ sx={{ zIndex: 1600 }}
15
+ keepMounted
16
+ maxWidth="sm"
17
+ fullWidth
18
+ open={isOpen}
19
+ transitionDuration={150}
20
+ >
21
+ <DialogTitle>Confirm</DialogTitle>
22
+ <DialogContent sx={{ minHeight: '40px' }}>{prompt}</DialogContent>
23
+ <DialogActions>
24
+ <Button variant="contained" color="primary" onClick={proceed}>
25
+ Ok
26
+ </Button>
27
+ <Button color="secondary" variant="outlined" onClick={cancel}>
28
+ Cancel
29
+ </Button>
30
+ </DialogActions>
31
+ </Dialog>
32
+ )
33
33
  }
34
34
  export default PopupConfirm
@@ -1,47 +1,47 @@
1
- import {ReactNode, useContext, useEffect, useState} from 'react'
2
- import {ConfirmContext} from './ConfirmContextProvider'
1
+ import { ReactNode, useContext, useEffect, useState } from 'react'
2
+ import { ConfirmContext } from './ConfirmContextProvider'
3
3
 
4
4
  export default function useConfirm(): {
5
- isConfirmed: (prompt?: string) => Promise<boolean>
6
- prompt?: ReactNode
7
- isOpen?: boolean
8
- proceed?: () => void
9
- cancel?: () => void
5
+ isConfirmed: (prompt?: string) => Promise<boolean>
6
+ prompt?: ReactNode
7
+ isOpen?: boolean
8
+ proceed?: () => void
9
+ cancel?: () => void
10
10
  } {
11
- const {confirm, setConfirm} = useContext(ConfirmContext)
12
- const [needsCleanup, setNeedsCleanup] = useState(false)
11
+ const { confirm, setConfirm } = useContext(ConfirmContext)
12
+ const [needsCleanup, setNeedsCleanup] = useState(false)
13
13
 
14
- const isConfirmed = (prompt) => {
15
- setNeedsCleanup(true)
16
- const promise = new Promise((resolve, reject) => {
17
- setConfirm({
18
- prompt,
19
- isOpen: true,
20
- proceed: resolve,
21
- cancel: reject,
22
- })
23
- })
24
- return promise.then(
25
- () => {
26
- setConfirm({...confirm, isOpen: false})
27
- return true
28
- },
29
- () => {
30
- setConfirm({...confirm, isOpen: false})
31
- return false
32
- }
33
- )
34
- }
14
+ const isConfirmed = (prompt) => {
15
+ setNeedsCleanup(true)
16
+ const promise = new Promise((resolve, reject) => {
17
+ setConfirm({
18
+ prompt,
19
+ isOpen: true,
20
+ proceed: resolve,
21
+ cancel: reject,
22
+ })
23
+ })
24
+ return promise.then(
25
+ () => {
26
+ setConfirm({ ...confirm, isOpen: false })
27
+ return true
28
+ },
29
+ () => {
30
+ setConfirm({ ...confirm, isOpen: false })
31
+ return false
32
+ },
33
+ )
34
+ }
35
35
 
36
- useEffect(() => {
37
- return () => {
38
- if (confirm.cancel && needsCleanup) {
39
- confirm.cancel()
40
- }
41
- }
42
- }, [confirm, needsCleanup])
43
- return {
44
- ...confirm,
45
- isConfirmed,
46
- }
36
+ useEffect(() => {
37
+ return () => {
38
+ if (confirm.cancel && needsCleanup) {
39
+ confirm.cancel()
40
+ }
41
+ }
42
+ }, [confirm, needsCleanup])
43
+ return {
44
+ ...confirm,
45
+ isConfirmed,
46
+ }
47
47
  }
@@ -1,29 +1,29 @@
1
- import { KeyboardBackspace } from "@mui/icons-material";
2
- import { Box, styled as styledMui, Typography } from "@mui/material";
3
- import { useNavigate } from "react-router-dom";
1
+ import { KeyboardBackspace } from '@mui/icons-material'
2
+ import { Box, styled as styledMui, Typography } from '@mui/material'
3
+ import { useNavigate } from 'react-router-dom'
4
4
 
5
5
  const StyledSideMenuHeader = styledMui(Box)(({ theme }) => ({
6
- height: "60px",
7
- display: "flex",
8
- gap: "8px",
9
- alignItems: "center",
10
- cursor: "pointer",
11
- background: "#1d1d1d",
12
- }));
6
+ height: '60px',
7
+ display: 'flex',
8
+ gap: '8px',
9
+ alignItems: 'center',
10
+ cursor: 'pointer',
11
+ background: '#1d1d1d',
12
+ }))
13
13
 
14
14
  export const SideMenuHeader = ({ title, path }) => {
15
- const navigate = useNavigate();
15
+ const navigate = useNavigate()
16
16
 
17
17
  return (
18
18
  <StyledSideMenuHeader
19
19
  onClick={() => {
20
- navigate(path);
20
+ navigate(path)
21
21
  }}
22
22
  >
23
23
  <KeyboardBackspace />
24
- <Typography variant="h3" color={"white"}>
24
+ <Typography variant="h3" color={'white'}>
25
25
  {title}
26
26
  </Typography>
27
27
  </StyledSideMenuHeader>
28
- );
29
- };
28
+ )
29
+ }
@@ -1,150 +1,150 @@
1
1
  import {
2
- Box,
3
- Collapse,
4
- List,
5
- ListItemIcon,
6
- ListItemText,
7
- styled,
2
+ Box,
3
+ Collapse,
4
+ List,
5
+ ListItemIcon,
6
+ ListItemText,
7
+ styled,
8
8
  } from '@mui/material'
9
- import {Store} from 'pullstate'
10
- import {memo, ReactNode} from 'react'
11
- import {Link, useMatch, useResolvedPath} from 'react-router-dom'
12
- import {PermissionsStore} from '../permissions'
9
+ import { Store } from 'pullstate'
10
+ import { memo, ReactNode } from 'react'
11
+ import { Link, useMatch, useResolvedPath } from 'react-router-dom'
12
+ import { PermissionsStore } from '../permissions'
13
13
  import {
14
- ListItemButton,
15
- StyledChevronIcon,
16
- StyledListItemButton,
14
+ ListItemButton,
15
+ StyledChevronIcon,
16
+ StyledListItemButton,
17
17
  } from './ListItemButton'
18
18
 
19
19
  const accessIfNoKey = process.env.NODE_ENV === 'development' ? true : false
20
20
 
21
21
  const sideNavStore = new Store({
22
- activeKey: '',
22
+ activeKey: '',
23
23
  })
24
24
 
25
25
  const StyledLink = styled(Link)({
26
- textDecoration: 'none',
26
+ textDecoration: 'none',
27
27
  })
28
28
 
29
29
  const SideNav = ({
30
- menuItems,
31
- header,
30
+ menuItems,
31
+ header,
32
32
  }: {
33
- menuItems: any[]
34
- header?: ReactNode
33
+ menuItems: any[]
34
+ header?: ReactNode
35
35
  }) => {
36
- return (
37
- <Box
38
- sx={{
39
- background: (theme) => theme.palette.secondary.main,
40
- }}
41
- >
42
- {header ? header : null}
43
- <Box>
44
- {menuItems.map((item, index) => (
45
- <RenderMenuItem key={index} menuItem={item} />
46
- ))}
47
- </Box>
48
- </Box>
49
- )
36
+ return (
37
+ <Box
38
+ sx={{
39
+ background: (theme) => theme.palette.secondary.main,
40
+ }}
41
+ >
42
+ {header ? header : null}
43
+ <Box>
44
+ {menuItems.map((item, index) => (
45
+ <RenderMenuItem key={index} menuItem={item} />
46
+ ))}
47
+ </Box>
48
+ </Box>
49
+ )
50
50
  }
51
51
 
52
52
  export default memo(SideNav)
53
53
 
54
- const RenderMenuItem = ({menuItem}) => {
55
- const {path, children, title, icon, permissionKey} = menuItem
56
- let resolved = useResolvedPath(path)
57
- let match = useMatch({path: resolved.pathname, end: false})
54
+ const RenderMenuItem = ({ menuItem }) => {
55
+ const { path, children, title, icon, permissionKey } = menuItem
56
+ let resolved = useResolvedPath(path)
57
+ let match = useMatch({ path: resolved.pathname, end: false })
58
58
 
59
- const permissions = PermissionsStore.useState((s) => s).permissions
60
- const hasAccess = permissionKey ? permissions[permissionKey] : accessIfNoKey
59
+ const permissions = PermissionsStore.useState((s) => s).permissions
60
+ const hasAccess = permissionKey ? permissions[permissionKey] : accessIfNoKey
61
61
 
62
- if (children?.length)
63
- return (
64
- <Box sx={{position: 'relative'}}>
65
- <DropDownMenu
66
- icon={icon}
67
- menuItems={children}
68
- path={path}
69
- title={title}
70
- />
71
- </Box>
72
- )
62
+ if (children?.length)
63
+ return (
64
+ <Box sx={{ position: 'relative' }}>
65
+ <DropDownMenu
66
+ icon={icon}
67
+ menuItems={children}
68
+ path={path}
69
+ title={title}
70
+ />
71
+ </Box>
72
+ )
73
73
 
74
- return (
75
- <>
76
- {hasAccess ? (
77
- <StyledLink to={path}>
78
- <ListItemButton
79
- hasChildren={false}
80
- label={title}
81
- isActive={!!match}
82
- icon={icon}
83
- />
84
- </StyledLink>
85
- ) : null}
86
- </>
87
- )
74
+ return (
75
+ <>
76
+ {hasAccess ? (
77
+ <StyledLink to={path}>
78
+ <ListItemButton
79
+ hasChildren={false}
80
+ label={title}
81
+ isActive={!!match}
82
+ icon={icon}
83
+ />
84
+ </StyledLink>
85
+ ) : null}
86
+ </>
87
+ )
88
88
  }
89
89
 
90
- const DropDownMenu = ({path, title, icon, menuItems}) => {
91
- const {activeKey} = sideNavStore.useState((s) => s)
92
- const permissions = PermissionsStore.useState((s) => s).permissions
90
+ const DropDownMenu = ({ path, title, icon, menuItems }) => {
91
+ const { activeKey } = sideNavStore.useState((s) => s)
92
+ const permissions = PermissionsStore.useState((s) => s).permissions
93
93
 
94
- const validateDropdownAccess = () => {
95
- if (process.env.NODE_ENV === 'development' && !permissions) return true
94
+ const validateDropdownAccess = () => {
95
+ if (process.env.NODE_ENV === 'development' && !permissions) return true
96
96
 
97
- return menuItems?.every((item) =>
98
- item?.permissionKey ? permissions[item.permissionKey] : accessIfNoKey
99
- )
100
- }
97
+ return menuItems?.every((item) =>
98
+ item?.permissionKey ? permissions[item.permissionKey] : accessIfNoKey,
99
+ )
100
+ }
101
101
 
102
- if (!validateDropdownAccess()) return null
103
- return (
104
- <Box sx={{position: 'relative'}}>
105
- <MenuDropDownButton
106
- isActive={activeKey === path}
107
- onClick={() => {
108
- sideNavStore.update((s) => {
109
- s.activeKey = activeKey === path ? '' : path
110
- })
111
- }}
112
- label={title}
113
- icon={icon}
114
- />
115
- <Collapse timeout={200} in={activeKey === path}>
116
- <List>
117
- {menuItems?.map((child) => (
118
- <RenderMenuItem
119
- key={child.path}
120
- menuItem={{
121
- ...child,
122
- path: path + child.path,
123
- }}
124
- />
125
- ))}
126
- </List>
127
- </Collapse>
128
- </Box>
129
- )
102
+ if (!validateDropdownAccess()) return null
103
+ return (
104
+ <Box sx={{ position: 'relative' }}>
105
+ <MenuDropDownButton
106
+ isActive={activeKey === path}
107
+ onClick={() => {
108
+ sideNavStore.update((s) => {
109
+ s.activeKey = activeKey === path ? '' : path
110
+ })
111
+ }}
112
+ label={title}
113
+ icon={icon}
114
+ />
115
+ <Collapse timeout={200} in={activeKey === path}>
116
+ <List>
117
+ {menuItems?.map((child) => (
118
+ <RenderMenuItem
119
+ key={child.path}
120
+ menuItem={{
121
+ ...child,
122
+ path: path + child.path,
123
+ }}
124
+ />
125
+ ))}
126
+ </List>
127
+ </Collapse>
128
+ </Box>
129
+ )
130
130
  }
131
131
 
132
- const MenuDropDownButton = ({icon: Icon, label, onClick, isActive}) => {
133
- return (
134
- <>
135
- <StyledListItemButton
136
- dropDown={true}
137
- onClick={onClick}
138
- isActive={isActive}
139
- >
140
- {Icon ? (
141
- <ListItemIcon>{<Icon />}</ListItemIcon>
142
- ) : (
143
- <Box minWidth={16}></Box>
144
- )}
145
- <ListItemText primary={label} />
146
- <StyledChevronIcon open={isActive} />
147
- </StyledListItemButton>
148
- </>
149
- )
132
+ const MenuDropDownButton = ({ icon: Icon, label, onClick, isActive }) => {
133
+ return (
134
+ <>
135
+ <StyledListItemButton
136
+ dropDown={true}
137
+ onClick={onClick}
138
+ isActive={isActive}
139
+ >
140
+ {Icon ? (
141
+ <ListItemIcon>{<Icon />}</ListItemIcon>
142
+ ) : (
143
+ <Box minWidth={16}></Box>
144
+ )}
145
+ <ListItemText primary={label} />
146
+ <StyledChevronIcon open={isActive} />
147
+ </StyledListItemButton>
148
+ </>
149
+ )
150
150
  }
@@ -1,18 +1,18 @@
1
- import {CircularProgress} from '@mui/material'
1
+ import { CircularProgress } from '@mui/material'
2
2
 
3
- function Spinner({height = '200px'}: {height?: string | number}) {
4
- return (
5
- <div
6
- style={{
7
- justifyContent: 'center',
8
- alignItems: 'center',
9
- height,
10
- display: 'flex',
11
- }}
12
- >
13
- <CircularProgress />
14
- </div>
15
- )
3
+ function Spinner({ height = '200px' }: { height?: string | number }) {
4
+ return (
5
+ <div
6
+ style={{
7
+ justifyContent: 'center',
8
+ alignItems: 'center',
9
+ height,
10
+ display: 'flex',
11
+ }}
12
+ >
13
+ <CircularProgress />
14
+ </div>
15
+ )
16
16
  }
17
17
 
18
18
  export default Spinner