icleafreportui 0.2.5 → 0.2.6
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 +1 -1
- package/dist/Reports/CourseReport.js +73 -30
- package/dist/Reports/Report.js +1 -1
- package/package.json +16 -14
package/dist/App.js
CHANGED
|
@@ -12,7 +12,7 @@ const App = () => {
|
|
|
12
12
|
|
|
13
13
|
// Configuration for API calls
|
|
14
14
|
const config = {
|
|
15
|
-
baseURL: process.env.REACT_APP_BASE_URL || 'http://192.168.2.203:8080/icleafreport',
|
|
15
|
+
baseURL: process.env.REACT_APP_BASE_URL || 'http://192.168.2.203:8080/icleafreport/',
|
|
16
16
|
tenantToken: 'tn_96ef3426276611f19d84005056575b50'
|
|
17
17
|
};
|
|
18
18
|
return /*#__PURE__*/_jsx(TenantProvider, {
|
|
@@ -5,6 +5,7 @@ import { useNavigate } from 'react-router-dom';
|
|
|
5
5
|
import Header from '../components/Header';
|
|
6
6
|
import Sidebar from '../components/sidebar';
|
|
7
7
|
import '../App.css';
|
|
8
|
+
import { useTenant } from '../context/TenantProvider';
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
function CourseReport() {
|
|
10
11
|
const [token, setToken] = useState(localStorage.getItem("token"));
|
|
@@ -19,6 +20,9 @@ function CourseReport() {
|
|
|
19
20
|
const [loading, setLoading] = useState(false);
|
|
20
21
|
const [alertOpen, setAlertOpen] = useState(false);
|
|
21
22
|
const baseURL = process.env.REACT_APP_BASE_URL;
|
|
23
|
+
const {
|
|
24
|
+
apiClient
|
|
25
|
+
} = useTenant();
|
|
22
26
|
useEffect(() => {
|
|
23
27
|
if (token == null) {
|
|
24
28
|
navigate("/login");
|
|
@@ -26,33 +30,32 @@ function CourseReport() {
|
|
|
26
30
|
fetchAllSubjects();
|
|
27
31
|
}
|
|
28
32
|
}, []);
|
|
33
|
+
|
|
34
|
+
// const fetchAllSubjects = async () => {
|
|
35
|
+
// try {
|
|
36
|
+
// const response = await axios({
|
|
37
|
+
// method: "get",
|
|
38
|
+
// url: `${baseURL}api/showAllSubjects`,
|
|
39
|
+
// headers: { Authorization: `Bearer ${token}` },
|
|
40
|
+
// });
|
|
41
|
+
// setSubjects(response.data);
|
|
42
|
+
// } catch (error) {
|
|
43
|
+
// console.error('Error fetching subjects:', error);
|
|
44
|
+
// }
|
|
45
|
+
// };
|
|
46
|
+
|
|
29
47
|
const fetchAllSubjects = async () => {
|
|
30
48
|
try {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
url: `${baseURL}api/showAllSubjects`,
|
|
34
|
-
headers: {
|
|
35
|
-
Authorization: `Bearer ${token}`
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
setSubjects(response.data);
|
|
49
|
+
const data = await apiClient.get('/api/showAllSubjects');
|
|
50
|
+
setSubjects(data);
|
|
39
51
|
} catch (error) {
|
|
40
52
|
console.error('Error fetching subjects:', error);
|
|
41
53
|
}
|
|
42
54
|
};
|
|
43
55
|
const fetchCourses = async subjectId => {
|
|
44
56
|
try {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
params: {
|
|
48
|
-
subjectId
|
|
49
|
-
},
|
|
50
|
-
url: `${baseURL}api/getCoursesBySubject`,
|
|
51
|
-
headers: {
|
|
52
|
-
Authorization: `Bearer ${token}`
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
setCourses(response.data);
|
|
57
|
+
const data = await apiClient.get(`/api/getCoursesBySubject?subjectId=${subjectId}`);
|
|
58
|
+
setCourses(data);
|
|
56
59
|
} catch (error) {
|
|
57
60
|
console.error('Error fetching courses:', error);
|
|
58
61
|
}
|
|
@@ -71,35 +74,75 @@ function CourseReport() {
|
|
|
71
74
|
const handleReportTypeChange = (event, newValue) => {
|
|
72
75
|
setSelectedReportType(newValue);
|
|
73
76
|
};
|
|
77
|
+
|
|
78
|
+
// const handleDownload = async () => {
|
|
79
|
+
// setLoading(true);
|
|
80
|
+
// try {
|
|
81
|
+
// let url;
|
|
82
|
+
// if (selectedReportType === 'Summary') {
|
|
83
|
+
// url = `${baseURL}api/downloadUserCorpCourseExcel?corpCourseId=${selectedCourse.id}`;
|
|
84
|
+
// } else if (selectedReportType === 'Daywise') {
|
|
85
|
+
// url = `${baseURL}api/downloadUserCorpCourseExcelDayWise?corpCourseId=${selectedCourse.id}`;
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
// const response = await axios.get(url, {
|
|
89
|
+
// responseType: 'blob',
|
|
90
|
+
// headers: {
|
|
91
|
+
// Authorization: `Bearer ${token}`
|
|
92
|
+
// }
|
|
93
|
+
// });
|
|
94
|
+
// const contentDisposition = response.headers['content-disposition'];
|
|
95
|
+
// const text = await response.data.text();
|
|
96
|
+
// if (text.includes('Course not configured')) {
|
|
97
|
+
// setAlertMessage('Course not configured.');
|
|
98
|
+
// setAlertOpen(true);
|
|
99
|
+
// } else {
|
|
100
|
+
// const filename = 'course_report.xlsx';
|
|
101
|
+
// const blob = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
|
102
|
+
// const blobUrl = URL.createObjectURL(blob);
|
|
103
|
+
// const link = document.createElement('a');
|
|
104
|
+
// link.href = blobUrl;
|
|
105
|
+
// link.setAttribute('download', filename);
|
|
106
|
+
// document.body.appendChild(link);
|
|
107
|
+
// link.click();
|
|
108
|
+
// link.parentNode.removeChild(link);
|
|
109
|
+
// URL.revokeObjectURL(blobUrl);
|
|
110
|
+
// }
|
|
111
|
+
// } catch (error) {
|
|
112
|
+
// console.error('Error downloading course report:', error);
|
|
113
|
+
// } finally {
|
|
114
|
+
// setLoading(false);
|
|
115
|
+
// }
|
|
116
|
+
// };
|
|
117
|
+
|
|
74
118
|
const handleDownload = async () => {
|
|
75
119
|
setLoading(true);
|
|
76
120
|
try {
|
|
77
121
|
let url;
|
|
78
122
|
if (selectedReportType === 'Summary') {
|
|
79
|
-
url =
|
|
123
|
+
url = '/api/downloadUserCorpCourseExcel';
|
|
80
124
|
} else if (selectedReportType === 'Daywise') {
|
|
81
|
-
url =
|
|
125
|
+
url = '/api/downloadUserCorpCourseExcelDayWise';
|
|
82
126
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
127
|
+
const fullUrl = `${url}?corpCourseId=${selectedCourse.id}`;
|
|
128
|
+
const response = await fetch(`${baseURL}${fullUrl}`, {
|
|
85
129
|
headers: {
|
|
86
|
-
|
|
130
|
+
'X-Tenant-Token': apiClient.tenantToken
|
|
87
131
|
}
|
|
88
132
|
});
|
|
89
|
-
const
|
|
90
|
-
const text = await
|
|
133
|
+
const blob = await response.blob();
|
|
134
|
+
const text = await blob.text();
|
|
91
135
|
if (text.includes('Course not configured')) {
|
|
92
136
|
setAlertMessage('Course not configured.');
|
|
93
137
|
setAlertOpen(true);
|
|
94
138
|
} else {
|
|
95
|
-
const
|
|
96
|
-
const blob = new Blob([response.data], {
|
|
139
|
+
const downloadBlob = new Blob([blob], {
|
|
97
140
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
98
141
|
});
|
|
99
|
-
const blobUrl = URL.createObjectURL(
|
|
142
|
+
const blobUrl = URL.createObjectURL(downloadBlob);
|
|
100
143
|
const link = document.createElement('a');
|
|
101
144
|
link.href = blobUrl;
|
|
102
|
-
link.setAttribute('download',
|
|
145
|
+
link.setAttribute('download', 'course_report.xlsx');
|
|
103
146
|
document.body.appendChild(link);
|
|
104
147
|
link.click();
|
|
105
148
|
link.parentNode.removeChild(link);
|
package/dist/Reports/Report.js
CHANGED
|
@@ -374,7 +374,7 @@ function Report(_ref) {
|
|
|
374
374
|
const handleDownload = async () => {
|
|
375
375
|
setLoading(true);
|
|
376
376
|
try {
|
|
377
|
-
const response = await fetch(`${baseURL}api/generateReportForSingleUser?subjectId=${selectedSubject.subjectId}&examPackId=${selectedExamPack.id}&examId=${selectedExam.id}&userId=${selectedUser.id}&wrongAnswerFlag=${onlyWrongAnswers}`, {
|
|
377
|
+
const response = await fetch(`${baseURL}/api/generateReportForSingleUser?subjectId=${selectedSubject.subjectId}&examPackId=${selectedExamPack.id}&examId=${selectedExam.id}&userId=${selectedUser.id}&wrongAnswerFlag=${onlyWrongAnswers}`, {
|
|
378
378
|
headers: {
|
|
379
379
|
'X-Tenant-Token': apiClient.tenantToken
|
|
380
380
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icleafreportui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/package.js",
|
|
6
6
|
"files": [
|
|
@@ -8,25 +8,27 @@
|
|
|
8
8
|
],
|
|
9
9
|
"homepage": "/reports",
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"react": "^
|
|
12
|
-
"
|
|
13
|
-
"@mui/material": "^5.15.20",
|
|
11
|
+
"@emotion/react": "^11.11.4",
|
|
12
|
+
"@emotion/styled": "^11.11.5",
|
|
14
13
|
"@mui/icons-material": "^5.15.20",
|
|
14
|
+
"@mui/material": "^5.15.20",
|
|
15
15
|
"@mui/x-data-grid": "^7.27.1",
|
|
16
16
|
"antd": "^5.18.3",
|
|
17
|
-
"react
|
|
17
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
18
18
|
"react-bootstrap": "^2.10.3",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
20
|
+
"react-router-dom": "^6.24.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@csstools/normalize.css": "^12.1.1",
|
|
24
24
|
"axios": "^1.7.2",
|
|
25
|
+
"bootstrap": "^5.3.8",
|
|
25
26
|
"file-saver": "^2.0.5",
|
|
26
|
-
"react-custom-scrollbars": "^4.2.1",
|
|
27
27
|
"react-icons": "^5.2.1",
|
|
28
28
|
"react-loader-spinner": "^6.1.6",
|
|
29
|
+
"react-scripts": "^5.0.1",
|
|
29
30
|
"sanitize.css": "^13.0.0",
|
|
31
|
+
"web-vitals": "^5.2.0",
|
|
30
32
|
"xlsx": "^0.18.5"
|
|
31
33
|
},
|
|
32
34
|
"scripts": {
|
|
@@ -58,15 +60,15 @@
|
|
|
58
60
|
"@babel/core": "^7.28.6",
|
|
59
61
|
"@babel/preset-env": "^7.29.2",
|
|
60
62
|
"@babel/preset-react": "^7.28.5",
|
|
61
|
-
"react": "^
|
|
62
|
-
"
|
|
63
|
-
"@mui/material": "^5.15.20",
|
|
63
|
+
"@emotion/react": "^11.11.4",
|
|
64
|
+
"@emotion/styled": "^11.11.5",
|
|
64
65
|
"@mui/icons-material": "^5.15.20",
|
|
66
|
+
"@mui/material": "^5.15.20",
|
|
65
67
|
"@mui/x-data-grid": "^7.27.1",
|
|
66
68
|
"antd": "^5.18.3",
|
|
67
|
-
"react
|
|
69
|
+
"react": "^18.3.1",
|
|
68
70
|
"react-bootstrap": "^2.10.3",
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
+
"react-dom": "^18.3.1",
|
|
72
|
+
"react-router-dom": "^6.24.0"
|
|
71
73
|
}
|
|
72
74
|
}
|