@campxdev/shared 1.11.21-alpha.0 → 1.11.21
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.
- package/.vscode/settings.json +1 -1
- package/package.json +2 -2
- package/src/assets/images/index.ts +1 -3
- package/src/components/ApplicationProfile/ApplicationProfile.tsx +0 -1
- package/src/components/ErrorModalWrapper/ErrorModalTemplate.tsx +55 -10
- package/src/components/ErrorModalWrapper/ErrorModalWrapper.tsx +20 -2
- package/src/components/FilterComponents/SearchBar.tsx +2 -5
- package/src/components/Layout/Header/AppHeader.tsx +0 -2
- package/src/components/Layout/Header/applications.ts +0 -13
- package/src/components/Tables/BasicTable/Table.tsx +13 -16
- package/src/constants/UIConstants.ts +1 -5
- package/src/permissions/PermissionsStore.ts +55 -657
- package/src/shared-state/PermissionsStore.ts +80 -656
- package/src/assets/images/X.png +0 -0
package/.vscode/settings.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@campxdev/shared",
|
|
3
|
-
"version": "1.11.21
|
|
3
|
+
"version": "1.11.21",
|
|
4
4
|
"main": "./exports.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "react-scripts start",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"axios": "^0.27.2",
|
|
39
39
|
"date-fns": "^2.28.0",
|
|
40
40
|
"date-fns-tz": "^2.0.0",
|
|
41
|
-
"device-detector-js": "^3.0.3",
|
|
42
41
|
"fuse.js": "^6.6.2",
|
|
43
42
|
"js-cookie": "^3.0.1",
|
|
43
|
+
"device-detector-js": "^3.0.3",
|
|
44
44
|
"moment": "^2.29.4",
|
|
45
45
|
"pullstate": "^1.24.0",
|
|
46
46
|
"react": "^18.2.0",
|
|
@@ -5,7 +5,6 @@ const internalserver = require('./500.png')
|
|
|
5
5
|
const unauth = require('./401.png')
|
|
6
6
|
const nointernet = require('./nointernet.png')
|
|
7
7
|
const campxLogoPrimary = require('./campx_logo__full_primary.png')
|
|
8
|
-
const campxLogoSquare = require('./X.png')
|
|
9
8
|
const animatedImage = require('./animation.gif')
|
|
10
9
|
const activeDevices = require('./active_devices.svg')
|
|
11
10
|
const changePassword = require('./change_password.svg')
|
|
@@ -23,8 +22,6 @@ export {
|
|
|
23
22
|
animatedImage,
|
|
24
23
|
avatarImage,
|
|
25
24
|
campxLogoPrimary,
|
|
26
|
-
campxLogoSquare,
|
|
27
|
-
careers,
|
|
28
25
|
changePassword,
|
|
29
26
|
clogWheel,
|
|
30
27
|
internalserver,
|
|
@@ -39,4 +36,5 @@ export {
|
|
|
39
36
|
profile,
|
|
40
37
|
unauth,
|
|
41
38
|
web,
|
|
39
|
+
careers,
|
|
42
40
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Alert,
|
|
3
|
+
Box,
|
|
4
|
+
Button,
|
|
5
|
+
Modal,
|
|
6
|
+
Stack,
|
|
7
|
+
styled,
|
|
8
|
+
Typography,
|
|
9
|
+
} from '@mui/material'
|
|
2
10
|
import { animatedImage } from '../../assets/images'
|
|
3
11
|
|
|
4
12
|
const style = {
|
|
@@ -13,7 +21,7 @@ const style = {
|
|
|
13
21
|
display: 'flex',
|
|
14
22
|
gap: '15px',
|
|
15
23
|
flexDirection: 'column',
|
|
16
|
-
padding: '
|
|
24
|
+
padding: '35px',
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
const StyledImage = styled(Box)(({ theme }) => ({
|
|
@@ -27,8 +35,7 @@ const StyledImage = styled(Box)(({ theme }) => ({
|
|
|
27
35
|
}))
|
|
28
36
|
|
|
29
37
|
const MessageContainer = styled(Box)(({ theme }) => ({
|
|
30
|
-
maxHeight: '
|
|
31
|
-
padding: '15px',
|
|
38
|
+
maxHeight: '40vh',
|
|
32
39
|
overflowY: 'auto',
|
|
33
40
|
'&::-webkit-scrollbar': {
|
|
34
41
|
width: '0.5em',
|
|
@@ -43,6 +50,31 @@ const MessageContainer = styled(Box)(({ theme }) => ({
|
|
|
43
50
|
},
|
|
44
51
|
}))
|
|
45
52
|
|
|
53
|
+
export const StyledTableContainer = styled(Box)({
|
|
54
|
+
background: 'white',
|
|
55
|
+
borderRadius: '16px',
|
|
56
|
+
marginTop: '10px',
|
|
57
|
+
'& table thead tr': {
|
|
58
|
+
backgroundColor: '#efefef',
|
|
59
|
+
},
|
|
60
|
+
'& table tr th': {
|
|
61
|
+
border: '1px solid #bebebe',
|
|
62
|
+
padding: '2px 8px',
|
|
63
|
+
textAlign: 'center',
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
'& table td': {
|
|
67
|
+
border: '1px solid #bebebe',
|
|
68
|
+
padding: '5px 10px',
|
|
69
|
+
fontWeight: 900,
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
'& table': {
|
|
73
|
+
width: ' 100%',
|
|
74
|
+
borderCollapse: 'collapse',
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
|
|
46
78
|
export const ErrorModalTemplate = ({ handleClose, modal, setModal }) => {
|
|
47
79
|
return (
|
|
48
80
|
<Modal open={modal.open} onClose={handleClose}>
|
|
@@ -50,14 +82,27 @@ export const ErrorModalTemplate = ({ handleClose, modal, setModal }) => {
|
|
|
50
82
|
<StyledImage>
|
|
51
83
|
<img src={animatedImage} alt="Error Image" />
|
|
52
84
|
</StyledImage>
|
|
53
|
-
{
|
|
85
|
+
<Alert severity={'error'} sx={{ padding: '10px' }}>
|
|
86
|
+
Please resolve the below mentioned errors to proceed further
|
|
87
|
+
</Alert>
|
|
54
88
|
<MessageContainer>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
89
|
+
{modal.type == 'String' ? (
|
|
90
|
+
<Typography
|
|
91
|
+
variant="h6"
|
|
92
|
+
sx={{ textAlign: 'center', lineHeight: 1.7 }}
|
|
93
|
+
dangerouslySetInnerHTML={{ __html: modal?.errorMessage }}
|
|
94
|
+
/>
|
|
95
|
+
) : (
|
|
96
|
+
<>
|
|
97
|
+
<Stack gap={2}>
|
|
98
|
+
<StyledTableContainer
|
|
99
|
+
dangerouslySetInnerHTML={{ __html: modal?.errorMessage }}
|
|
100
|
+
/>
|
|
101
|
+
</Stack>
|
|
102
|
+
</>
|
|
103
|
+
)}
|
|
60
104
|
</MessageContainer>
|
|
105
|
+
|
|
61
106
|
{modal.content && modal.content({ close: handleClose })}
|
|
62
107
|
<Button
|
|
63
108
|
variant="outlined"
|
|
@@ -16,6 +16,7 @@ export default function ErrorModalProvider({ children }) {
|
|
|
16
16
|
open: false,
|
|
17
17
|
content: ({ close }) => null,
|
|
18
18
|
errorMessage: null,
|
|
19
|
+
type: 'String',
|
|
19
20
|
})
|
|
20
21
|
|
|
21
22
|
const handleClose = () => {
|
|
@@ -25,17 +26,34 @@ export default function ErrorModalProvider({ children }) {
|
|
|
25
26
|
})
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
const convertMessageToTable = (message) => {
|
|
30
|
+
const tableRows = message.map((element, index) => {
|
|
31
|
+
return `<tr><td>${index + 1}</td><td>${element}</td></tr>`
|
|
32
|
+
})
|
|
33
|
+
return `<table>
|
|
34
|
+
<thead>
|
|
35
|
+
<tr><th>S No.</th><th>Message</th></tr>
|
|
36
|
+
</thead>
|
|
37
|
+
<tbody>
|
|
38
|
+
${tableRows.join('')}</tbody></table>`
|
|
39
|
+
}
|
|
40
|
+
|
|
28
41
|
const showModal = (props) => {
|
|
29
42
|
const fallbackMessage = props.fallBack ?? 'Something went wrong.'
|
|
43
|
+
const type =
|
|
44
|
+
typeof props.error?.response?.data?.message !== 'string'
|
|
45
|
+
? 'Object'
|
|
46
|
+
: 'String'
|
|
30
47
|
const errorMessage =
|
|
31
48
|
typeof props.error?.response?.data?.message !== 'string'
|
|
32
|
-
? props.error?.response?.data?.message
|
|
49
|
+
? convertMessageToTable(props.error?.response?.data?.message) ??
|
|
33
50
|
fallbackMessage
|
|
34
|
-
: props.error?.response?.data?.message
|
|
51
|
+
: props.error?.response?.data?.message
|
|
35
52
|
|
|
36
53
|
setModal({
|
|
37
54
|
...modal,
|
|
38
55
|
open: true,
|
|
56
|
+
type: type,
|
|
39
57
|
content: props.content,
|
|
40
58
|
errorMessage: errorMessage,
|
|
41
59
|
})
|
|
@@ -8,19 +8,17 @@ import { ITextFieldProps } from '../Input/TextField'
|
|
|
8
8
|
interface SearchBarProps {
|
|
9
9
|
onSearch: (v: string) => void
|
|
10
10
|
label?: ReactNode
|
|
11
|
-
placeholder?: string
|
|
12
|
-
value?: string
|
|
13
11
|
textFieldProps?: ITextFieldProps
|
|
12
|
+
placeholder?: string
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export default function SearchBar({
|
|
17
16
|
onSearch,
|
|
18
17
|
label,
|
|
19
18
|
placeholder = 'Search',
|
|
20
|
-
value,
|
|
21
19
|
...restProps
|
|
22
20
|
}: SearchBarProps) {
|
|
23
|
-
const [, setSearch] = useState(
|
|
21
|
+
const [, setSearch] = useState('')
|
|
24
22
|
|
|
25
23
|
const debouncedChangeHandler = useMemo(
|
|
26
24
|
() =>
|
|
@@ -36,7 +34,6 @@ export default function SearchBar({
|
|
|
36
34
|
label={label}
|
|
37
35
|
placeholder={placeholder}
|
|
38
36
|
onChange={debouncedChangeHandler}
|
|
39
|
-
defaultValue={value || ''}
|
|
40
37
|
InputProps={{
|
|
41
38
|
endAdornment: (
|
|
42
39
|
<InputAdornment position="end">
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
peoplex,
|
|
14
14
|
} from './assets'
|
|
15
15
|
|
|
16
|
-
import { campxLogoPrimary } from '../../../assets/images'
|
|
17
16
|
import HeaderActions from './HeaderActions/HeaderActions'
|
|
18
17
|
import {
|
|
19
18
|
StyledHeader,
|
|
@@ -31,7 +30,6 @@ const imageMap = {
|
|
|
31
30
|
campx: collegex,
|
|
32
31
|
commute: commutex,
|
|
33
32
|
hostel: hostelx,
|
|
34
|
-
admin: campxLogoPrimary,
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
interface AppHeaderProps {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { campxLogoSquare } from '../../../assets/images'
|
|
2
1
|
import { isDevelopment } from '../../../constants'
|
|
3
2
|
import {
|
|
4
3
|
campxSquareSmall,
|
|
@@ -11,10 +10,6 @@ import {
|
|
|
11
10
|
} from './assets'
|
|
12
11
|
|
|
13
12
|
const origins = {
|
|
14
|
-
admin: {
|
|
15
|
-
dev: 'https://admin.campx.dev',
|
|
16
|
-
prod: 'https://admin.campx.in',
|
|
17
|
-
},
|
|
18
13
|
ums: {
|
|
19
14
|
dev: 'https://ums.campx.dev',
|
|
20
15
|
prod: 'https://ums.campx.in',
|
|
@@ -46,14 +41,6 @@ const origins = {
|
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
export const applications = [
|
|
49
|
-
{
|
|
50
|
-
title: 'Admin',
|
|
51
|
-
path: isDevelopment ? origins.admin.dev : origins.admin.prod,
|
|
52
|
-
icon: campxLogoSquare,
|
|
53
|
-
key: 'admin',
|
|
54
|
-
domainName: 'admin',
|
|
55
|
-
description: 'Manage Complete Campus Root Configuration',
|
|
56
|
-
},
|
|
57
44
|
{
|
|
58
45
|
title: 'CollegeX',
|
|
59
46
|
path: isDevelopment ? origins.ums.dev : origins.ums.prod,
|
|
@@ -23,23 +23,21 @@ import {
|
|
|
23
23
|
type Order = 'asc' | 'desc' | ''
|
|
24
24
|
type Sort = {}
|
|
25
25
|
type DataType = 'currency' | 'string' | 'number'
|
|
26
|
-
|
|
27
|
-
export interface TableColumn<T> {
|
|
26
|
+
export interface TableColumn {
|
|
28
27
|
dataIndex: string
|
|
29
28
|
key: string
|
|
30
29
|
title: any
|
|
31
|
-
render?: (cellData: any, row:
|
|
30
|
+
render?: (cellData: any, row: any, index: number) => any
|
|
32
31
|
textColor?: string
|
|
33
32
|
sort?: boolean
|
|
34
33
|
width?: string //pixels
|
|
35
34
|
dataType?: DataType
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
interface TableProps<T> {
|
|
36
|
+
interface TableProps {
|
|
39
37
|
showSerialNumber?: boolean
|
|
40
|
-
columns: Array<TableColumn
|
|
38
|
+
columns: Array<TableColumn>
|
|
41
39
|
rowKey?: string
|
|
42
|
-
dataSource?:
|
|
40
|
+
dataSource?: any[]
|
|
43
41
|
loading?: boolean
|
|
44
42
|
onRowClick?: (row: any) => void
|
|
45
43
|
pagination?: {
|
|
@@ -56,8 +54,7 @@ interface TableProps<T> {
|
|
|
56
54
|
totalColumns?: number[]
|
|
57
55
|
showTotalInFirstCellOfTotalRow?: boolean
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
export default function Table<T>({
|
|
57
|
+
export default function Table({
|
|
61
58
|
showSerialNumber = false,
|
|
62
59
|
columns,
|
|
63
60
|
dataSource,
|
|
@@ -70,7 +67,7 @@ export default function Table<T>({
|
|
|
70
67
|
sx,
|
|
71
68
|
totalColumns,
|
|
72
69
|
showTotalInFirstCellOfTotalRow,
|
|
73
|
-
}: TableProps
|
|
70
|
+
}: TableProps) {
|
|
74
71
|
const [sort, setSort] = useState<Sort>({})
|
|
75
72
|
let totalCount = []
|
|
76
73
|
let totalCols = []
|
|
@@ -80,18 +77,18 @@ export default function Table<T>({
|
|
|
80
77
|
totalCols = totalColumns ? [...totalColumns] : []
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
const handleSortClick = (
|
|
80
|
+
const handleSortClick = (sortBykey) => {
|
|
84
81
|
setSort((prev) => {
|
|
85
|
-
if (prev[
|
|
86
|
-
if (prev[
|
|
87
|
-
if (prev[
|
|
88
|
-
delete prev[
|
|
82
|
+
if (prev[sortBykey]) {
|
|
83
|
+
if (prev[sortBykey] === 'desc') return { ...prev, [sortBykey]: 'asc' }
|
|
84
|
+
if (prev[sortBykey] === 'asc') {
|
|
85
|
+
delete prev[sortBykey]
|
|
89
86
|
return { ...prev }
|
|
90
87
|
}
|
|
91
88
|
} else {
|
|
92
89
|
return {
|
|
93
90
|
...prev,
|
|
94
|
-
[
|
|
91
|
+
[sortBykey]: 'desc',
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
94
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from
|
|
1
|
+
import { ReactNode } from "react"
|
|
2
2
|
|
|
3
3
|
export const batchOptions = Array.from({ length: 12 }, (_, i) => {
|
|
4
4
|
return `${2012 + i} - ${2012 + i + 1}`
|
|
@@ -127,10 +127,6 @@ export const ProfileApplicationType = [
|
|
|
127
127
|
label: 'PeopleX',
|
|
128
128
|
value: 'hrms',
|
|
129
129
|
},
|
|
130
|
-
{
|
|
131
|
-
label: 'AdminX',
|
|
132
|
-
value: 'admin',
|
|
133
|
-
},
|
|
134
130
|
]
|
|
135
131
|
|
|
136
132
|
export interface Option {
|