@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
package/.eslintignore ADDED
@@ -0,0 +1,4 @@
1
+ # .estlintignore file
2
+ dist
3
+ build
4
+ node_modules/
package/.eslintrc.js ADDED
@@ -0,0 +1,34 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ jest: true,
6
+ },
7
+ parser: '@typescript-eslint/parser',
8
+ extends: ['prettier'],
9
+ overrides: [],
10
+ parserOptions: {
11
+ ecmaVersion: 'latest',
12
+ sourceType: 'module',
13
+ ecmaFeatures: {
14
+ jsx: true,
15
+ },
16
+ },
17
+ settings: {
18
+ 'import/resolver': {
19
+ typescript: {},
20
+ },
21
+ },
22
+ plugins: ['react', '@typescript-eslint', 'prettier'],
23
+ rules: {
24
+ 'react/react-in-jsx-scope': 'off',
25
+ 'spaced-comment': 'error',
26
+ 'no-duplicate-imports': 'error',
27
+ 'no-console': 'warn',
28
+ 'react/prop-types': ['off'],
29
+ 'react/jsx-key': ['warn'],
30
+ 'react/no-unescaped-entities': 'off',
31
+ 'spaced-comment': 'off',
32
+ },
33
+ ignorePatterns: ['**/*.html'],
34
+ }
package/.prettierrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "bracketSpacing": true,
3
+ "printWidth": 80,
4
+ "singleQuote": true,
5
+ "trailingComma": "all",
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "bracketSameLine": false,
9
+ "semi": false
10
+ }
package/exports.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  export * from './src/components'
2
2
  export * from './src/constants'
3
- export {default as axios, axiosErrorToast} from './src/config/axios'
3
+ export { default as axios, axiosErrorToast } from './src/config/axios'
4
+ export { default as axiosTenant } from './src/config/axiosXTenant'
4
5
 
5
6
  export * from './src/permissions'
6
7
  export * from './src/utils'
7
8
  export * from './src/hooks'
8
- export {useModal} from './src/components/DrawerWrapper/DrawerWrapper'
9
- export {default as MuiThemeProvider} from './src/theme/MuiThemeProvider'
10
- export {default as ConfirmContextProvider} from './src/components/PopupConfirm/ConfirmContextProvider'
11
- export {default as DialogProvider} from './src/components/DrawerWrapper/DrawerWrapper'
12
- export {default as Providers} from './src/contexts/Providers'
9
+ export { useModal } from './src/components/DrawerWrapper/DrawerWrapper'
10
+ export { default as MuiThemeProvider } from './src/theme/MuiThemeProvider'
11
+ export { default as ConfirmContextProvider } from './src/components/PopupConfirm/ConfirmContextProvider'
12
+ export { default as DialogProvider } from './src/components/DrawerWrapper/DrawerWrapper'
13
+ export { default as Providers } from './src/contexts/Providers'
13
14
 
14
15
  export * from './src/shared-state'
15
16
  export * from './src/assets/images'
package/package.json CHANGED
@@ -1,52 +1,66 @@
1
1
  {
2
- "name": "@campxdev/shared",
3
- "version": "0.5.21",
4
- "main": "./exports.ts",
5
- "scripts": {
6
- "start": "react-scripts start",
7
- "build": "CI=false && react-scripts build",
8
- "test": "react-scripts test",
9
- "eject": "react-scripts eject"
10
- },
11
- "browserslist": {
12
- "production": [
13
- ">0.2%",
14
- "not dead",
15
- "not op_mini all"
16
- ],
17
- "development": [
18
- "last 1 chrome version",
19
- "last 1 firefox version",
20
- "last 1 safari version"
21
- ]
22
- },
23
- "dependencies": {
24
- "@emotion/react": "^11.9.0",
25
- "@emotion/styled": "^11.8.1",
26
- "@mui/icons-material": "^5.6.2",
27
- "@mui/material": "^5.7.0",
28
- "@mui/x-date-pickers": "^5.0.0-alpha.3",
29
- "@types/js-cookie": "^3.0.2",
30
- "@types/node": "^18.11.8",
31
- "axios": "^0.27.2",
32
- "date-fns": "^2.28.0",
33
- "js-cookie": "^3.0.1",
34
- "moment": "^2.29.4",
35
- "pullstate": "^1.24.0",
36
- "react": "^18.2.0",
37
- "react-dom": "^18.2.0",
38
- "react-error-boundary": "^3.1.4",
39
- "react-hook-form": "^7.31.1",
40
- "react-query": "^3.39.0",
41
- "react-router-dom": "^6.4.2",
42
- "react-table": "^7.8.0",
43
- "react-toastify": "^9.0.1",
44
- "styled-components": "^5.3.5",
45
- "swiper": "^8.1.5",
46
- "typescript": "^4.8.4"
47
- },
48
- "devDependencies": {
49
- "@types/react": "^18.0.25",
50
- "react-scripts": "^5.0.1"
51
- }
2
+ "name": "@campxdev/shared",
3
+ "version": "0.5.22",
4
+ "main": "./exports.ts",
5
+ "scripts": {
6
+ "start": "react-scripts start",
7
+ "build": "CI=false && react-scripts build",
8
+ "test": "react-scripts test",
9
+ "eject": "react-scripts eject",
10
+ "lint": "eslint ./src/**/*.{js,jsx,ts,tsx,json}",
11
+ "lint:fix": "eslint --fix \"./src/**/*.{js,jsx,ts,tsx,json}\"",
12
+ "format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,css,md,json}\" --config ./.prettierrc",
13
+ "publish": "./publish.sh"
14
+ },
15
+ "browserslist": {
16
+ "production": [
17
+ ">0.2%",
18
+ "not dead",
19
+ "not op_mini all"
20
+ ],
21
+ "development": [
22
+ "last 1 chrome version",
23
+ "last 1 firefox version",
24
+ "last 1 safari version"
25
+ ]
26
+ },
27
+ "dependencies": {
28
+ "@emotion/react": "^11.9.0",
29
+ "@emotion/styled": "^11.8.1",
30
+ "@mui/icons-material": "^5.6.2",
31
+ "@mui/material": "^5.7.0",
32
+ "@mui/x-date-pickers": "^5.0.0-alpha.3",
33
+ "axios": "^0.27.2",
34
+ "date-fns": "^2.28.0",
35
+ "js-cookie": "^3.0.1",
36
+ "moment": "^2.29.4",
37
+ "pullstate": "^1.24.0",
38
+ "react": "^18.2.0",
39
+ "react-dom": "^18.2.0",
40
+ "react-error-boundary": "^3.1.4",
41
+ "react-hook-form": "^7.31.1",
42
+ "react-query": "^3.39.0",
43
+ "react-router-dom": "^6.4.2",
44
+ "react-table": "^7.8.0",
45
+ "react-toastify": "^9.0.1",
46
+ "styled-components": "^5.3.5",
47
+ "swiper": "^8.1.5"
48
+ },
49
+ "devDependencies": {
50
+ "@types/js-cookie": "^3.0.2",
51
+ "@types/node": "^18.11.8",
52
+ "typescript": "^4.8.4",
53
+ "@types/react": "^18.0.25",
54
+ "react-scripts": "^5.0.1",
55
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
56
+ "@typescript-eslint/parser": "^5.35.1",
57
+ "eslint": "^8.23.0",
58
+ "eslint-config-prettier": "^8.5.0",
59
+ "eslint-import-resolver-typescript": "^3.5.0",
60
+ "eslint-plugin-import": "^2.26.0",
61
+ "eslint-plugin-prettier": "^4.2.1",
62
+ "eslint-plugin-react": "^7.31.1",
63
+ "lerna": "^5.5.1",
64
+ "prettier": "^2.5.0"
65
+ }
52
66
  }
package/publish.sh ADDED
@@ -0,0 +1,2 @@
1
+ npm version patch
2
+ npm publish --verbose --production
@@ -1,10 +1,10 @@
1
- const avatarImage = require("./avatar.png");
2
- const pagenotfound = require("./notfound.png");
3
- const permissiondenied = require("./403.png");
4
- const internalserver = require("./500.png");
5
- const unauth = require("./401.png");
6
- const nointernet = require("./nointernet.png");
7
- const campxLogoPrimary = require("./campx_logo__full_primary.png");
1
+ const avatarImage = require('./avatar.png')
2
+ const pagenotfound = require('./notfound.png')
3
+ const permissiondenied = require('./403.png')
4
+ const internalserver = require('./500.png')
5
+ const unauth = require('./401.png')
6
+ const nointernet = require('./nointernet.png')
7
+ const campxLogoPrimary = require('./campx_logo__full_primary.png')
8
8
 
9
9
  export {
10
10
  avatarImage,
@@ -14,4 +14,4 @@ export {
14
14
  internalserver,
15
15
  unauth,
16
16
  nointernet,
17
- };
17
+ }
@@ -50,7 +50,7 @@ export default function Breadcrumbs({ links, icon }: BreadcrumbsProps) {
50
50
  const backLink = links.slice(-2)[0]
51
51
 
52
52
  return (
53
- <StyledStack direction={'row'} alignItems='center'>
53
+ <StyledStack direction={'row'} alignItems="center">
54
54
  {linksArray?.length ? (
55
55
  <StyledIconButton
56
56
  onClick={() => {
@@ -60,13 +60,13 @@ export default function Breadcrumbs({ links, icon }: BreadcrumbsProps) {
60
60
  {icon ? icon : <ChevronLeft />}
61
61
  </StyledIconButton>
62
62
  ) : null}
63
- <MuiBreadcrumbs separator={<Typography variant='h3'>/</Typography>}>
63
+ <MuiBreadcrumbs separator={<Typography variant="h3">/</Typography>}>
64
64
  {linksArray.map((link, index) => (
65
65
  <StyledLink to={link.to} key={index}>
66
66
  {link?.name}
67
67
  </StyledLink>
68
68
  ))}
69
- <Typography variant='h3'>{currentPage?.name}</Typography>
69
+ <Typography variant="h3">{currentPage?.name}</Typography>
70
70
  </MuiBreadcrumbs>
71
71
  </StyledStack>
72
72
  )
@@ -1,164 +1,164 @@
1
1
  import {
2
- Button,
3
- CircularProgress,
4
- Dialog,
5
- DialogTitle,
6
- IconButton,
7
- InputAdornment,
8
- Stack,
9
- styled,
10
- Typography,
2
+ Button,
3
+ CircularProgress,
4
+ Dialog,
5
+ DialogTitle,
6
+ IconButton,
7
+ InputAdornment,
8
+ Stack,
9
+ styled,
10
+ Typography,
11
11
  } from '@mui/material'
12
- import {isDevelopment} from '../constants/isDevelopment'
12
+ import { isDevelopment } from '../constants/isDevelopment'
13
13
  import CloseIcon from '@mui/icons-material/Close'
14
- import {Visibility, VisibilityOff} from '@mui/icons-material'
15
- import React, {useState} from 'react'
16
- import {useForm} from 'react-hook-form'
17
- import {useModal} from './DrawerWrapper/DrawerWrapper'
18
- import {FormTextField} from '.'
19
- import axios, {axiosErrorToast} from '../config/axios'
20
- import {toast} from 'react-toastify'
14
+ import { Visibility, VisibilityOff } from '@mui/icons-material'
15
+ import React, { useState } from 'react'
16
+ import { useForm } from 'react-hook-form'
17
+ import { useModal } from './DrawerWrapper/DrawerWrapper'
18
+ import { FormTextField } from '.'
19
+ import axios, { axiosErrorToast } from '../config/axios'
20
+ import { toast } from 'react-toastify'
21
21
 
22
22
  export interface DialogProps {
23
- open: boolean
24
- onClose: any
23
+ open: boolean
24
+ onClose: any
25
25
  }
26
26
 
27
27
  function ChangePassword(props: DialogProps) {
28
- const {onClose, open} = props
29
- const handleClose = () => {
30
- onClose()
31
- }
32
- const modal = useModal()
28
+ const { onClose, open } = props
29
+ const handleClose = () => {
30
+ onClose()
31
+ }
32
+ const modal = useModal()
33
33
 
34
- const [showPassword, setShowPassword] = useState({
35
- oldPassword: false,
36
- newPassword: false,
37
- confirmPassword: false,
38
- })
39
- const [isLoading, setIsLoading] = useState(false)
40
- const {handleSubmit, control, reset} = useForm()
41
- const onSubmit = async (formData) => {
42
- setIsLoading(true)
43
- const {oldPassword, newPassword, confirmPassword} = formData
44
- if (newPassword === confirmPassword) {
45
- try {
46
- await axios.post(
47
- isDevelopment
48
- ? 'https://auth-api.campx.dev/auth/change-password'
49
- : 'https://auth-api.campx.in/auth/change-password',
50
- {
51
- oldPassword,
52
- newPassword,
53
- }
54
- )
55
- toast.success('Password Changed Successfully')
56
- setIsLoading(false)
57
- reset()
58
- handleClose()
59
- } catch (error) {
60
- axiosErrorToast(error)
61
- setIsLoading(false)
62
- reset()
63
- handleClose()
64
- }
65
- } else {
66
- toast.error('New Password, Confirm Password must be same')
67
- setIsLoading(false)
68
- }
69
- }
34
+ const [showPassword, setShowPassword] = useState({
35
+ oldPassword: false,
36
+ newPassword: false,
37
+ confirmPassword: false,
38
+ })
39
+ const [isLoading, setIsLoading] = useState(false)
40
+ const { handleSubmit, control, reset } = useForm()
41
+ const onSubmit = async (formData) => {
42
+ setIsLoading(true)
43
+ const { oldPassword, newPassword, confirmPassword } = formData
44
+ if (newPassword === confirmPassword) {
45
+ try {
46
+ await axios.post(
47
+ isDevelopment
48
+ ? 'https://auth-api.campx.dev/auth/change-password'
49
+ : 'https://auth-api.campx.in/auth/change-password',
50
+ {
51
+ oldPassword,
52
+ newPassword,
53
+ },
54
+ )
55
+ toast.success('Password Changed Successfully')
56
+ setIsLoading(false)
57
+ reset()
58
+ handleClose()
59
+ } catch (error) {
60
+ axiosErrorToast(error)
61
+ setIsLoading(false)
62
+ reset()
63
+ handleClose()
64
+ }
65
+ } else {
66
+ toast.error('New Password, Confirm Password must be same')
67
+ setIsLoading(false)
68
+ }
69
+ }
70
70
 
71
- const fields = [
72
- {label: 'Old Password', name: 'oldPassword'},
73
- {label: 'New Password', name: 'newPassword'},
74
- {label: 'Confirm Password', name: 'confirmPassword'},
75
- ]
71
+ const fields = [
72
+ { label: 'Old Password', name: 'oldPassword' },
73
+ { label: 'New Password', name: 'newPassword' },
74
+ { label: 'Confirm Password', name: 'confirmPassword' },
75
+ ]
76
76
 
77
- return (
78
- <Dialog
79
- open={open}
80
- PaperProps={{
81
- sx: {
82
- borderRadius: '20px',
83
- width: '500px',
84
- padding: '20px',
85
- },
86
- }}
87
- >
88
- <StyledDialogTitle>
89
- <Typography variant='h3'>Change Password</Typography>
90
- <IconButton onClick={handleClose}>
91
- <CloseIcon />
92
- </IconButton>
93
- </StyledDialogTitle>
94
- <form onSubmit={handleSubmit(onSubmit)}>
95
- <Stack gap={2} direction='column'>
96
- {fields.map((item) => {
97
- return (
98
- <>
99
- <FormTextField
100
- label={item.label}
101
- control={control}
102
- name={item.name}
103
- type={showPassword[item.name] ? 'text' : 'password'}
104
- required
105
- InputProps={{
106
- endAdornment: (
107
- <InputAdornment position='end'>
108
- <IconButton
109
- size='small'
110
- onClick={() =>
111
- setShowPassword((prev) => ({
112
- ...prev,
113
- [item.name]: !prev[item.name],
114
- }))
115
- }
116
- edge='end'
117
- >
118
- {showPassword[item.name] ? (
119
- <VisibilityOff />
120
- ) : (
121
- <Visibility />
122
- )}
123
- </IconButton>
124
- </InputAdornment>
125
- ),
126
- }}
127
- />
128
- </>
129
- )
130
- })}
77
+ return (
78
+ <Dialog
79
+ open={open}
80
+ PaperProps={{
81
+ sx: {
82
+ borderRadius: '20px',
83
+ width: '500px',
84
+ padding: '20px',
85
+ },
86
+ }}
87
+ >
88
+ <StyledDialogTitle>
89
+ <Typography variant="h3">Change Password</Typography>
90
+ <IconButton onClick={handleClose}>
91
+ <CloseIcon />
92
+ </IconButton>
93
+ </StyledDialogTitle>
94
+ <form onSubmit={handleSubmit(onSubmit)}>
95
+ <Stack gap={2} direction="column">
96
+ {fields.map((item) => {
97
+ return (
98
+ <>
99
+ <FormTextField
100
+ label={item.label}
101
+ control={control}
102
+ name={item.name}
103
+ type={showPassword[item.name] ? 'text' : 'password'}
104
+ required
105
+ InputProps={{
106
+ endAdornment: (
107
+ <InputAdornment position="end">
108
+ <IconButton
109
+ size="small"
110
+ onClick={() =>
111
+ setShowPassword((prev) => ({
112
+ ...prev,
113
+ [item.name]: !prev[item.name],
114
+ }))
115
+ }
116
+ edge="end"
117
+ >
118
+ {showPassword[item.name] ? (
119
+ <VisibilityOff />
120
+ ) : (
121
+ <Visibility />
122
+ )}
123
+ </IconButton>
124
+ </InputAdornment>
125
+ ),
126
+ }}
127
+ />
128
+ </>
129
+ )
130
+ })}
131
131
 
132
- <Stack direction={'row'} gap={2} sx={{marginTop: '20px'}}>
133
- <Button variant='outlined' onClick={handleClose}>
134
- Cancel
135
- </Button>
136
- <Button
137
- type='submit'
138
- endIcon={
139
- isLoading && (
140
- <CircularProgress
141
- style={{color: 'white'}}
142
- size='30px'
143
- thickness={1.7}
144
- />
145
- )
146
- }
147
- >
148
- Submit
149
- </Button>
150
- </Stack>
151
- </Stack>
152
- </form>
153
- </Dialog>
154
- )
132
+ <Stack direction={'row'} gap={2} sx={{ marginTop: '20px' }}>
133
+ <Button variant="outlined" onClick={handleClose}>
134
+ Cancel
135
+ </Button>
136
+ <Button
137
+ type="submit"
138
+ endIcon={
139
+ isLoading && (
140
+ <CircularProgress
141
+ style={{ color: 'white' }}
142
+ size="30px"
143
+ thickness={1.7}
144
+ />
145
+ )
146
+ }
147
+ >
148
+ Submit
149
+ </Button>
150
+ </Stack>
151
+ </Stack>
152
+ </form>
153
+ </Dialog>
154
+ )
155
155
  }
156
156
 
157
157
  const StyledDialogTitle = styled(DialogTitle)({
158
- display: 'flex',
159
- alignItems: 'center',
160
- justifyContent: 'space-between',
161
- padding: '10px',
162
- marginBottom: '20px',
158
+ display: 'flex',
159
+ alignItems: 'center',
160
+ justifyContent: 'space-between',
161
+ padding: '10px',
162
+ marginBottom: '20px',
163
163
  })
164
164
  export default ChangePassword