@campxdev/shared 1.11.2 → 1.11.4
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/package.json +1 -1
- package/src/components/HookForm/AutoCompleteSearch.tsx +6 -0
- package/src/components/HookForm/MultiCheckbox.tsx +9 -6
- package/src/components/HookForm/MultiSelect.tsx +3 -0
- package/src/components/HookForm/RadioGroup.tsx +3 -0
- package/src/components/Input/MultiCheckbox.tsx +4 -2
- package/src/components/Input/MultiSelect.tsx +4 -0
- package/src/components/Input/RadioGroup.tsx +2 -2
- package/src/components/Tables/BasicTable/Table.tsx +22 -0
- package/src/components/Tables/BasicTable/interface.ts +1 -1
- package/src/components/Tables/ReactTable/ReactTable.tsx +3 -0
- package/src/components/Tables/ReactTable/RenderTableBody.tsx +4 -2
- package/src/components/Tables/common/types.ts +1 -0
- package/src/config/axios.ts +5 -0
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ interface MultiSelectProps {
|
|
|
23
23
|
loading?: boolean
|
|
24
24
|
[key: string]: any
|
|
25
25
|
multiple?: boolean
|
|
26
|
+
disabled?: boolean
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export default function FormAutoCompleteSearch({
|
|
@@ -33,6 +34,7 @@ export default function FormAutoCompleteSearch({
|
|
|
33
34
|
loading, // pass this variable when options are from an async operation
|
|
34
35
|
hookForm = true,
|
|
35
36
|
multiple = false,
|
|
37
|
+
disabled = false,
|
|
36
38
|
...props
|
|
37
39
|
}: MultiSelectProps) {
|
|
38
40
|
if (!hookForm) {
|
|
@@ -44,12 +46,14 @@ export default function FormAutoCompleteSearch({
|
|
|
44
46
|
onChange={(e, value) => {
|
|
45
47
|
props.onChange(value)
|
|
46
48
|
}}
|
|
49
|
+
disabled={disabled}
|
|
47
50
|
options={options || []}
|
|
48
51
|
getOptionLabel={(option: Option) => option?.label || ''}
|
|
49
52
|
renderInput={(params) => (
|
|
50
53
|
<TextField
|
|
51
54
|
variant="outlined"
|
|
52
55
|
label={<FormLabel label={label} required={props.required} />}
|
|
56
|
+
disabled={disabled}
|
|
53
57
|
{...params}
|
|
54
58
|
/>
|
|
55
59
|
)}
|
|
@@ -74,11 +78,13 @@ export default function FormAutoCompleteSearch({
|
|
|
74
78
|
}}
|
|
75
79
|
options={options || []}
|
|
76
80
|
getOptionLabel={(option: Option) => option?.label || ''}
|
|
81
|
+
disabled={disabled}
|
|
77
82
|
renderInput={(params) => (
|
|
78
83
|
<TextField
|
|
79
84
|
error={Boolean(error)}
|
|
80
85
|
variant="outlined"
|
|
81
86
|
label={<FormLabel label={label} required={props.required} />}
|
|
87
|
+
disabled={disabled}
|
|
82
88
|
InputProps={{
|
|
83
89
|
...params.InputProps,
|
|
84
90
|
endAdornment: (
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
import { ReactNode } from 'react'
|
|
9
9
|
import { Controller } from 'react-hook-form'
|
|
10
10
|
import { FormLabel, SingleCheckbox } from '../Input'
|
|
11
|
-
import { IOption } from '../Input/types'
|
|
12
11
|
|
|
13
12
|
interface Props extends FormGroupProps {
|
|
14
13
|
label?: ReactNode
|
|
15
14
|
name: string
|
|
16
15
|
control: any
|
|
17
|
-
options:
|
|
16
|
+
options: { label: ReactNode; value: any; disabled?: boolean }[]
|
|
18
17
|
required?: boolean
|
|
18
|
+
disabled?: boolean
|
|
19
19
|
row?: boolean
|
|
20
20
|
containerProps?: BoxProps
|
|
21
21
|
disableSelected?: boolean
|
|
@@ -29,6 +29,7 @@ export default function FormMultiCheckbox({
|
|
|
29
29
|
required = false,
|
|
30
30
|
row = true,
|
|
31
31
|
disableSelected = false,
|
|
32
|
+
disabled = false,
|
|
32
33
|
containerProps,
|
|
33
34
|
...rest
|
|
34
35
|
}: Props) {
|
|
@@ -45,10 +46,12 @@ export default function FormMultiCheckbox({
|
|
|
45
46
|
key={index}
|
|
46
47
|
name={name}
|
|
47
48
|
disabled={
|
|
48
|
-
disableSelected &&
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
(disableSelected &&
|
|
50
|
+
field?.value
|
|
51
|
+
?.map((item: any) => item?.value)
|
|
52
|
+
?.includes(item?.value)) ||
|
|
53
|
+
disabled ||
|
|
54
|
+
item?.disabled
|
|
52
55
|
}
|
|
53
56
|
checked={field?.value
|
|
54
57
|
?.map((item: any) => item?.value)
|
|
@@ -17,6 +17,7 @@ interface MultiSelectProps {
|
|
|
17
17
|
reason: AutocompleteInputChangeReason,
|
|
18
18
|
) => void
|
|
19
19
|
required?: boolean
|
|
20
|
+
disabled?: boolean
|
|
20
21
|
value?: IOption[] | IOption
|
|
21
22
|
onChange?: (value: IOption[] | IOption) => void
|
|
22
23
|
multiple?: boolean
|
|
@@ -31,6 +32,7 @@ export default function FormMultiSelect({
|
|
|
31
32
|
label,
|
|
32
33
|
loading,
|
|
33
34
|
required,
|
|
35
|
+
disabled = false,
|
|
34
36
|
multiple = true,
|
|
35
37
|
noOptionsText,
|
|
36
38
|
onInputChange,
|
|
@@ -56,6 +58,7 @@ export default function FormMultiSelect({
|
|
|
56
58
|
error={!!error}
|
|
57
59
|
noOptionsText={noOptionsText}
|
|
58
60
|
required={required}
|
|
61
|
+
disabled={disabled}
|
|
59
62
|
helperText={error ? error.message : null}
|
|
60
63
|
limitTags={limitTags}
|
|
61
64
|
{...props}
|
|
@@ -10,6 +10,7 @@ interface Props extends RadioGroupProps {
|
|
|
10
10
|
sx?: any
|
|
11
11
|
row?: boolean
|
|
12
12
|
required?: boolean
|
|
13
|
+
disabled?: boolean
|
|
13
14
|
options: { value: any; label: string | ReactNode; disabled?: boolean }[]
|
|
14
15
|
containerProps?: BoxProps
|
|
15
16
|
}
|
|
@@ -21,6 +22,7 @@ export default function FormRadioGroup({
|
|
|
21
22
|
options = [],
|
|
22
23
|
row = false,
|
|
23
24
|
containerProps,
|
|
25
|
+
disabled = false,
|
|
24
26
|
...rest
|
|
25
27
|
}: Props) {
|
|
26
28
|
return (
|
|
@@ -36,6 +38,7 @@ export default function FormRadioGroup({
|
|
|
36
38
|
options={options}
|
|
37
39
|
value={field.value}
|
|
38
40
|
onChange={field.onChange}
|
|
41
|
+
disabled={disabled}
|
|
39
42
|
error={error ? true : false}
|
|
40
43
|
helperText={error ? error?.message : null}
|
|
41
44
|
{...rest}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Box, BoxProps, FormGroup, FormHelperText } from '@mui/material'
|
|
2
2
|
import { ReactNode } from 'react'
|
|
3
|
-
import { Controller } from 'react-hook-form'
|
|
4
3
|
import FormLabel from './FormLabel'
|
|
5
4
|
import SingleCheckbox from './SingleCheckbox'
|
|
6
5
|
|
|
@@ -8,8 +7,9 @@ interface Props {
|
|
|
8
7
|
label?: ReactNode
|
|
9
8
|
name: string
|
|
10
9
|
size?: 'small' | 'medium'
|
|
11
|
-
options: Array<{ label: ReactNode; value: any }>
|
|
10
|
+
options: Array<{ label: ReactNode; value: any; disabled?: boolean }>
|
|
12
11
|
required?: boolean
|
|
12
|
+
disabled?: boolean
|
|
13
13
|
row?: boolean
|
|
14
14
|
error?: boolean
|
|
15
15
|
helperText?: ReactNode
|
|
@@ -23,6 +23,7 @@ export default function MultiCheckbox({
|
|
|
23
23
|
label,
|
|
24
24
|
options = [],
|
|
25
25
|
required = false,
|
|
26
|
+
disabled = false,
|
|
26
27
|
value = [],
|
|
27
28
|
onChange,
|
|
28
29
|
error,
|
|
@@ -43,6 +44,7 @@ export default function MultiCheckbox({
|
|
|
43
44
|
checked={value
|
|
44
45
|
?.map((item: any) => item?.value)
|
|
45
46
|
?.includes(item?.value)}
|
|
47
|
+
disabled={disabled || item?.disabled}
|
|
46
48
|
onChange={(e) => {
|
|
47
49
|
if (e.target.checked) {
|
|
48
50
|
let newValue = [...value, item]
|
|
@@ -83,6 +83,7 @@ interface MultiSelectProps {
|
|
|
83
83
|
reason: AutocompleteInputChangeReason,
|
|
84
84
|
) => void
|
|
85
85
|
required?: boolean
|
|
86
|
+
disabled?: boolean
|
|
86
87
|
error?: boolean
|
|
87
88
|
helperText?: string
|
|
88
89
|
multiple?: boolean
|
|
@@ -99,6 +100,7 @@ export default function MultiSelect({
|
|
|
99
100
|
onChange,
|
|
100
101
|
onInputChange,
|
|
101
102
|
required,
|
|
103
|
+
disabled = false,
|
|
102
104
|
error,
|
|
103
105
|
noOptionsText,
|
|
104
106
|
helperText,
|
|
@@ -126,6 +128,7 @@ export default function MultiSelect({
|
|
|
126
128
|
option?.value === value?.value
|
|
127
129
|
}
|
|
128
130
|
disableCloseOnSelect
|
|
131
|
+
disabled={disabled}
|
|
129
132
|
PopperComponent={StyledPopper}
|
|
130
133
|
renderOption={(props, option: any, { selected }) => (
|
|
131
134
|
<li {...props}>
|
|
@@ -145,6 +148,7 @@ export default function MultiSelect({
|
|
|
145
148
|
helperText={helperText}
|
|
146
149
|
label={label}
|
|
147
150
|
required={required}
|
|
151
|
+
disabled={disabled}
|
|
148
152
|
InputProps={{
|
|
149
153
|
...params.InputProps,
|
|
150
154
|
endAdornment: (
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
BoxProps,
|
|
4
4
|
FormControlLabel,
|
|
5
5
|
FormHelperText,
|
|
6
|
-
Radio,
|
|
7
6
|
RadioGroup as MuiRadioGroup,
|
|
7
|
+
Radio,
|
|
8
8
|
RadioGroupProps,
|
|
9
9
|
styled,
|
|
10
10
|
} from '@mui/material'
|
|
@@ -97,7 +97,7 @@ export default function RadioGroup(props: Props) {
|
|
|
97
97
|
<Radio
|
|
98
98
|
checkedIcon={<BpCheckedIcon />}
|
|
99
99
|
icon={<BpIcon />}
|
|
100
|
-
disabled={disabled || item.disabled}
|
|
100
|
+
disabled={disabled || item.disabled}
|
|
101
101
|
/>
|
|
102
102
|
}
|
|
103
103
|
label={item.label}
|
|
@@ -34,6 +34,7 @@ export interface TableColumn {
|
|
|
34
34
|
dataType?: DataType
|
|
35
35
|
}
|
|
36
36
|
interface TableProps {
|
|
37
|
+
showSerialNumber?: boolean
|
|
37
38
|
columns: Array<TableColumn>
|
|
38
39
|
rowKey?: string
|
|
39
40
|
dataSource?: any[]
|
|
@@ -54,6 +55,7 @@ interface TableProps {
|
|
|
54
55
|
showTotalInFirstCellOfTotalRow?: boolean
|
|
55
56
|
}
|
|
56
57
|
export default function Table({
|
|
58
|
+
showSerialNumber = false,
|
|
57
59
|
columns,
|
|
58
60
|
dataSource,
|
|
59
61
|
onRowClick,
|
|
@@ -135,6 +137,16 @@ export default function Table({
|
|
|
135
137
|
<StyledMuiTable sx={sx}>
|
|
136
138
|
<TableHead>
|
|
137
139
|
<TableRow>
|
|
140
|
+
{showSerialNumber && (
|
|
141
|
+
<StyledTableCell
|
|
142
|
+
sx={sx}
|
|
143
|
+
columnIndex={0}
|
|
144
|
+
rowIndex={0}
|
|
145
|
+
columnsLength={1}
|
|
146
|
+
>
|
|
147
|
+
S. No.
|
|
148
|
+
</StyledTableCell>
|
|
149
|
+
)}
|
|
138
150
|
{columns.map((col, columnIndex) => (
|
|
139
151
|
<StyledTableCell
|
|
140
152
|
key={columnIndex}
|
|
@@ -177,6 +189,16 @@ export default function Table({
|
|
|
177
189
|
return onRowClick && onRowClick(row)
|
|
178
190
|
}}
|
|
179
191
|
>
|
|
192
|
+
{showSerialNumber && (
|
|
193
|
+
<StyledTableCell
|
|
194
|
+
sx={sx}
|
|
195
|
+
columnIndex={0}
|
|
196
|
+
rowIndex={rowIndex + 1}
|
|
197
|
+
columnsLength={1}
|
|
198
|
+
>
|
|
199
|
+
{rowIndex + 1}
|
|
200
|
+
</StyledTableCell>
|
|
201
|
+
)}
|
|
180
202
|
<> {showTotal && calculateTotal(row)}</>
|
|
181
203
|
{columns.map((col, colIndex) => (
|
|
182
204
|
<StyledTableCell
|
|
@@ -74,6 +74,7 @@ const getTableCol = (headerItem: ColumnProps) => {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export default function ReactTable({
|
|
77
|
+
showSerialNumber = false,
|
|
77
78
|
columns,
|
|
78
79
|
rowKey = 'id',
|
|
79
80
|
dataSource,
|
|
@@ -197,6 +198,7 @@ export default function ReactTable({
|
|
|
197
198
|
<TableHead>
|
|
198
199
|
{headerGroups.map((headerGroup, index) => (
|
|
199
200
|
<TableRow key={index} {...headerGroup.getHeaderGroupProps()}>
|
|
201
|
+
{showSerialNumber && <TableCell>S. No.</TableCell>}
|
|
200
202
|
{headerGroup.headers.map((column: any, index) => (
|
|
201
203
|
<TableCell key={index} {...column.getHeaderProps()}>
|
|
202
204
|
{column.render('Header')}
|
|
@@ -219,6 +221,7 @@ export default function ReactTable({
|
|
|
219
221
|
))}
|
|
220
222
|
</TableHead>
|
|
221
223
|
<RenderTableBody
|
|
224
|
+
showSerialNumber={showSerialNumber}
|
|
222
225
|
onRowClick={onRowClick}
|
|
223
226
|
colLength={columns?.length}
|
|
224
227
|
loading={loading || refetching}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TableBody, TableCell } from '@mui/material'
|
|
2
2
|
import Spinner from '../../Spinner'
|
|
3
|
-
import { StyledTableRow } from '../common/styles'
|
|
4
3
|
import NoRecordsFound from '../common/NoRecordsFound'
|
|
4
|
+
import { StyledTableRow } from '../common/styles'
|
|
5
5
|
|
|
6
6
|
export const RenderTableBody = ({
|
|
7
|
+
showSerialNumber,
|
|
7
8
|
getTableBodyProps,
|
|
8
9
|
prepareRow,
|
|
9
10
|
rows,
|
|
@@ -34,6 +35,7 @@ export const RenderTableBody = ({
|
|
|
34
35
|
{...row.getRowProps()}
|
|
35
36
|
isSelected={row?.isSelected}
|
|
36
37
|
>
|
|
38
|
+
{showSerialNumber && <TableCell>{index + 1}</TableCell>}
|
|
37
39
|
{row.cells?.map((cell, index) => {
|
|
38
40
|
return (
|
|
39
41
|
<TableCell key={index} {...cell.getCellProps()}>
|
package/src/config/axios.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { InstitutionsStore } from '../shared-state/InstitutionsStore'
|
|
|
8
8
|
const sessionKey = Cookies.get('campx_session_key')
|
|
9
9
|
const clientId = window.location.pathname.split('/')[1] ?? 'campx_dev'
|
|
10
10
|
const institutionId = window.location.pathname.split('/')[2] ?? 'campx_dev'
|
|
11
|
+
const openPaymentsKey = Cookies.get('campx_open_payments_key')
|
|
11
12
|
|
|
12
13
|
export const formatParams = (params) => {
|
|
13
14
|
return Object.fromEntries(
|
|
@@ -26,6 +27,10 @@ let axios = Axios.create({
|
|
|
26
27
|
...((isDevelopment || isSetup) && sessionKey
|
|
27
28
|
? { campx_session_key: sessionKey }
|
|
28
29
|
: {}),
|
|
30
|
+
|
|
31
|
+
...(openPaymentsKey && {
|
|
32
|
+
campx_open_payments_key: openPaymentsKey,
|
|
33
|
+
}),
|
|
29
34
|
},
|
|
30
35
|
})
|
|
31
36
|
|