@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,103 +1,103 @@
1
- import {Visibility, VisibilityOff} from '@mui/icons-material'
1
+ import { Visibility, VisibilityOff } from '@mui/icons-material'
2
2
  import {
3
- Alert,
4
- Box,
5
- Button,
6
- IconButton,
7
- InputAdornment,
8
- Stack,
9
- styled,
3
+ Alert,
4
+ Box,
5
+ Button,
6
+ IconButton,
7
+ InputAdornment,
8
+ Stack,
9
+ styled,
10
10
  } from '@mui/material'
11
11
  import axiosBase from 'axios'
12
12
  import Cookies from 'js-cookie'
13
- import {useState} from 'react'
14
- import {useForm} from 'react-hook-form'
15
- import {FormTextField} from './HookForm'
13
+ import { useState } from 'react'
14
+ import { useForm } from 'react-hook-form'
15
+ import { FormTextField } from './HookForm'
16
16
 
17
17
  const developmentOrigin = window.location.origin + '/campx_dev'
18
18
 
19
- export const StyledTextField = styled(FormTextField)(({theme}) => ({
20
- '& .MuiInputBase-root': {
21
- minHeight: '60px',
22
- },
23
- '& .MuiOutlinedInput-input': {
24
- padding: '18.5px 14px',
25
- },
19
+ export const StyledTextField = styled(FormTextField)(({ theme }) => ({
20
+ '& .MuiInputBase-root': {
21
+ minHeight: '60px',
22
+ },
23
+ '& .MuiOutlinedInput-input': {
24
+ padding: '18.5px 14px',
25
+ },
26
26
  }))
27
27
 
28
- export const StyledButton = styled(Button)(({theme}) => ({
29
- borderRadius: '10px',
30
- height: '60px',
31
- fontSize: '18px',
28
+ export const StyledButton = styled(Button)(({ theme }) => ({
29
+ borderRadius: '10px',
30
+ height: '60px',
31
+ fontSize: '18px',
32
32
  }))
33
33
 
34
34
  export function LoginForm() {
35
- const [showPassword, setShowPassword] = useState(false)
36
- const {handleSubmit, control} = useForm()
37
- const [error, setError] = useState('')
35
+ const [showPassword, setShowPassword] = useState(false)
36
+ const { handleSubmit, control } = useForm()
37
+ const [error, setError] = useState('')
38
38
 
39
- const onSubmit = async (values) => {
40
- try {
41
- const res = await axiosBase({
42
- method: 'POST',
43
- url: 'https://auth-api.campx.dev/auth/login',
44
- data: values,
45
- })
46
- Cookies.set('campx_session_key', res.data.cookie)
47
- window.location.href = developmentOrigin
48
- } catch (err) {
49
- // eslint-disable-next-line no-console
50
- console.log(err)
51
- setError(err.response.data.message ?? 'Server Error')
52
- }
53
- }
39
+ const onSubmit = async (values) => {
40
+ try {
41
+ const res = await axiosBase({
42
+ method: 'POST',
43
+ url: 'https://auth-api.campx.dev/auth/login',
44
+ data: values,
45
+ })
46
+ Cookies.set('campx_session_key', res.data.cookie)
47
+ window.location.href = developmentOrigin
48
+ } catch (err) {
49
+ // eslint-disable-next-line no-console
50
+ console.log(err)
51
+ setError(err.response.data.message ?? 'Server Error')
52
+ }
53
+ }
54
54
 
55
- return (
56
- <Box sx={{maxWidth: '500px'}} margin='0 auto' padding={'0 1rem'}>
57
- <form onSubmit={handleSubmit(onSubmit)}>
58
- <Stack gap={'40px'}>
59
- <Box>
60
- <StyledTextField
61
- size='medium'
62
- control={control}
63
- name='username'
64
- label='User ID'
65
- required
66
- />
67
- </Box>
68
- <Box>
69
- <StyledTextField
70
- control={control}
71
- name='password'
72
- label='Password'
73
- type={showPassword ? 'text' : 'password'}
74
- required
75
- InputProps={{
76
- endAdornment: (
77
- <InputAdornment position='end'>
78
- <IconButton
79
- size='small'
80
- aria-label='toggle password visibility'
81
- onClick={() => setShowPassword((prev) => !prev)}
82
- edge='end'
83
- >
84
- {showPassword ? <VisibilityOff /> : <Visibility />}
85
- </IconButton>
86
- </InputAdornment>
87
- ),
88
- }}
89
- />
90
- </Box>
91
- <StyledButton type='submit'>Login</StyledButton>
92
- </Stack>
93
- </form>
94
- {error && (
95
- <Alert severity='error' sx={{marginTop: '20px'}}>
96
- {error}
97
- </Alert>
98
- )}
99
- </Box>
100
- )
55
+ return (
56
+ <Box sx={{ maxWidth: '500px' }} margin="0 auto" padding={'0 1rem'}>
57
+ <form onSubmit={handleSubmit(onSubmit)}>
58
+ <Stack gap={'40px'}>
59
+ <Box>
60
+ <StyledTextField
61
+ size="medium"
62
+ control={control}
63
+ name="username"
64
+ label="User ID"
65
+ required
66
+ />
67
+ </Box>
68
+ <Box>
69
+ <StyledTextField
70
+ control={control}
71
+ name="password"
72
+ label="Password"
73
+ type={showPassword ? 'text' : 'password'}
74
+ required
75
+ InputProps={{
76
+ endAdornment: (
77
+ <InputAdornment position="end">
78
+ <IconButton
79
+ size="small"
80
+ aria-label="toggle password visibility"
81
+ onClick={() => setShowPassword((prev) => !prev)}
82
+ edge="end"
83
+ >
84
+ {showPassword ? <VisibilityOff /> : <Visibility />}
85
+ </IconButton>
86
+ </InputAdornment>
87
+ ),
88
+ }}
89
+ />
90
+ </Box>
91
+ <StyledButton type="submit">Login</StyledButton>
92
+ </Stack>
93
+ </form>
94
+ {error && (
95
+ <Alert severity="error" sx={{ marginTop: '20px' }}>
96
+ {error}
97
+ </Alert>
98
+ )}
99
+ </Box>
100
+ )
101
101
  }
102
102
 
103
103
  export default LoginForm
@@ -1,103 +1,103 @@
1
1
  import {
2
- ListItemIcon,
3
- ListItemText,
4
- Menu,
5
- MenuItem,
6
- MenuListProps,
7
- MenuProps,
8
- styled,
2
+ ListItemIcon,
3
+ ListItemText,
4
+ Menu,
5
+ MenuItem,
6
+ MenuListProps,
7
+ MenuProps,
8
+ styled,
9
9
  } from '@mui/material'
10
- import {cloneElement, ReactNode, useState} from 'react'
10
+ import { cloneElement, ReactNode, useState } from 'react'
11
11
 
12
12
  interface Props {
13
- anchor: any
14
- loading?: boolean
15
- menu: {
16
- label: string | ReactNode
17
- icon?: ReactNode
18
- onClick: (props?: any) => any
19
- component?: ReactNode
20
- }[]
21
- menuProps?: Omit<MenuProps, 'open'>
22
- menuListProps?: MenuListProps
13
+ anchor: any
14
+ loading?: boolean
15
+ menu: {
16
+ label: string | ReactNode
17
+ icon?: ReactNode
18
+ onClick: (props?: any) => any
19
+ component?: ReactNode
20
+ }[]
21
+ menuProps?: Omit<MenuProps, 'open'>
22
+ menuListProps?: MenuListProps
23
23
  }
24
24
 
25
25
  export default function MenuButton({
26
- menu,
27
- menuProps,
28
- menuListProps,
29
- loading = false,
30
- anchor,
26
+ menu,
27
+ menuProps,
28
+ menuListProps,
29
+ loading = false,
30
+ anchor,
31
31
  }: Props) {
32
- const [anchorEl, setAnchorEl] = useState<any>(null)
33
- const open = Boolean(anchorEl)
32
+ const [anchorEl, setAnchorEl] = useState<any>(null)
33
+ const open = Boolean(anchorEl)
34
34
 
35
- const handleClick = (event) => {
36
- setAnchorEl(event.currentTarget)
37
- }
35
+ const handleClick = (event) => {
36
+ setAnchorEl(event.currentTarget)
37
+ }
38
38
 
39
- const handleClose = () => {
40
- setAnchorEl(null)
41
- }
39
+ const handleClose = () => {
40
+ setAnchorEl(null)
41
+ }
42
42
 
43
- const AnchorEl = cloneElement(anchor, {
44
- onClick: handleClick,
45
- })
43
+ const AnchorEl = cloneElement(anchor, {
44
+ onClick: handleClick,
45
+ })
46
46
 
47
- return (
48
- <>
49
- {AnchorEl}
50
- <Menu
51
- elevation={2}
52
- id='basic-menu'
53
- anchorEl={anchorEl}
54
- open={open}
55
- onClose={handleClose}
56
- MenuListProps={{
57
- sx: {padding: 0},
58
- ...menuListProps,
59
- }}
60
- anchorOrigin={{
61
- vertical: 'bottom',
62
- horizontal: 'right',
63
- }}
64
- transformOrigin={{
65
- vertical: 'top',
66
- horizontal: 'right',
67
- }}
68
- {...menuProps}
69
- >
70
- {menu.map((item, index) => (
71
- <StyledMenuItem
72
- sx={{minWidth: '120px', width: '100%'}}
73
- key={index}
74
- onClick={() => {
75
- handleClose()
76
- item.onClick()
77
- }}
78
- >
79
- {item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
80
- <ListItemText>{item.label}</ListItemText>
81
- </StyledMenuItem>
82
- ))}
83
- </Menu>
84
- </>
85
- )
47
+ return (
48
+ <>
49
+ {AnchorEl}
50
+ <Menu
51
+ elevation={2}
52
+ id="basic-menu"
53
+ anchorEl={anchorEl}
54
+ open={open}
55
+ onClose={handleClose}
56
+ MenuListProps={{
57
+ sx: { padding: 0 },
58
+ ...menuListProps,
59
+ }}
60
+ anchorOrigin={{
61
+ vertical: 'bottom',
62
+ horizontal: 'right',
63
+ }}
64
+ transformOrigin={{
65
+ vertical: 'top',
66
+ horizontal: 'right',
67
+ }}
68
+ {...menuProps}
69
+ >
70
+ {menu.map((item, index) => (
71
+ <StyledMenuItem
72
+ sx={{ minWidth: '120px', width: '100%' }}
73
+ key={index}
74
+ onClick={() => {
75
+ handleClose()
76
+ item.onClick()
77
+ }}
78
+ >
79
+ {item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
80
+ <ListItemText>{item.label}</ListItemText>
81
+ </StyledMenuItem>
82
+ ))}
83
+ </Menu>
84
+ </>
85
+ )
86
86
  }
87
87
 
88
- const StyledMenuItem = styled(MenuItem)(({theme}) => ({
89
- padding: '10px 20px',
90
- display: 'flex',
91
- alignItems: 'center',
92
- '& .MuiListItemIcon-root': {
93
- minWidth: '24px',
94
- },
95
- '& .MuiSvgIcon-root': {
96
- height: '18px',
97
- width: '18px',
98
- },
99
- '& .MuiTypography-root': {
100
- fontWeight: 600,
101
- },
102
- borderBottom: theme.borders.grayLight,
88
+ const StyledMenuItem = styled(MenuItem)(({ theme }) => ({
89
+ padding: '10px 20px',
90
+ display: 'flex',
91
+ alignItems: 'center',
92
+ '& .MuiListItemIcon-root': {
93
+ minWidth: '24px',
94
+ },
95
+ '& .MuiSvgIcon-root': {
96
+ height: '18px',
97
+ width: '18px',
98
+ },
99
+ '& .MuiTypography-root': {
100
+ fontWeight: 600,
101
+ },
102
+ borderBottom: theme.borders.grayLight,
103
103
  }))
@@ -1,85 +1,85 @@
1
- import {Close} from '@mui/icons-material'
1
+ import { Close } from '@mui/icons-material'
2
2
  import {
3
- alpha,
4
- Box,
5
- ButtonProps,
6
- Dialog,
7
- DialogProps,
8
- IconButton,
9
- styled,
10
- Typography,
3
+ alpha,
4
+ Box,
5
+ ButtonProps,
6
+ Dialog,
7
+ DialogProps,
8
+ IconButton,
9
+ styled,
10
+ Typography,
11
11
  } from '@mui/material'
12
- import {createElement, ReactNode, useState} from 'react'
12
+ import { createElement, ReactNode, useState } from 'react'
13
13
 
14
- const StyledDialogHeader = styled(Box)(({theme}) => ({
15
- height: '64px',
16
- backgroundColor: alpha(theme.palette.text.secondary, 0.1),
17
- display: 'flex',
18
- justifyContent: 'space-between',
19
- alignItems: 'center',
20
- padding: '0.6rem 1rem',
14
+ const StyledDialogHeader = styled(Box)(({ theme }) => ({
15
+ height: '64px',
16
+ backgroundColor: alpha(theme.palette.text.secondary, 0.1),
17
+ display: 'flex',
18
+ justifyContent: 'space-between',
19
+ alignItems: 'center',
20
+ padding: '0.6rem 1rem',
21
21
  }))
22
22
 
23
- const StyledDialogContent = styled(Box)(({theme}) => ({
24
- width: '100%',
25
- padding: '1rem',
23
+ const StyledDialogContent = styled(Box)(({ theme }) => ({
24
+ width: '100%',
25
+ padding: '1rem',
26
26
  }))
27
27
 
28
28
  type ContentProps = {
29
- close: () => void
29
+ close: () => void
30
30
  }
31
31
 
32
32
  interface DrawerButtonProps {
33
- button: any
34
- content: (props: ContentProps) => ReactNode
35
- title: string | ReactNode
36
- btnTxt?: string | ReactNode
37
- btnProps?: ButtonProps
38
- dialogProps?: Omit<DialogProps, 'open'>
33
+ button: any
34
+ content: (props: ContentProps) => ReactNode
35
+ title: string | ReactNode
36
+ btnTxt?: string | ReactNode
37
+ btnProps?: ButtonProps
38
+ dialogProps?: Omit<DialogProps, 'open'>
39
39
  }
40
40
 
41
41
  export default function DialogButton({
42
- button: Button,
43
- content,
44
- title,
45
- btnTxt,
46
- btnProps,
47
- dialogProps,
42
+ button: Button,
43
+ content,
44
+ title,
45
+ btnTxt,
46
+ btnProps,
47
+ dialogProps,
48
48
  }: DrawerButtonProps) {
49
- const [open, setOpen] = useState(false)
49
+ const [open, setOpen] = useState(false)
50
50
 
51
- const ButtonEl = (props) => (
52
- <Button {...props} {...btnProps}>
53
- {btnTxt}
54
- </Button>
55
- )
51
+ const ButtonEl = (props) => (
52
+ <Button {...props} {...btnProps}>
53
+ {btnTxt}
54
+ </Button>
55
+ )
56
56
 
57
- const MyButton = createElement(ButtonEl, {
58
- onClick: () => setOpen(true),
59
- })
57
+ const MyButton = createElement(ButtonEl, {
58
+ onClick: () => setOpen(true),
59
+ })
60
60
 
61
- const onClose = () => {
62
- setOpen(false)
63
- }
64
- return (
65
- <>
66
- {MyButton}
67
- <Dialog
68
- PaperProps={{sx: {borderRadius: '10px'}}}
69
- fullWidth
70
- onClose={onClose}
71
- open={open}
72
- transitionDuration={200}
73
- {...dialogProps}
74
- >
75
- <StyledDialogHeader>
76
- <Typography fontWeight={600}>{title}</Typography>
77
- <IconButton onClick={onClose}>
78
- <Close />
79
- </IconButton>
80
- </StyledDialogHeader>
81
- <StyledDialogContent>{content({close: onClose})}</StyledDialogContent>
82
- </Dialog>
83
- </>
84
- )
61
+ const onClose = () => {
62
+ setOpen(false)
63
+ }
64
+ return (
65
+ <>
66
+ {MyButton}
67
+ <Dialog
68
+ PaperProps={{ sx: { borderRadius: '10px' } }}
69
+ fullWidth
70
+ onClose={onClose}
71
+ open={open}
72
+ transitionDuration={200}
73
+ {...dialogProps}
74
+ >
75
+ <StyledDialogHeader>
76
+ <Typography fontWeight={600}>{title}</Typography>
77
+ <IconButton onClick={onClose}>
78
+ <Close />
79
+ </IconButton>
80
+ </StyledDialogHeader>
81
+ <StyledDialogContent>{content({ close: onClose })}</StyledDialogContent>
82
+ </Dialog>
83
+ </>
84
+ )
85
85
  }
@@ -1,17 +1,17 @@
1
- import {Box, styled} from '@mui/material'
1
+ import { Box, styled } from '@mui/material'
2
2
  import ErrorBoundary from './ErrorBoundary'
3
3
 
4
4
  const StyledPageContent = styled(Box)(() => ({
5
- paddingLeft: '25px',
6
- paddingRight: '25px',
7
- marginTop: '16px',
8
- paddingBottom: '3rem',
5
+ paddingLeft: '25px',
6
+ paddingRight: '25px',
7
+ marginTop: '16px',
8
+ paddingBottom: '3rem',
9
9
  }))
10
10
 
11
11
  export function PageContent(props) {
12
- return (
13
- <StyledPageContent style={props.style}>
14
- <ErrorBoundary>{props.children}</ErrorBoundary>
15
- </StyledPageContent>
16
- )
12
+ return (
13
+ <StyledPageContent style={props.style}>
14
+ <ErrorBoundary>{props.children}</ErrorBoundary>
15
+ </StyledPageContent>
16
+ )
17
17
  }
@@ -1,26 +1,26 @@
1
- import { Box, Button, Typography } from "@mui/material";
2
- import axios from "axios";
3
- import React, { useEffect, useState } from "react";
4
- import { pagenotfound } from "../assets/images";
1
+ import { Box, Button, Typography } from '@mui/material'
2
+ import axios from 'axios'
3
+ import React, { useEffect, useState } from 'react'
4
+ import { pagenotfound } from '../assets/images'
5
5
 
6
6
  function PageNotFound() {
7
7
  return (
8
8
  <>
9
9
  <Box
10
10
  sx={{
11
- width: "100%",
12
- display: "flex",
13
- flexDirection: "column",
14
- alignItems: "center",
15
- justifyContent: "center",
16
- marginTop: "50px",
11
+ width: '100%',
12
+ display: 'flex',
13
+ flexDirection: 'column',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ marginTop: '50px',
17
17
  }}
18
18
  >
19
19
  <img src={pagenotfound} alt="page not found" width={470} />
20
20
  <Typography variant="h1">Page Not Found.</Typography>
21
21
  </Box>
22
22
  </>
23
- );
23
+ )
24
24
  }
25
25
 
26
- export default PageNotFound;
26
+ export default PageNotFound