authscape 1.0.458 → 1.0.462

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.458",
3
+ "version": "1.0.462",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,381 @@
1
+ import React, {useEffect, useState} from 'react';
2
+ import { Box } from '@mui/system';
3
+ import Grid from '@mui/material/Grid';
4
+ import Tabs from '@mui/material/Tabs';
5
+ import Tab from '@mui/material/Tab';
6
+ import Typography from '@mui/material/Typography';
7
+ import InputLabel from '@mui/material/InputLabel';
8
+ import MenuItem from '@mui/material/MenuItem';
9
+ import FormControl from '@mui/material/FormControl';
10
+ import Select from '@mui/material/Select';
11
+ // import { apiService } from 'authscape';
12
+ import TextField from '@mui/material/TextField';
13
+ import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete';
14
+ // import Comments from '../comments';
15
+ import { Button, Card, CardActions, CardContent, CardMedia, Stack } from "@mui/material";
16
+ import InsertDriveFileRoundedIcon from '@mui/icons-material/InsertDriveFileRounded';
17
+ import ArrowBackIosRoundedIcon from '@mui/icons-material/ArrowBackIosRounded';
18
+
19
+ const TicketDetail = ({ticketId, setIsLoading, currentUser, GoBackToViewTickets = null, customTabName = null, customTabElement = null}) => {
20
+
21
+ const [value, setValue] = useState(0);
22
+ const [status, setStatus] = useState(null);
23
+ const [ticketType, setTicketType] = useState(null);
24
+ const [ticket, setTicket] = useState(null);
25
+ const [priorty, setPriority] = useState(0);
26
+ const [participants, setParticipants] = useState([]);
27
+ const [ticketAttachments, setTicketAttachments] = useState([]);
28
+ const [customTabPayload, setCustomTabPayload] = useState(null);
29
+
30
+ const [createdByList, setCreatedByList] = useState([]);
31
+ const [selectedCreatedBy, setSelectedCreatedBy] = useState(null);
32
+
33
+
34
+ useEffect(() => {
35
+
36
+ const fetchData = async () => {
37
+ setIsLoading(true);
38
+ let response = await apiService().get("/Ticket/GetTicket?ticketId=" + ticketId);
39
+ if (response != null && response.status == 200)
40
+ {
41
+ setTicket(response.data);
42
+
43
+ setIsLoading(false);
44
+ setStatus(response.data.selectedTicketStatusId);
45
+ setTicketType(response.data.selectedTicketTypeId);
46
+ setPriority(response.data.selectedPriortyId);
47
+ setSelectedCreatedBy(response.data.selectedCreatedBy);
48
+ setParticipants(response.data.participants);
49
+ setTicketAttachments(response.data.attachments);
50
+ setCustomTabPayload(response.data.customTabPayload)
51
+ }
52
+ }
53
+
54
+ fetchData();
55
+
56
+ }, []);
57
+
58
+ function TabPanel(props) {
59
+ const { children, value, index, ...other } = props;
60
+
61
+ return (
62
+ <div
63
+ role="tabpanel"
64
+ hidden={value !== index}
65
+ id={`simple-tabpanel-${index}`}
66
+ aria-labelledby={`simple-tab-${index}`}
67
+ {...other}
68
+ >
69
+ {value === index && (
70
+ <Box sx={{ p: 3 }}>
71
+ <Typography>{children}</Typography>
72
+ </Box>
73
+ )}
74
+ </div>
75
+ );
76
+ }
77
+
78
+ function a11yProps(index) {
79
+ return {
80
+ id: `simple-tab-${index}`,
81
+ 'aria-controls': `simple-tabpanel-${index}`,
82
+ };
83
+ }
84
+
85
+ const handleChange = (event, newValue) => {
86
+ setValue(newValue);
87
+ };
88
+
89
+ const refreshCreatedByList = async (query) => {
90
+
91
+ let response = await apiService().get("/ticket/findUser?query=" + query);
92
+ if (response != null && response.status == 200)
93
+ {
94
+ setCreatedByList(response.data);
95
+ }
96
+ }
97
+
98
+ const DownloadFile = ({fileName, uri}) => {
99
+
100
+ return (
101
+ <Card
102
+ sx={{
103
+ border: "1px solid black",
104
+ padding: "10px",
105
+ margin: "10px",
106
+ width: "200px",
107
+ textAlign:"center",
108
+ // display: "flex",
109
+ // alignItems: "center",
110
+ justifyContent: "space-between",
111
+ }}>
112
+ <Stack spacing={2}>
113
+ <Box sx={{textAlign:"center"}}>
114
+ <InsertDriveFileRoundedIcon sx={{fontSize:50}} />
115
+ </Box>
116
+ <Typography variant="h6" component="div">
117
+ {fileName}
118
+ </Typography>
119
+ <Button variant="contained" color="primary" onClick={() => {
120
+ window.open(uri);
121
+ }}>
122
+ Download
123
+ </Button>
124
+ </Stack>
125
+ </Card>
126
+ )
127
+ }
128
+
129
+ return (
130
+ <div>
131
+
132
+ <Box sx={{width: '100%' }}>
133
+
134
+ <Button variant="contained" startIcon={<ArrowBackIosRoundedIcon />} onClick={() => {
135
+
136
+ if (GoBackToViewTickets != null)
137
+ {
138
+ GoBackToViewTickets();
139
+ }
140
+
141
+ }}>Go Back</Button>
142
+
143
+
144
+ <Box>
145
+ <h2>{ticket != null && ticket.name}</h2>
146
+ </Box>
147
+
148
+ <Grid container spacing={2}>
149
+ <Grid item xs={4}>
150
+
151
+ <Box sx={{ minWidth: 120 }}>
152
+ <Box>
153
+ Status:
154
+ </Box>
155
+ <FormControl fullWidth>
156
+ <Select
157
+ labelId="demo-simple-select-label"
158
+ id="demo-simple-select"
159
+ value={status}
160
+ displayEmpty
161
+ inputProps={{ 'aria-label': 'Without label' }}
162
+ InputLabelProps={{ shrink: true }}
163
+ onChange={async (val) =>{
164
+ setStatus(val.target.value);
165
+
166
+ await apiService().put("/ticket/UpdateStatus", {
167
+ id: ticket.id,
168
+ ticketStatusId: val.target.value
169
+ });
170
+
171
+ }}>
172
+
173
+ {ticket != null && ticket.ticketStatuses.map((status, index) => {
174
+ return (
175
+ <MenuItem key={index} value={status.id}>{status.name}</MenuItem>
176
+ )
177
+ })}
178
+
179
+ </Select>
180
+ </FormControl>
181
+ </Box>
182
+
183
+ <Box sx={{paddingTop:2}}>
184
+ <Box>
185
+ Assigned to:
186
+ </Box>
187
+
188
+ {selectedCreatedBy != null &&
189
+ <Autocomplete
190
+ disablePortal
191
+ options={createdByList}
192
+ value={selectedCreatedBy}
193
+ onChange={async (event, newValue) => {
194
+ setSelectedCreatedBy(newValue.id);
195
+ }}
196
+ renderInput={(params) => <TextField {...params} label={""} onChange={(val) => {
197
+ refreshCreatedByList(val.currentTarget.value);
198
+ }} />}
199
+ />
200
+ }
201
+
202
+ {ticket != null &&
203
+ <>
204
+ <Box sx={{paddingTop:1, fontSize:18}}>
205
+ {ticket.assignedFirstName + " " + ticket.assignedLastName} ({ticket.assignedEmail})
206
+ </Box>
207
+ </>
208
+ }
209
+
210
+ </Box>
211
+
212
+ {/* <Box>
213
+ Company
214
+ </Box> */}
215
+
216
+ <Box sx={{paddingTop:2}}>
217
+ <Box sx={{ minWidth: 120 }}>
218
+ <Box>
219
+ Priority:
220
+ </Box>
221
+ <FormControl fullWidth>
222
+ <InputLabel id="demo-simple-select-label"></InputLabel>
223
+ <Select
224
+ labelId="demo-simple-select-label"
225
+ id="demo-simple-select"
226
+ value={priorty}
227
+ label=""
228
+ onChange={async (val) =>{
229
+ setPriority(val.target.value);
230
+
231
+ await apiService().put("/ticket/UpdateTicketPriority", {
232
+ id: ticket.id,
233
+ priorityLevel: val.target.value
234
+ });
235
+
236
+ }}>
237
+ <MenuItem value={0}>None</MenuItem>
238
+ <MenuItem value={1}>Low</MenuItem>
239
+ <MenuItem value={2}>Medium</MenuItem>
240
+ <MenuItem value={3}>High</MenuItem>
241
+ <MenuItem value={4}>Urgent</MenuItem>
242
+ </Select>
243
+ </FormControl>
244
+ </Box>
245
+ </Box>
246
+
247
+
248
+ </Grid>
249
+ <Grid item xs={4}>
250
+
251
+ <Box sx={{ minWidth: 120 }}>
252
+ <Box>
253
+ Ticket Type:
254
+ </Box>
255
+ <FormControl fullWidth>
256
+ <InputLabel id="demo-simple-select-label"></InputLabel>
257
+ <Select
258
+ labelId="demo-simple-select-label"
259
+ id="ticketType"
260
+ value={ticketType}
261
+ label=""
262
+ onChange={async (val) =>{
263
+ setTicketType(val.target.value);
264
+
265
+ await apiService().put("/ticket/UpdateTicketType", {
266
+ id: ticket.id,
267
+ TicketTypeId: val.target.value
268
+ });
269
+
270
+ }}>
271
+ {ticket != null && ticket.ticketTypes.map((status, index) => {
272
+ return (
273
+ <MenuItem key={index} value={status.id}>{status.name}</MenuItem>
274
+ )
275
+ })}
276
+
277
+ </Select>
278
+ </FormControl>
279
+ </Box>
280
+
281
+ <Box sx={{paddingTop:2}}>
282
+
283
+ <Box>
284
+ Participants:
285
+ </Box>
286
+ <Autocomplete
287
+ multiple={true}
288
+ disablePortal
289
+ value={participants}
290
+ options={createdByList}
291
+ onChange={async (event, newValue) => {
292
+
293
+ // alert(JSON.stringify(newValue));
294
+
295
+ await apiService().put("/ticket/UpdateParticipants", {
296
+ ticketId: router.query.id,
297
+ participants: newValue
298
+ });
299
+
300
+ setParticipants(newValue);
301
+ }}
302
+ renderInput={(params) => <TextField {...params} label={""} onChange={(val) => {
303
+ refreshCreatedByList(val.currentTarget.value);
304
+ }} />}
305
+ />
306
+ {/* <TextField id="lastUpdated" fullWidth={true} InputLabelProps={{ shrink: true }} disabled={true} label="Participants" variant="outlined" autoFocus={true} value={(ticket != null ? ticket.lastUpdated : "")} /> */}
307
+ </Box>
308
+ </Grid>
309
+ <Grid item xs={4}>
310
+ <Box>
311
+ <Box>
312
+ Created:
313
+ </Box>
314
+ <TextField id="created" fullWidth={true} InputLabelProps={{ shrink: true }} disabled={true} label="" variant="outlined" autoFocus={true} value={(ticket != null ? ticket.created : "")} />
315
+ </Box>
316
+ <Box sx={{paddingTop:2}}>
317
+ <Box>
318
+ Last Updated:
319
+ </Box>
320
+ <TextField id="lastUpdated" fullWidth={true} InputLabelProps={{ shrink: true }} disabled={true} label="" variant="outlined" autoFocus={true} value={(ticket != null ? ticket.lastUpdated : "")} />
321
+ </Box>
322
+ </Grid>
323
+ </Grid>
324
+ </Box>
325
+
326
+ <Box sx={{ width: '100%', marginTop:2 }}>
327
+ <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
328
+ <Tabs value={value} onChange={handleChange} aria-label="basic tabs example">
329
+ <Tab label="Chat" {...a11yProps(0)} />
330
+ <Tab label="Notes" {...a11yProps(1)} />
331
+ <Tab label="Attachments" {...a11yProps(2)} />
332
+
333
+ {customTabName != null &&
334
+ <Tab label={customTabName} {...a11yProps(3)} />
335
+ }
336
+
337
+ </Tabs>
338
+ </Box>
339
+ <TabPanel value={value} index={0}>
340
+
341
+ {ticket != null &&
342
+ <Comments ticketId={ticket.id} isDisabled={false} isNote={false} currentUser={currentUser} />
343
+ }
344
+ </TabPanel>
345
+ <TabPanel value={value} index={1}>
346
+ {ticket != null &&
347
+ <Comments ticketId={ticket.id} isDisabled={false} isNote={true} currentUser={currentUser} />
348
+ }
349
+ </TabPanel>
350
+ <TabPanel value={value} index={2}>
351
+ {ticket != null &&
352
+ <>
353
+ {ticketAttachments.map((attachment) => {
354
+ return (
355
+ <DownloadFile fileName={attachment.name} uri={attachment.url} />
356
+ )
357
+ })}
358
+
359
+ {ticketAttachments.length == 0 &&
360
+ <Box>
361
+ There are no attachments
362
+ </Box>
363
+ }
364
+
365
+ </>
366
+ }
367
+ </TabPanel>
368
+
369
+ {customTabName != null &&
370
+ <TabPanel value={value} index={3}>
371
+ {customTabElement(customTabPayload)}
372
+ </TabPanel>
373
+ }
374
+
375
+ </Box>
376
+
377
+ </div>
378
+ )
379
+ }
380
+
381
+ export default TicketDetail;
@@ -0,0 +1,247 @@
1
+ import React, {useEffect, useState} from 'react';
2
+ // import {apiService, authService} from 'authscape';
3
+ import Button from '@mui/material/Button';
4
+ import { Box } from '@mui/system';
5
+ import {
6
+ DataGrid,
7
+ GridActionsCellItem,
8
+ } from "@mui/x-data-grid";
9
+ import DeleteRoundedIcon from "@mui/icons-material/DeleteRounded";
10
+ import Typography from '@mui/material/Typography';
11
+ import AppBar from '@mui/material/AppBar';
12
+ import Toolbar from '@mui/material/Toolbar';
13
+ import YesNoDialog from '../../components/yesNoDialog';
14
+ import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded';
15
+ import AddRoundedIcon from '@mui/icons-material/AddRounded';
16
+ import InputLabel from '@mui/material/InputLabel';
17
+ import MenuItem from '@mui/material/MenuItem';
18
+ import FormControl from '@mui/material/FormControl';
19
+ import Select, { SelectChangeEvent } from '@mui/material/Select';
20
+ import Grid from '@mui/material/Grid';
21
+ // import TicketDetail from './TicketDetail';
22
+ import { useRouter } from 'next/router';
23
+
24
+ export default function Tickets({loadedUser, setIsLoading, currentUser, customTabName = null, customTabElement = null }) {
25
+
26
+ const [tickets, setTickets] = useState([]);
27
+
28
+ const [archiveTicketId, setArchiveTicketId] = useState(null);
29
+ const [totalTickets, setTotalTickets] = useState(0);
30
+ const [pageNumber, setPageNumber] = useState(1);
31
+
32
+ const [ticketStatuses, setTicketStatuses] = useState([]);
33
+ const [ticketTypes, setTicketTypes] = useState([]);
34
+
35
+ const [ticketTypeId, setTicketTypeId] = useState(null);
36
+ const [statusId, setStatusId] = useState(null);
37
+
38
+ const [selectedTicketId, setSelectedTicketId] = useState(null);
39
+
40
+ const router = useRouter();
41
+
42
+
43
+ useEffect(() => {
44
+
45
+ if (router.query.id != null)
46
+ {
47
+ setSelectedTicketId(router.query.id);
48
+ }
49
+
50
+ }, [router.isReady])
51
+
52
+ const columns = [
53
+ { field: 'id', headerName: 'Id', width: 150 },
54
+ { field: 'title', flex: 1, headerName: 'Customer', width: 200 },
55
+ { field: 'ticketStatus', headerName: 'Status', width: 150 },
56
+ { field: 'ticketType', headerName: 'Ticket Type', width: 150 },
57
+ { field: 'created', headerName: 'Created', width: 150 },
58
+ { field: 'ticketParticipants', headerName: 'Participants', width: 150 },
59
+ { field: 'messages', headerName: 'Messages', width: 150 },
60
+ {
61
+ field: "actions",
62
+ type: "actions",
63
+ width: 200,
64
+ headerName: "Actions",
65
+ cellClassName: "actions",
66
+ getActions: ({ id, row }) => {
67
+ return [
68
+ <GridActionsCellItem key={id}
69
+ icon={<VisibilityRoundedIcon />}
70
+ label="View"
71
+ onClick={() => {
72
+ setSelectedTicketId(row.id);
73
+ }}
74
+ />,
75
+ <GridActionsCellItem key={id}
76
+ icon={<DeleteRoundedIcon />}
77
+ label="Delete"
78
+ className="textPrimary"
79
+ onClick={() => {
80
+ setArchiveTicketId(row.id);
81
+ }}
82
+ />,
83
+ ];
84
+ },
85
+ }
86
+ ];
87
+
88
+ const reloadTickets = async () => {
89
+ let response = await apiService().get("/ticket/GetTickets?pageNumber=" + pageNumber + "&pageSize=20&ticketStatusId=" + (statusId != null ? statusId: "") + "&ticketTypeId=" + (ticketTypeId != null ? ticketTypeId : ""));
90
+ if (response != null && response.status == 200)
91
+ {
92
+ setTotalTickets(response.data.data.length);
93
+ setTickets(response.data.data);
94
+ }
95
+ }
96
+
97
+ useEffect(() => {
98
+
99
+ if (loadedUser)
100
+ {
101
+ let fetchStatusesAndTypes = async () => {
102
+ let responseStatus = await apiService().get("/Ticket/GetStatuses");
103
+ if (responseStatus != null && responseStatus.status == 200)
104
+ {
105
+ setTicketStatuses(responseStatus.data);
106
+ }
107
+
108
+ let responseType = await apiService().get("/Ticket/GetTicketTypes");
109
+ if (responseType != null && responseType.status == 200)
110
+ {
111
+ setTicketTypes(responseType.data);
112
+ }
113
+ }
114
+
115
+ fetchStatusesAndTypes();
116
+ setTicketStatuses();
117
+ }
118
+
119
+ }, [loadedUser]);
120
+
121
+
122
+ useEffect(() => {
123
+
124
+ if (loadedUser)
125
+ {
126
+ reloadTickets();
127
+ }
128
+
129
+ }, [loadedUser, ticketTypeId, statusId]);
130
+
131
+ return (
132
+ <div>
133
+
134
+ {selectedTicketId != null &&
135
+ <TicketDetail ticketId={selectedTicketId} setIsLoading={setIsLoading} currentUser={currentUser} customTabName={customTabName} customTabElement={customTabElement} GoBackToViewTickets={() =>
136
+ {
137
+ setSelectedTicketId(null);
138
+ }} />
139
+ }
140
+ {selectedTicketId == null &&
141
+ <>
142
+ <Box sx={{ flexGrow: 1 }}>
143
+ <AppBar position="static" color='inherit' elevation={0}>
144
+ <Toolbar>
145
+ <Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
146
+ Tickets
147
+ </Typography>
148
+ <Button color="primary" variant="contained" startIcon={<AddRoundedIcon/>} onClick={async () => {
149
+
150
+ let response = await apiService().post("/Ticket/CreateTicket", {
151
+ ticketTypeId: 1,
152
+ ticketStatusId: 1,
153
+ description: "about this",
154
+ message: "More about this"
155
+ });
156
+
157
+ window.location.href = "/ticket/" + response.data;
158
+
159
+ }}>Create Ticket</Button>
160
+ </Toolbar>
161
+ </AppBar>
162
+ </Box>
163
+
164
+ <Grid container spacing={2} sx={{paddingTop:2, paddingBottom:2}}>
165
+ <Grid item xs={4}>
166
+
167
+ <Box>
168
+ <FormControl fullWidth>
169
+ <InputLabel id="demo-simple-select-label">Ticket Status</InputLabel>
170
+ <Select
171
+ labelId="demo-simple-select-label"
172
+ id="demo-simple-select"
173
+ value={statusId}
174
+ label="ticketStatus"
175
+ onChange={(event) => {
176
+ setStatusId(event.target.value);
177
+ }}>
178
+
179
+ <MenuItem value={null}>Not Assigned</MenuItem>
180
+
181
+ {ticketStatuses != null && ticketStatuses.map((tStatus) => {
182
+ return (
183
+ <MenuItem value={tStatus.id}>{tStatus.name}</MenuItem>
184
+ )
185
+ })}
186
+
187
+ </Select>
188
+ </FormControl>
189
+ </Box>
190
+
191
+ </Grid>
192
+ <Grid item xs={4}>
193
+
194
+ <Box>
195
+ <FormControl fullWidth>
196
+ <InputLabel id="demo-simple-select-label">Ticket Type</InputLabel>
197
+ <Select
198
+ labelId="demo-simple-select-label"
199
+ id="demo-simple-select"
200
+ value={ticketTypeId}
201
+ label="TicketType"
202
+ onChange={(event) => {
203
+ setTicketTypeId(event.target.value);
204
+ }}>
205
+
206
+ <MenuItem value={null}>Not Assigned</MenuItem>
207
+
208
+ {ticketTypes != null && ticketTypes.map((tTicketType) => {
209
+ return (
210
+ <MenuItem value={tTicketType.id}>{tTicketType.name}</MenuItem>
211
+ )
212
+ })}
213
+
214
+ </Select>
215
+ </FormControl>
216
+ </Box>
217
+
218
+ </Grid>
219
+ </Grid>
220
+
221
+ <Box sx={{height: 600, width: '100%' }}>
222
+ <DataGrid
223
+ rows={tickets}
224
+ columns={columns}
225
+ onPageChange={(newPage) => {
226
+ setPageNumber(newPage);
227
+ }}
228
+ pageSize={totalTickets}
229
+ rowsPerPageOptions={[20]}
230
+ />
231
+ </Box>
232
+
233
+ <YesNoDialog open={archiveTicketId != null ? true : false} title={"Remove Ticket"} message={"Are you sure you want to archive this ticket?"}
234
+ YesAction={async () => {
235
+ await apiService().delete("/Ticket/ArchiveTicket?id=" + archiveTicketId);
236
+ await reloadTickets();
237
+ setArchiveTicketId(null);
238
+ }}
239
+ NoAction={() => {
240
+ setArchiveTicketId(null);
241
+ }} />
242
+ </>
243
+ }
244
+ </div>
245
+
246
+ )
247
+ }