icleafreportui 0.1.6 → 0.1.7

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.
@@ -1,36 +1,27 @@
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
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- 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); }
16
- 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; }
17
- 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); }
1
+ import React, { useState, useEffect } from 'react';
2
+ import axios from 'axios';
3
+ import { Autocomplete, FormControl, Button, Grid, Box, Typography, Paper, Snackbar, Alert, CircularProgress, TextField, Checkbox, FormControlLabel } from '@mui/material';
4
+ import { useNavigate } from 'react-router-dom';
5
+ import Header from '../components/Header';
6
+ import Sidebar from '../components/sidebar';
7
+ import '../App.css';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
9
  function ExamReport() {
19
- const [token, setToken] = (0, _react.useState)(localStorage.getItem("token"));
20
- const navigate = (0, _reactRouterDom.useNavigate)();
21
- const [subjects, setSubjects] = (0, _react.useState)([]);
22
- const [examPacks, setExamPacks] = (0, _react.useState)([]);
23
- const [exams, setExams] = (0, _react.useState)([]);
24
- const [users, setUsers] = (0, _react.useState)([]);
25
- const [selectedSubject, setSelectedSubject] = (0, _react.useState)(null);
26
- const [selectedExamPack, setSelectedExamPack] = (0, _react.useState)(null);
27
- const [selectedExam, setSelectedExam] = (0, _react.useState)(null);
28
- const [selectedUser, setSelectedUser] = (0, _react.useState)(null);
29
- const [alertMessage, setAlertMessage] = (0, _react.useState)('');
30
- const [openAlert, setOpenAlert] = (0, _react.useState)(false);
31
- const [loading, setLoading] = (0, _react.useState)(false);
10
+ const [token, setToken] = useState(localStorage.getItem("token"));
11
+ const navigate = useNavigate();
12
+ const [subjects, setSubjects] = useState([]);
13
+ const [examPacks, setExamPacks] = useState([]);
14
+ const [exams, setExams] = useState([]);
15
+ const [users, setUsers] = useState([]);
16
+ const [selectedSubject, setSelectedSubject] = useState(null);
17
+ const [selectedExamPack, setSelectedExamPack] = useState(null);
18
+ const [selectedExam, setSelectedExam] = useState(null);
19
+ const [selectedUser, setSelectedUser] = useState(null);
20
+ const [alertMessage, setAlertMessage] = useState('');
21
+ const [openAlert, setOpenAlert] = useState(false);
22
+ const [loading, setLoading] = useState(false);
32
23
  const baseURL = process.env.REACT_APP_BASE_URL;
33
- (0, _react.useEffect)(() => {
24
+ useEffect(() => {
34
25
  if (token == null) {
35
26
  navigate("/login");
36
27
  } else {
@@ -39,7 +30,7 @@ function ExamReport() {
39
30
  }, []);
40
31
  const fetchAllSubjects = async () => {
41
32
  try {
42
- const response = await (0, _axios.default)({
33
+ const response = await axios({
43
34
  method: "get",
44
35
  url: `${baseURL}api/showAllSubjects`,
45
36
  headers: {
@@ -53,7 +44,7 @@ function ExamReport() {
53
44
  };
54
45
  const fetchExamPacks = async subjectId => {
55
46
  try {
56
- const response = await (0, _axios.default)({
47
+ const response = await axios({
57
48
  method: "get",
58
49
  params: {
59
50
  subjectId
@@ -70,7 +61,7 @@ function ExamReport() {
70
61
  };
71
62
  const fetchExams = async examPackId => {
72
63
  try {
73
- const response = await (0, _axios.default)({
64
+ const response = await axios({
74
65
  method: "get",
75
66
  params: {
76
67
  examPackId
@@ -87,7 +78,7 @@ function ExamReport() {
87
78
  };
88
79
  const fetchUsers = async examId => {
89
80
  try {
90
- const response = await (0, _axios.default)({
81
+ const response = await axios({
91
82
  method: "get",
92
83
  params: {
93
84
  examId
@@ -139,7 +130,7 @@ function ExamReport() {
139
130
  setLoading(true);
140
131
  try {
141
132
  const url = `${baseURL}api/generateReportForExam?subjectId=${selectedSubject.subjectId}&examPackId=${selectedExamPack.id}&examId=${selectedExam.id}`;
142
- const response = await _axios.default.get(url, {
133
+ const response = await axios.get(url, {
143
134
  responseType: 'blob',
144
135
  headers: {
145
136
  Authorization: `Bearer ${token}`
@@ -162,129 +153,150 @@ function ExamReport() {
162
153
  setLoading(false);
163
154
  }
164
155
  };
165
- 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", {
166
- style: {
167
- padding: "100px 0px 0px 100px",
168
- marginLeft: "140px"
169
- }
170
- }, /*#__PURE__*/_react.default.createElement(_material.Box, {
171
- sx: {
172
- maxWidth: 800,
173
- mx: 'auto',
174
- my: 4,
175
- p: 3,
176
- backgroundColor: '#f5f5f5',
177
- borderRadius: 2
178
- }
179
- }, /*#__PURE__*/_react.default.createElement(_material.Paper, {
180
- elevation: 6,
181
- sx: {
182
- p: 5,
183
- textAlign: 'center',
184
- backgroundColor: '#fff'
185
- }
186
- }, /*#__PURE__*/_react.default.createElement(_material.Typography, {
187
- variant: "h4",
188
- component: "h1",
189
- gutterBottom: true,
190
- sx: {
191
- color: '#3f51b5',
192
- marginBottom: "20px"
193
- }
194
- }, "Exam Questions Report"), /*#__PURE__*/_react.default.createElement(_material.Grid, {
195
- container: true,
196
- spacing: 2,
197
- justifyContent: "center"
198
- }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
199
- item: true,
200
- xs: 12,
201
- sm: 6
202
- }, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
203
- fullWidth: true
204
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
205
- id: "ddlSubject",
206
- options: subjects,
207
- getOptionLabel: option => option.subjectName,
208
- value: selectedSubject,
209
- onChange: handleSubjectChange,
210
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
211
- label: "Subject"
212
- }))
213
- }))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
214
- item: true,
215
- xs: 12,
216
- sm: 6
217
- }, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
218
- fullWidth: true
219
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
220
- id: "ddlExamPack",
221
- options: examPacks,
222
- getOptionLabel: option => option.name,
223
- value: selectedExamPack,
224
- onChange: handleExamPackChange,
225
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
226
- label: "Exam Pack"
227
- }))
228
- }))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
229
- item: true,
230
- xs: 12,
231
- sm: 6
232
- }, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
233
- fullWidth: true
234
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
235
- id: "ddlExam",
236
- options: exams,
237
- getOptionLabel: option => option.examName,
238
- value: selectedExam,
239
- onChange: handleExamChange,
240
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
241
- label: "Exam"
242
- }))
243
- })))), /*#__PURE__*/_react.default.createElement(_material.Box, {
244
- sx: {
245
- mt: 3,
246
- position: 'relative'
247
- }
248
- }, /*#__PURE__*/_react.default.createElement(_material.Box, {
249
- sx: {
250
- mt: 2,
251
- position: 'relative'
252
- }
253
- }, /*#__PURE__*/_react.default.createElement(_material.Button, {
254
- variant: "contained",
255
- color: "primary",
256
- onClick: handleDownload,
257
- disabled: !selectedSubject || !selectedExamPack || !selectedExam || loading,
258
- sx: {
259
- width: 'auto',
260
- backgroundColor: '#3f51b5',
261
- '&:hover': {
262
- backgroundColor: '#303f9f'
263
- }
264
- }
265
- }, loading ? 'Downloading...' : 'Download Report'), loading && /*#__PURE__*/_react.default.createElement(_material.CircularProgress, {
266
- size: 24,
267
- sx: {
268
- position: 'absolute',
269
- top: '50%',
270
- left: '50%',
271
- marginTop: '-12px',
272
- marginLeft: '-12px'
273
- }
274
- }))))), /*#__PURE__*/_react.default.createElement(_material.Snackbar, {
275
- open: openAlert,
276
- autoHideDuration: 6000,
277
- onClose: () => setOpenAlert(false),
278
- anchorOrigin: {
279
- vertical: 'top',
280
- horizontal: 'center'
281
- }
282
- }, /*#__PURE__*/_react.default.createElement(_material.Alert, {
283
- onClose: () => setOpenAlert(false),
284
- severity: "info",
285
- sx: {
286
- width: '100%'
287
- }
288
- }, alertMessage))));
156
+ return /*#__PURE__*/_jsxs("div", {
157
+ children: [/*#__PURE__*/_jsx(Header, {}), /*#__PURE__*/_jsx(Sidebar, {}), /*#__PURE__*/_jsxs("div", {
158
+ style: {
159
+ padding: "100px 0px 0px 100px",
160
+ marginLeft: "140px"
161
+ },
162
+ children: [/*#__PURE__*/_jsx(Box, {
163
+ sx: {
164
+ maxWidth: 800,
165
+ mx: 'auto',
166
+ my: 4,
167
+ p: 3,
168
+ backgroundColor: '#f5f5f5',
169
+ borderRadius: 2
170
+ },
171
+ children: /*#__PURE__*/_jsxs(Paper, {
172
+ elevation: 6,
173
+ sx: {
174
+ p: 5,
175
+ textAlign: 'center',
176
+ backgroundColor: '#fff'
177
+ },
178
+ children: [/*#__PURE__*/_jsx(Typography, {
179
+ variant: "h4",
180
+ component: "h1",
181
+ gutterBottom: true,
182
+ sx: {
183
+ color: '#3f51b5',
184
+ marginBottom: "20px"
185
+ },
186
+ children: "Exam Questions Report"
187
+ }), /*#__PURE__*/_jsxs(Grid, {
188
+ container: true,
189
+ spacing: 2,
190
+ justifyContent: "center",
191
+ children: [/*#__PURE__*/_jsx(Grid, {
192
+ item: true,
193
+ xs: 12,
194
+ sm: 6,
195
+ children: /*#__PURE__*/_jsx(FormControl, {
196
+ fullWidth: true,
197
+ children: /*#__PURE__*/_jsx(Autocomplete, {
198
+ id: "ddlSubject",
199
+ options: subjects,
200
+ getOptionLabel: option => option.subjectName,
201
+ value: selectedSubject,
202
+ onChange: handleSubjectChange,
203
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
204
+ ...params,
205
+ label: "Subject"
206
+ })
207
+ })
208
+ })
209
+ }), /*#__PURE__*/_jsx(Grid, {
210
+ item: true,
211
+ xs: 12,
212
+ sm: 6,
213
+ children: /*#__PURE__*/_jsx(FormControl, {
214
+ fullWidth: true,
215
+ children: /*#__PURE__*/_jsx(Autocomplete, {
216
+ id: "ddlExamPack",
217
+ options: examPacks,
218
+ getOptionLabel: option => option.name,
219
+ value: selectedExamPack,
220
+ onChange: handleExamPackChange,
221
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
222
+ ...params,
223
+ label: "Exam Pack"
224
+ })
225
+ })
226
+ })
227
+ }), /*#__PURE__*/_jsx(Grid, {
228
+ item: true,
229
+ xs: 12,
230
+ sm: 6,
231
+ children: /*#__PURE__*/_jsx(FormControl, {
232
+ fullWidth: true,
233
+ children: /*#__PURE__*/_jsx(Autocomplete, {
234
+ id: "ddlExam",
235
+ options: exams,
236
+ getOptionLabel: option => option.examName,
237
+ value: selectedExam,
238
+ onChange: handleExamChange,
239
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
240
+ ...params,
241
+ label: "Exam"
242
+ })
243
+ })
244
+ })
245
+ })]
246
+ }), /*#__PURE__*/_jsx(Box, {
247
+ sx: {
248
+ mt: 3,
249
+ position: 'relative'
250
+ },
251
+ children: /*#__PURE__*/_jsxs(Box, {
252
+ sx: {
253
+ mt: 2,
254
+ position: 'relative'
255
+ },
256
+ children: [/*#__PURE__*/_jsx(Button, {
257
+ variant: "contained",
258
+ color: "primary",
259
+ onClick: handleDownload,
260
+ disabled: !selectedSubject || !selectedExamPack || !selectedExam || loading,
261
+ sx: {
262
+ width: 'auto',
263
+ backgroundColor: '#3f51b5',
264
+ '&:hover': {
265
+ backgroundColor: '#303f9f'
266
+ }
267
+ },
268
+ children: loading ? 'Downloading...' : 'Download Report'
269
+ }), loading && /*#__PURE__*/_jsx(CircularProgress, {
270
+ size: 24,
271
+ sx: {
272
+ position: 'absolute',
273
+ top: '50%',
274
+ left: '50%',
275
+ marginTop: '-12px',
276
+ marginLeft: '-12px'
277
+ }
278
+ })]
279
+ })
280
+ })]
281
+ })
282
+ }), /*#__PURE__*/_jsx(Snackbar, {
283
+ open: openAlert,
284
+ autoHideDuration: 6000,
285
+ onClose: () => setOpenAlert(false),
286
+ anchorOrigin: {
287
+ vertical: 'top',
288
+ horizontal: 'center'
289
+ },
290
+ children: /*#__PURE__*/_jsx(Alert, {
291
+ onClose: () => setOpenAlert(false),
292
+ severity: "info",
293
+ sx: {
294
+ width: '100%'
295
+ },
296
+ children: alertMessage
297
+ })
298
+ })]
299
+ })]
300
+ });
289
301
  }
290
- var _default = exports.default = ExamReport;
302
+ export default ExamReport;