authscape-tickets 1.0.14
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/.babelrc +3 -0
- package/dist/Container.module.css +103 -0
- package/dist/Item.module.css +135 -0
- package/index.js +1092 -0
- package/package.json +26 -0
- package/readme.md +1 -0
- package/src/comments.js +149 -0
- package/src/ticketDetail.js +406 -0
- package/src/tickets.js +225 -0
package/src/tickets.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import React, {useEffect, useState} from 'react';
|
|
2
|
+
import { Grid } from '@mui/material';
|
|
3
|
+
import { Box } from '@mui/system';
|
|
4
|
+
import {
|
|
5
|
+
DataGrid,
|
|
6
|
+
GridActionsCellItem,
|
|
7
|
+
} from "@mui/x-data-grid";
|
|
8
|
+
import DeleteRoundedIcon from "@mui/icons-material/DeleteRounded";
|
|
9
|
+
import VisibilityRoundedIcon from '@mui/icons-material/VisibilityRounded';
|
|
10
|
+
import InputLabel from '@mui/material/InputLabel';
|
|
11
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
12
|
+
import FormControl from '@mui/material/FormControl';
|
|
13
|
+
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
|
14
|
+
import { useRouter } from 'next/router';
|
|
15
|
+
import { YesNoDialog, apiService, EditableDatagrid } from 'authscape';
|
|
16
|
+
//import { TicketDetail } from './ticketDetail';
|
|
17
|
+
import Dialog from '@mui/material/Dialog';
|
|
18
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
19
|
+
|
|
20
|
+
export default function Tickets({setIsLoading, currentUser, customTabName = null, customTabElement = null }) {
|
|
21
|
+
|
|
22
|
+
const [archiveTicketId, setArchiveTicketId] = useState(null);
|
|
23
|
+
const [ticketStatuses, setTicketStatuses] = useState([]);
|
|
24
|
+
const [ticketTypes, setTicketTypes] = useState([]);
|
|
25
|
+
const [ticketTypeId, setTicketTypeId] = useState(null);
|
|
26
|
+
const [dataGridRefreshKey, setDataGridRefreshKey] = useState(0);
|
|
27
|
+
const [statusId, setStatusId] = useState(null);
|
|
28
|
+
const [selectedTicketId, setSelectedTicketId] = useState(null);
|
|
29
|
+
|
|
30
|
+
const router = useRouter();
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
|
|
34
|
+
if (router.query.id != null)
|
|
35
|
+
{
|
|
36
|
+
setSelectedTicketId(router.query.id);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}, [router.isReady])
|
|
40
|
+
|
|
41
|
+
const columns = [
|
|
42
|
+
{ field: 'id', headerName: 'Id', width: 150 },
|
|
43
|
+
{ field: 'title', flex: 1, headerName: 'Customer', width: 200 },
|
|
44
|
+
{ field: 'ticketStatus', headerName: 'Status', width: 150 },
|
|
45
|
+
{ field: 'ticketType', headerName: 'Ticket Type', width: 150 },
|
|
46
|
+
{ field: 'created', headerName: 'Created', width: 150 },
|
|
47
|
+
{ field: 'ticketParticipants', headerName: 'Participants', width: 150 },
|
|
48
|
+
{ field: 'messages', headerName: 'Messages', width: 150 },
|
|
49
|
+
{
|
|
50
|
+
field: "actions",
|
|
51
|
+
type: "actions",
|
|
52
|
+
width: 200,
|
|
53
|
+
headerName: "Actions",
|
|
54
|
+
cellClassName: "actions",
|
|
55
|
+
getActions: ({ id, row }) => {
|
|
56
|
+
return [
|
|
57
|
+
<GridActionsCellItem key={id}
|
|
58
|
+
icon={<VisibilityRoundedIcon />}
|
|
59
|
+
label="View"
|
|
60
|
+
onClick={() => {
|
|
61
|
+
setSelectedTicketId(row.id);
|
|
62
|
+
}}
|
|
63
|
+
/>,
|
|
64
|
+
<GridActionsCellItem key={id}
|
|
65
|
+
icon={<DeleteRoundedIcon />}
|
|
66
|
+
label="Delete"
|
|
67
|
+
className="textPrimary"
|
|
68
|
+
onClick={() => {
|
|
69
|
+
setArchiveTicketId(row.id);
|
|
70
|
+
}}
|
|
71
|
+
/>,
|
|
72
|
+
];
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
|
|
79
|
+
let fetchStatusesAndTypes = async () => {
|
|
80
|
+
let responseStatus = await apiService().get("/Ticket/GetStatuses");
|
|
81
|
+
if (responseStatus != null && responseStatus.status == 200)
|
|
82
|
+
{
|
|
83
|
+
setTicketStatuses(responseStatus.data);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let responseType = await apiService().get("/Ticket/GetTicketTypes");
|
|
87
|
+
if (responseType != null && responseType.status == 200)
|
|
88
|
+
{
|
|
89
|
+
setTicketTypes(responseType.data);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fetchStatusesAndTypes();
|
|
94
|
+
setTicketStatuses();
|
|
95
|
+
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
|
|
101
|
+
let newKey = dataGridRefreshKey + 1;
|
|
102
|
+
setDataGridRefreshKey(newKey);
|
|
103
|
+
|
|
104
|
+
}, [ticketTypeId, statusId]);
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Box>
|
|
108
|
+
<Grid container spacing={2} sx={{paddingTop:2, paddingBottom:2}}>
|
|
109
|
+
<Grid item xs={4}>
|
|
110
|
+
|
|
111
|
+
<Box>
|
|
112
|
+
<FormControl fullWidth>
|
|
113
|
+
<InputLabel id="demo-simple-select-label">Ticket Status</InputLabel>
|
|
114
|
+
<Select
|
|
115
|
+
labelId="demo-simple-select-label"
|
|
116
|
+
id="demo-simple-select"
|
|
117
|
+
value={statusId}
|
|
118
|
+
label="ticketStatus"
|
|
119
|
+
onChange={(event) => {
|
|
120
|
+
setStatusId(event.target.value);
|
|
121
|
+
}}>
|
|
122
|
+
|
|
123
|
+
<MenuItem value={null}>Not Assigned</MenuItem>
|
|
124
|
+
|
|
125
|
+
{ticketStatuses != null && ticketStatuses.map((tStatus) => {
|
|
126
|
+
return (
|
|
127
|
+
<MenuItem value={tStatus.id}>{tStatus.name}</MenuItem>
|
|
128
|
+
)
|
|
129
|
+
})}
|
|
130
|
+
|
|
131
|
+
</Select>
|
|
132
|
+
</FormControl>
|
|
133
|
+
</Box>
|
|
134
|
+
|
|
135
|
+
</Grid>
|
|
136
|
+
<Grid item xs={4}>
|
|
137
|
+
|
|
138
|
+
<Box>
|
|
139
|
+
<FormControl fullWidth>
|
|
140
|
+
<InputLabel id="demo-simple-select-label">Ticket Type</InputLabel>
|
|
141
|
+
<Select
|
|
142
|
+
labelId="demo-simple-select-label"
|
|
143
|
+
id="demo-simple-select"
|
|
144
|
+
value={ticketTypeId}
|
|
145
|
+
label="TicketType"
|
|
146
|
+
onChange={(event) => {
|
|
147
|
+
setTicketTypeId(event.target.value);
|
|
148
|
+
}}>
|
|
149
|
+
|
|
150
|
+
<MenuItem value={null}>Not Assigned</MenuItem>
|
|
151
|
+
|
|
152
|
+
{ticketTypes != null && ticketTypes.map((tTicketType) => {
|
|
153
|
+
return (
|
|
154
|
+
<MenuItem value={tTicketType.id}>{tTicketType.name}</MenuItem>
|
|
155
|
+
)
|
|
156
|
+
})}
|
|
157
|
+
|
|
158
|
+
</Select>
|
|
159
|
+
</FormControl>
|
|
160
|
+
</Box>
|
|
161
|
+
|
|
162
|
+
</Grid>
|
|
163
|
+
</Grid>
|
|
164
|
+
|
|
165
|
+
<Box sx={{height: 600, width: '100%' }}>
|
|
166
|
+
<EditableDatagrid
|
|
167
|
+
height={"80vh"}
|
|
168
|
+
key={dataGridRefreshKey}
|
|
169
|
+
url={"/ticket/GetTickets"}
|
|
170
|
+
params={{
|
|
171
|
+
ticketStatusId: statusId,
|
|
172
|
+
ticketTypeId: ticketTypeId
|
|
173
|
+
}}
|
|
174
|
+
columns={columns}
|
|
175
|
+
/>
|
|
176
|
+
</Box>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
<Dialog
|
|
180
|
+
open={selectedTicketId != null ? true : false}
|
|
181
|
+
onClose={() => {
|
|
182
|
+
|
|
183
|
+
let newKey = dataGridRefreshKey + 1;
|
|
184
|
+
setDataGridRefreshKey(newKey);
|
|
185
|
+
|
|
186
|
+
setSelectedTicketId(null);
|
|
187
|
+
}}
|
|
188
|
+
fullWidth={true}
|
|
189
|
+
maxWidth={"lg"}
|
|
190
|
+
aria-labelledby="alert-dialog-title"
|
|
191
|
+
aria-describedby="alert-dialog-description">
|
|
192
|
+
<DialogContent>
|
|
193
|
+
<Box sx={{padding:2, width:"100%"}}>
|
|
194
|
+
<TicketDetail ticketId={selectedTicketId} setIsLoading={setIsLoading} currentUser={currentUser} customTabName={customTabName} customTabElement={customTabElement} GoBackToViewTickets={() =>
|
|
195
|
+
{
|
|
196
|
+
let newKey = dataGridRefreshKey + 1;
|
|
197
|
+
setDataGridRefreshKey(newKey);
|
|
198
|
+
setSelectedTicketId(null);
|
|
199
|
+
}} />
|
|
200
|
+
</Box>
|
|
201
|
+
</DialogContent>
|
|
202
|
+
</Dialog>
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<YesNoDialog open={archiveTicketId != null ? true : false} title={"Remove Ticket"} message={"Are you sure you want to close this ticket?"}
|
|
206
|
+
YesAction={async () => {
|
|
207
|
+
await apiService().delete("/Ticket/ArchiveTicket?id=" + archiveTicketId);
|
|
208
|
+
|
|
209
|
+
let newKey = dataGridRefreshKey + 1;
|
|
210
|
+
setDataGridRefreshKey(newKey);
|
|
211
|
+
setArchiveTicketId(null);
|
|
212
|
+
setSelectedTicketId(null);
|
|
213
|
+
|
|
214
|
+
}}
|
|
215
|
+
NoAction={() => {
|
|
216
|
+
|
|
217
|
+
let newKey = dataGridRefreshKey + 1;
|
|
218
|
+
setDataGridRefreshKey(newKey);
|
|
219
|
+
setArchiveTicketId(null);
|
|
220
|
+
setSelectedTicketId(null);
|
|
221
|
+
|
|
222
|
+
}} />
|
|
223
|
+
</Box>
|
|
224
|
+
)
|
|
225
|
+
}
|