@campxdev/shared 1.6.1 → 1.6.3
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/antd.customize.less +73 -73
- package/exports.ts +18 -18
- package/package.json +86 -86
- package/src/assets/fonts/avenir/index.ts +13 -13
- package/src/assets/fonts/poppins/index.ts +18 -18
- package/src/assets/images/index.ts +17 -17
- package/src/assets/images/unauth.svg +92 -92
- package/src/components/ActionButton.tsx +20 -20
- package/src/components/Attachment.tsx +26 -26
- package/src/components/AutocompleteSearch/AutocompleteSearch.tsx +57 -57
- package/src/components/AutocompleteSearch/index.tsx +1 -1
- package/src/components/Breadcrumbs.tsx +72 -72
- package/src/components/Card.tsx +98 -98
- package/src/components/CardsGrid.tsx +28 -28
- package/src/components/ChangePassword.tsx +123 -123
- package/src/components/Chips.tsx +81 -81
- package/src/components/Detail.tsx +15 -15
- package/src/components/DetailsGrid.tsx +52 -52
- package/src/components/DividerHeading.tsx +41 -41
- package/src/components/DrawerWrapper/DialogWrapper.tsx +67 -67
- package/src/components/DrawerWrapper/DrawerTemplate.tsx +53 -53
- package/src/components/DrawerWrapper/DrawerWrapper.tsx +53 -53
- package/src/components/DropDownButton/AnchorElement.tsx +44 -44
- package/src/components/DropDownButton/DropDownButton.tsx +184 -184
- package/src/components/DropDownButton/DropdownMenuItem.tsx +110 -110
- package/src/components/DropDownButton/index.tsx +1 -1
- package/src/components/DropDownButton/styles.tsx +59 -59
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +28 -28
- package/src/components/ErrorBoundary/ErrorFallback.tsx +236 -236
- package/src/components/ErrorBoundary/GlobalNetworkLoadingIndicator.tsx +13 -13
- package/src/components/ErrorBoundary/index.tsx +1 -1
- package/src/components/ErrorBox.tsx +42 -42
- package/src/components/FilterComponents/FilterButton.tsx +56 -56
- package/src/components/FilterComponents/SearchBar.tsx +45 -45
- package/src/components/FloatingContainer.tsx +33 -33
- package/src/components/Form/Form.tsx +156 -156
- package/src/components/Form/RenderForm.tsx +188 -188
- package/src/components/FullCalendar/Actions.tsx +162 -162
- package/src/components/FullCalendar/FullCalendarWrapper.tsx +54 -54
- package/src/components/FullScreenLoader.tsx +19 -19
- package/src/components/HookForm/AutoCompleteSearch.tsx +113 -113
- package/src/components/HookForm/DatePicker.tsx +40 -40
- package/src/components/HookForm/DateTimePicker.tsx +47 -47
- package/src/components/HookForm/FormLabel.tsx +14 -14
- package/src/components/HookForm/MultiCheckbox.tsx +69 -69
- package/src/components/HookForm/MultiSelect.tsx +53 -53
- package/src/components/HookForm/RadioGroup.tsx +45 -45
- package/src/components/HookForm/SingleCheckbox.tsx +34 -34
- package/src/components/HookForm/SingleSelect.tsx +46 -46
- package/src/components/HookForm/TextField.tsx +40 -40
- package/src/components/HookForm/TimePicker.tsx +40 -40
- package/src/components/HookForm/index.ts +23 -23
- package/src/components/IconButtons/IconButtons.tsx +137 -137
- package/src/components/IconButtons/Icons.tsx +268 -268
- package/src/components/IconButtons/assets/edit.svg +4 -4
- package/src/components/IconButtons/assets/eye.svg +6 -6
- package/src/components/IconButtons/assets/trash.svg +7 -7
- package/src/components/IconButtons/index.tsx +8 -8
- package/src/components/IconLabel.tsx +37 -37
- package/src/components/Image/Image.tsx +45 -45
- package/src/components/Image/index.tsx +1 -1
- package/src/components/ImageUpload.tsx +98 -98
- package/src/components/Input/AsyncSearchSelect/AsyncSearchSelect.tsx +216 -216
- package/src/components/Input/AsyncSearchSelect/index.tsx +1 -1
- package/src/components/Input/AsyncSearchSelect/styles.tsx +105 -105
- package/src/components/Input/AutoCompleteSearch.tsx +121 -121
- package/src/components/Input/DatePicker.tsx +73 -73
- package/src/components/Input/DateRangePicker.tsx +105 -105
- package/src/components/Input/DateTimePicker.tsx +81 -81
- package/src/components/Input/FormLabel.tsx +21 -21
- package/src/components/Input/MultiCheckbox.tsx +64 -64
- package/src/components/Input/MultiSelect.tsx +150 -150
- package/src/components/Input/RadioGroup.tsx +104 -104
- package/src/components/Input/SingleCheckbox.tsx +78 -78
- package/src/components/Input/SingleSelect.tsx +104 -104
- package/src/components/Input/TextField.tsx +46 -46
- package/src/components/Input/TimePicker.tsx +74 -74
- package/src/components/Input/index.ts +26 -26
- package/src/components/Input/types.ts +3 -3
- package/src/components/JsonPreview.tsx +7 -7
- package/src/components/LabelValue.tsx +21 -21
- package/src/components/Layout/ChangePassword.tsx +49 -49
- package/src/components/Layout/Header/AppHeader.tsx +121 -102
- package/src/components/Layout/Header/AppsMenu.tsx +102 -102
- package/src/components/Layout/Header/CogWheelMenu.tsx +33 -33
- package/src/components/Layout/Header/Notification.tsx +13 -13
- package/src/components/Layout/Header/UserBox.tsx +61 -70
- package/src/components/Layout/Header/applications.ts +91 -91
- package/src/components/Layout/Header/assets/campx_square_small.svg +8 -8
- package/src/components/Layout/Header/assets/commuteX.png +0 -0
- package/src/components/Layout/Header/assets/commutex.svg +14 -14
- package/src/components/Layout/Header/assets/commutexSmall.svg +11 -11
- package/src/components/Layout/Header/assets/enroll.svg +14 -14
- package/src/components/Layout/Header/assets/enrollx.svg +14 -14
- package/src/components/Layout/Header/assets/exams_small.svg +11 -11
- package/src/components/Layout/Header/assets/examsx.svg +14 -14
- package/src/components/Layout/Header/assets/hostel_small.svg +13 -13
- package/src/components/Layout/Header/assets/hostelx.svg +13 -13
- package/src/components/Layout/Header/assets/index.ts +33 -33
- package/src/components/Layout/Header/assets/libraryx.svg +12 -12
- package/src/components/Layout/Header/assets/pay_small.svg +15 -15
- package/src/components/Layout/Header/assets/payx.svg +19 -19
- package/src/components/Layout/Header/assets/people_small.svg +9 -9
- package/src/components/Layout/Header/assets/peoplex.svg +12 -12
- package/src/components/Layout/Header/assets/squarex.svg +12 -12
- package/src/components/Layout/Header/icons.tsx +57 -57
- package/src/components/Layout/Header/index.tsx +1 -1
- package/src/components/Layout/Header/styles.tsx +133 -133
- package/src/components/Layout/Helmet.tsx +49 -49
- package/src/components/Layout/LayoutWrapper.tsx +28 -28
- package/src/components/Layout/SideMenuHeader.tsx +29 -29
- package/src/components/Layout/SideNav.tsx +168 -168
- package/src/components/Layout/Tickets/HelpWidget/HelpWidget.tsx +273 -273
- package/src/components/Layout/Tickets/HelpWidget/styles.tsx +94 -94
- package/src/components/Layout/Tickets/MyTickets.tsx +72 -72
- package/src/components/Layout/Tickets/TicketDetails.tsx +65 -65
- package/src/components/Layout/Tickets/TimeLine.tsx +64 -64
- package/src/components/Layout/Tickets/index.tsx +1 -1
- package/src/components/Layout/Tickets/services.ts +11 -11
- package/src/components/Layout/Tickets/styles.tsx +136 -136
- package/src/components/LinearProgress.tsx +19 -19
- package/src/components/ListItemButton.tsx +95 -95
- package/src/components/LoginForm.tsx +80 -80
- package/src/components/MediaRow/MediaRow.tsx +69 -69
- package/src/components/MediaRow/index.tsx +1 -1
- package/src/components/ModalButtons/DialogButton.tsx +121 -121
- package/src/components/ModalButtons/DrawerButton.tsx +113 -113
- package/src/components/ModalButtons/index.tsx +4 -4
- package/src/components/NoDataIllustration.tsx +32 -32
- package/src/components/PageContent.tsx +12 -12
- package/src/components/PageHeader.tsx +55 -55
- package/src/components/PageNotFound.tsx +26 -26
- package/src/components/PopupConfirm/ConfirmContextProvider.tsx +40 -40
- package/src/components/PopupConfirm/PopupConfirm.tsx +67 -67
- package/src/components/PopupConfirm/index.tsx +1 -1
- package/src/components/PopupConfirm/useConfirm.ts +47 -47
- package/src/components/Row.tsx +24 -24
- package/src/components/Spinner.tsx +18 -18
- package/src/components/StepsHeader/StepsHeader.tsx +115 -115
- package/src/components/StepsHeader/index.tsx +1 -1
- package/src/components/StyledTableContainer.tsx +33 -33
- package/src/components/SwitchButton.tsx +41 -41
- package/src/components/Table.tsx +42 -42
- package/src/components/TableComponent/BatchActionsHeader.tsx +58 -58
- package/src/components/TableComponent/Icons/index.tsx +50 -50
- package/src/components/TableComponent/ReactTable.tsx +295 -295
- package/src/components/TableComponent/RenderTableBody.tsx +68 -68
- package/src/components/TableComponent/Table.tsx +197 -197
- package/src/components/TableComponent/TableFooter/TableFooter.tsx +104 -104
- package/src/components/TableComponent/TableFooter/index.tsx +1 -1
- package/src/components/TableComponent/TableFooter/styles.tsx +28 -28
- package/src/components/TableComponent/index.tsx +1 -1
- package/src/components/TableComponent/react-table-config.d.ts +128 -128
- package/src/components/TableComponent/styles.tsx +170 -170
- package/src/components/TableComponent/types.ts +57 -57
- package/src/components/Tabs/NavigationTabs.tsx +80 -80
- package/src/components/Tabs/Tabs.tsx +53 -53
- package/src/components/Tabs/TabsContainer.tsx +50 -50
- package/src/components/Tabs/index.tsx +1 -1
- package/src/components/Tabs/styles.tsx +55 -55
- package/src/components/ToastContainer/ToastContainer.tsx +57 -57
- package/src/components/ToastContainer/index.tsx +1 -1
- package/src/components/UploadButton/UploadButton.tsx +126 -126
- package/src/components/UploadButton/index.tsx +1 -1
- package/src/components/UploadButton/types.ts +19 -19
- package/src/components/UploadDocument.tsx +108 -108
- package/src/components/UploadFileDialog/UploadFileDialog.tsx +238 -238
- package/src/components/UploadFileDialog/index.tsx +1 -1
- package/src/components/index.ts +93 -93
- package/src/config/axios.ts +73 -73
- package/src/config/axiosEvaluator.ts +53 -53
- package/src/config/axiosXTenant.ts +57 -57
- package/src/constants/UIConstants.ts +97 -97
- package/src/constants/formValidations.ts +6 -6
- package/src/constants/index.ts +5 -5
- package/src/constants/isDevelopment.ts +3 -3
- package/src/constants/permissions.ts +67 -67
- package/src/constants/validateMessages.ts +12 -12
- package/src/contexts/LoginFormProvider.tsx +39 -39
- package/src/contexts/Providers.tsx +44 -73
- package/src/contexts/PublicProviders.tsx +30 -30
- package/src/contexts/QueryClientProvider.tsx +22 -22
- package/src/hooks/index.ts +4 -4
- package/src/hooks/useAuth.ts +96 -96
- package/src/hooks/useFetch.ts +53 -53
- package/src/hooks/useFilters.ts +80 -80
- package/src/hooks/useRouter.ts +31 -31
- package/src/layouts/Components/DashBoardMenu.tsx +232 -232
- package/src/layouts/Components/icons/index.tsx +403 -403
- package/src/layouts/Components/styles.tsx +74 -74
- package/src/layouts/ComponentsLayout.tsx +3 -3
- package/src/permissions/PageWithPermission.tsx +18 -18
- package/src/permissions/PermissionDeniedPage.tsx +16 -16
- package/src/permissions/ValidateAccess.tsx +18 -18
- package/src/permissions/index.ts +2 -2
- package/src/react-app-env.d.ts +1 -1
- package/src/shared-state/AssetsStore.ts +15 -15
- package/src/shared-state/PermissionsStore.ts +352 -352
- package/src/shared-state/UserStore.ts +13 -13
- package/src/shared-state/index.ts +4 -4
- package/src/theme/App.less +3 -3
- package/src/theme/MuiThemeProvider.tsx +18 -13
- package/src/theme/customCssBaseline.ts +135 -135
- package/src/theme/index.css +28 -28
- package/src/theme/muiTheme.ts +592 -592
- package/src/theme/theme.d.ts +75 -75
- package/src/utils/alphabet.ts +23 -23
- package/src/utils/arrayPadEnd.ts +3 -3
- package/src/utils/formatCurrency.ts +9 -9
- package/src/utils/getUrlParams.ts +5 -5
- package/src/utils/index.ts +7 -7
- package/src/utils/logout.ts +25 -25
- package/src/utils/ordinalSuffixOf.ts +14 -14
- package/src/utils/romanize.ts +40 -40
- package/src/utils/withRouteWrapper.tsx +25 -25
- package/src/utils/withSuspense.tsx +6 -6
- package/styled-components.tsx +60 -60
- package/tsconfig.json +21 -21
- package/yarn-error.log +0 -109
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
import { Add, Close } from '@mui/icons-material'
|
|
2
|
-
import {
|
|
3
|
-
alpha,
|
|
4
|
-
Box,
|
|
5
|
-
Button,
|
|
6
|
-
ButtonProps,
|
|
7
|
-
CircularProgress,
|
|
8
|
-
Dialog,
|
|
9
|
-
DialogContent,
|
|
10
|
-
DialogProps,
|
|
11
|
-
IconButton,
|
|
12
|
-
styled,
|
|
13
|
-
Typography,
|
|
14
|
-
} from '@mui/material'
|
|
15
|
-
import { DeleteButton, EditButton } from '../IconButtons'
|
|
16
|
-
import { ReactNode, useEffect, useRef, useState } from 'react'
|
|
17
|
-
import { toast } from 'react-toastify'
|
|
18
|
-
import axios, { axiosErrorToast } from '../../config/axios'
|
|
19
|
-
const animatedImage = require('./AnimatedUploadFile.gif')
|
|
20
|
-
|
|
21
|
-
const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
22
|
-
height: '64px',
|
|
23
|
-
backgroundColor: alpha(theme.palette.text.secondary, 0.1),
|
|
24
|
-
display: 'flex',
|
|
25
|
-
justifyContent: 'space-between',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
padding: '0.6rem 1rem',
|
|
28
|
-
}))
|
|
29
|
-
const StyledDialogContent = styled(DialogContent)(({ theme }) => ({
|
|
30
|
-
display: 'flex',
|
|
31
|
-
flexDirection: 'column',
|
|
32
|
-
gap: '1rem',
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
padding: '40px',
|
|
35
|
-
}))
|
|
36
|
-
|
|
37
|
-
const StyledImage = styled((props: any) => (
|
|
38
|
-
<Box>
|
|
39
|
-
<img {...props} />
|
|
40
|
-
</Box>
|
|
41
|
-
))(({ theme }) => ({
|
|
42
|
-
height: '90px',
|
|
43
|
-
width: '90px',
|
|
44
|
-
'> img': {
|
|
45
|
-
width: '100%',
|
|
46
|
-
height: '100%',
|
|
47
|
-
objectFit: 'contain',
|
|
48
|
-
},
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
const StyledChooseFileButton = styled(Button)(({ theme }) => ({
|
|
52
|
-
padding: '15px 20px',
|
|
53
|
-
height: '50px',
|
|
54
|
-
'> .MuiBox-root': {
|
|
55
|
-
display: 'flex',
|
|
56
|
-
width: '100%',
|
|
57
|
-
alignItems: 'center',
|
|
58
|
-
justifyContent: 'space-between',
|
|
59
|
-
},
|
|
60
|
-
}))
|
|
61
|
-
|
|
62
|
-
const StyledFileLabel = styled(Box)(({ theme }) => ({
|
|
63
|
-
background: theme.palette.secondary.light,
|
|
64
|
-
borderRadius: '5px',
|
|
65
|
-
padding: '16px',
|
|
66
|
-
display: 'flex',
|
|
67
|
-
justifyContent: 'space-between',
|
|
68
|
-
alignItems: 'center',
|
|
69
|
-
}))
|
|
70
|
-
|
|
71
|
-
interface UploadFileDialogProps {
|
|
72
|
-
buttonProps?: ButtonProps
|
|
73
|
-
dialogProps?: DialogProps
|
|
74
|
-
buttonText: string | ReactNode
|
|
75
|
-
children?: ReactNode
|
|
76
|
-
dialogTitle: ReactNode | string
|
|
77
|
-
sampleFileUrl?: string
|
|
78
|
-
uploadUrl: string
|
|
79
|
-
successMessage?: string
|
|
80
|
-
refetchFn: () => void
|
|
81
|
-
postBody?: { [key: string]: string }
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default function UploadFileDialog({
|
|
85
|
-
buttonProps,
|
|
86
|
-
dialogProps,
|
|
87
|
-
buttonText,
|
|
88
|
-
dialogTitle,
|
|
89
|
-
uploadUrl,
|
|
90
|
-
sampleFileUrl,
|
|
91
|
-
successMessage,
|
|
92
|
-
refetchFn,
|
|
93
|
-
postBody = {},
|
|
94
|
-
}: UploadFileDialogProps) {
|
|
95
|
-
const inputRef: any = useRef(null)
|
|
96
|
-
const [loading, setLoading] = useState(false)
|
|
97
|
-
|
|
98
|
-
const [file, setFile] = useState(null)
|
|
99
|
-
const [open, setOpen] = useState(false)
|
|
100
|
-
const onClose = () => {
|
|
101
|
-
setOpen(false)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const triggerUpload = () => {
|
|
105
|
-
if (!inputRef.current) return
|
|
106
|
-
inputRef?.current?.click()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const handleImageChange = (e) => {
|
|
110
|
-
setFile(e.target.files[0])
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const handleOnUpload = () => {
|
|
114
|
-
if (!file) return ``
|
|
115
|
-
const formData = new FormData()
|
|
116
|
-
formData.append('file', file)
|
|
117
|
-
if (postBody) {
|
|
118
|
-
Object.keys(postBody).forEach((key) => {
|
|
119
|
-
formData.append(key, postBody[key])
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
setLoading(true)
|
|
123
|
-
|
|
124
|
-
axios
|
|
125
|
-
.post(uploadUrl, formData)
|
|
126
|
-
.then((res) => {
|
|
127
|
-
setLoading(false)
|
|
128
|
-
refetchFn()
|
|
129
|
-
setOpen(false)
|
|
130
|
-
toast.success(successMessage ?? 'Successful')
|
|
131
|
-
setFile(null)
|
|
132
|
-
})
|
|
133
|
-
.catch((err) => {
|
|
134
|
-
console.log(err)
|
|
135
|
-
setLoading(false)
|
|
136
|
-
axiosErrorToast(err)
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
return () => {
|
|
142
|
-
setFile(null)
|
|
143
|
-
inputRef.current = null
|
|
144
|
-
}
|
|
145
|
-
}, [])
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<>
|
|
149
|
-
<Button
|
|
150
|
-
onClick={() => {
|
|
151
|
-
setOpen(true)
|
|
152
|
-
}}
|
|
153
|
-
variant="outlined"
|
|
154
|
-
{...buttonProps}
|
|
155
|
-
>
|
|
156
|
-
{buttonText}
|
|
157
|
-
</Button>
|
|
158
|
-
<Dialog
|
|
159
|
-
open={open}
|
|
160
|
-
onClose={onClose}
|
|
161
|
-
maxWidth="sm"
|
|
162
|
-
fullWidth
|
|
163
|
-
{...dialogProps}
|
|
164
|
-
>
|
|
165
|
-
<StyledDialogHeader>
|
|
166
|
-
<Typography fontWeight={600}>{dialogTitle}</Typography>
|
|
167
|
-
<IconButton onClick={onClose}>
|
|
168
|
-
<Close />
|
|
169
|
-
</IconButton>
|
|
170
|
-
</StyledDialogHeader>
|
|
171
|
-
<StyledDialogContent>
|
|
172
|
-
<StyledImage src={animatedImage} alt="Upload Image" />
|
|
173
|
-
<Typography variant="h6">{dialogTitle}</Typography>
|
|
174
|
-
<Typography textAlign={'center'}>
|
|
175
|
-
Before importing, download Sample CSV File or Sample XLSX file and
|
|
176
|
-
compare it with your sheet or edit the sample sheet
|
|
177
|
-
</Typography>
|
|
178
|
-
<Box sx={{ minWidth: '400px', marginBottom: '20px' }}>
|
|
179
|
-
{!file ? (
|
|
180
|
-
<>
|
|
181
|
-
<input
|
|
182
|
-
onChange={handleImageChange}
|
|
183
|
-
hidden
|
|
184
|
-
type="file"
|
|
185
|
-
ref={inputRef}
|
|
186
|
-
/>
|
|
187
|
-
<StyledChooseFileButton
|
|
188
|
-
variant="outlined"
|
|
189
|
-
fullWidth
|
|
190
|
-
onClick={triggerUpload}
|
|
191
|
-
>
|
|
192
|
-
<Box>
|
|
193
|
-
<Typography variant="h6" color="primary">
|
|
194
|
-
Choose File
|
|
195
|
-
</Typography>
|
|
196
|
-
<Add />
|
|
197
|
-
</Box>
|
|
198
|
-
</StyledChooseFileButton>
|
|
199
|
-
</>
|
|
200
|
-
) : (
|
|
201
|
-
<StyledFileLabel>
|
|
202
|
-
<Typography variant="body2">{file?.name}</Typography>
|
|
203
|
-
<Box display={'flex'} gap="16px">
|
|
204
|
-
<EditButton
|
|
205
|
-
onClick={() => {
|
|
206
|
-
triggerUpload()
|
|
207
|
-
}}
|
|
208
|
-
/>
|
|
209
|
-
<DeleteButton onClick={() => setFile(null)} />
|
|
210
|
-
</Box>
|
|
211
|
-
</StyledFileLabel>
|
|
212
|
-
)}
|
|
213
|
-
</Box>
|
|
214
|
-
|
|
215
|
-
<Button
|
|
216
|
-
fullWidth
|
|
217
|
-
sx={{ maxWidth: '255px' }}
|
|
218
|
-
onClick={handleOnUpload}
|
|
219
|
-
endIcon={
|
|
220
|
-
loading ? (
|
|
221
|
-
<CircularProgress size={20} sx={{ color: 'white' }} />
|
|
222
|
-
) : null
|
|
223
|
-
}
|
|
224
|
-
>
|
|
225
|
-
Upload File
|
|
226
|
-
</Button>
|
|
227
|
-
{sampleFileUrl && (
|
|
228
|
-
<a href={sampleFileUrl} target="_blank" rel="noreferrer">
|
|
229
|
-
<Button fullWidth sx={{ maxWidth: '255px' }} variant="outlined">
|
|
230
|
-
Download Sample File
|
|
231
|
-
</Button>
|
|
232
|
-
</a>
|
|
233
|
-
)}
|
|
234
|
-
</StyledDialogContent>
|
|
235
|
-
</Dialog>
|
|
236
|
-
</>
|
|
237
|
-
)
|
|
238
|
-
}
|
|
1
|
+
import { Add, Close } from '@mui/icons-material'
|
|
2
|
+
import {
|
|
3
|
+
alpha,
|
|
4
|
+
Box,
|
|
5
|
+
Button,
|
|
6
|
+
ButtonProps,
|
|
7
|
+
CircularProgress,
|
|
8
|
+
Dialog,
|
|
9
|
+
DialogContent,
|
|
10
|
+
DialogProps,
|
|
11
|
+
IconButton,
|
|
12
|
+
styled,
|
|
13
|
+
Typography,
|
|
14
|
+
} from '@mui/material'
|
|
15
|
+
import { DeleteButton, EditButton } from '../IconButtons'
|
|
16
|
+
import { ReactNode, useEffect, useRef, useState } from 'react'
|
|
17
|
+
import { toast } from 'react-toastify'
|
|
18
|
+
import axios, { axiosErrorToast } from '../../config/axios'
|
|
19
|
+
const animatedImage = require('./AnimatedUploadFile.gif')
|
|
20
|
+
|
|
21
|
+
const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
22
|
+
height: '64px',
|
|
23
|
+
backgroundColor: alpha(theme.palette.text.secondary, 0.1),
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'space-between',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
padding: '0.6rem 1rem',
|
|
28
|
+
}))
|
|
29
|
+
const StyledDialogContent = styled(DialogContent)(({ theme }) => ({
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
gap: '1rem',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
padding: '40px',
|
|
35
|
+
}))
|
|
36
|
+
|
|
37
|
+
const StyledImage = styled((props: any) => (
|
|
38
|
+
<Box>
|
|
39
|
+
<img {...props} />
|
|
40
|
+
</Box>
|
|
41
|
+
))(({ theme }) => ({
|
|
42
|
+
height: '90px',
|
|
43
|
+
width: '90px',
|
|
44
|
+
'> img': {
|
|
45
|
+
width: '100%',
|
|
46
|
+
height: '100%',
|
|
47
|
+
objectFit: 'contain',
|
|
48
|
+
},
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
const StyledChooseFileButton = styled(Button)(({ theme }) => ({
|
|
52
|
+
padding: '15px 20px',
|
|
53
|
+
height: '50px',
|
|
54
|
+
'> .MuiBox-root': {
|
|
55
|
+
display: 'flex',
|
|
56
|
+
width: '100%',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
justifyContent: 'space-between',
|
|
59
|
+
},
|
|
60
|
+
}))
|
|
61
|
+
|
|
62
|
+
const StyledFileLabel = styled(Box)(({ theme }) => ({
|
|
63
|
+
background: theme.palette.secondary.light,
|
|
64
|
+
borderRadius: '5px',
|
|
65
|
+
padding: '16px',
|
|
66
|
+
display: 'flex',
|
|
67
|
+
justifyContent: 'space-between',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
}))
|
|
70
|
+
|
|
71
|
+
interface UploadFileDialogProps {
|
|
72
|
+
buttonProps?: ButtonProps
|
|
73
|
+
dialogProps?: DialogProps
|
|
74
|
+
buttonText: string | ReactNode
|
|
75
|
+
children?: ReactNode
|
|
76
|
+
dialogTitle: ReactNode | string
|
|
77
|
+
sampleFileUrl?: string
|
|
78
|
+
uploadUrl: string
|
|
79
|
+
successMessage?: string
|
|
80
|
+
refetchFn: () => void
|
|
81
|
+
postBody?: { [key: string]: string }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function UploadFileDialog({
|
|
85
|
+
buttonProps,
|
|
86
|
+
dialogProps,
|
|
87
|
+
buttonText,
|
|
88
|
+
dialogTitle,
|
|
89
|
+
uploadUrl,
|
|
90
|
+
sampleFileUrl,
|
|
91
|
+
successMessage,
|
|
92
|
+
refetchFn,
|
|
93
|
+
postBody = {},
|
|
94
|
+
}: UploadFileDialogProps) {
|
|
95
|
+
const inputRef: any = useRef(null)
|
|
96
|
+
const [loading, setLoading] = useState(false)
|
|
97
|
+
|
|
98
|
+
const [file, setFile] = useState(null)
|
|
99
|
+
const [open, setOpen] = useState(false)
|
|
100
|
+
const onClose = () => {
|
|
101
|
+
setOpen(false)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const triggerUpload = () => {
|
|
105
|
+
if (!inputRef.current) return
|
|
106
|
+
inputRef?.current?.click()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const handleImageChange = (e) => {
|
|
110
|
+
setFile(e.target.files[0])
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const handleOnUpload = () => {
|
|
114
|
+
if (!file) return ``
|
|
115
|
+
const formData = new FormData()
|
|
116
|
+
formData.append('file', file)
|
|
117
|
+
if (postBody) {
|
|
118
|
+
Object.keys(postBody).forEach((key) => {
|
|
119
|
+
formData.append(key, postBody[key])
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
setLoading(true)
|
|
123
|
+
|
|
124
|
+
axios
|
|
125
|
+
.post(uploadUrl, formData)
|
|
126
|
+
.then((res) => {
|
|
127
|
+
setLoading(false)
|
|
128
|
+
refetchFn()
|
|
129
|
+
setOpen(false)
|
|
130
|
+
toast.success(successMessage ?? 'Successful')
|
|
131
|
+
setFile(null)
|
|
132
|
+
})
|
|
133
|
+
.catch((err) => {
|
|
134
|
+
console.log(err)
|
|
135
|
+
setLoading(false)
|
|
136
|
+
axiosErrorToast(err)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
return () => {
|
|
142
|
+
setFile(null)
|
|
143
|
+
inputRef.current = null
|
|
144
|
+
}
|
|
145
|
+
}, [])
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
<Button
|
|
150
|
+
onClick={() => {
|
|
151
|
+
setOpen(true)
|
|
152
|
+
}}
|
|
153
|
+
variant="outlined"
|
|
154
|
+
{...buttonProps}
|
|
155
|
+
>
|
|
156
|
+
{buttonText}
|
|
157
|
+
</Button>
|
|
158
|
+
<Dialog
|
|
159
|
+
open={open}
|
|
160
|
+
onClose={onClose}
|
|
161
|
+
maxWidth="sm"
|
|
162
|
+
fullWidth
|
|
163
|
+
{...dialogProps}
|
|
164
|
+
>
|
|
165
|
+
<StyledDialogHeader>
|
|
166
|
+
<Typography fontWeight={600}>{dialogTitle}</Typography>
|
|
167
|
+
<IconButton onClick={onClose}>
|
|
168
|
+
<Close />
|
|
169
|
+
</IconButton>
|
|
170
|
+
</StyledDialogHeader>
|
|
171
|
+
<StyledDialogContent>
|
|
172
|
+
<StyledImage src={animatedImage} alt="Upload Image" />
|
|
173
|
+
<Typography variant="h6">{dialogTitle}</Typography>
|
|
174
|
+
<Typography textAlign={'center'}>
|
|
175
|
+
Before importing, download Sample CSV File or Sample XLSX file and
|
|
176
|
+
compare it with your sheet or edit the sample sheet
|
|
177
|
+
</Typography>
|
|
178
|
+
<Box sx={{ minWidth: '400px', marginBottom: '20px' }}>
|
|
179
|
+
{!file ? (
|
|
180
|
+
<>
|
|
181
|
+
<input
|
|
182
|
+
onChange={handleImageChange}
|
|
183
|
+
hidden
|
|
184
|
+
type="file"
|
|
185
|
+
ref={inputRef}
|
|
186
|
+
/>
|
|
187
|
+
<StyledChooseFileButton
|
|
188
|
+
variant="outlined"
|
|
189
|
+
fullWidth
|
|
190
|
+
onClick={triggerUpload}
|
|
191
|
+
>
|
|
192
|
+
<Box>
|
|
193
|
+
<Typography variant="h6" color="primary">
|
|
194
|
+
Choose File
|
|
195
|
+
</Typography>
|
|
196
|
+
<Add />
|
|
197
|
+
</Box>
|
|
198
|
+
</StyledChooseFileButton>
|
|
199
|
+
</>
|
|
200
|
+
) : (
|
|
201
|
+
<StyledFileLabel>
|
|
202
|
+
<Typography variant="body2">{file?.name}</Typography>
|
|
203
|
+
<Box display={'flex'} gap="16px">
|
|
204
|
+
<EditButton
|
|
205
|
+
onClick={() => {
|
|
206
|
+
triggerUpload()
|
|
207
|
+
}}
|
|
208
|
+
/>
|
|
209
|
+
<DeleteButton onClick={() => setFile(null)} />
|
|
210
|
+
</Box>
|
|
211
|
+
</StyledFileLabel>
|
|
212
|
+
)}
|
|
213
|
+
</Box>
|
|
214
|
+
|
|
215
|
+
<Button
|
|
216
|
+
fullWidth
|
|
217
|
+
sx={{ maxWidth: '255px' }}
|
|
218
|
+
onClick={handleOnUpload}
|
|
219
|
+
endIcon={
|
|
220
|
+
loading ? (
|
|
221
|
+
<CircularProgress size={20} sx={{ color: 'white' }} />
|
|
222
|
+
) : null
|
|
223
|
+
}
|
|
224
|
+
>
|
|
225
|
+
Upload File
|
|
226
|
+
</Button>
|
|
227
|
+
{sampleFileUrl && (
|
|
228
|
+
<a href={sampleFileUrl} target="_blank" rel="noreferrer">
|
|
229
|
+
<Button fullWidth sx={{ maxWidth: '255px' }} variant="outlined">
|
|
230
|
+
Download Sample File
|
|
231
|
+
</Button>
|
|
232
|
+
</a>
|
|
233
|
+
)}
|
|
234
|
+
</StyledDialogContent>
|
|
235
|
+
</Dialog>
|
|
236
|
+
</>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './UploadFileDialog'
|
|
1
|
+
export { default } from './UploadFileDialog'
|
package/src/components/index.ts
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import UploadFileDialog from './UploadFileDialog'
|
|
2
|
-
import Chips from './Chips'
|
|
3
|
-
import ImageUpload from './ImageUpload'
|
|
4
|
-
import FloatingContainer from './FloatingContainer'
|
|
5
|
-
import TabsContainer from './Tabs/TabsContainer'
|
|
6
|
-
import { StyledTableContainer } from './StyledTableContainer'
|
|
7
|
-
import SearchBar from './FilterComponents/SearchBar'
|
|
8
|
-
import { DrawerButton, DialogButton } from './ModalButtons'
|
|
9
|
-
import DetailsGrid from './DetailsGrid'
|
|
10
|
-
import AppHeader from './Layout/Header'
|
|
11
|
-
import StepsHeader from './StepsHeader'
|
|
12
|
-
import UploadDocument from './UploadDocument'
|
|
13
|
-
import { Table as StyledTable } from './Table'
|
|
14
|
-
import ErrorBoundary from './ErrorBoundary'
|
|
15
|
-
import FullScreenLoader from './FullScreenLoader'
|
|
16
|
-
import LoginForm from './LoginForm'
|
|
17
|
-
import { SideMenuHeader } from './Layout/SideMenuHeader'
|
|
18
|
-
import SideNav from './Layout/SideNav'
|
|
19
|
-
import { ListItemButton } from './ListItemButton'
|
|
20
|
-
import LayoutWrapper from './Layout/LayoutWrapper'
|
|
21
|
-
import PageNotFound from './PageNotFound'
|
|
22
|
-
import ChangePassword from './ChangePassword'
|
|
23
|
-
import UploadButton from './UploadButton'
|
|
24
|
-
import DialogWrapper from './DrawerWrapper/DialogWrapper'
|
|
25
|
-
import Form from './Form/Form'
|
|
26
|
-
import RenderForm from './Form/RenderForm'
|
|
27
|
-
import AsyncSearchSelect from './Input/AsyncSearchSelect'
|
|
28
|
-
import FilterButton from './FilterComponents/FilterButton'
|
|
29
|
-
import Helmet from './Layout/Helmet'
|
|
30
|
-
import NavigationTabs from './Tabs/NavigationTabs'
|
|
31
|
-
export { default as Image } from './Image'
|
|
32
|
-
export { default as PageHeader } from './PageHeader'
|
|
33
|
-
export { PageContent } from './PageContent'
|
|
34
|
-
export { default as ActionButton } from './ActionButton'
|
|
35
|
-
export { default as Breadcrumbs } from './Breadcrumbs'
|
|
36
|
-
export { default as Table } from './TableComponent'
|
|
37
|
-
export { default as Spinner } from './Spinner'
|
|
38
|
-
export { default as AutocompleteSearch } from './AutocompleteSearch'
|
|
39
|
-
export { FullCalendarWrapper } from './FullCalendar/FullCalendarWrapper'
|
|
40
|
-
export { default as JsonPreview } from './JsonPreview'
|
|
41
|
-
export { default as LabelValue } from './LabelValue'
|
|
42
|
-
export { LinearProgress } from './LinearProgress'
|
|
43
|
-
export { default as MediaRow } from './MediaRow'
|
|
44
|
-
export { default as NoDataIllustration } from './NoDataIllustration'
|
|
45
|
-
export { default as SwitchButton } from './SwitchButton'
|
|
46
|
-
export { default as Tabs } from './Tabs/Tabs'
|
|
47
|
-
export { default as ToastContainer } from './ToastContainer'
|
|
48
|
-
export { default as Card } from './Card'
|
|
49
|
-
export { default as CardsGrid } from './CardsGrid'
|
|
50
|
-
export { default as DividerHeading } from './DividerHeading'
|
|
51
|
-
export { default as ReactTable } from './TableComponent/ReactTable'
|
|
52
|
-
export { default as TableFooter } from './TableComponent/TableFooter'
|
|
53
|
-
export { default as DropDownButton } from './DropDownButton'
|
|
54
|
-
export { default as useConfirm } from './PopupConfirm/useConfirm'
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
UploadFileDialog,
|
|
58
|
-
Chips,
|
|
59
|
-
ImageUpload,
|
|
60
|
-
FloatingContainer,
|
|
61
|
-
TabsContainer,
|
|
62
|
-
StyledTableContainer,
|
|
63
|
-
SearchBar,
|
|
64
|
-
DrawerButton,
|
|
65
|
-
DialogButton,
|
|
66
|
-
DetailsGrid,
|
|
67
|
-
AppHeader,
|
|
68
|
-
StepsHeader,
|
|
69
|
-
UploadDocument,
|
|
70
|
-
StyledTable,
|
|
71
|
-
ErrorBoundary,
|
|
72
|
-
FullScreenLoader,
|
|
73
|
-
LoginForm,
|
|
74
|
-
SideMenuHeader,
|
|
75
|
-
ListItemButton,
|
|
76
|
-
LayoutWrapper,
|
|
77
|
-
PageNotFound,
|
|
78
|
-
SideNav,
|
|
79
|
-
ChangePassword,
|
|
80
|
-
UploadButton,
|
|
81
|
-
DialogWrapper,
|
|
82
|
-
Form,
|
|
83
|
-
RenderForm,
|
|
84
|
-
AsyncSearchSelect,
|
|
85
|
-
FilterButton,
|
|
86
|
-
Helmet,
|
|
87
|
-
NavigationTabs,
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export * from './UploadButton/types'
|
|
91
|
-
export * from './HookForm'
|
|
92
|
-
export * from './Input'
|
|
93
|
-
export * from './IconButtons'
|
|
1
|
+
import UploadFileDialog from './UploadFileDialog'
|
|
2
|
+
import Chips from './Chips'
|
|
3
|
+
import ImageUpload from './ImageUpload'
|
|
4
|
+
import FloatingContainer from './FloatingContainer'
|
|
5
|
+
import TabsContainer from './Tabs/TabsContainer'
|
|
6
|
+
import { StyledTableContainer } from './StyledTableContainer'
|
|
7
|
+
import SearchBar from './FilterComponents/SearchBar'
|
|
8
|
+
import { DrawerButton, DialogButton } from './ModalButtons'
|
|
9
|
+
import DetailsGrid from './DetailsGrid'
|
|
10
|
+
import AppHeader from './Layout/Header'
|
|
11
|
+
import StepsHeader from './StepsHeader'
|
|
12
|
+
import UploadDocument from './UploadDocument'
|
|
13
|
+
import { Table as StyledTable } from './Table'
|
|
14
|
+
import ErrorBoundary from './ErrorBoundary'
|
|
15
|
+
import FullScreenLoader from './FullScreenLoader'
|
|
16
|
+
import LoginForm from './LoginForm'
|
|
17
|
+
import { SideMenuHeader } from './Layout/SideMenuHeader'
|
|
18
|
+
import SideNav from './Layout/SideNav'
|
|
19
|
+
import { ListItemButton } from './ListItemButton'
|
|
20
|
+
import LayoutWrapper from './Layout/LayoutWrapper'
|
|
21
|
+
import PageNotFound from './PageNotFound'
|
|
22
|
+
import ChangePassword from './ChangePassword'
|
|
23
|
+
import UploadButton from './UploadButton'
|
|
24
|
+
import DialogWrapper from './DrawerWrapper/DialogWrapper'
|
|
25
|
+
import Form from './Form/Form'
|
|
26
|
+
import RenderForm from './Form/RenderForm'
|
|
27
|
+
import AsyncSearchSelect from './Input/AsyncSearchSelect'
|
|
28
|
+
import FilterButton from './FilterComponents/FilterButton'
|
|
29
|
+
import Helmet from './Layout/Helmet'
|
|
30
|
+
import NavigationTabs from './Tabs/NavigationTabs'
|
|
31
|
+
export { default as Image } from './Image'
|
|
32
|
+
export { default as PageHeader } from './PageHeader'
|
|
33
|
+
export { PageContent } from './PageContent'
|
|
34
|
+
export { default as ActionButton } from './ActionButton'
|
|
35
|
+
export { default as Breadcrumbs } from './Breadcrumbs'
|
|
36
|
+
export { default as Table } from './TableComponent'
|
|
37
|
+
export { default as Spinner } from './Spinner'
|
|
38
|
+
export { default as AutocompleteSearch } from './AutocompleteSearch'
|
|
39
|
+
export { FullCalendarWrapper } from './FullCalendar/FullCalendarWrapper'
|
|
40
|
+
export { default as JsonPreview } from './JsonPreview'
|
|
41
|
+
export { default as LabelValue } from './LabelValue'
|
|
42
|
+
export { LinearProgress } from './LinearProgress'
|
|
43
|
+
export { default as MediaRow } from './MediaRow'
|
|
44
|
+
export { default as NoDataIllustration } from './NoDataIllustration'
|
|
45
|
+
export { default as SwitchButton } from './SwitchButton'
|
|
46
|
+
export { default as Tabs } from './Tabs/Tabs'
|
|
47
|
+
export { default as ToastContainer } from './ToastContainer'
|
|
48
|
+
export { default as Card } from './Card'
|
|
49
|
+
export { default as CardsGrid } from './CardsGrid'
|
|
50
|
+
export { default as DividerHeading } from './DividerHeading'
|
|
51
|
+
export { default as ReactTable } from './TableComponent/ReactTable'
|
|
52
|
+
export { default as TableFooter } from './TableComponent/TableFooter'
|
|
53
|
+
export { default as DropDownButton } from './DropDownButton'
|
|
54
|
+
export { default as useConfirm } from './PopupConfirm/useConfirm'
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
UploadFileDialog,
|
|
58
|
+
Chips,
|
|
59
|
+
ImageUpload,
|
|
60
|
+
FloatingContainer,
|
|
61
|
+
TabsContainer,
|
|
62
|
+
StyledTableContainer,
|
|
63
|
+
SearchBar,
|
|
64
|
+
DrawerButton,
|
|
65
|
+
DialogButton,
|
|
66
|
+
DetailsGrid,
|
|
67
|
+
AppHeader,
|
|
68
|
+
StepsHeader,
|
|
69
|
+
UploadDocument,
|
|
70
|
+
StyledTable,
|
|
71
|
+
ErrorBoundary,
|
|
72
|
+
FullScreenLoader,
|
|
73
|
+
LoginForm,
|
|
74
|
+
SideMenuHeader,
|
|
75
|
+
ListItemButton,
|
|
76
|
+
LayoutWrapper,
|
|
77
|
+
PageNotFound,
|
|
78
|
+
SideNav,
|
|
79
|
+
ChangePassword,
|
|
80
|
+
UploadButton,
|
|
81
|
+
DialogWrapper,
|
|
82
|
+
Form,
|
|
83
|
+
RenderForm,
|
|
84
|
+
AsyncSearchSelect,
|
|
85
|
+
FilterButton,
|
|
86
|
+
Helmet,
|
|
87
|
+
NavigationTabs,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export * from './UploadButton/types'
|
|
91
|
+
export * from './HookForm'
|
|
92
|
+
export * from './Input'
|
|
93
|
+
export * from './IconButtons'
|