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,34 +1,25 @@
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 } 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 CourseReport() {
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 [courses, setCourses] = (0, _react.useState)([]);
23
- const [selectedSubject, setSelectedSubject] = (0, _react.useState)(null);
24
- const [selectedCourse, setSelectedCourse] = (0, _react.useState)(null);
25
- const [reportTypes] = (0, _react.useState)(['Summary', 'Daywise']);
26
- const [selectedReportType, setSelectedReportType] = (0, _react.useState)(null);
27
- const [alertMessage, setAlertMessage] = (0, _react.useState)('');
28
- const [loading, setLoading] = (0, _react.useState)(false);
29
- const [alertOpen, setAlertOpen] = (0, _react.useState)(false);
10
+ const [token, setToken] = useState(localStorage.getItem("token"));
11
+ const navigate = useNavigate();
12
+ const [subjects, setSubjects] = useState([]);
13
+ const [courses, setCourses] = useState([]);
14
+ const [selectedSubject, setSelectedSubject] = useState(null);
15
+ const [selectedCourse, setSelectedCourse] = useState(null);
16
+ const [reportTypes] = useState(['Summary', 'Daywise']);
17
+ const [selectedReportType, setSelectedReportType] = useState(null);
18
+ const [alertMessage, setAlertMessage] = useState('');
19
+ const [loading, setLoading] = useState(false);
20
+ const [alertOpen, setAlertOpen] = useState(false);
30
21
  const baseURL = process.env.REACT_APP_BASE_URL;
31
- (0, _react.useEffect)(() => {
22
+ useEffect(() => {
32
23
  if (token == null) {
33
24
  navigate("/login");
34
25
  } else {
@@ -37,7 +28,7 @@ function CourseReport() {
37
28
  }, []);
38
29
  const fetchAllSubjects = async () => {
39
30
  try {
40
- const response = await (0, _axios.default)({
31
+ const response = await axios({
41
32
  method: "get",
42
33
  url: `${baseURL}api/showAllSubjects`,
43
34
  headers: {
@@ -51,7 +42,7 @@ function CourseReport() {
51
42
  };
52
43
  const fetchCourses = async subjectId => {
53
44
  try {
54
- const response = await (0, _axios.default)({
45
+ const response = await axios({
55
46
  method: "get",
56
47
  params: {
57
48
  subjectId
@@ -89,7 +80,7 @@ function CourseReport() {
89
80
  } else if (selectedReportType === 'Daywise') {
90
81
  url = `${baseURL}api/downloadUserCorpCourseExcelDayWise?corpCourseId=${selectedCourse.id}`;
91
82
  }
92
- const response = await _axios.default.get(url, {
83
+ const response = await axios.get(url, {
93
84
  responseType: 'blob',
94
85
  headers: {
95
86
  Authorization: `Bearer ${token}`
@@ -120,124 +111,144 @@ function CourseReport() {
120
111
  setLoading(false);
121
112
  }
122
113
  };
123
- 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", {
124
- style: {
125
- padding: "100px 0px 0px 100px",
126
- marginLeft: "140px"
127
- }
128
- }, /*#__PURE__*/_react.default.createElement(_material.Box, {
129
- sx: {
130
- maxWidth: 800,
131
- mx: 'auto',
132
- my: 4,
133
- p: 3,
134
- backgroundColor: '#f5f5f5',
135
- borderRadius: 2
136
- }
137
- }, /*#__PURE__*/_react.default.createElement(_material.Paper, {
138
- elevation: 6,
139
- sx: {
140
- p: 5,
141
- textAlign: 'center',
142
- backgroundColor: '#fff'
143
- }
144
- }, /*#__PURE__*/_react.default.createElement(_material.Typography, {
145
- variant: "h4",
146
- component: "h1",
147
- gutterBottom: true,
148
- sx: {
149
- color: '#3f51b5',
150
- marginBottom: "20px"
151
- }
152
- }, "Course Report"), /*#__PURE__*/_react.default.createElement(_material.Grid, {
153
- container: true,
154
- spacing: 2,
155
- justifyContent: "center"
156
- }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
157
- item: true,
158
- xs: 12,
159
- sm: 4
160
- }, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
161
- fullWidth: true
162
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
163
- id: "ddlSubject",
164
- options: subjects,
165
- getOptionLabel: option => option.subjectName,
166
- value: selectedSubject,
167
- onChange: handleSubjectChange,
168
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
169
- label: "Subject"
170
- }))
171
- }))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
172
- item: true,
173
- xs: 12,
174
- sm: 4
175
- }, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
176
- fullWidth: true
177
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
178
- id: "ddlCourse",
179
- options: courses,
180
- getOptionLabel: option => option.courseName,
181
- value: selectedCourse,
182
- onChange: handleCourseChange,
183
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
184
- label: "Course"
185
- }))
186
- }))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
187
- item: true,
188
- xs: 12,
189
- sm: 4
190
- }, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
191
- fullWidth: true
192
- }, /*#__PURE__*/_react.default.createElement(_material.Autocomplete, {
193
- id: "ddlReportType",
194
- options: reportTypes,
195
- getOptionLabel: option => option,
196
- value: selectedReportType,
197
- onChange: handleReportTypeChange,
198
- renderInput: params => /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({}, params, {
199
- label: "Report Type"
200
- }))
201
- })))), /*#__PURE__*/_react.default.createElement(_material.Box, {
202
- sx: {
203
- mt: 3,
204
- position: 'relative'
205
- }
206
- }, /*#__PURE__*/_react.default.createElement(_material.Button, {
207
- variant: "contained",
208
- color: "primary",
209
- onClick: handleDownload,
210
- disabled: !selectedSubject || !selectedCourse || !selectedReportType || loading,
211
- sx: {
212
- width: 'auto',
213
- backgroundColor: '#3f51b5',
214
- '&:hover': {
215
- backgroundColor: '#303f9f'
216
- }
217
- }
218
- }, loading ? 'Downloading...' : 'Download Report'), loading && /*#__PURE__*/_react.default.createElement(_material.CircularProgress, {
219
- size: 24,
220
- sx: {
221
- position: 'absolute',
222
- top: '50%',
223
- left: '50%',
224
- marginTop: '-12px',
225
- marginLeft: '-12px'
226
- }
227
- })))), /*#__PURE__*/_react.default.createElement(_material.Snackbar, {
228
- open: alertOpen,
229
- autoHideDuration: 6000,
230
- onClose: () => setAlertOpen(false),
231
- anchorOrigin: {
232
- vertical: 'top',
233
- horizontal: 'center'
234
- }
235
- }, /*#__PURE__*/_react.default.createElement(_material.Alert, {
236
- onClose: () => setAlertOpen(false),
237
- severity: "info",
238
- sx: {
239
- width: '100%'
240
- }
241
- }, alertMessage))));
114
+ return /*#__PURE__*/_jsxs("div", {
115
+ children: [/*#__PURE__*/_jsx(Header, {}), /*#__PURE__*/_jsx(Sidebar, {}), /*#__PURE__*/_jsxs("div", {
116
+ style: {
117
+ padding: "100px 0px 0px 100px",
118
+ marginLeft: "140px"
119
+ },
120
+ children: [/*#__PURE__*/_jsx(Box, {
121
+ sx: {
122
+ maxWidth: 800,
123
+ mx: 'auto',
124
+ my: 4,
125
+ p: 3,
126
+ backgroundColor: '#f5f5f5',
127
+ borderRadius: 2
128
+ },
129
+ children: /*#__PURE__*/_jsxs(Paper, {
130
+ elevation: 6,
131
+ sx: {
132
+ p: 5,
133
+ textAlign: 'center',
134
+ backgroundColor: '#fff'
135
+ },
136
+ children: [/*#__PURE__*/_jsx(Typography, {
137
+ variant: "h4",
138
+ component: "h1",
139
+ gutterBottom: true,
140
+ sx: {
141
+ color: '#3f51b5',
142
+ marginBottom: "20px"
143
+ },
144
+ children: "Course Report"
145
+ }), /*#__PURE__*/_jsxs(Grid, {
146
+ container: true,
147
+ spacing: 2,
148
+ justifyContent: "center",
149
+ children: [/*#__PURE__*/_jsx(Grid, {
150
+ item: true,
151
+ xs: 12,
152
+ sm: 4,
153
+ children: /*#__PURE__*/_jsx(FormControl, {
154
+ fullWidth: true,
155
+ children: /*#__PURE__*/_jsx(Autocomplete, {
156
+ id: "ddlSubject",
157
+ options: subjects,
158
+ getOptionLabel: option => option.subjectName,
159
+ value: selectedSubject,
160
+ onChange: handleSubjectChange,
161
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
162
+ ...params,
163
+ label: "Subject"
164
+ })
165
+ })
166
+ })
167
+ }), /*#__PURE__*/_jsx(Grid, {
168
+ item: true,
169
+ xs: 12,
170
+ sm: 4,
171
+ children: /*#__PURE__*/_jsx(FormControl, {
172
+ fullWidth: true,
173
+ children: /*#__PURE__*/_jsx(Autocomplete, {
174
+ id: "ddlCourse",
175
+ options: courses,
176
+ getOptionLabel: option => option.courseName,
177
+ value: selectedCourse,
178
+ onChange: handleCourseChange,
179
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
180
+ ...params,
181
+ label: "Course"
182
+ })
183
+ })
184
+ })
185
+ }), /*#__PURE__*/_jsx(Grid, {
186
+ item: true,
187
+ xs: 12,
188
+ sm: 4,
189
+ children: /*#__PURE__*/_jsx(FormControl, {
190
+ fullWidth: true,
191
+ children: /*#__PURE__*/_jsx(Autocomplete, {
192
+ id: "ddlReportType",
193
+ options: reportTypes,
194
+ getOptionLabel: option => option,
195
+ value: selectedReportType,
196
+ onChange: handleReportTypeChange,
197
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
198
+ ...params,
199
+ label: "Report Type"
200
+ })
201
+ })
202
+ })
203
+ })]
204
+ }), /*#__PURE__*/_jsxs(Box, {
205
+ sx: {
206
+ mt: 3,
207
+ position: 'relative'
208
+ },
209
+ children: [/*#__PURE__*/_jsx(Button, {
210
+ variant: "contained",
211
+ color: "primary",
212
+ onClick: handleDownload,
213
+ disabled: !selectedSubject || !selectedCourse || !selectedReportType || loading,
214
+ sx: {
215
+ width: 'auto',
216
+ backgroundColor: '#3f51b5',
217
+ '&:hover': {
218
+ backgroundColor: '#303f9f'
219
+ }
220
+ },
221
+ children: loading ? 'Downloading...' : 'Download Report'
222
+ }), loading && /*#__PURE__*/_jsx(CircularProgress, {
223
+ size: 24,
224
+ sx: {
225
+ position: 'absolute',
226
+ top: '50%',
227
+ left: '50%',
228
+ marginTop: '-12px',
229
+ marginLeft: '-12px'
230
+ }
231
+ })]
232
+ })]
233
+ })
234
+ }), /*#__PURE__*/_jsx(Snackbar, {
235
+ open: alertOpen,
236
+ autoHideDuration: 6000,
237
+ onClose: () => setAlertOpen(false),
238
+ anchorOrigin: {
239
+ vertical: 'top',
240
+ horizontal: 'center'
241
+ },
242
+ children: /*#__PURE__*/_jsx(Alert, {
243
+ onClose: () => setAlertOpen(false),
244
+ severity: "info",
245
+ sx: {
246
+ width: '100%'
247
+ },
248
+ children: alertMessage
249
+ })
250
+ })]
251
+ })]
252
+ });
242
253
  }
243
- var _default = exports.default = CourseReport;
254
+ export default CourseReport;