@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,113 +1,113 @@
1
- import {Box, styled, Typography} from '@mui/material'
2
- import {ReactNode} from 'react'
3
- import {Link} from 'react-router-dom'
4
- import {isDevelopment} from '../../../constants/isDevelopment'
5
- import {applications} from './applications'
1
+ import { Box, styled, Typography } from '@mui/material'
2
+ import { ReactNode } from 'react'
3
+ import { Link } from 'react-router-dom'
4
+ import { isDevelopment } from '../../../constants/isDevelopment'
5
+ import { applications } from './applications'
6
6
  import AppsMenu from './AppsMenu'
7
- import {collegex, enrollx, examx, payx, peoplex} from './assets'
7
+ import { collegex, enrollx, examx, payx, peoplex } from './assets'
8
8
  import CogWheelMenu from './CogWheelMenu'
9
9
  import FreshDeskHelpButton from './FreshDeskHelpButton'
10
10
  import Notification from './Notification'
11
- import {StyledHeader, StyledImageWrapper} from './styles'
11
+ import { StyledHeader, StyledImageWrapper } from './styles'
12
12
  import UserBox from './UserBox'
13
13
 
14
14
  const StyledLogosWrapper = styled(Box)(() => ({
15
- display: 'flex',
16
- alignItems: 'center',
17
- gap: '10px',
18
- padding: '10px',
19
- transition: 'background ease 0.3s',
20
- borderRadius: '5px',
21
- '&:hover': {
22
- background: 'rgba(0, 0, 0, 0.05)',
23
- },
15
+ display: 'flex',
16
+ alignItems: 'center',
17
+ gap: '10px',
18
+ padding: '10px',
19
+ transition: 'background ease 0.3s',
20
+ borderRadius: '5px',
21
+ '&:hover': {
22
+ background: 'rgba(0, 0, 0, 0.05)',
23
+ },
24
24
  }))
25
25
 
26
26
  const StyledLink = styled(Link)(() => ({
27
- textDecoration: 'none',
27
+ textDecoration: 'none',
28
28
  }))
29
29
 
30
30
  const imageMap = {
31
- ums: collegex,
32
- enroll: enrollx,
33
- exams: examx,
34
- payments: payx,
35
- peoplex: peoplex,
36
- campx: collegex,
31
+ ums: collegex,
32
+ enroll: enrollx,
33
+ exams: examx,
34
+ payments: payx,
35
+ peoplex: peoplex,
36
+ campx: collegex,
37
37
  }
38
38
 
39
39
  interface AppHeaderProps {
40
- clientLogo: string
41
- username: string
42
- profileIcon: string
43
- permissions?: any
44
- userBoxActions: {
45
- label: ReactNode
46
- icon?: ReactNode
47
- onClick: any
48
- }[]
49
- cogWheelMenu?: {label: string; path: string}[]
40
+ clientLogo: string
41
+ username: string
42
+ profileIcon: string
43
+ permissions?: any
44
+ userBoxActions: {
45
+ label: ReactNode
46
+ icon?: ReactNode
47
+ onClick: any
48
+ }[]
49
+ cogWheelMenu?: { label: string; path: string }[]
50
50
  }
51
51
 
52
52
  export default function AppHeader({
53
- clientLogo = imageMap.campx,
54
- username,
55
- profileIcon,
56
- permissions,
57
- userBoxActions = [],
58
- cogWheelMenu = [],
53
+ clientLogo = imageMap.campx,
54
+ username,
55
+ profileIcon,
56
+ permissions,
57
+ userBoxActions = [],
58
+ cogWheelMenu = [],
59
59
  }: AppHeaderProps) {
60
- return (
61
- <StyledHeader>
62
- <Box sx={{display: 'flex', alignItems: 'center', gap: '10px'}}>
63
- <AppsMenu />
64
- <AppLogo clientLogo={clientLogo} />
65
- </Box>
66
- <Box className='actions'>
67
- <FreshDeskHelpButton />
68
- {/* <Notification /> */}
69
- {cogWheelMenu?.length ? <CogWheelMenu menu={cogWheelMenu} /> : null}
70
- <UserBox
71
- username={username}
72
- profileIcon={profileIcon}
73
- actions={userBoxActions}
74
- />
75
- </Box>
76
- </StyledHeader>
77
- )
60
+ return (
61
+ <StyledHeader>
62
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
63
+ <AppsMenu />
64
+ <AppLogo clientLogo={clientLogo} />
65
+ </Box>
66
+ <Box className="actions">
67
+ <FreshDeskHelpButton />
68
+ {/* <Notification /> */}
69
+ {cogWheelMenu?.length ? <CogWheelMenu menu={cogWheelMenu} /> : null}
70
+ <UserBox
71
+ username={username}
72
+ profileIcon={profileIcon}
73
+ actions={userBoxActions}
74
+ />
75
+ </Box>
76
+ </StyledHeader>
77
+ )
78
78
  }
79
79
 
80
- const AppLogo = ({clientLogo}) => {
81
- const originSubdomain = window.location.host.split('.')?.slice(-3)[0] ?? 'ums'
82
- const currentApp =
83
- applications.find((item) => item.key === originSubdomain)?.key ?? 'campx'
80
+ const AppLogo = ({ clientLogo }) => {
81
+ const originSubdomain = window.location.host.split('.')?.slice(-3)[0] ?? 'ums'
82
+ const currentApp =
83
+ applications.find((item) => item.key === originSubdomain)?.key ?? 'campx'
84
84
 
85
- return (
86
- <StyledLink to={'/'}>
87
- <StyledLogosWrapper>
88
- <StyledImageWrapper>
89
- <img src={imageMap[currentApp]} />
90
- </StyledImageWrapper>
91
- <Box
92
- sx={{
93
- height: '26px',
94
- width: '2px',
95
- background: 'gray',
96
- }}
97
- ></Box>
98
- <StyledImageWrapper>
99
- {isDevelopment ? (
100
- <Typography variant='h1'>Developer</Typography>
101
- ) : (
102
- <img
103
- src={clientLogo}
104
- onError={(e: any) => {
105
- e.target.src = imageMap.campx
106
- }}
107
- />
108
- )}
109
- </StyledImageWrapper>
110
- </StyledLogosWrapper>
111
- </StyledLink>
112
- )
85
+ return (
86
+ <StyledLink to={'/'}>
87
+ <StyledLogosWrapper>
88
+ <StyledImageWrapper>
89
+ <img src={imageMap[currentApp]} />
90
+ </StyledImageWrapper>
91
+ <Box
92
+ sx={{
93
+ height: '26px',
94
+ width: '2px',
95
+ background: 'gray',
96
+ }}
97
+ ></Box>
98
+ <StyledImageWrapper>
99
+ {isDevelopment ? (
100
+ <Typography variant="h1">Developer</Typography>
101
+ ) : (
102
+ <img
103
+ src={clientLogo}
104
+ onError={(e: any) => {
105
+ e.target.src = imageMap.campx
106
+ }}
107
+ />
108
+ )}
109
+ </StyledImageWrapper>
110
+ </StyledLogosWrapper>
111
+ </StyledLink>
112
+ )
113
113
  }
@@ -1,92 +1,92 @@
1
- import {Box, Menu, Typography} from '@mui/material'
2
- import {useState} from 'react'
3
- import {applications} from './applications'
4
- import {AppsIcon} from './icons'
1
+ import { Box, Menu, Typography } from '@mui/material'
2
+ import { useState } from 'react'
3
+ import { applications } from './applications'
4
+ import { AppsIcon } from './icons'
5
5
  import {
6
- StyledDescription,
7
- StyledIconButton,
8
- StyledMenuItem,
9
- StyledMenuItemContainer,
10
- StyledLink,
6
+ StyledDescription,
7
+ StyledIconButton,
8
+ StyledMenuItem,
9
+ StyledMenuItemContainer,
10
+ StyledLink,
11
11
  } from './styles'
12
12
 
13
13
  const AppsMenu = () => {
14
- const [anchorEl, setAnchorEl] = useState<any>(null)
15
- const open = Boolean(anchorEl)
14
+ const [anchorEl, setAnchorEl] = useState<any>(null)
15
+ const open = Boolean(anchorEl)
16
16
 
17
- const handleClick = (event) => {
18
- setAnchorEl(event.currentTarget)
19
- }
17
+ const handleClick = (event) => {
18
+ setAnchorEl(event.currentTarget)
19
+ }
20
20
 
21
- const handleClose = () => {
22
- setAnchorEl(null)
23
- }
21
+ const handleClose = () => {
22
+ setAnchorEl(null)
23
+ }
24
24
 
25
- return (
26
- <>
27
- <StyledIconButton onClick={handleClick}>
28
- <AppsIcon />
29
- </StyledIconButton>
25
+ return (
26
+ <>
27
+ <StyledIconButton onClick={handleClick}>
28
+ <AppsIcon />
29
+ </StyledIconButton>
30
30
 
31
- <Menu
32
- transitionDuration={150}
33
- elevation={3}
34
- id='basic-menu'
35
- anchorEl={anchorEl}
36
- open={open}
37
- onClose={handleClose}
38
- anchorOrigin={{
39
- vertical: 'bottom',
40
- horizontal: 'left',
41
- }}
42
- transformOrigin={{
43
- vertical: 'top',
44
- horizontal: 'left',
45
- }}
46
- sx={{
47
- '& .MuiPaper-root': {
48
- left: '0 !important',
49
- top: '64px !important',
50
- },
51
- }}
52
- >
53
- <Box sx={{padding: '0.3rem 1rem'}}>
54
- <Typography variant='body2'>Switch to</Typography>
55
- </Box>
56
- <Box>
57
- {applications.map((item, index) => (
58
- <StyledLink href={item.path}>
59
- <StyledMenuItemContainer
60
- key={index}
61
- onClick={() => {
62
- window.location.href = item.path
63
- handleClose()
64
- }}
65
- >
66
- <MenuItem data={item} />
67
- </StyledMenuItemContainer>
68
- </StyledLink>
69
- ))}
70
- </Box>
71
- </Menu>
72
- </>
73
- )
31
+ <Menu
32
+ transitionDuration={150}
33
+ elevation={3}
34
+ id="basic-menu"
35
+ anchorEl={anchorEl}
36
+ open={open}
37
+ onClose={handleClose}
38
+ anchorOrigin={{
39
+ vertical: 'bottom',
40
+ horizontal: 'left',
41
+ }}
42
+ transformOrigin={{
43
+ vertical: 'top',
44
+ horizontal: 'left',
45
+ }}
46
+ sx={{
47
+ '& .MuiPaper-root': {
48
+ left: '0 !important',
49
+ top: '64px !important',
50
+ },
51
+ }}
52
+ >
53
+ <Box sx={{ padding: '0.3rem 1rem' }}>
54
+ <Typography variant="body2">Switch to</Typography>
55
+ </Box>
56
+ <Box>
57
+ {applications.map((item, index) => (
58
+ <StyledLink href={item.path}>
59
+ <StyledMenuItemContainer
60
+ key={index}
61
+ onClick={() => {
62
+ window.location.href = item.path
63
+ handleClose()
64
+ }}
65
+ >
66
+ <MenuItem data={item} />
67
+ </StyledMenuItemContainer>
68
+ </StyledLink>
69
+ ))}
70
+ </Box>
71
+ </Menu>
72
+ </>
73
+ )
74
74
  }
75
75
 
76
76
  export default AppsMenu
77
77
 
78
- const MenuItem = ({data}) => {
79
- return (
80
- <StyledMenuItem>
81
- <Box>
82
- <img src={data.icon} style={{width: '32px', height: '32px'}} />
83
- </Box>
84
- <Box>
85
- <Typography variant='h1' sx={{marginBottom: '7px'}}>
86
- {data?.title}
87
- </Typography>
88
- <StyledDescription>{data?.description}</StyledDescription>
89
- </Box>
90
- </StyledMenuItem>
91
- )
78
+ const MenuItem = ({ data }) => {
79
+ return (
80
+ <StyledMenuItem>
81
+ <Box>
82
+ <img src={data.icon} style={{ width: '32px', height: '32px' }} />
83
+ </Box>
84
+ <Box>
85
+ <Typography variant="h1" sx={{ marginBottom: '7px' }}>
86
+ {data?.title}
87
+ </Typography>
88
+ <StyledDescription>{data?.description}</StyledDescription>
89
+ </Box>
90
+ </StyledMenuItem>
91
+ )
92
92
  }
@@ -1,33 +1,33 @@
1
- import {SettingsOutlined} from '@mui/icons-material'
2
- import {IconButton} from '@mui/material'
3
- import {useHistory} from '../../../hooks/useRouter'
1
+ import { SettingsOutlined } from '@mui/icons-material'
2
+ import { IconButton } from '@mui/material'
3
+ import { useHistory } from '../../../hooks/useRouter'
4
4
  import MenuButton from '../../MenuButton'
5
5
 
6
- const CogWheelMenu = ({menu}) => {
7
- const history = useHistory()
6
+ const CogWheelMenu = ({ menu }) => {
7
+ const history = useHistory()
8
8
 
9
- return (
10
- <MenuButton
11
- anchor={
12
- <IconButton color='secondary'>
13
- <SettingsOutlined />
14
- </IconButton>
15
- }
16
- menu={menu?.map((item) => ({
17
- label: item?.label,
18
- onClick: () => {
19
- history.push(item?.path)
20
- },
21
- }))}
22
- menuProps={{
23
- PaperProps: {sx: {top: '64px !important'}},
24
- transformOrigin: {
25
- horizontal: 'center',
26
- vertical: 'bottom',
27
- },
28
- }}
29
- />
30
- )
9
+ return (
10
+ <MenuButton
11
+ anchor={
12
+ <IconButton color="secondary">
13
+ <SettingsOutlined />
14
+ </IconButton>
15
+ }
16
+ menu={menu?.map((item) => ({
17
+ label: item?.label,
18
+ onClick: () => {
19
+ history.push(item?.path)
20
+ },
21
+ }))}
22
+ menuProps={{
23
+ PaperProps: { sx: { top: '64px !important' } },
24
+ transformOrigin: {
25
+ horizontal: 'center',
26
+ vertical: 'bottom',
27
+ },
28
+ }}
29
+ />
30
+ )
31
31
  }
32
32
 
33
33
  export default CogWheelMenu
@@ -1,45 +1,45 @@
1
- import { Box, Typography } from "@mui/material";
2
- import { ReactNode, useState } from "react";
3
- import { avatarImage } from "../../../assets/images";
4
- import MenuButton from "../../MenuButton";
5
- import { StyledUser } from "./styles";
6
- import logout from "../../../utils/logout";
7
- import ChangePassword from "../../ChangePassword";
8
- import { ExitToAppOutlined, HttpsOutlined } from "@mui/icons-material";
1
+ import { Box, Typography } from '@mui/material'
2
+ import { ReactNode, useState } from 'react'
3
+ import { avatarImage } from '../../../assets/images'
4
+ import MenuButton from '../../MenuButton'
5
+ import { StyledUser } from './styles'
6
+ import logout from '../../../utils/logout'
7
+ import ChangePassword from '../../ChangePassword'
8
+ import { ExitToAppOutlined, HttpsOutlined } from '@mui/icons-material'
9
9
 
10
10
  export default function UserBox({
11
11
  username,
12
12
  profileIcon,
13
13
  actions,
14
14
  }: {
15
- username: string;
16
- profileIcon: string;
17
- actions: { label: ReactNode; icon?: ReactNode; onClick: any }[];
15
+ username: string
16
+ profileIcon: string
17
+ actions: { label: ReactNode; icon?: ReactNode; onClick: any }[]
18
18
  }) {
19
- const [open, setOpen] = useState(false);
19
+ const [open, setOpen] = useState(false)
20
20
 
21
21
  const handleClickOpen = () => {
22
- setOpen(true);
23
- };
22
+ setOpen(true)
23
+ }
24
24
  const handleClose = (value: string) => {
25
- setOpen(false);
26
- };
25
+ setOpen(false)
26
+ }
27
27
 
28
28
  return (
29
29
  <>
30
30
  <MenuButton
31
31
  anchor={
32
- <Box minWidth={"80px"} textAlign="center">
32
+ <Box minWidth={'80px'} textAlign="center">
33
33
  <StyledUser>
34
34
  <img
35
35
  src={profileIcon ?? avatarImage}
36
36
  style={{
37
- height: "32px",
38
- width: "32px",
39
- objectFit: "contain",
37
+ height: '32px',
38
+ width: '32px',
39
+ objectFit: 'contain',
40
40
  }}
41
41
  onError={(e: any) => {
42
- e.target.src = avatarImage;
42
+ e.target.src = avatarImage
43
43
  }}
44
44
  />
45
45
  <Typography variant="h6">{username}</Typography>
@@ -50,21 +50,21 @@ export default function UserBox({
50
50
  ...actions,
51
51
 
52
52
  {
53
- label: "Change Password",
53
+ label: 'Change Password',
54
54
  icon: <HttpsOutlined />,
55
55
  onClick: handleClickOpen,
56
56
  },
57
57
  {
58
- label: "Logout",
58
+ label: 'Logout',
59
59
  icon: <ExitToAppOutlined />,
60
60
  onClick: logout,
61
61
  },
62
62
  ]}
63
63
  menuProps={{
64
- PaperProps: { sx: { top: "64px !important" } },
64
+ PaperProps: { sx: { top: '64px !important' } },
65
65
  }}
66
66
  />
67
67
  <ChangePassword open={open} onClose={handleClose} />
68
68
  </>
69
- );
69
+ )
70
70
  }