icleafreportui 0.1.1 → 0.1.2
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/dist/App.js +52 -0
- package/dist/Login.js +177 -0
- package/dist/Reports/CourseReport.js +243 -0
- package/dist/Reports/ExamPackReport.js +559 -0
- package/dist/Reports/ExamReport.js +290 -0
- package/dist/Reports/Report.js +299 -0
- package/dist/api/client.js +44 -0
- package/dist/components/Header.js +147 -0
- package/dist/components/Loader.js +30 -0
- package/dist/components/imagePathUrl.js +17 -0
- package/dist/components/sidebar.js +78 -0
- package/dist/context/TenantProvider.js +34 -0
- package/dist/index.js +19 -0
- package/dist/package.js +101 -0
- package/dist/reportWebVitals.js +27 -0
- package/dist/setupTests.js +3 -0
- package/package.json +11 -3
- package/.env +0 -7
- package/public/favicon.ico +0 -0
- package/public/images/EResourcesImg.png +0 -0
- package/public/images/courseCardImg.png +0 -0
- package/public/images/courseInfo.png +0 -0
- package/public/images/exam-options.png +0 -0
- package/public/images/icleaf-11.png +0 -0
- package/public/images/icleaf_logo.png +0 -0
- package/public/images/template.png +0 -0
- package/public/images/unnamed.png +0 -0
- package/public/images/user.jpg +0 -0
- package/public/images/young-man-studying-library-using-laptop-1.png +0 -0
- package/public/index.html +0 -45
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/src/App.js +0 -37
- package/src/Login.js +0 -159
- package/src/Reports/CourseReport.js +0 -209
- package/src/Reports/ExamPackReport.js +0 -554
- package/src/Reports/ExamReport.js +0 -269
- package/src/Reports/Report.js +0 -271
- package/src/api/client.jsx +0 -42
- package/src/components/Header.jsx +0 -192
- package/src/components/Loader.jsx +0 -23
- package/src/components/imagePathUrl.jsx +0 -11
- package/src/components/sidebar.jsx +0 -81
- package/src/context/TenantProvider.jsx +0 -22
- package/src/index.js +0 -21
- package/src/package.js +0 -14
- package/src/reportWebVitals.js +0 -13
- package/src/setupTests.js +0 -5
- /package/{src → dist}/App.css +0 -0
- /package/{src → dist}/components/Header.css +0 -0
- /package/{src → dist}/components/sidebar.css +0 -0
- /package/{src → dist}/fonts/210000.jpg +0 -0
- /package/{src → dist}/fonts/210001.jpg +0 -0
- /package/{src → dist}/fonts/210003.jpg +0 -0
- /package/{src → dist}/fonts/210004.jpg +0 -0
- /package/{src → dist}/fonts/210006.jpg +0 -0
- /package/{src → dist}/fonts/210018.jpg +0 -0
- /package/{src → dist}/fonts/210019.jpg +0 -0
- /package/{src → dist}/fonts/210020.jpg +0 -0
- /package/{src → dist}/fonts/210279.jpg +0 -0
- /package/{src → dist}/fonts/210280.jpg +0 -0
- /package/{src → dist}/fonts/Gilroy-Black.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-BlackItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-Bold.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-BoldItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-ExtraBold.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-ExtraBoldItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-Heavy.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-HeavyItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-Light.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-LightItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-Medium.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-MediumItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-Regular.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-RegularItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-SemiBold.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-SemiBoldItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-Thin.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-ThinItalic.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-UltraLight.ttf +0 -0
- /package/{src → dist}/fonts/Gilroy-UltraLightItalic.ttf +0 -0
- /package/{src → dist}/fonts/Help - Guide Document.pdf +0 -0
- /package/{src → dist}/fonts/License.txt +0 -0
- /package/{src → dist}/fonts/More Free Fonts on fontshmonts.com.url +0 -0
- /package/{src → dist}/fonts/cover.jpg +0 -0
- /package/{src → dist}/index.css +0 -0
- /package/{src → dist}/login.css +0 -0
- /package/{src → dist}/logo.svg +0 -0
- /package/{src → dist}/styles.css +0 -0
- /package/{src → dist}/theme.css +0 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _reactRouterDom = require("react-router-dom");
|
|
11
|
+
var _Header = _interopRequireDefault(require("../components/Header"));
|
|
12
|
+
var _sidebar = _interopRequireDefault(require("../components/sidebar"));
|
|
13
|
+
require("../App.css");
|
|
14
|
+
var _Backdrop = _interopRequireDefault(require("@mui/material/Backdrop"));
|
|
15
|
+
var _xDataGrid = require("@mui/x-data-grid");
|
|
16
|
+
var _FileDownloadOutlined = _interopRequireDefault(require("@mui/icons-material/FileDownloadOutlined"));
|
|
17
|
+
var _SearchOutlined = _interopRequireDefault(require("@mui/icons-material/SearchOutlined"));
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
22
|
+
function ExamPackReport() {
|
|
23
|
+
const [token] = (0, _react.useState)(localStorage.getItem("token"));
|
|
24
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
25
|
+
const [subjects, setSubjects] = (0, _react.useState)([]);
|
|
26
|
+
const [courses, setCourses] = (0, _react.useState)([]);
|
|
27
|
+
const [selectedSubject, setSelectedSubject] = (0, _react.useState)(null);
|
|
28
|
+
const [selectedCourse, setSelectedCourse] = (0, _react.useState)(null);
|
|
29
|
+
const [alertMessage, setAlertMessage] = (0, _react.useState)('');
|
|
30
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
31
|
+
const [alertOpen, setAlertOpen] = (0, _react.useState)(false);
|
|
32
|
+
const reportType = [{
|
|
33
|
+
value: "Batch Wise",
|
|
34
|
+
label: "Batch Wise"
|
|
35
|
+
}, {
|
|
36
|
+
value: "User Wise",
|
|
37
|
+
label: "User Wise"
|
|
38
|
+
}];
|
|
39
|
+
const [selectedReportType, setSelectedReportType] = (0, _react.useState)(null);
|
|
40
|
+
const [columns, setColumns] = (0, _react.useState)(null);
|
|
41
|
+
const [rows, setRows] = (0, _react.useState)([]);
|
|
42
|
+
const [tableShow, setTableShow] = (0, _react.useState)(false);
|
|
43
|
+
const [multiLoading, setMultiLoading] = (0, _react.useState)(false);
|
|
44
|
+
const [userSelect, setUserSelect] = (0, _react.useState)(false);
|
|
45
|
+
const [selectedUserList, setSelectedUserList] = (0, _react.useState)([]);
|
|
46
|
+
const baseURL = process.env.REACT_APP_BASE_URL;
|
|
47
|
+
const [tableKey, setTableKey] = (0, _react.useState)(0);
|
|
48
|
+
const [searchQuery, setSearchQuery] = (0, _react.useState)("");
|
|
49
|
+
const filteredRows = userSelect ? rows.filter(row => {
|
|
50
|
+
const searchTerms = searchQuery.split(',').map(term => term.trim().toLowerCase()).filter(term => term.length > 0);
|
|
51
|
+
if (searchTerms.length === 0) return true;
|
|
52
|
+
const email = row.userName.toLowerCase();
|
|
53
|
+
const localPart = email.split('@')[0];
|
|
54
|
+
return searchTerms.some(term => {
|
|
55
|
+
if (term.includes('@')) {
|
|
56
|
+
// Exact full email match
|
|
57
|
+
return email === term;
|
|
58
|
+
} else {
|
|
59
|
+
// Match with the part before @
|
|
60
|
+
return localPart.includes(term);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}) : rows;
|
|
64
|
+
const batchListColumns = [{
|
|
65
|
+
field: 'sno',
|
|
66
|
+
headerName: 'S.No',
|
|
67
|
+
width: 60,
|
|
68
|
+
sortable: false,
|
|
69
|
+
renderCell: params => params.api.getAllRowIds().indexOf(params.id) + 1
|
|
70
|
+
}, {
|
|
71
|
+
field: 'batchName',
|
|
72
|
+
headerName: 'Batch Name',
|
|
73
|
+
width: 230
|
|
74
|
+
}, {
|
|
75
|
+
field: 'batchStatus',
|
|
76
|
+
headerName: 'Status',
|
|
77
|
+
width: 170,
|
|
78
|
+
renderCell: params => {
|
|
79
|
+
const isActive = params.value; // Assuming it's a boolean (true/false)
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
81
|
+
style: {
|
|
82
|
+
color: isActive ? 'green' : 'red',
|
|
83
|
+
fontWeight: 'bold'
|
|
84
|
+
}
|
|
85
|
+
}, isActive ? 'Active' : 'Inactive');
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
field: 'dailyProgressMail',
|
|
89
|
+
headerName: 'Daily Progress Mail',
|
|
90
|
+
width: 130,
|
|
91
|
+
renderCell: params => {
|
|
92
|
+
const isActive = params.value;
|
|
93
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
94
|
+
style: {
|
|
95
|
+
color: isActive ? 'green' : 'red',
|
|
96
|
+
fontWeight: 'bold'
|
|
97
|
+
}
|
|
98
|
+
}, isActive ? 'Active' : 'Inactive');
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
field: "report",
|
|
102
|
+
headerName: "Report",
|
|
103
|
+
sortable: false,
|
|
104
|
+
width: 70,
|
|
105
|
+
renderCell: params => /*#__PURE__*/_react.default.createElement(_FileDownloadOutlined.default, {
|
|
106
|
+
onClick: () => handleDownloadBatchReport(params.row),
|
|
107
|
+
fontSize: "small",
|
|
108
|
+
style: {
|
|
109
|
+
cursor: "pointer"
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}];
|
|
113
|
+
const userListColumns = [{
|
|
114
|
+
field: 'sno',
|
|
115
|
+
headerName: 'S.No',
|
|
116
|
+
width: 60,
|
|
117
|
+
sortable: false,
|
|
118
|
+
renderCell: params => params.api.getAllRowIds().indexOf(params.id) + 1
|
|
119
|
+
}, {
|
|
120
|
+
field: 'userName',
|
|
121
|
+
headerName: 'User Name',
|
|
122
|
+
width: 280
|
|
123
|
+
}, {
|
|
124
|
+
field: 'userRoleType',
|
|
125
|
+
headerName: 'Role Type',
|
|
126
|
+
width: 200,
|
|
127
|
+
renderCell: params => {
|
|
128
|
+
const isActive = params.value;
|
|
129
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
130
|
+
style: {
|
|
131
|
+
color: isActive ? 'green' : 'red',
|
|
132
|
+
fontWeight: 'bold'
|
|
133
|
+
}
|
|
134
|
+
}, isActive ? 'User' : '');
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
field: "report",
|
|
138
|
+
headerName: "Report",
|
|
139
|
+
sortable: false,
|
|
140
|
+
width: 70,
|
|
141
|
+
renderCell: params => /*#__PURE__*/_react.default.createElement(_FileDownloadOutlined.default, {
|
|
142
|
+
onClick: () => handleDownloadSingleUserReport(params.row),
|
|
143
|
+
fontSize: "small",
|
|
144
|
+
style: {
|
|
145
|
+
cursor: "pointer"
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
}];
|
|
149
|
+
(0, _react.useEffect)(() => {
|
|
150
|
+
if (token == null) {
|
|
151
|
+
navigate("/login");
|
|
152
|
+
} else {
|
|
153
|
+
fetchAllSubjects();
|
|
154
|
+
}
|
|
155
|
+
}, []);
|
|
156
|
+
const fetchAllSubjects = async () => {
|
|
157
|
+
try {
|
|
158
|
+
const response = await (0, _axios.default)({
|
|
159
|
+
method: "get",
|
|
160
|
+
url: `${baseURL}api/showAllSubjects`,
|
|
161
|
+
headers: {
|
|
162
|
+
Authorization: `Bearer ${token}`
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
setSubjects(response.data);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('Error fetching subjects:', error);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const fetchCourses = async subjectId => {
|
|
171
|
+
try {
|
|
172
|
+
const response = await (0, _axios.default)({
|
|
173
|
+
method: "get",
|
|
174
|
+
params: {
|
|
175
|
+
subjectId
|
|
176
|
+
},
|
|
177
|
+
url: `${baseURL}api/getCoursesBySubject`,
|
|
178
|
+
headers: {
|
|
179
|
+
Authorization: `Bearer ${token}`
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
setCourses(response.data);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error('Error fetching courses:', error);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const handleSubjectChange = (event, newValue) => {
|
|
188
|
+
setSelectedSubject(newValue);
|
|
189
|
+
setSelectedCourse(null);
|
|
190
|
+
setCourses([]);
|
|
191
|
+
setSelectedReportType(null);
|
|
192
|
+
setTableShow(false);
|
|
193
|
+
setRows([]);
|
|
194
|
+
setColumns([]);
|
|
195
|
+
if (newValue?.subjectId) {
|
|
196
|
+
fetchCourses(newValue.subjectId);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const handleCourseChange = (event, newValue) => {
|
|
200
|
+
setSelectedCourse(newValue);
|
|
201
|
+
setTableKey(prevKey => prevKey + 1);
|
|
202
|
+
fetchReportData(newValue?.id, selectedReportType?.value);
|
|
203
|
+
};
|
|
204
|
+
const handleReportTypeChange = (event, newValue) => {
|
|
205
|
+
setSelectedReportType(newValue);
|
|
206
|
+
setTableKey(prevKey => prevKey + 1);
|
|
207
|
+
fetchReportData(selectedCourse?.id, newValue?.value);
|
|
208
|
+
};
|
|
209
|
+
const fetchReportData = (courseId, reportType) => {
|
|
210
|
+
if (!selectedSubject?.subjectId || !courseId) return;
|
|
211
|
+
const apiMap = {
|
|
212
|
+
"Batch Wise": getBatchWiseList,
|
|
213
|
+
"User Wise": getUserWiseList
|
|
214
|
+
};
|
|
215
|
+
apiMap[reportType]?.(courseId);
|
|
216
|
+
};
|
|
217
|
+
const getBatchWiseList = async () => {
|
|
218
|
+
setLoading(true);
|
|
219
|
+
try {
|
|
220
|
+
const response = await _axios.default.get(`${baseURL}api/getCorpCourseBatches?subjectId=${selectedSubject.subjectId}&corpCourseId=${selectedCourse.id}`, {
|
|
221
|
+
headers: {
|
|
222
|
+
Authorization: `Bearer ${token}`
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
if (response.status === 200) {
|
|
226
|
+
setUserSelect(false);
|
|
227
|
+
setRows(response.data.corpCourseBatches);
|
|
228
|
+
setColumns(batchListColumns);
|
|
229
|
+
setTableShow(true);
|
|
230
|
+
}
|
|
231
|
+
console.log(response.data, "Batch Wise");
|
|
232
|
+
} catch (error) {
|
|
233
|
+
setAlertOpen(true);
|
|
234
|
+
setAlertMessage(error.response.data.error);
|
|
235
|
+
setTableShow(false);
|
|
236
|
+
setRows([]);
|
|
237
|
+
setColumns([]);
|
|
238
|
+
console.error("Error fetching batch-wise data:", error);
|
|
239
|
+
} finally {
|
|
240
|
+
setLoading(false);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const getUserWiseList = async () => {
|
|
244
|
+
setLoading(true);
|
|
245
|
+
try {
|
|
246
|
+
const response = await _axios.default.get(`${baseURL}api/getCorpCourseUsers?subjectId=${selectedSubject.subjectId}&corpCourseId=${selectedCourse.id}`, {
|
|
247
|
+
headers: {
|
|
248
|
+
Authorization: `Bearer ${token}`
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
if (response.status === 200) {
|
|
252
|
+
setRows(response.data.users);
|
|
253
|
+
setColumns(userListColumns);
|
|
254
|
+
setTableShow(true);
|
|
255
|
+
setUserSelect(true);
|
|
256
|
+
}
|
|
257
|
+
console.log(response.data, "User Wise");
|
|
258
|
+
} catch (error) {
|
|
259
|
+
setAlertOpen(true);
|
|
260
|
+
setAlertMessage(error.response.data.error);
|
|
261
|
+
setTableShow(false);
|
|
262
|
+
setRows([]);
|
|
263
|
+
setColumns([]);
|
|
264
|
+
console.error("Error fetching batch-wise data:", error);
|
|
265
|
+
} finally {
|
|
266
|
+
setLoading(false);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const handleRowSelection = newSelection => {
|
|
270
|
+
setSelectedUserList(newSelection);
|
|
271
|
+
};
|
|
272
|
+
const handleDownloadBatchReport = async item => {
|
|
273
|
+
setLoading(true);
|
|
274
|
+
try {
|
|
275
|
+
let url;
|
|
276
|
+
url = `${baseURL}api/downloadCourseAndBatchWiseReport?subjectId=${selectedSubject.subjectId}&corpCourseId=${selectedCourse.id}&batchId=${item.id}`;
|
|
277
|
+
const response = await _axios.default.post(url, {}, {
|
|
278
|
+
responseType: 'blob',
|
|
279
|
+
headers: {
|
|
280
|
+
Authorization: `Bearer ${token}`
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
const text = await response.data.text();
|
|
284
|
+
if (text.includes('Course not configured')) {
|
|
285
|
+
setAlertMessage('Course not configured.');
|
|
286
|
+
setAlertOpen(true);
|
|
287
|
+
} else {
|
|
288
|
+
const filename = `${item.batchName}_Batch_Report.xlsx`;
|
|
289
|
+
const blob = new Blob([response.data], {
|
|
290
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
291
|
+
});
|
|
292
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
293
|
+
const link = document.createElement('a');
|
|
294
|
+
link.href = blobUrl;
|
|
295
|
+
link.setAttribute('download', filename);
|
|
296
|
+
document.body.appendChild(link);
|
|
297
|
+
link.click();
|
|
298
|
+
link.parentNode.removeChild(link);
|
|
299
|
+
URL.revokeObjectURL(blobUrl);
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
setAlertOpen(true);
|
|
303
|
+
setAlertMessage(error.response.data.error);
|
|
304
|
+
console.error('Error downloading course report:', error);
|
|
305
|
+
} finally {
|
|
306
|
+
setLoading(false);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
const handleDownloadSingleUserReport = async item => {
|
|
310
|
+
setLoading(true);
|
|
311
|
+
try {
|
|
312
|
+
let url;
|
|
313
|
+
url = `${baseURL}api/downloadExamPackReportByCourse?userId=${item.id}&corpCourseId=${selectedCourse.id}&subjectId=${selectedSubject.subjectId}`;
|
|
314
|
+
const response = await _axios.default.get(url, {
|
|
315
|
+
responseType: 'blob',
|
|
316
|
+
headers: {
|
|
317
|
+
Authorization: `Bearer ${token}`
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const text = await response.data.text();
|
|
321
|
+
if (text.includes('Course not configured')) {
|
|
322
|
+
setAlertMessage('Course not configured.');
|
|
323
|
+
setAlertOpen(true);
|
|
324
|
+
} else {
|
|
325
|
+
const filename = `${item.userName}_Pack_Report.xlsx`;
|
|
326
|
+
const blob = new Blob([response.data], {
|
|
327
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
328
|
+
});
|
|
329
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
330
|
+
const link = document.createElement('a');
|
|
331
|
+
link.href = blobUrl;
|
|
332
|
+
link.setAttribute('download', filename);
|
|
333
|
+
document.body.appendChild(link);
|
|
334
|
+
link.click();
|
|
335
|
+
link.parentNode.removeChild(link);
|
|
336
|
+
URL.revokeObjectURL(blobUrl);
|
|
337
|
+
}
|
|
338
|
+
} catch (error) {
|
|
339
|
+
setAlertOpen(true);
|
|
340
|
+
setAlertMessage(error.response.data.error);
|
|
341
|
+
console.error('Error downloading course report:', error);
|
|
342
|
+
} finally {
|
|
343
|
+
setLoading(false);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const handleSummeryDownload = async () => {
|
|
347
|
+
setMultiLoading(true);
|
|
348
|
+
const selectedRowIds = rows.filter(row => selectedUserList.includes(row.id)).map(row => row.id);
|
|
349
|
+
try {
|
|
350
|
+
let url;
|
|
351
|
+
url = `${baseURL}api/downloadExamPacksAndUserIdsReport?subjectId=${selectedSubject.subjectId}&corpCourseId=${selectedCourse.id}`;
|
|
352
|
+
const response = await _axios.default.post(url, {
|
|
353
|
+
userIds: selectedRowIds
|
|
354
|
+
}, {
|
|
355
|
+
responseType: 'blob',
|
|
356
|
+
headers: {
|
|
357
|
+
Authorization: `Bearer ${token}`
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
const text = await response.data.text();
|
|
361
|
+
if (text.includes('Course not configured')) {
|
|
362
|
+
setAlertMessage('Course not configured.');
|
|
363
|
+
setAlertOpen(true);
|
|
364
|
+
} else {
|
|
365
|
+
const filename = 'User_Exam_Pack_Report.xlsx';
|
|
366
|
+
const blob = new Blob([response.data], {
|
|
367
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
368
|
+
});
|
|
369
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
370
|
+
const link = document.createElement('a');
|
|
371
|
+
link.href = blobUrl;
|
|
372
|
+
link.setAttribute('download', filename);
|
|
373
|
+
document.body.appendChild(link);
|
|
374
|
+
link.click();
|
|
375
|
+
link.parentNode.removeChild(link);
|
|
376
|
+
URL.revokeObjectURL(blobUrl);
|
|
377
|
+
}
|
|
378
|
+
} catch (error) {
|
|
379
|
+
setAlertOpen(true);
|
|
380
|
+
setAlertMessage(error.response.data.error);
|
|
381
|
+
console.error('Error downloading course report:', error);
|
|
382
|
+
} finally {
|
|
383
|
+
setMultiLoading(false);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const paginationModel = {
|
|
387
|
+
page: 0,
|
|
388
|
+
pageSize: 5
|
|
389
|
+
};
|
|
390
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Header.default, null), /*#__PURE__*/_react.default.createElement(_sidebar.default, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
391
|
+
style: {
|
|
392
|
+
padding: "100px 0px 0px 100px",
|
|
393
|
+
marginLeft: "140px"
|
|
394
|
+
}
|
|
395
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
396
|
+
sx: {
|
|
397
|
+
maxWidth: 800,
|
|
398
|
+
mx: 'auto',
|
|
399
|
+
my: 4,
|
|
400
|
+
p: 3,
|
|
401
|
+
backgroundColor: '#f5f5f5',
|
|
402
|
+
borderRadius: 2
|
|
403
|
+
}
|
|
404
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Paper, {
|
|
405
|
+
elevation: 6,
|
|
406
|
+
sx: {
|
|
407
|
+
p: 5,
|
|
408
|
+
textAlign: 'center',
|
|
409
|
+
backgroundColor: '#fff'
|
|
410
|
+
}
|
|
411
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
412
|
+
variant: "h4",
|
|
413
|
+
component: "h1",
|
|
414
|
+
gutterBottom: true,
|
|
415
|
+
sx: {
|
|
416
|
+
color: '#3f51b5',
|
|
417
|
+
marginBottom: "20px"
|
|
418
|
+
}
|
|
419
|
+
}, "Exam Pack Report"), /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
420
|
+
container: true,
|
|
421
|
+
spacing: 2,
|
|
422
|
+
justifyContent: "center"
|
|
423
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
424
|
+
item: true,
|
|
425
|
+
xs: 12,
|
|
426
|
+
sm: 4
|
|
427
|
+
}, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
|
|
428
|
+
fullWidth: true
|
|
429
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
|
|
430
|
+
id: "ddlSubject",
|
|
431
|
+
options: subjects,
|
|
432
|
+
getOptionLabel: option => option.subjectName,
|
|
433
|
+
value: selectedSubject,
|
|
434
|
+
onChange: handleSubjectChange,
|
|
435
|
+
renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
|
|
436
|
+
label: "Subject"
|
|
437
|
+
}))
|
|
438
|
+
}))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
439
|
+
item: true,
|
|
440
|
+
xs: 12,
|
|
441
|
+
sm: 4
|
|
442
|
+
}, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
|
|
443
|
+
fullWidth: true
|
|
444
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
|
|
445
|
+
id: "ddlCourse",
|
|
446
|
+
options: courses,
|
|
447
|
+
getOptionLabel: option => option.courseName,
|
|
448
|
+
value: selectedCourse,
|
|
449
|
+
onChange: handleCourseChange,
|
|
450
|
+
renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
|
|
451
|
+
label: "Course"
|
|
452
|
+
}))
|
|
453
|
+
}))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
454
|
+
item: true,
|
|
455
|
+
xs: 12,
|
|
456
|
+
sm: 4
|
|
457
|
+
}, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
|
|
458
|
+
fullWidth: true
|
|
459
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
|
|
460
|
+
id: "checkboxes-tags-demo",
|
|
461
|
+
options: reportType,
|
|
462
|
+
getOptionLabel: option => option.label,
|
|
463
|
+
value: selectedReportType,
|
|
464
|
+
onChange: handleReportTypeChange,
|
|
465
|
+
renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
|
|
466
|
+
label: "Report Type"
|
|
467
|
+
}))
|
|
468
|
+
})))), tableShow && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Box, {
|
|
469
|
+
sx: {
|
|
470
|
+
display: "flex",
|
|
471
|
+
justifyContent: "flex-end",
|
|
472
|
+
width: "100%",
|
|
473
|
+
margin: "20px 0px"
|
|
474
|
+
}
|
|
475
|
+
}, userSelect && /*#__PURE__*/_react.default.createElement(_material.Button, {
|
|
476
|
+
variant: "contained",
|
|
477
|
+
color: "primary",
|
|
478
|
+
onClick: handleSummeryDownload,
|
|
479
|
+
disabled: selectedUserList.length <= 1,
|
|
480
|
+
sx: {
|
|
481
|
+
width: 'auto',
|
|
482
|
+
backgroundColor: '#3f51b5',
|
|
483
|
+
'&:hover': {
|
|
484
|
+
backgroundColor: '#303f9f'
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}, multiLoading ? 'Downloading...' : 'Download Report')), /*#__PURE__*/_react.default.createElement(_material.Paper, {
|
|
488
|
+
sx: {
|
|
489
|
+
width: '100%'
|
|
490
|
+
}
|
|
491
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
492
|
+
style: {
|
|
493
|
+
display: "flex",
|
|
494
|
+
justifyContent: "end",
|
|
495
|
+
alignItems: "center",
|
|
496
|
+
height: "100%",
|
|
497
|
+
padding: "10px 5px"
|
|
498
|
+
}
|
|
499
|
+
}, userSelect && /*#__PURE__*/_react.default.createElement(_material.TextField, {
|
|
500
|
+
label: "Search",
|
|
501
|
+
variant: "outlined",
|
|
502
|
+
size: "small",
|
|
503
|
+
sx: {
|
|
504
|
+
mb: 2
|
|
505
|
+
},
|
|
506
|
+
value: searchQuery,
|
|
507
|
+
onChange: e => setSearchQuery(e.target.value),
|
|
508
|
+
InputProps: {
|
|
509
|
+
endAdornment: /*#__PURE__*/_react.default.createElement(_material.InputAdornment, {
|
|
510
|
+
position: "start"
|
|
511
|
+
}, /*#__PURE__*/_react.default.createElement(_SearchOutlined.default, null))
|
|
512
|
+
}
|
|
513
|
+
})), /*#__PURE__*/_react.default.createElement(_xDataGrid.DataGrid, {
|
|
514
|
+
key: tableKey,
|
|
515
|
+
rows: userSelect ? filteredRows : rows,
|
|
516
|
+
columns: columns,
|
|
517
|
+
initialState: {
|
|
518
|
+
pagination: {
|
|
519
|
+
paginationModel
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
pageSizeOptions: [5, 10, 50, 100],
|
|
523
|
+
checkboxSelection: userSelect,
|
|
524
|
+
disableRowSelectionOnClick: true,
|
|
525
|
+
onRowSelectionModelChange: handleRowSelection,
|
|
526
|
+
sx: {
|
|
527
|
+
border: 0,
|
|
528
|
+
"& .MuiTablePagination-selectLabel": {
|
|
529
|
+
margin: "unset"
|
|
530
|
+
},
|
|
531
|
+
"& .MuiTablePagination-displayedRows": {
|
|
532
|
+
margin: "unset"
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}))))), /*#__PURE__*/_react.default.createElement(_material.Snackbar, {
|
|
536
|
+
open: alertOpen,
|
|
537
|
+
autoHideDuration: 6000,
|
|
538
|
+
onClose: () => setAlertOpen(false),
|
|
539
|
+
anchorOrigin: {
|
|
540
|
+
vertical: 'top',
|
|
541
|
+
horizontal: 'center'
|
|
542
|
+
}
|
|
543
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Alert, {
|
|
544
|
+
onClose: () => setAlertOpen(false),
|
|
545
|
+
severity: "info",
|
|
546
|
+
sx: {
|
|
547
|
+
width: '100%'
|
|
548
|
+
}
|
|
549
|
+
}, alertMessage)), /*#__PURE__*/_react.default.createElement(_Backdrop.default, {
|
|
550
|
+
sx: theme => ({
|
|
551
|
+
color: '#fff',
|
|
552
|
+
zIndex: theme.zIndex.drawer + 1
|
|
553
|
+
}),
|
|
554
|
+
open: loading || multiLoading
|
|
555
|
+
}, /*#__PURE__*/_react.default.createElement(_material.CircularProgress, {
|
|
556
|
+
color: "inherit"
|
|
557
|
+
}))));
|
|
558
|
+
}
|
|
559
|
+
var _default = exports.default = ExamPackReport;
|