@campxdev/shared 1.2.9 → 1.3.1
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 +2 -1
- package/src/components/ActionButton.tsx +9 -18
- package/src/components/ChangePassword.tsx +65 -106
- package/src/components/DropDownButton/DropDownButton.tsx +173 -0
- package/src/components/DropDownButton/index.tsx +1 -0
- package/src/components/DropDownButton/styles.tsx +29 -0
- package/src/components/Layout/Header/AppHeader.tsx +14 -35
- package/src/components/Layout/Header/CogWheelMenu.tsx +6 -6
- package/src/components/Layout/Header/HelpWidget/HelpWidget.tsx +182 -208
- package/src/components/Layout/Header/HelpWidget/styles.tsx +15 -15
- package/src/components/Layout/Header/UserBox.tsx +51 -61
- package/src/components/Layout/Header/icons.tsx +2 -2
- package/src/components/Layout/Header/styles.tsx +27 -1
- package/src/components/Layout/Tickets/MyTickets.tsx +24 -28
- package/src/components/Layout/Tickets/TicketDetails.tsx +9 -10
- package/src/components/Layout/Tickets/{Services.tsx → services.ts} +5 -0
- package/src/components/ModalButtons/DialogButton.tsx +38 -33
- package/src/components/ModalButtons/DrawerButton.tsx +21 -25
- package/src/components/TableComponent/BatchActionsHeader.tsx +1 -1
- package/src/components/TableComponent/TableFooter/TableFooter.tsx +12 -10
- package/src/components/index.ts +0 -2
- package/src/hooks/useAuth.ts +1 -1
- package/src/theme/muiTheme.ts +19 -15
- package/src/components/DropDownButton.tsx +0 -194
- package/src/components/MenuButton.tsx +0 -103
|
@@ -20,12 +20,12 @@ import { useState } from 'react'
|
|
|
20
20
|
import { useForm } from 'react-hook-form'
|
|
21
21
|
import { useQuery } from 'react-query'
|
|
22
22
|
import { toast } from 'react-toastify'
|
|
23
|
+
import * as yup from 'yup'
|
|
23
24
|
import axios, { axiosErrorToast } from '../../../../config/axios'
|
|
24
25
|
import { queryClient } from '../../../../contexts/QueryClientProvider'
|
|
25
26
|
import { FormSingleSelect, FormTextField } from '../../../HookForm'
|
|
26
27
|
import ImageUpload from '../../../ImageUpload'
|
|
27
28
|
import MediaRow from '../../../MediaRow'
|
|
28
|
-
import * as yup from 'yup'
|
|
29
29
|
import Spinner from '../../../Spinner'
|
|
30
30
|
import { Media } from '../../../UploadButton/types'
|
|
31
31
|
import {
|
|
@@ -35,7 +35,9 @@ import {
|
|
|
35
35
|
StyledDialog,
|
|
36
36
|
StyledDialogCard,
|
|
37
37
|
StyledDialogHeader,
|
|
38
|
+
Transition,
|
|
38
39
|
} from './styles'
|
|
40
|
+
|
|
39
41
|
const schema = yup.object().shape({
|
|
40
42
|
name: yup.string().required('Name is required'),
|
|
41
43
|
subject: yup.string().required('Subject is required'),
|
|
@@ -43,28 +45,139 @@ const schema = yup.object().shape({
|
|
|
43
45
|
categoryId: yup.string().required('Category is required'),
|
|
44
46
|
serviceId: yup.string().required('Service is required'),
|
|
45
47
|
})
|
|
46
|
-
|
|
48
|
+
|
|
49
|
+
const HelpWidgetButton = () => {
|
|
47
50
|
const [open, setOpen] = useState(false)
|
|
51
|
+
|
|
52
|
+
const onOpen = () => {
|
|
53
|
+
setOpen(true)
|
|
54
|
+
}
|
|
55
|
+
const onClose = () => {
|
|
56
|
+
setOpen(false)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<IconButton color="secondary">
|
|
62
|
+
<HelpOutline onClick={onOpen} />
|
|
63
|
+
</IconButton>
|
|
64
|
+
<HelpWidget onClose={onClose} open={open} />
|
|
65
|
+
</>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default HelpWidgetButton
|
|
70
|
+
|
|
71
|
+
const HelpWidget = ({ open, onClose }) => {
|
|
72
|
+
const [state, setState] = useState(0)
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<StyledDialog
|
|
76
|
+
fullWidth
|
|
77
|
+
onClose={onClose}
|
|
78
|
+
open={open}
|
|
79
|
+
PaperProps={{
|
|
80
|
+
elevation: 2,
|
|
81
|
+
sx: { borderRadius: '10px' },
|
|
82
|
+
}}
|
|
83
|
+
transitionDuration={200}
|
|
84
|
+
TransitionComponent={Transition}
|
|
85
|
+
>
|
|
86
|
+
{state == 0 ? (
|
|
87
|
+
<>
|
|
88
|
+
<StyledDialogHeader>
|
|
89
|
+
<IconButton onClick={onClose}>
|
|
90
|
+
<Close sx={{ position: 'absolute', color: 'white', top: 5 }} />
|
|
91
|
+
</IconButton>
|
|
92
|
+
</StyledDialogHeader>
|
|
93
|
+
<DialogContent sx={{ padding: '0' }}>
|
|
94
|
+
<Box>
|
|
95
|
+
<StyledCard>
|
|
96
|
+
<Box
|
|
97
|
+
sx={{ display: 'flex', gap: '10px', alignItems: 'center' }}
|
|
98
|
+
>
|
|
99
|
+
<NotesSharp />
|
|
100
|
+
<Typography variant="h5" sx={{ fontSize: '14px' }}>
|
|
101
|
+
Knowledge Base
|
|
102
|
+
</Typography>
|
|
103
|
+
</Box>
|
|
104
|
+
<ArrowForwardIos sx={{ width: '15px', color: 'blue' }} />
|
|
105
|
+
</StyledCard>
|
|
106
|
+
</Box>
|
|
107
|
+
<Box sx={{ padding: '15px 20px 20px 20px' }}>
|
|
108
|
+
<Card
|
|
109
|
+
sx={{
|
|
110
|
+
boxShadow: '0px 3px 15px #0000001A',
|
|
111
|
+
padding: '20px 15px',
|
|
112
|
+
marginTop: '30px',
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
<Stack gap={1}>
|
|
116
|
+
<Typography variant="h3">Want to get in touch?</Typography>
|
|
117
|
+
<Typography variant="subtitle2" sx={{ maxWidth: '290px' }}>
|
|
118
|
+
We’re standing by to answer all of your questions right now.
|
|
119
|
+
</Typography>
|
|
120
|
+
</Stack>
|
|
121
|
+
<Button
|
|
122
|
+
fullWidth
|
|
123
|
+
sx={{
|
|
124
|
+
borderRadius: '8px',
|
|
125
|
+
marginTop: '15px',
|
|
126
|
+
height: '50px',
|
|
127
|
+
}}
|
|
128
|
+
onClick={() => setState(1)}
|
|
129
|
+
>
|
|
130
|
+
Contact Us
|
|
131
|
+
</Button>
|
|
132
|
+
</Card>
|
|
133
|
+
</Box>
|
|
134
|
+
</DialogContent>
|
|
135
|
+
</>
|
|
136
|
+
) : (
|
|
137
|
+
<>
|
|
138
|
+
<Box>
|
|
139
|
+
<StyledContactHeader>
|
|
140
|
+
<StyledContactBoxHeader onClick={() => setState(0)}>
|
|
141
|
+
<ArrowBackIosNew sx={{ fontSize: 'small', color: 'white' }} />
|
|
142
|
+
<Typography sx={{ color: 'white' }} variant="h3">
|
|
143
|
+
Contact Us
|
|
144
|
+
</Typography>
|
|
145
|
+
</StyledContactBoxHeader>
|
|
146
|
+
<IconButton onClick={onClose}>
|
|
147
|
+
<Close
|
|
148
|
+
sx={{
|
|
149
|
+
position: 'absolute',
|
|
150
|
+
color: 'white',
|
|
151
|
+
top: 5,
|
|
152
|
+
right: 2,
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
</IconButton>
|
|
156
|
+
</StyledContactHeader>
|
|
157
|
+
<DialogContent sx={{ height: '500px' }}>
|
|
158
|
+
<StyledDialogCard>
|
|
159
|
+
<HelpWidgetForm onClose={onClose} />
|
|
160
|
+
</StyledDialogCard>
|
|
161
|
+
</DialogContent>
|
|
162
|
+
</Box>
|
|
163
|
+
</>
|
|
164
|
+
)}
|
|
165
|
+
</StyledDialog>
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const HelpWidgetForm = ({ onClose }) => {
|
|
170
|
+
const [uploadMedia, setUploadMedia] = useState<Media[]>([])
|
|
171
|
+
|
|
48
172
|
const { control, handleSubmit, watch, reset } = useForm({
|
|
49
173
|
resolver: yupResolver(schema),
|
|
50
174
|
})
|
|
51
|
-
const [state, setState] = useState(0)
|
|
52
175
|
const { data: ticketCategories, isLoading } = useQuery(
|
|
53
176
|
'ticketCategories',
|
|
54
177
|
() =>
|
|
55
178
|
axios.get(`/square/service-tickets/categories`).then((res) => res.data),
|
|
56
179
|
)
|
|
57
|
-
// console.log(ticketCategories)
|
|
58
|
-
const [uploadMedia, setUploadMedia] = useState<Media[]>([])
|
|
59
180
|
|
|
60
|
-
const handleClickOpen = () => {
|
|
61
|
-
setOpen(true)
|
|
62
|
-
setState(0)
|
|
63
|
-
}
|
|
64
|
-
const handleClose = () => {
|
|
65
|
-
setOpen(false)
|
|
66
|
-
reset()
|
|
67
|
-
}
|
|
68
181
|
const handleUploadImageChange = (v) => {
|
|
69
182
|
setUploadMedia([
|
|
70
183
|
...uploadMedia,
|
|
@@ -90,210 +203,71 @@ const HelpWidget = () => {
|
|
|
90
203
|
await axios(config)
|
|
91
204
|
queryClient.invalidateQueries('ticketCategories')
|
|
92
205
|
toast.success('Ticket Created Successfully')
|
|
93
|
-
handleClose()
|
|
94
206
|
reset()
|
|
207
|
+
onClose()
|
|
95
208
|
setUploadMedia([])
|
|
96
209
|
} catch (error) {
|
|
97
210
|
axiosErrorToast(error)
|
|
98
211
|
}
|
|
99
212
|
}
|
|
100
|
-
if (isLoading) return <Spinner />
|
|
101
213
|
|
|
214
|
+
if (isLoading) return <Spinner />
|
|
102
215
|
return (
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
padding: '20px 15px',
|
|
144
|
-
marginTop: '30px',
|
|
145
|
-
}}
|
|
146
|
-
>
|
|
147
|
-
<Stack gap={1}>
|
|
148
|
-
<Typography variant="h3">Want to get in touch?</Typography>
|
|
149
|
-
<Typography variant="subtitle2" sx={{ maxWidth: '290px' }}>
|
|
150
|
-
We’re standing by to answer all of your questions right
|
|
151
|
-
now.
|
|
152
|
-
</Typography>
|
|
153
|
-
</Stack>
|
|
154
|
-
<Button
|
|
155
|
-
fullWidth
|
|
156
|
-
sx={{
|
|
157
|
-
borderRadius: '8px',
|
|
158
|
-
marginTop: '15px',
|
|
159
|
-
height: '50px',
|
|
160
|
-
}}
|
|
161
|
-
onClick={() => setState(1)}
|
|
162
|
-
>
|
|
163
|
-
Contact Us
|
|
164
|
-
</Button>
|
|
165
|
-
</Card>
|
|
166
|
-
</Box>
|
|
167
|
-
</DialogContent>
|
|
168
|
-
</>
|
|
216
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
217
|
+
<Stack gap={'20px'}>
|
|
218
|
+
<FormTextField label={'Your Name'} name={'name'} control={control} />
|
|
219
|
+
<FormTextField label={'Subject'} name={'subject'} control={control} />
|
|
220
|
+
<FormTextField
|
|
221
|
+
label={'Description'}
|
|
222
|
+
name={'description'}
|
|
223
|
+
control={control}
|
|
224
|
+
multiline
|
|
225
|
+
rows={5}
|
|
226
|
+
required
|
|
227
|
+
/>
|
|
228
|
+
<FormSingleSelect
|
|
229
|
+
label={'Category'}
|
|
230
|
+
name={'categoryId'}
|
|
231
|
+
control={control}
|
|
232
|
+
options={ticketCategories?.map((item) => {
|
|
233
|
+
return { label: item.name, value: item._id }
|
|
234
|
+
})}
|
|
235
|
+
required
|
|
236
|
+
/>
|
|
237
|
+
<FormSingleSelect
|
|
238
|
+
label={'Service'}
|
|
239
|
+
name={'serviceId'}
|
|
240
|
+
control={control}
|
|
241
|
+
options={
|
|
242
|
+
ticketCategories
|
|
243
|
+
?.find((item) => item?._id === watch('categoryId'))
|
|
244
|
+
?.services?.map((item) => ({
|
|
245
|
+
label: item.name,
|
|
246
|
+
value: item._id,
|
|
247
|
+
})) ?? []
|
|
248
|
+
}
|
|
249
|
+
required
|
|
250
|
+
/>
|
|
251
|
+
{!uploadMedia?.length ? (
|
|
252
|
+
<ImageUpload
|
|
253
|
+
onFileUploaded={handleUploadImageChange}
|
|
254
|
+
postUrl="/square/tickets/upload-issue-file"
|
|
255
|
+
/>
|
|
169
256
|
) : (
|
|
170
|
-
|
|
171
|
-
<Box>
|
|
172
|
-
<StyledContactHeader>
|
|
173
|
-
<StyledContactBoxHeader onClick={() => setState(0)}>
|
|
174
|
-
<ArrowBackIosNew sx={{ fontSize: 'small', color: 'white' }} />
|
|
175
|
-
<Typography sx={{ color: 'white' }} variant="h3">
|
|
176
|
-
Contact Us
|
|
177
|
-
</Typography>
|
|
178
|
-
</StyledContactBoxHeader>
|
|
179
|
-
<IconButton onClick={handleClose}>
|
|
180
|
-
<Close
|
|
181
|
-
sx={{
|
|
182
|
-
position: 'absolute',
|
|
183
|
-
color: 'white',
|
|
184
|
-
top: 5,
|
|
185
|
-
right: 2,
|
|
186
|
-
}}
|
|
187
|
-
/>
|
|
188
|
-
</IconButton>
|
|
189
|
-
</StyledContactHeader>
|
|
190
|
-
<DialogContent sx={{ height: '500px' }}>
|
|
191
|
-
<StyledDialogCard>
|
|
192
|
-
<form onSubmit={handleSubmit(onSubmit)}>
|
|
193
|
-
<Stack gap={'20px'}>
|
|
194
|
-
<FormTextField
|
|
195
|
-
label={'Your Name'}
|
|
196
|
-
name={'name'}
|
|
197
|
-
control={control}
|
|
198
|
-
/>
|
|
199
|
-
<FormTextField
|
|
200
|
-
label={'Subject'}
|
|
201
|
-
name={'subject'}
|
|
202
|
-
control={control}
|
|
203
|
-
/>
|
|
204
|
-
<FormTextField
|
|
205
|
-
label={'Description'}
|
|
206
|
-
name={'description'}
|
|
207
|
-
control={control}
|
|
208
|
-
multiline
|
|
209
|
-
rows={5}
|
|
210
|
-
required
|
|
211
|
-
/>
|
|
212
|
-
<FormSingleSelect
|
|
213
|
-
label={'Category'}
|
|
214
|
-
name={'categoryId'}
|
|
215
|
-
control={control}
|
|
216
|
-
options={ticketCategories?.map((item) => {
|
|
217
|
-
return { label: item.name, value: item._id }
|
|
218
|
-
})}
|
|
219
|
-
// onChange={(value) => {
|
|
220
|
-
// mutate({ id: value })
|
|
221
|
-
// }}
|
|
222
|
-
required
|
|
223
|
-
/>
|
|
224
|
-
<FormSingleSelect
|
|
225
|
-
label={'Service'}
|
|
226
|
-
name={'serviceId'}
|
|
227
|
-
control={control}
|
|
228
|
-
options={
|
|
229
|
-
ticketCategories
|
|
230
|
-
?.find((item) => item?._id === watch('categoryId'))
|
|
231
|
-
?.services?.map((item) => ({
|
|
232
|
-
label: item.name,
|
|
233
|
-
value: item._id,
|
|
234
|
-
})) ?? []
|
|
235
|
-
}
|
|
236
|
-
required
|
|
237
|
-
/>
|
|
238
|
-
|
|
239
|
-
{/* <StyledContactCard>
|
|
240
|
-
<Screenshot />
|
|
241
|
-
<Typography sx={{ fontSize: '12px' }} variant="h5">
|
|
242
|
-
Take screenshot
|
|
243
|
-
</Typography>
|
|
244
|
-
</StyledContactCard> */}
|
|
245
|
-
{/* <StyledContactCard
|
|
246
|
-
sx={{
|
|
247
|
-
minHeight: '120px',
|
|
248
|
-
flexDirection: 'column',
|
|
249
|
-
border: '2px dashed #0000001A',
|
|
250
|
-
}}
|
|
251
|
-
> */}
|
|
252
|
-
{/* <Upload />
|
|
253
|
-
<Typography sx={{ fontSize: '12px' }} variant="h5">
|
|
254
|
-
Upload files (max 5)
|
|
255
|
-
</Typography>
|
|
256
|
-
<Typography variant="h4" sx={{ fontSize: '10px' }}>
|
|
257
|
-
Click to add or drag & drop files
|
|
258
|
-
</Typography> */}
|
|
259
|
-
{/* category id , service id and priority is required */}
|
|
260
|
-
{!uploadMedia?.length ? (
|
|
261
|
-
<ImageUpload
|
|
262
|
-
onFileUploaded={handleUploadImageChange}
|
|
263
|
-
postUrl="/square/tickets/upload-issue-file"
|
|
264
|
-
// postUrl="/"
|
|
265
|
-
/>
|
|
266
|
-
) : (
|
|
267
|
-
<MediaRow
|
|
268
|
-
list={uploadMedia}
|
|
269
|
-
onDelete={handleUploadDeleteImage}
|
|
270
|
-
/>
|
|
271
|
-
)}
|
|
272
|
-
{/* </StyledContactCard> */}
|
|
273
|
-
<Button
|
|
274
|
-
type="submit"
|
|
275
|
-
fullWidth
|
|
276
|
-
sx={{
|
|
277
|
-
height: '60px',
|
|
278
|
-
borderRadius: '10px',
|
|
279
|
-
fontSize: '18px',
|
|
280
|
-
}}
|
|
281
|
-
>
|
|
282
|
-
Send
|
|
283
|
-
</Button>
|
|
284
|
-
</Stack>
|
|
285
|
-
</form>
|
|
286
|
-
</StyledDialogCard>
|
|
287
|
-
</DialogContent>
|
|
288
|
-
</Box>
|
|
289
|
-
</>
|
|
257
|
+
<MediaRow list={uploadMedia} onDelete={handleUploadDeleteImage} />
|
|
290
258
|
)}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
259
|
+
<Button
|
|
260
|
+
type="submit"
|
|
261
|
+
fullWidth
|
|
262
|
+
sx={{
|
|
263
|
+
height: '60px',
|
|
264
|
+
borderRadius: '10px',
|
|
265
|
+
fontSize: '18px',
|
|
266
|
+
}}
|
|
267
|
+
>
|
|
268
|
+
Send
|
|
269
|
+
</Button>
|
|
270
|
+
</Stack>
|
|
271
|
+
</form>
|
|
297
272
|
)
|
|
298
273
|
}
|
|
299
|
-
export default HelpWidget
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { alpha, Box, Card, Dialog, styled } from '@mui/material'
|
|
1
|
+
import { alpha, Box, Card, Dialog, Slide, styled } from '@mui/material'
|
|
2
|
+
import { TransitionProps } from '@mui/material/transitions'
|
|
3
|
+
import { forwardRef } from 'react'
|
|
2
4
|
import { background, contactBg } from '../assets'
|
|
3
|
-
|
|
5
|
+
|
|
4
6
|
export const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
5
7
|
height: '180px',
|
|
6
8
|
backgroundColor: alpha(theme.palette.text.secondary, 0.1),
|
|
@@ -11,6 +13,7 @@ export const StyledDialogHeader = styled(Box)(({ theme }) => ({
|
|
|
11
13
|
justifyContent: 'flex-end',
|
|
12
14
|
padding: '0.6rem 1rem',
|
|
13
15
|
}))
|
|
16
|
+
|
|
14
17
|
export const StyledDialog = styled(Dialog)(() => ({
|
|
15
18
|
zIndex: 500,
|
|
16
19
|
transition: 'max-height 0.3s ease-in-out',
|
|
@@ -23,6 +26,7 @@ export const StyledDialog = styled(Dialog)(() => ({
|
|
|
23
26
|
},
|
|
24
27
|
},
|
|
25
28
|
}))
|
|
29
|
+
|
|
26
30
|
export const StyledCard = styled(Card)(() => ({
|
|
27
31
|
display: 'flex',
|
|
28
32
|
position: 'absolute',
|
|
@@ -45,19 +49,6 @@ export const StyledContactHeader = styled(Box)(({ theme }) => ({
|
|
|
45
49
|
padding: '0.6rem 1rem',
|
|
46
50
|
}))
|
|
47
51
|
|
|
48
|
-
// export const StyledContact = styled(Dialog)(() => ({
|
|
49
|
-
// zIndex: 500,
|
|
50
|
-
// height: '950px',
|
|
51
|
-
// '& .MuiDialog-container': {
|
|
52
|
-
// bottom: 0,
|
|
53
|
-
// justifyContent: 'flex-end',
|
|
54
|
-
// alignItems: 'end',
|
|
55
|
-
// '& .MuiPaper-root': {
|
|
56
|
-
// maxWidth: '380px',
|
|
57
|
-
// },
|
|
58
|
-
// },
|
|
59
|
-
// }))
|
|
60
|
-
|
|
61
52
|
export const StyledContactCard = styled(Card)(() => ({
|
|
62
53
|
minHeight: '50px',
|
|
63
54
|
display: 'flex',
|
|
@@ -92,3 +83,12 @@ export const StyledContactBoxHeader = styled(Box)(() => ({
|
|
|
92
83
|
gap: '5px',
|
|
93
84
|
cursor: 'pointer',
|
|
94
85
|
}))
|
|
86
|
+
|
|
87
|
+
export const Transition = forwardRef(function Transition(
|
|
88
|
+
props: TransitionProps & {
|
|
89
|
+
children: React.ReactElement
|
|
90
|
+
},
|
|
91
|
+
ref: React.Ref<unknown>,
|
|
92
|
+
) {
|
|
93
|
+
return <Slide direction="up" ref={ref} {...props} />
|
|
94
|
+
})
|
|
@@ -1,71 +1,70 @@
|
|
|
1
|
-
import { Box, Typography } from '@mui/material'
|
|
2
|
-
import { ReactNode, useState } from 'react'
|
|
3
|
-
import { avatarImage } from '../../../assets/images'
|
|
4
|
-
import MenuButton from '../../MenuButton'
|
|
5
|
-
import { StyledUser } from './styles'
|
|
6
|
-
import logout from '../../../utils/logout'
|
|
7
|
-
import ChangePassword from '../../ChangePassword'
|
|
8
1
|
import { ExitToAppOutlined, HttpsOutlined } from '@mui/icons-material'
|
|
9
2
|
import ConfirmationNumberOutlinedIcon from '@mui/icons-material/ConfirmationNumberOutlined'
|
|
10
|
-
import
|
|
3
|
+
import { ReactNode } from 'react'
|
|
4
|
+
import logout from '../../../utils/logout'
|
|
5
|
+
import ChangePassword from '../../ChangePassword'
|
|
6
|
+
import DropDownButton from '../../DropDownButton/DropDownButton'
|
|
7
|
+
import { DialogButton } from '../../ModalButtons'
|
|
11
8
|
import MyTickets from '../Tickets/MyTickets'
|
|
9
|
+
import { StyledAvatar } from './styles'
|
|
10
|
+
|
|
11
|
+
const getStartingLetters = (text: string) => {
|
|
12
|
+
if (!text) return ''
|
|
13
|
+
return text
|
|
14
|
+
.split(' ')
|
|
15
|
+
?.map((w) => w[0])
|
|
16
|
+
?.join('')
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
export default function UserBox({
|
|
14
|
-
|
|
15
|
-
profileIcon,
|
|
20
|
+
fullName,
|
|
16
21
|
actions,
|
|
17
22
|
}: {
|
|
18
|
-
|
|
19
|
-
profileIcon: string
|
|
23
|
+
fullName: string
|
|
20
24
|
actions: { label: ReactNode; icon?: ReactNode; onClick: any }[]
|
|
21
25
|
}) {
|
|
22
|
-
const [open, setOpen] = useState(false)
|
|
23
|
-
const [openTicket, setOpenTicket] = useState(false)
|
|
24
|
-
const handleClickOpen = () => {
|
|
25
|
-
setOpen(true)
|
|
26
|
-
}
|
|
27
|
-
const handleClose = (value: string) => {
|
|
28
|
-
setOpen(false)
|
|
29
|
-
}
|
|
30
|
-
const handleTicketOpen = () => {
|
|
31
|
-
setOpenTicket(true)
|
|
32
|
-
}
|
|
33
|
-
const handleTicketClose = () => {
|
|
34
|
-
setOpenTicket(false)
|
|
35
|
-
}
|
|
36
26
|
return (
|
|
37
27
|
<>
|
|
38
|
-
<
|
|
39
|
-
anchor={
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
style={{
|
|
45
|
-
height: '32px',
|
|
46
|
-
width: '32px',
|
|
47
|
-
objectFit: 'contain',
|
|
48
|
-
}}
|
|
49
|
-
onError={(e: any) => {
|
|
50
|
-
e.target.src = avatarImage
|
|
51
|
-
}}
|
|
52
|
-
/>
|
|
53
|
-
<Typography variant="h6">{username}</Typography>
|
|
54
|
-
</StyledUser>
|
|
55
|
-
</Box>
|
|
56
|
-
}
|
|
28
|
+
<DropDownButton
|
|
29
|
+
anchor={({ open }) => (
|
|
30
|
+
<StyledAvatar onClick={open}>
|
|
31
|
+
{getStartingLetters(fullName)}
|
|
32
|
+
</StyledAvatar>
|
|
33
|
+
)}
|
|
57
34
|
menu={[
|
|
58
35
|
...actions,
|
|
59
36
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
customButton: (
|
|
38
|
+
<DialogButton
|
|
39
|
+
dialogProps={{
|
|
40
|
+
maxWidth: 'xl',
|
|
41
|
+
}}
|
|
42
|
+
title="My Tickets"
|
|
43
|
+
anchor={({ open }) => (
|
|
44
|
+
<DropDownButton.MenuItem
|
|
45
|
+
onClick={open}
|
|
46
|
+
icon={<ConfirmationNumberOutlinedIcon />}
|
|
47
|
+
label="My Tickets"
|
|
48
|
+
/>
|
|
49
|
+
)}
|
|
50
|
+
content={({ close }) => <MyTickets close={close} />}
|
|
51
|
+
/>
|
|
52
|
+
),
|
|
63
53
|
},
|
|
64
|
-
|
|
65
54
|
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
customButton: (
|
|
56
|
+
<DialogButton
|
|
57
|
+
title="Change Password"
|
|
58
|
+
anchor={({ open }) => (
|
|
59
|
+
<DropDownButton.MenuItem
|
|
60
|
+
onClick={open}
|
|
61
|
+
icon={<HttpsOutlined />}
|
|
62
|
+
label="Change Password"
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
content={({ close }) => <ChangePassword close={close} />}
|
|
66
|
+
/>
|
|
67
|
+
),
|
|
69
68
|
},
|
|
70
69
|
{
|
|
71
70
|
label: 'Logout',
|
|
@@ -77,15 +76,6 @@ export default function UserBox({
|
|
|
77
76
|
PaperProps: { sx: { top: '64px !important' } },
|
|
78
77
|
}}
|
|
79
78
|
/>
|
|
80
|
-
<DialogWrapper
|
|
81
|
-
open={openTicket}
|
|
82
|
-
title={'All Tickets'}
|
|
83
|
-
children={<MyTickets />}
|
|
84
|
-
onClose={() => {
|
|
85
|
-
handleTicketClose()
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
<ChangePassword open={open} onClose={handleClose} />
|
|
89
79
|
</>
|
|
90
80
|
)
|
|
91
81
|
}
|