touchstudy-core 0.1.120 → 0.1.121

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.
Files changed (54) hide show
  1. package/README.md +46 -46
  2. package/dist/StudyTouch_Character_v1_Question~jLFvuYmI.png +0 -0
  3. package/dist/components/CkEditor/CkEditor.d.ts +11 -2
  4. package/dist/components/MathJax/MathJaxContainer.d.ts +6 -0
  5. package/dist/components/MathJax/index.d.ts +2 -0
  6. package/dist/components/Selectors/InActiveAcademySelector.d.ts +16 -0
  7. package/dist/components/index.d.ts +2 -1
  8. package/dist/containers/Academies/hooks/usePassCodeDialog.d.ts +10 -0
  9. package/dist/containers/ExamResult/components/MyAnswer/components/CreateNewQuestion.d.ts +3 -2
  10. package/dist/containers/ExamResult/configs/types.d.ts +3 -0
  11. package/dist/containers/PreparedTextbook/apiClients/academyService.d.ts +1 -0
  12. package/dist/containers/PreparedTextbook/configs/constants.d.ts +3 -1
  13. package/dist/index.css +12 -9
  14. package/dist/index.d.ts +3 -1
  15. package/dist/index.js +2104 -1993
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.modern.js +2100 -2000
  18. package/dist/index.modern.js.map +1 -1
  19. package/dist/tests/performances/do-exam-session-list-student.d.ts +19 -0
  20. package/dist/tests/performances/do-exam-session-request-answer-one-time.d.ts +19 -0
  21. package/dist/tests/performances/do-exam-session-skip-answer.d.ts +19 -0
  22. package/dist/tests/performances/do-exam-session2.d.ts +19 -0
  23. package/dist/utils/enums/examStatus.d.ts +4 -0
  24. package/dist/utils/enums/index.d.ts +2 -2
  25. package/dist/utils/types/examResults.d.ts +2 -0
  26. package/dist/utils/types/exams.d.ts +3 -0
  27. package/package.json +102 -101
  28. package/dist/components/List/List.d.ts +0 -7
  29. package/dist/containers/ExamResult/components/Dialog/CreateNewQuestion2.d.ts +0 -9
  30. package/dist/containers/ExamResult/components/Notes/components/ActionItem.d.ts +0 -7
  31. package/dist/containers/ExamResult/components/Notes/components/ActionsTooltip.d.ts +0 -14
  32. package/dist/containers/ExamResult/components/Notes/components/ContentTooltip.d.ts +0 -14
  33. package/dist/containers/ExamResult/components/Notes/components/NewNoteButton.d.ts +0 -6
  34. package/dist/containers/ExamResult/components/Notes/components/NoteItem.d.ts +0 -9
  35. package/dist/containers/ExamResult/components/Notes/components/NoteList.d.ts +0 -12
  36. package/dist/containers/ExamResult/components/Notes/configs/constants.d.ts +0 -2
  37. package/dist/containers/ExamResult/components/Notes/configs/interfaces.d.ts +0 -4
  38. package/dist/containers/ExamResult/components/Notes/hooks/useNotes.d.ts +0 -8
  39. package/dist/containers/ExamResult/components/Notes/styles/styles.d.ts +0 -67
  40. package/dist/containers/ExamResult/components/StudentNotes/components/ActionItem.d.ts +0 -7
  41. package/dist/containers/ExamResult/components/StudentNotes/components/ActionsTooltip.d.ts +0 -14
  42. package/dist/containers/ExamResult/components/StudentNotes/components/NewNoteButton.d.ts +0 -6
  43. package/dist/containers/ExamResult/components/StudentNotes/components/NoteItem.d.ts +0 -9
  44. package/dist/containers/ExamResult/components/StudentNotes/configs/constants.d.ts +0 -2
  45. package/dist/containers/ExamResult/components/StudentNotes/configs/interfaces.d.ts +0 -7
  46. package/dist/containers/ExamResult/components/StudentNotes/hooks/useStudentNotes.d.ts +0 -12
  47. package/dist/containers/ExamResult/components/StudentNotes/index.d.ts +0 -4
  48. package/dist/containers/ExamResult/components/StudentNotes/styles/styles.d.ts +0 -67
  49. package/dist/containers/ExamResult/hooks/useExamNoteDialog.d.ts +0 -18
  50. package/dist/containers/Login/views/LoginQRCode.d.ts +0 -10
  51. package/dist/containers/Notes/components/ActionItem.d.ts +0 -7
  52. package/dist/containers/Notes/components/ActionsTooltip.d.ts +0 -16
  53. package/dist/containers/Notes/components/NoteDialog.d.ts +0 -4
  54. package/dist/containers/Textbooks/components/TextbookShareDialog.d.ts +0 -26
package/dist/index.js CHANGED
@@ -5,26 +5,27 @@ var toolkit = require('@reduxjs/toolkit');
5
5
  var i18n = require('i18next');
6
6
  var i18n__default = _interopDefault(i18n);
7
7
  var reactI18next = require('react-i18next');
8
- var axios = _interopDefault(require('axios'));
9
- var moment = _interopDefault(require('moment'));
10
- var _ = _interopDefault(require('lodash'));
11
- var reactRedux = require('react-redux');
12
- var React = require('react');
13
- var React__default = _interopDefault(React);
14
- var GoogleLogin = require('@leecheuk/react-google-login');
15
- var GoogleLogin__default = _interopDefault(GoogleLogin);
16
- require('moment/locale/ko.js');
17
- require('moment/locale/en-au.js');
8
+ var betterReactMathjax = require('better-react-mathjax');
18
9
  var xDatePickers = require('@mui/x-date-pickers');
19
10
  var AdapterMoment = require('@mui/x-date-pickers/AdapterMoment');
20
11
  var demo = require('@mui/x-date-pickers/internals/demo');
12
+ var React = require('react');
13
+ var React__default = _interopDefault(React);
21
14
  var material = require('@mui/material');
15
+ var reactRedux = require('react-redux');
16
+ var moment = _interopDefault(require('moment'));
17
+ require('moment/locale/ko.js');
18
+ require('moment/locale/en-au.js');
19
+ var _ = _interopDefault(require('lodash'));
22
20
  var fa = require('react-icons/fa');
23
21
  var io = require('react-icons/io');
24
22
  var io5 = require('react-icons/io5');
25
23
  var Select = require('react-select');
26
24
  var Select__default = _interopDefault(Select);
27
25
  var CreatableSelect = _interopDefault(require('react-select/creatable'));
26
+ var axios = _interopDefault(require('axios'));
27
+ var GoogleLogin = require('@leecheuk/react-google-login');
28
+ var GoogleLogin__default = _interopDefault(GoogleLogin);
28
29
  var formik = require('formik');
29
30
  var ckeditor4React = require('ckeditor4-react');
30
31
  var reactVirtualized = require('react-virtualized');
@@ -1371,6 +1372,12 @@ var today_schedule = "오늘 스케줄";
1371
1372
  var schedule_achieved = "달성한 스케줄";
1372
1373
  var i_dont_have_my_phone_number_yet = "휴대폰 번호가 없어요";
1373
1374
  var duplicate_passcode_for_siblings_please_contact_admin_for_assistance = "형제자매의 중복된 비밀번호. 도움이 필요하면 관리자에게 문의하세요";
1375
+ var textual_answer = "문자 답변";
1376
+ var question_answer_type = "질문 답변 유형";
1377
+ var choiceoption = "선택 옵션";
1378
+ var textual = "텍스트";
1379
+ var import_student_exam_short_answer_results = "학생 시험 짧은 답변 결과 가져오기";
1380
+ var file = "파일";
1374
1381
  var lang_ko = {
1375
1382
  problem_solving: problem_solving,
1376
1383
  my_story: my_story,
@@ -2385,7 +2392,13 @@ var lang_ko = {
2385
2392
  today_schedule: today_schedule,
2386
2393
  schedule_achieved: schedule_achieved,
2387
2394
  i_dont_have_my_phone_number_yet: i_dont_have_my_phone_number_yet,
2388
- duplicate_passcode_for_siblings_please_contact_admin_for_assistance: duplicate_passcode_for_siblings_please_contact_admin_for_assistance
2395
+ duplicate_passcode_for_siblings_please_contact_admin_for_assistance: duplicate_passcode_for_siblings_please_contact_admin_for_assistance,
2396
+ textual_answer: textual_answer,
2397
+ question_answer_type: question_answer_type,
2398
+ choiceoption: choiceoption,
2399
+ textual: textual,
2400
+ import_student_exam_short_answer_results: import_student_exam_short_answer_results,
2401
+ file: file
2389
2402
  };
2390
2403
 
2391
2404
  var problem_solving$1 = "Problem Solving";
@@ -3419,6 +3432,12 @@ var today_schedule$1 = "Today's schedule";
3419
3432
  var schedule_achieved$1 = "Schedule achieved";
3420
3433
  var i_dont_have_my_phone_number_yet$1 = "I don't have my phone number yet";
3421
3434
  var duplicate_passcode_for_siblings_please_contact_admin_for_assistance$1 = "Duplicate passcode for siblings. Please contact admin for assistance";
3435
+ var textual_answer$1 = "Textual answer";
3436
+ var question_answer_type$1 = "Question Answer Type";
3437
+ var choiceoption$1 = "Choice Option";
3438
+ var textual$1 = "Textual";
3439
+ var import_student_exam_short_answer_results$1 = "Import Student Exam Short Answer Results";
3440
+ var file$1 = "File";
3422
3441
  var lang_en = {
3423
3442
  problem_solving: problem_solving$1,
3424
3443
  my_story: my_story$1,
@@ -4435,7 +4454,13 @@ var lang_en = {
4435
4454
  today_schedule: today_schedule$1,
4436
4455
  schedule_achieved: schedule_achieved$1,
4437
4456
  i_dont_have_my_phone_number_yet: i_dont_have_my_phone_number_yet$1,
4438
- duplicate_passcode_for_siblings_please_contact_admin_for_assistance: duplicate_passcode_for_siblings_please_contact_admin_for_assistance$1
4457
+ duplicate_passcode_for_siblings_please_contact_admin_for_assistance: duplicate_passcode_for_siblings_please_contact_admin_for_assistance$1,
4458
+ textual_answer: textual_answer$1,
4459
+ question_answer_type: question_answer_type$1,
4460
+ choiceoption: choiceoption$1,
4461
+ textual: textual$1,
4462
+ import_student_exam_short_answer_results: import_student_exam_short_answer_results$1,
4463
+ file: file$1
4439
4464
  };
4440
4465
 
4441
4466
  i18n__default.use(reactI18next.initReactI18next).init({
@@ -4454,6 +4479,104 @@ i18n__default.use(reactI18next.initReactI18next).init({
4454
4479
  }
4455
4480
  });
4456
4481
 
4482
+ function _extends() {
4483
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
4484
+ for (var i = 1; i < arguments.length; i++) {
4485
+ var source = arguments[i];
4486
+ for (var key in source) {
4487
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
4488
+ target[key] = source[key];
4489
+ }
4490
+ }
4491
+ }
4492
+ return target;
4493
+ };
4494
+ return _extends.apply(this, arguments);
4495
+ }
4496
+ function _objectDestructuringEmpty(obj) {
4497
+ if (obj == null) throw new TypeError("Cannot destructure " + obj);
4498
+ }
4499
+ function _objectWithoutPropertiesLoose(source, excluded) {
4500
+ if (source == null) return {};
4501
+ var target = {};
4502
+ var sourceKeys = Object.keys(source);
4503
+ var key, i;
4504
+ for (i = 0; i < sourceKeys.length; i++) {
4505
+ key = sourceKeys[i];
4506
+ if (excluded.indexOf(key) >= 0) continue;
4507
+ target[key] = source[key];
4508
+ }
4509
+ return target;
4510
+ }
4511
+ function _taggedTemplateLiteralLoose(strings, raw) {
4512
+ if (!raw) {
4513
+ raw = strings.slice(0);
4514
+ }
4515
+ strings.raw = raw;
4516
+ return strings;
4517
+ }
4518
+
4519
+ var LANGUAGES = [{
4520
+ code: "ko",
4521
+ fullName: "Korean",
4522
+ shortName: "Korean",
4523
+ nativeName: "Korean",
4524
+ name: "Korean",
4525
+ image: "/images/korea.png",
4526
+ momentLangCode: "ko"
4527
+ }, {
4528
+ code: "en",
4529
+ fullName: "English",
4530
+ shortName: "English",
4531
+ nativeName: "English",
4532
+ name: "English",
4533
+ image: "/images/usa.png",
4534
+ momentLangCode: "en-au"
4535
+ }];
4536
+ var DEFAULT_LANGUAGE = LANGUAGES[0];
4537
+ var LOGIN_URL = "/login";
4538
+
4539
+ var pushTo = function pushTo(history, data, isReplace) {
4540
+ if (isReplace === void 0) {
4541
+ isReplace = false;
4542
+ }
4543
+ if (history.push && !isReplace || history.replace && isReplace) {
4544
+ !isReplace && history.push(data);
4545
+ isReplace && history.replace(data);
4546
+ } else history(data, {
4547
+ replace: isReplace
4548
+ });
4549
+ };
4550
+
4551
+ var canAccess = function canAccess(userRoles, componentRoles) {
4552
+ if (!Array.isArray(userRoles)) {
4553
+ return false;
4554
+ }
4555
+ if (Array.isArray(componentRoles)) {
4556
+ var intersects = userRoles.filter(function (i) {
4557
+ return componentRoles.includes(i);
4558
+ });
4559
+ return intersects.length > 0;
4560
+ }
4561
+ return true;
4562
+ };
4563
+
4564
+ var checkSuperUrl = function checkSuperUrl(superUrls, pathname) {
4565
+ return superUrls.some(function (i) {
4566
+ if (i.includes(":")) {
4567
+ var urls = i.split("/");
4568
+ var names = pathname.split("/");
4569
+ if (urls.length != names.length) return false;
4570
+ var isMatches = true;
4571
+ urls.forEach(function (u, index) {
4572
+ if (u != names[index] && !u.startsWith(":")) isMatches = false;
4573
+ });
4574
+ return isMatches;
4575
+ }
4576
+ return pathname.startsWith(i);
4577
+ });
4578
+ };
4579
+
4457
4580
  var GOOGLE_RECAPTCHA_KEY = process.env.REACT_APP_GOOGLE_RECAPTCHA_KEY || "";
4458
4581
  var GOOGLE_CLIENT_ID = process.env.REACT_APP_GOOGLE_CLIENT_ID || "";
4459
4582
  var GOOGLE_RECAPTCHA_ID = process.env.REACT_APP_GOOGLE_RECAPTCHA_ID || "";
@@ -4523,80 +4646,6 @@ var DEFAULT_PAGING_RESPONSE = {
4523
4646
  totalPages: 0
4524
4647
  };
4525
4648
 
4526
- (function (PreparedType) {
4527
- PreparedType[PreparedType["csat_past_questions"] = 1] = "csat_past_questions";
4528
- PreparedType[PreparedType["official_mock_exam"] = 2] = "official_mock_exam";
4529
- PreparedType[PreparedType["private_mock_exam"] = 3] = "private_mock_exam";
4530
- })(exports.PreparedType || (exports.PreparedType = {}));
4531
-
4532
- (function (ExamEvent) {
4533
- ExamEvent["StartExam"] = "start-exam";
4534
- ExamEvent["TerminateExam"] = "terminate-exam";
4535
- ExamEvent["AddExtraDuration"] = "add-extra-duration-exam";
4536
- ExamEvent["TeacherKickOutStudent"] = "teacher-kick-out-student";
4537
- })(exports.ExamEvent || (exports.ExamEvent = {}));
4538
-
4539
- (function (ExamStatus) {
4540
- ExamStatus[ExamStatus["Default"] = 0] = "Default";
4541
- ExamStatus[ExamStatus["Pending"] = 1] = "Pending";
4542
- ExamStatus[ExamStatus["InProgress"] = 2] = "InProgress";
4543
- ExamStatus[ExamStatus["Completed"] = 3] = "Completed";
4544
- })(exports.ExamStatus || (exports.ExamStatus = {}));
4545
-
4546
- (function (OrderType) {
4547
- OrderType["ASC"] = "ASC";
4548
- OrderType["DESC"] = "DESC";
4549
- })(exports.OrderType || (exports.OrderType = {}));
4550
-
4551
- (function (RecentUserAction) {
4552
- RecentUserAction["ViewedUser"] = "ViewedUser";
4553
- RecentUserAction["ViewedQNA"] = "ViewedQNA";
4554
- RecentUserAction["ViewedExamResult"] = "ViewedExamResult";
4555
- RecentUserAction["PrintedExamResult"] = "PrintedExamResult";
4556
- RecentUserAction["ViewedAttendance"] = "ViewedAttendance";
4557
- })(exports.RecentUserAction || (exports.RecentUserAction = {}));
4558
-
4559
- (function (UserSortColumn) {
4560
- UserSortColumn["CreatedAt"] = "CreatedAt";
4561
- UserSortColumn["FullName"] = "FullName";
4562
- UserSortColumn["PhoneNumber"] = "PhoneNumber";
4563
- UserSortColumn["Email"] = "Email";
4564
- UserSortColumn["SchoolName"] = "SchoolName";
4565
- UserSortColumn["Major"] = "Major";
4566
- UserSortColumn["ParentName"] = "ParentName";
4567
- UserSortColumn["ParentPhoneNumber"] = "ParentPhoneNumber";
4568
- UserSortColumn["Grade"] = "Grade";
4569
- })(exports.UserSortColumn || (exports.UserSortColumn = {}));
4570
-
4571
- var canAccess = function canAccess(userRoles, componentRoles) {
4572
- if (!Array.isArray(userRoles)) {
4573
- return false;
4574
- }
4575
- if (Array.isArray(componentRoles)) {
4576
- var intersects = userRoles.filter(function (i) {
4577
- return componentRoles.includes(i);
4578
- });
4579
- return intersects.length > 0;
4580
- }
4581
- return true;
4582
- };
4583
-
4584
- var checkSuperUrl = function checkSuperUrl(superUrls, pathname) {
4585
- return superUrls.some(function (i) {
4586
- if (i.includes(":")) {
4587
- var urls = i.split("/");
4588
- var names = pathname.split("/");
4589
- if (urls.length != names.length) return false;
4590
- var isMatches = true;
4591
- urls.forEach(function (u, index) {
4592
- if (u != names[index] && !u.startsWith(":")) isMatches = false;
4593
- });
4594
- return isMatches;
4595
- }
4596
- return pathname.startsWith(i);
4597
- });
4598
- };
4599
-
4600
4649
  var diffFromNow = (function (time, unitOfTime, targetTime) {
4601
4650
  if (time === DATE_MIN_VALUE || targetTime === DATE_MIN_VALUE) return 0;
4602
4651
  try {
@@ -4692,18 +4741,6 @@ var minutesToTimeSpan = (function (time) {
4692
4741
  return h.toString().padStart(2, "0") + ":" + m.toString().padStart(2, "0") + ":00";
4693
4742
  });
4694
4743
 
4695
- var pushTo = function pushTo(history, data, isReplace) {
4696
- if (isReplace === void 0) {
4697
- isReplace = false;
4698
- }
4699
- if (history.push && !isReplace || history.replace && isReplace) {
4700
- !isReplace && history.push(data);
4701
- isReplace && history.replace(data);
4702
- } else history(data, {
4703
- replace: isReplace
4704
- });
4705
- };
4706
-
4707
4744
  var timAgo = function timAgo(date, t) {
4708
4745
  if (date === DATE_MIN_VALUE || date === DATE_TIME_MIN_VALUE) return '';
4709
4746
  var time = moment.utc(date).local();
@@ -4776,42 +4813,6 @@ var getRemainTime = function getRemainTime(startTime, duration) {
4776
4813
  return durationInNumber - timePass;
4777
4814
  };
4778
4815
 
4779
- function _extends() {
4780
- _extends = Object.assign ? Object.assign.bind() : function (target) {
4781
- for (var i = 1; i < arguments.length; i++) {
4782
- var source = arguments[i];
4783
- for (var key in source) {
4784
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4785
- target[key] = source[key];
4786
- }
4787
- }
4788
- }
4789
- return target;
4790
- };
4791
- return _extends.apply(this, arguments);
4792
- }
4793
- function _objectDestructuringEmpty(obj) {
4794
- if (obj == null) throw new TypeError("Cannot destructure " + obj);
4795
- }
4796
- function _objectWithoutPropertiesLoose(source, excluded) {
4797
- if (source == null) return {};
4798
- var target = {};
4799
- for (var key in source) {
4800
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4801
- if (excluded.indexOf(key) >= 0) continue;
4802
- target[key] = source[key];
4803
- }
4804
- }
4805
- return target;
4806
- }
4807
- function _taggedTemplateLiteralLoose(strings, raw) {
4808
- if (!raw) {
4809
- raw = strings.slice(0);
4810
- }
4811
- strings.raw = raw;
4812
- return strings;
4813
- }
4814
-
4815
4816
  var formatDateTime = function formatDateTime(inputDate) {
4816
4817
  var date = new Date(inputDate);
4817
4818
  var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
@@ -4954,257 +4955,6 @@ var getRole = function getRole(roles) {
4954
4955
  return null;
4955
4956
  };
4956
4957
 
4957
- var LANGUAGES = [{
4958
- code: "ko",
4959
- fullName: "Korean",
4960
- shortName: "Korean",
4961
- nativeName: "Korean",
4962
- name: "Korean",
4963
- image: "/images/korea.png",
4964
- momentLangCode: "ko"
4965
- }, {
4966
- code: "en",
4967
- fullName: "English",
4968
- shortName: "English",
4969
- nativeName: "English",
4970
- name: "English",
4971
- image: "/images/usa.png",
4972
- momentLangCode: "en-au"
4973
- }];
4974
- var DEFAULT_LANGUAGE = LANGUAGES[0];
4975
- var LOGIN_URL = "/login";
4976
-
4977
- var useAutoAcademyDomain = function useAutoAcademyDomain(_, history, superUrls, homeUrl, homeAcademyUrl, isAuthPage) {
4978
- if (isAuthPage === void 0) {
4979
- isAuthPage = true;
4980
- }
4981
- var user = reactRedux.useSelector(function (state) {
4982
- var _state$common;
4983
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
4984
- });
4985
- var _ref = user || {},
4986
- email = _ref.email,
4987
- academyDomain = _ref.academyDomain,
4988
- isLearningSpace = _ref.isLearningSpace;
4989
- var pathname = window.location.pathname;
4990
- var changeAcademySearchParams = function changeAcademySearchParams() {
4991
- var isLoginPage = LOGIN_URL === pathname;
4992
- var search = window.location.search;
4993
- var searchParams = new URLSearchParams(search);
4994
- var paramAcademyDomain = searchParams.get("domain");
4995
- var domain = getAcademyDomain();
4996
- if (!!email !== isAuthPage) return;
4997
- var isSuperUrl = checkSuperUrl(superUrls, pathname);
4998
- if (!academyDomain && !isLearningSpace) {
4999
- if (!isSuperUrl) {
5000
- if (isLoginPage) searchParams["delete"]("domain");else if (!paramAcademyDomain && domain) searchParams.set("domain", domain);
5001
- pushTo(history, {
5002
- pathname: homeUrl,
5003
- search: searchParams.toString()
5004
- });
5005
- return;
5006
- }
5007
- if (paramAcademyDomain) {
5008
- searchParams["delete"]("domain");
5009
- pushTo(history, _extends({}, window.location, {
5010
- search: searchParams.toString()
5011
- }), true);
5012
- return;
5013
- }
5014
- } else {
5015
- if (isSuperUrl) {
5016
- searchParams["delete"]("domain");
5017
- pushTo(history, {
5018
- pathname: homeAcademyUrl,
5019
- search: searchParams.toString()
5020
- });
5021
- return;
5022
- }
5023
- if (!paramAcademyDomain || academyDomain.trim().toLocaleLowerCase() !== (paramAcademyDomain === null || paramAcademyDomain === void 0 ? void 0 : paramAcademyDomain.trim().toLocaleLowerCase())) {
5024
- if (isLoginPage || isLearningSpace) searchParams["delete"]("domain");else searchParams.set("domain", academyDomain);
5025
- pushTo(history, _extends({}, window.location, {
5026
- search: searchParams.toString()
5027
- }), true);
5028
- return;
5029
- }
5030
- }
5031
- };
5032
- React.useEffect(function () {
5033
- changeAcademySearchParams();
5034
- }, [pathname, window.location.search, isAuthPage, email, academyDomain]);
5035
- };
5036
-
5037
- // A type of promise-like that resolves synchronously and supports only one observer
5038
-
5039
- const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
5040
-
5041
- const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
5042
-
5043
- // Asynchronously call a function and send errors to recovery continuation
5044
- function _catch(body, recover) {
5045
- try {
5046
- var result = body();
5047
- } catch(e) {
5048
- return recover(e);
5049
- }
5050
- if (result && result.then) {
5051
- return result.then(void 0, recover);
5052
- }
5053
- return result;
5054
- }
5055
-
5056
- // Asynchronously await a promise and pass the result to a finally continuation
5057
- function _finallyRethrows(body, finalizer) {
5058
- try {
5059
- var result = body();
5060
- } catch (e) {
5061
- return finalizer(true, e);
5062
- }
5063
- if (result && result.then) {
5064
- return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
5065
- }
5066
- return finalizer(false, result);
5067
- }
5068
-
5069
- // Asynchronously await a promise and invoke a finally continuation that always overrides the result
5070
- function _finally(body, finalizer) {
5071
- try {
5072
- var result = body();
5073
- } catch (e) {
5074
- return finalizer();
5075
- }
5076
- if (result && result.then) {
5077
- return result.then(finalizer, finalizer);
5078
- }
5079
- return finalizer();
5080
- }
5081
-
5082
- var EXAM_SESSION_URL = BASE_URL + "/api/examSession";
5083
- var getCheckStatusExam = function getCheckStatusExam(examCode) {
5084
- return api.get(EXAM_SESSION_URL + "/" + examCode + "/status");
5085
- };
5086
-
5087
- var ONE_SECOND_IN_MILLISECONDS = 1000;
5088
- var useCountDownTimer = function useCountDownTimer(props) {
5089
- var startTime = props.startTime,
5090
- status = props.status,
5091
- code = props.code,
5092
- duration = props.duration,
5093
- onFinish = props.onFinish;
5094
- var dispatch = reactRedux.useDispatch();
5095
- var _useState = React.useState(),
5096
- remainTime = _useState[0],
5097
- setRemainTime = _useState[1];
5098
- var checkStatusRef = React.useRef(null);
5099
- var requestRef = React.useRef(null);
5100
- var checkLiveExamStatus = React.useCallback(function () {
5101
- try {
5102
- !!checkStatusRef.current && clearTimeout(checkStatusRef.current);
5103
- if (!code || status === exports.ExamStatus.Completed) {
5104
- return Promise.resolve();
5105
- }
5106
- var isOk = false;
5107
- var _temp = _finallyRethrows(function () {
5108
- return _catch(function () {
5109
- dispatch(setLoading(true));
5110
- return Promise.resolve(getCheckStatusExam(code)).then(function (res) {
5111
- if (res.data.data.status === exports.ExamStatus.Completed) {
5112
- isOk = true;
5113
- clearTimeout(checkStatusRef.current);
5114
- dispatch(setLoading(false));
5115
- onFinish();
5116
- } else {
5117
- checkStatusRef.current = setTimeout(checkLiveExamStatus, ONE_SECOND_IN_MILLISECONDS);
5118
- }
5119
- });
5120
- }, function (error) {
5121
- console.log({
5122
- error: error
5123
- });
5124
- });
5125
- }, function (_wasThrown, _result) {
5126
- if (!isOk) checkStatusRef.current = setTimeout(checkLiveExamStatus, ONE_SECOND_IN_MILLISECONDS);
5127
- if (_wasThrown) throw _result;
5128
- return _result;
5129
- });
5130
- return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
5131
- } catch (e) {
5132
- return Promise.reject(e);
5133
- }
5134
- }, [code, status, onFinish]);
5135
- React.useEffect(function () {
5136
- if (status !== exports.ExamStatus.InProgress) return;
5137
- var animate = function animate() {
5138
- if (!startTime || !duration) return;
5139
- if (typeof remainTime === "number" && remainTime <= 0) {
5140
- return;
5141
- }
5142
- var remain = getRemainTime(startTime, duration);
5143
- if (typeof remain !== "number") {
5144
- setRemainTime(undefined);
5145
- return;
5146
- }
5147
- setRemainTime(remain || 0);
5148
- requestRef.current = requestAnimationFrame(animate);
5149
- };
5150
- requestRef.current = requestAnimationFrame(animate);
5151
- return function () {
5152
- !!requestRef.current && cancelAnimationFrame(requestRef.current);
5153
- setRemainTime(undefined);
5154
- };
5155
- }, [startTime, duration]);
5156
- React.useEffect(function () {
5157
- if (typeof remainTime === "number" && remainTime <= 0) checkLiveExamStatus();
5158
- }, [remainTime, checkLiveExamStatus]);
5159
- return remainTime;
5160
- };
5161
-
5162
- var useGoogleSignOut = function useGoogleSignOut(props) {
5163
- var dispatch = reactRedux.useDispatch();
5164
- var onLogoutSuccess = props.onLogoutSuccess,
5165
- onFailure = props.onFailure;
5166
- var handleLogoutSuccess = function handleLogoutSuccess() {
5167
- onLogoutSuccess === null || onLogoutSuccess === void 0 ? void 0 : onLogoutSuccess();
5168
- };
5169
- var handleLogoutFailure = function handleLogoutFailure() {
5170
- onFailure === null || onFailure === void 0 ? void 0 : onFailure();
5171
- };
5172
- var _useGoogleLogout = GoogleLogin.useGoogleLogout({
5173
- clientId: GOOGLE_CLIENT_ID,
5174
- onLogoutSuccess: handleLogoutSuccess,
5175
- onFailure: handleLogoutFailure
5176
- }),
5177
- signOut = _useGoogleLogout.signOut,
5178
- loaded = _useGoogleLogout.loaded;
5179
- var handleSignOut = function handleSignOut(isRemoveDomainStorage) {
5180
- if (isRemoveDomainStorage === void 0) {
5181
- isRemoveDomainStorage = false;
5182
- }
5183
- localStorage.removeItem("USER_INFORMATION");
5184
- localStorage.removeItem(ACCESS_TOKEN);
5185
- if (isRemoveDomainStorage) {
5186
- localStorage.removeItem(ACADEMY_DOMAIN);
5187
- localStorage.removeItem(LEARNING_SPACE);
5188
- }
5189
- try {
5190
- var _window$gapi, _window$gapi$auth, _auth2$signOut;
5191
- signOut();
5192
- var auth2 = (_window$gapi = window.gapi) === null || _window$gapi === void 0 ? void 0 : (_window$gapi$auth = _window$gapi.auth2) === null || _window$gapi$auth === void 0 ? void 0 : _window$gapi$auth.getAuthInstance();
5193
- auth2 === null || auth2 === void 0 ? void 0 : (_auth2$signOut = auth2.signOut) === null || _auth2$signOut === void 0 ? void 0 : _auth2$signOut.call(auth2);
5194
- } catch (error) {
5195
- console.log({
5196
- error: error
5197
- });
5198
- }
5199
- dispatch(reset());
5200
- window.location.href = "/login";
5201
- };
5202
- return {
5203
- handleSignOut: handleSignOut,
5204
- loaded: loaded
5205
- };
5206
- };
5207
-
5208
4958
  var useLanguage = function useLanguage(history) {
5209
4959
  var dispatch = reactRedux.useDispatch();
5210
4960
  var _useTranslation = reactI18next.useTranslation(),
@@ -5272,1677 +5022,1975 @@ var useLanguage = function useLanguage(history) {
5272
5022
  };
5273
5023
  };
5274
5024
 
5275
- var useList = function useList(fetchData, defaultQuery) {
5276
- var dispatch = reactRedux.useDispatch();
5277
- var _useState = React.useState(defaultQuery),
5278
- filter = _useState[0],
5279
- setFilter = _useState[1];
5280
- var _useState2 = React.useState(DEFAULT_PAGING_RESPONSE),
5281
- paging = _useState2[0],
5282
- setPaging = _useState2[1];
5283
- var _useState3 = React.useState([]),
5284
- data = _useState3[0],
5285
- setData = _useState3[1];
5286
- var _useState4 = React.useState(),
5287
- selectedItem = _useState4[0],
5288
- setSelectedItem = _useState4[1];
5289
- var textSearchRef = React.useRef(null);
5290
- var isFirstLoadRef = React.useRef(true);
5291
- var _useTranslation = reactI18next.useTranslation(),
5292
- t = _useTranslation.t;
5293
- var handleChangeSelectedItem = function handleChangeSelectedItem(item) {
5294
- setSelectedItem(item);
5295
- };
5296
- var getData = function getData(isLoading) {
5297
- if (isLoading === void 0) {
5298
- isLoading = false;
5299
- }
5300
- try {
5301
- var _temp2 = function _temp2() {
5302
- isLoading && dispatch(setLoading(false));
5303
- };
5304
- if (!fetchData) return Promise.resolve();
5305
- if (isFirstLoadRef.current) isFirstLoadRef.current = false;
5306
- isLoading && dispatch(setLoading(true));
5307
- var _temp = _catch(function () {
5308
- return Promise.resolve(fetchData(filter)).then(function (res) {
5309
- var _res$data$items = res.data.items,
5310
- items = _res$data$items === void 0 ? [] : _res$data$items;
5311
- setPaging({
5312
- limit: res.data.limit || 0,
5313
- page: res.data.page || 0,
5314
- totalItems: res.data.totalItems || 0,
5315
- totalPages: res.data.totalPages || 0
5316
- });
5317
- setData(items);
5318
- });
5319
- }, function (error) {
5320
- setPaging(DEFAULT_PAGING_RESPONSE);
5321
- setData([]);
5322
- reactToastify.toast.error(getErrorMessage(t, error));
5025
+ var PrintState;
5026
+ (function (PrintState) {
5027
+ PrintState[PrintState["Idling"] = 0] = "Idling";
5028
+ PrintState[PrintState["Stopped"] = 1] = "Stopped";
5029
+ PrintState[PrintState["Printing"] = 2] = "Printing";
5030
+ PrintState[PrintState["Paused"] = 3] = "Paused";
5031
+ })(PrintState || (PrintState = {}));
5032
+
5033
+ var TabList = [{
5034
+ label: "comprehensive_analysis",
5035
+ value: 0
5036
+ }, {
5037
+ label: "solution_order",
5038
+ value: 1
5039
+ }, {
5040
+ label: "compare_solution",
5041
+ value: 2
5042
+ }, {
5043
+ label: "problem_analysis",
5044
+ value: 3
5045
+ }];
5046
+
5047
+ var TOTAL = 3;
5048
+ var PrintExamView2 = function PrintExamView2(_ref) {
5049
+ var history = _ref.history,
5050
+ role = _ref.role,
5051
+ dataExamSession = _ref.dataExamSession;
5052
+ var _useTranslation = reactI18next.useTranslation(),
5053
+ t = _useTranslation.t;
5054
+ var isTeacher = exports.Role.Teacher === role;
5055
+ var dataProps = isTeacher ? dataExamSession.map(function (i) {
5056
+ return {
5057
+ studentId: i === null || i === void 0 ? void 0 : i.studentId,
5058
+ examSessionId: i === null || i === void 0 ? void 0 : i.examSessionId
5059
+ };
5060
+ }) : dataExamSession.map(function (i) {
5061
+ return {
5062
+ code: i === null || i === void 0 ? void 0 : i.code
5063
+ };
5064
+ });
5065
+ useLanguage(history);
5066
+ var _useState = React.useState(dataProps),
5067
+ data = _useState[0],
5068
+ setData = _useState[1];
5069
+ var _useState2 = React.useState([]),
5070
+ completed = _useState2[0],
5071
+ setCompleted = _useState2[1];
5072
+ var _useState3 = React.useState([]),
5073
+ inprogress = _useState3[0],
5074
+ setInProgress = _useState3[1];
5075
+ var _useState4 = React.useState(PrintState.Idling),
5076
+ state = _useState4[0],
5077
+ setState = _useState4[1];
5078
+ var _useState5 = React.useState([]),
5079
+ errorLinks = _useState5[0],
5080
+ setErrorLinks = _useState5[1];
5081
+ var _useState6 = React.useState([]),
5082
+ status = _useState6[0],
5083
+ setStatus = _useState6[1];
5084
+ var theme = material.useTheme();
5085
+ var handleChangeStatus = function handleChangeStatus(event) {
5086
+ if (event.target.checked) {
5087
+ setStatus(function (prev) {
5088
+ var _event$target;
5089
+ return [].concat(prev, [(_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value]);
5090
+ });
5091
+ } else setStatus(function (prev) {
5092
+ return prev === null || prev === void 0 ? void 0 : prev.filter(function (i) {
5093
+ var _event$target2;
5094
+ return i !== ((_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.value);
5323
5095
  });
5324
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
5325
- } catch (e) {
5326
- return Promise.reject(e);
5327
- }
5328
- };
5329
- var handleSort = function handleSort(sortColumnName) {
5330
- var sortColumnDirection = exports.OrderType.ASC;
5331
- console.log({
5332
- sortColumnName: typeof sortColumnName,
5333
- filter: typeof filter.sortColumnName
5334
5096
  });
5335
- if (filter.sortColumnName == sortColumnName && filter.sortColumnDirection === exports.OrderType.ASC) sortColumnDirection = exports.OrderType.DESC;
5336
- setFilter(_extends({}, filter, {
5337
- sortColumnName: sortColumnName,
5338
- sortColumnDirection: sortColumnDirection,
5339
- currentPage: 1
5340
- }));
5341
- };
5342
- var handleChangeSearchText = function handleChangeSearchText(e) {
5343
- if (!textSearchRef.current) return;
5344
- textSearchRef.current.value = e.target.value.trim();
5345
- debounceSearch();
5346
- };
5347
- var handleChangePage = function handleChangePage(_, page) {
5348
- setFilter(_extends({}, filter, {
5349
- currentPage: page
5350
- }));
5351
- };
5352
- var calcOrderNumber = function calcOrderNumber(index) {
5353
- var _paging$page, _paging$limit;
5354
- return (((_paging$page = paging.page) != null ? _paging$page : 0) - 1) * ((_paging$limit = paging.limit) != null ? _paging$limit : 0) + index + 1;
5355
5097
  };
5356
- var debounceSearch = _.debounce(function () {
5357
- var _textSearchRef$curren;
5358
- setFilter(_extends({}, filter, {
5359
- currentPage: 1,
5360
- textSearch: (_textSearchRef$curren = textSearchRef.current) === null || _textSearchRef$curren === void 0 ? void 0 : _textSearchRef$curren.value
5361
- }));
5362
- }, 500);
5363
- React.useEffect(function () {
5364
- getData(isFirstLoadRef.current);
5365
- }, [JSON.stringify(filter)]);
5366
- return {
5367
- filter: filter,
5368
- textSearchRef: textSearchRef,
5369
- paging: paging,
5370
- data: data,
5371
- selectedItem: selectedItem,
5372
- handleSort: handleSort,
5373
- handleChangeSearchText: handleChangeSearchText,
5374
- handleChangePage: handleChangePage,
5375
- calcOrderNumber: calcOrderNumber,
5376
- handleChangeSelectedItem: handleChangeSelectedItem,
5377
- getData: getData
5098
+ var handleProgressPrint = function handleProgressPrint() {
5099
+ setData(dataProps);
5100
+ setCompleted([]);
5101
+ setInProgress([]);
5102
+ setErrorLinks([]);
5103
+ setState(PrintState.Printing);
5378
5104
  };
5379
- };
5380
-
5381
- var useLoadMore = function useLoadMore(props) {
5382
- var onLoadMore = props.onLoadMore,
5383
- loading = props.loading;
5384
- var observerTarget = React.useRef(null);
5385
- React.useEffect(function () {
5386
- var currentTarget = observerTarget.current;
5387
- var observer = new IntersectionObserver(function (entries) {
5388
- if (entries[0].isIntersecting && !loading) {
5389
- onLoadMore();
5105
+ console.log({
5106
+ status: status
5107
+ });
5108
+ var print = function print(_ref2) {
5109
+ var examSessionId = _ref2.examSessionId,
5110
+ studentId = _ref2.studentId,
5111
+ code = _ref2.code;
5112
+ var width = 200;
5113
+ var height = 200;
5114
+ var left = window.screenX + window.outerWidth / 2 - width / 2;
5115
+ var top = window.screenY + window.outerHeight / 2 - height / 2;
5116
+ var url = isTeacher ? window.location.origin + "/teacher/exam-results/" + examSessionId + "/students/" + studentId + "/print?status=" + status.join(",") : window.location.origin + "/student/exam-results/" + code + "/print";
5117
+ var windowName = isTeacher ? "popup-" + examSessionId + "-" + studentId : "popup-" + code;
5118
+ var windowSpecs = "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",location=yes,resizable=yes,scrollbars=yes,status=yes";
5119
+ var childWindow = window.open(url, windowName, windowSpecs);
5120
+ if (childWindow == null) {
5121
+ setErrorLinks(function (prev) {
5122
+ return [].concat(prev, [{
5123
+ code: code,
5124
+ examSessionId: "" + examSessionId,
5125
+ studentId: "" + studentId,
5126
+ message: isTeacher ? "/teacher/exam-results/" + examSessionId + "/students/" + studentId + "/print" : "/student/exam-results/" + code + "/print"
5127
+ }]);
5128
+ });
5129
+ if (!isTeacher) {
5130
+ setData(function (es) {
5131
+ return [].concat(es.filter(function (i) {
5132
+ return i.code !== code;
5133
+ }));
5134
+ });
5135
+ } else {
5136
+ setData(function (es) {
5137
+ return [].concat(es.filter(function (i) {
5138
+ return i.examSessionId !== examSessionId || i.studentId !== studentId;
5139
+ }));
5140
+ });
5390
5141
  }
5391
- }, {
5392
- threshold: 1
5393
- });
5394
- if (observerTarget.current) {
5395
- observer.observe(observerTarget.current);
5142
+ return;
5396
5143
  }
5397
- return function () {
5398
- if (currentTarget) {
5399
- observer.unobserve(currentTarget);
5144
+ if (!isTeacher) {
5145
+ setInProgress(function (es) {
5146
+ return [].concat(es.filter(function (i) {
5147
+ return i.code !== code;
5148
+ }), [{
5149
+ code: code
5150
+ }]);
5151
+ });
5152
+ setData(function (es) {
5153
+ return [].concat(es.filter(function (i) {
5154
+ return i.code !== code;
5155
+ }));
5156
+ });
5157
+ } else {
5158
+ setInProgress(function (es) {
5159
+ return [].concat(es.filter(function (i) {
5160
+ return i.examSessionId !== examSessionId || i.studentId !== studentId;
5161
+ }), [{
5162
+ examSessionId: examSessionId,
5163
+ studentId: studentId
5164
+ }]);
5165
+ });
5166
+ setData(function (es) {
5167
+ return [].concat(es.filter(function (i) {
5168
+ return i.examSessionId !== examSessionId || i.studentId !== studentId;
5169
+ }));
5170
+ });
5171
+ }
5172
+ window.addEventListener("message", function (event) {
5173
+ var isCheck = isTeacher ? event.data.examSessionId !== "" + examSessionId || event.data.studentId !== "" + studentId : event.data.code !== "" + code;
5174
+ if (event.origin !== window.location.origin || isCheck) {
5175
+ return;
5400
5176
  }
5401
- };
5402
- }, [observerTarget, loading, onLoadMore]);
5403
- return {
5404
- observerTarget: observerTarget
5405
- };
5406
- };
5407
-
5408
- var AUTH_URL = BASE_URL + "/api/auth";
5409
- var AUTH_SUPER_ADMIN_URL = SUPER_ADMIN_BASE_URL + "/api/auth";
5410
- var getInfo = function getInfo(role, isLearningSpace) {
5411
- var _headers;
5412
- return api.get(AUTH_URL + "/info", {
5413
- params: {
5414
- role: role
5415
- },
5416
- headers: (_headers = {}, _headers[NoAcademyHeaders] = isLearningSpace, _headers)
5417
- });
5418
- };
5419
- var getSuperAdminInfoFromWeb = function getSuperAdminInfoFromWeb() {
5420
- return api.get(AUTH_SUPER_ADMIN_URL + "/info");
5421
- };
5422
- var apiLoginGoogle = function apiLoginGoogle(body, isLearningSpace) {
5423
- var _headers2;
5424
- return api.post(AUTH_URL + "/login", body, {
5425
- headers: (_headers2 = {}, _headers2[NoAcademyHeaders] = isLearningSpace, _headers2)
5426
- });
5427
- };
5428
- var apiLoginGoogleSuperAdmin = function apiLoginGoogleSuperAdmin(body) {
5429
- return api.post(AUTH_SUPER_ADMIN_URL + "/login", body);
5177
+ if (event.data.succeed) {
5178
+ if (!isTeacher) {
5179
+ setCompleted(function (es) {
5180
+ return [].concat(es.filter(function (i) {
5181
+ return i.code !== code;
5182
+ }), [{
5183
+ code: code
5184
+ }]);
5185
+ });
5186
+ setInProgress(function (es) {
5187
+ return [].concat(es.filter(function (i) {
5188
+ return i.code !== code;
5189
+ }));
5190
+ });
5191
+ } else {
5192
+ setCompleted(function (es) {
5193
+ return [].concat(es.filter(function (i) {
5194
+ return i.examSessionId !== examSessionId || i.studentId !== studentId;
5195
+ }), [{
5196
+ examSessionId: examSessionId,
5197
+ studentId: studentId
5198
+ }]);
5199
+ });
5200
+ setInProgress(function (es) {
5201
+ return [].concat(es.filter(function (i) {
5202
+ return i.examSessionId !== examSessionId || i.studentId !== studentId;
5203
+ }));
5204
+ });
5205
+ }
5206
+ } else {
5207
+ setErrorLinks(function (prev) {
5208
+ var _event$data, _event$data2;
5209
+ return [].concat(prev, [{
5210
+ code: (_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.code,
5211
+ examSessionId: (_event$data2 = event.data) === null || _event$data2 === void 0 ? void 0 : _event$data2.examSessionId,
5212
+ studentId: "" + studentId,
5213
+ message: isTeacher ? "/teacher/exam-results/" + event.data.examSessionId + "/students/" + event.data.studentId + "/print" : "/student/exam-results/" + event.data.code + "/print"
5214
+ }]);
5215
+ });
5216
+ }
5217
+ childWindow === null || childWindow === void 0 ? void 0 : childWindow.close();
5218
+ });
5219
+ };
5220
+ React.useEffect(function () {
5221
+ if (inprogress.length < TOTAL && data.length > 0 && state === PrintState.Printing) {
5222
+ var item = data[0];
5223
+ print({
5224
+ examSessionId: item === null || item === void 0 ? void 0 : item.examSessionId,
5225
+ studentId: item === null || item === void 0 ? void 0 : item.studentId,
5226
+ code: item === null || item === void 0 ? void 0 : item.code
5227
+ });
5228
+ }
5229
+ }, [inprogress.length, completed.length, data.length, state, data]);
5230
+ return React__default.createElement(material.Container, null, state === PrintState.Idling ? React__default.createElement(material.Typography, null, t("total_number_of_selected_results") + ": ", " ", React__default.createElement("span", {
5231
+ className: "fw-bold"
5232
+ }, t("number_results", {
5233
+ number: ("" + data.length).padStart(2, "0")
5234
+ }))) : React__default.createElement(React.Fragment, null, React__default.createElement(material.Typography, null, t("completed") + ": ", React__default.createElement("span", {
5235
+ className: "fw-bold"
5236
+ }, t("number_results", {
5237
+ number: ("" + completed.length).padStart(2, "0")
5238
+ }))), React__default.createElement(material.Typography, null, t("in_progress") + ": ", React__default.createElement("span", {
5239
+ className: "fw-bold"
5240
+ }, t("number_results", {
5241
+ number: ("" + inprogress.length).padStart(2, "0")
5242
+ }))), React__default.createElement(material.Typography, null, t("remaining") + ": ", React__default.createElement("span", {
5243
+ className: "fw-bold"
5244
+ }, t("number_results", {
5245
+ number: ("" + data.length).padStart(2, "0")
5246
+ })))), !!errorLinks.length && React__default.createElement(material.Stack, {
5247
+ className: "mt-2"
5248
+ }, React__default.createElement(material.Typography, {
5249
+ fontWeight: 700
5250
+ }, t("download_failed"), ":"), Array.from(new Set(errorLinks)).map(function (i) {
5251
+ var _info$createdBy;
5252
+ var info = isTeacher ? dataExamSession.find(function (exam) {
5253
+ return "" + (exam === null || exam === void 0 ? void 0 : exam.examSessionId) === "" + (i === null || i === void 0 ? void 0 : i.examSessionId) && "" + (exam === null || exam === void 0 ? void 0 : exam.studentId) === "" + (i === null || i === void 0 ? void 0 : i.studentId);
5254
+ }) : dataExamSession.find(function (exam) {
5255
+ return (exam === null || exam === void 0 ? void 0 : exam.code) === (i === null || i === void 0 ? void 0 : i.code);
5256
+ });
5257
+ return React__default.createElement(material.Stack, {
5258
+ borderBottom: 1,
5259
+ borderColor: theme.palette.grey[500]
5260
+ }, React__default.createElement("a", {
5261
+ href: i.message,
5262
+ target: "_blank",
5263
+ rel: "noopener noreferrer"
5264
+ }, (info === null || info === void 0 ? void 0 : info.studentName) || (info === null || info === void 0 ? void 0 : (_info$createdBy = info.createdBy) === null || _info$createdBy === void 0 ? void 0 : _info$createdBy.fullName)), (info === null || info === void 0 ? void 0 : info.title) && React__default.createElement(material.Typography, null, t("exam") + ": " + (info === null || info === void 0 ? void 0 : info.title)), (info === null || info === void 0 ? void 0 : info.startTime) && React__default.createElement(material.Typography, null, t("start_time") + ": " + utcToLocalTime(info === null || info === void 0 ? void 0 : info.startTime, t("date_time_format"))));
5265
+ })), React__default.createElement(material.Stack, {
5266
+ direction: "column",
5267
+ className: "mt-3"
5268
+ }, React__default.createElement(material.Stack, null, React__default.createElement(material.Typography, {
5269
+ className: "fw-bold"
5270
+ }, React__default.createElement("span", {
5271
+ className: "text-danger me-1"
5272
+ }, "*"), t("your_browser_must"), ":"), React__default.createElement(material.List, {
5273
+ className: "ps-3 pt-0"
5274
+ }, React__default.createElement(material.ListItem, {
5275
+ disablePadding: true
5276
+ }, t("allowed_to_send_pop_ups_and_use_redirects")), React__default.createElement(material.ListItem, {
5277
+ disablePadding: true
5278
+ }, t("disable_ask_where_to_save_each_file_before_downloading")))), isTeacher && React__default.createElement(material.Stack, null, React__default.createElement(material.Typography, {
5279
+ fontWeight: 700
5280
+ }, t("choose_to_print"), ":"), React__default.createElement(material.FormGroup, {
5281
+ sx: {
5282
+ display: "flex",
5283
+ flexDirection: "row",
5284
+ gap: 1,
5285
+ flexWrap: "wrap"
5286
+ }
5287
+ }, TabList.map(function (_ref3) {
5288
+ var label = _ref3.label,
5289
+ value = _ref3.value;
5290
+ return React__default.createElement(material.FormControlLabel, {
5291
+ control: React__default.createElement(material.Checkbox, {
5292
+ onChange: handleChangeStatus,
5293
+ value: value,
5294
+ checked: status.some(function (i) {
5295
+ return i === value.toString();
5296
+ })
5297
+ }),
5298
+ label: t(label)
5299
+ });
5300
+ }))), React__default.createElement(material.Button, {
5301
+ className: "mt-3",
5302
+ variant: "contained",
5303
+ onClick: handleProgressPrint
5304
+ }, t("print_pdf"))));
5430
5305
  };
5431
- var apiLoginWithAccessToken = function apiLoginWithAccessToken(body, isLearningSpace, domain) {
5432
- var _headers3;
5433
- return api.post(AUTH_URL + "/login/access-token", body, {
5434
- params: {
5435
- isLearningSpace: isLearningSpace
5436
- },
5437
- headers: (_headers3 = {}, _headers3[AcademyHeaders] = domain, _headers3[NoAcademyHeaders] = isLearningSpace, _headers3)
5438
- });
5306
+
5307
+ var styles = {"lighter":"#F0FFF6","light":"#89F0B2","less_dark":"#3DC674","dark":"#349056","darker":"#18442A","gray_50":"#FBFBF9","gray_100":"#EAEAE5","gray_300":"#D0D0C8","gray_500":"#9A9A98","gray_700":"#5D5D5B","gray_900":"#363634","red_900":"#DB4D4D","green_support_900":"#3ACB46","yellow_900":"#FEAF06","purple_900":"#C3099A","btn-login-google":"_2HqmH","math-jax":"_3Pfdk","block-login":"_wWIyO","box-login":"_38Lo1","btn-primary":"_rd4Uy","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","dropdown-academy":"_3CMVp","image-academy":"_2ibYC","academy-btn":"_1JMRU","switch-icon":"_N4FNf","dropdown-content-academy":"_31Dr0","dropdown-academy-item":"_3bjcz","noGutters":"_31ZQk","custom-col-2":"_3yXyK","custom-col-3":"_1RsJQ","custom-col-5":"_L42CP","custom-col-10":"_2u6eL","custom-row":"_8x7OP","custom-col":"_1JmTh","custom-col-4":"_3HO1e","custom-col-8":"_Oy31M","custom-col-12":"_3aUKo","custom-container":"_39LRs","form-label":"__Ut-u","form-control":"_2k4dX","btn-outline-primary":"_2PWdX","sort-icons":"_mQvLF","active":"_3oAH-","form-select":"_3W3aw","truncate":"_3NJzN","headers":"_3xnI5","logo-container":"_3YG70","tabBox":"_1CQPn","routerBox":"_3hx2T","tabText":"_3UyhW","router-link-active":"_1TGKA","router-link":"_1AqMh","userImg":"_2RI6G","disabled-link":"_3aVHg","line-clamp":"_3fpky"};
5308
+
5309
+ var config = {
5310
+ loader: {
5311
+ load: ["input/tex", "output/svg"]
5312
+ }
5439
5313
  };
5440
- var apiLoginSuperAdminWithAccessToken = function apiLoginSuperAdminWithAccessToken(body) {
5441
- return api.post(AUTH_SUPER_ADMIN_URL + "/login/access-token", body);
5314
+ var MathJaxContainer = function MathJaxContainer(_ref) {
5315
+ var content = _ref.content;
5316
+ return React__default.createElement(betterReactMathjax.MathJaxContext, {
5317
+ config: config,
5318
+ asyncLoad: true
5319
+ }, React__default.createElement(betterReactMathjax.MathJax, {
5320
+ id: "" + styles["math-jax"],
5321
+ dangerouslySetInnerHTML: {
5322
+ __html: content
5323
+ }
5324
+ }));
5442
5325
  };
5443
5326
 
5444
- var useLogin = function useLogin(history, homeAcademyUrl, homeUrl, registerUrl, redirectAfterLogin) {
5445
- if (redirectAfterLogin === void 0) {
5446
- redirectAfterLogin = true;
5447
- }
5448
- var dispatch = reactRedux.useDispatch();
5327
+ var ReleaseAlert = function ReleaseAlert() {
5449
5328
  var _useTranslation = reactI18next.useTranslation(),
5450
5329
  t = _useTranslation.t;
5451
- var _useGoogleSignOut = useGoogleSignOut({}),
5452
- handleSignOut = _useGoogleSignOut.handleSignOut;
5453
- var searchParams = new URLSearchParams(window.location.search);
5454
- var paramDomain = searchParams.get('domain');
5455
- var handleLoginGoogle = function handleLoginGoogle(data, isLogout) {
5456
- if (isLogout === void 0) {
5457
- isLogout = true;
5458
- }
5459
- try {
5460
- var isStudent = data.role === exports.Role.Student;
5461
- var academyDomain = paramDomain || getAcademyDomain();
5462
- var isLearningSpace = getLearningSpace() || isStudent && !academyDomain;
5463
- if (!isStudent && isLearningSpace) {
5464
- isLearningSpace = false;
5465
- localStorage.removeItem(LEARNING_SPACE);
5330
+ var releaseDate = RELEASE_DATE;
5331
+ var isInValidDate = !releaseDate || releaseDate === DATE_MIN_VALUE || releaseDate === DATE_TIME_MIN_VALUE;
5332
+ var isLoginPage = window.location.pathname === LOGIN_URL;
5333
+ if (isInValidDate || !moment.utc(releaseDate).isValid()) return null;else {
5334
+ var version = moment(releaseDate).format("HH.mm.YYYY.MM.DD");
5335
+ return React__default.createElement(material.Box, {
5336
+ sx: {
5337
+ position: "fixed",
5338
+ right: 10,
5339
+ bottom: isLoginPage ? undefined : 5,
5340
+ top: isLoginPage ? 10 : undefined,
5341
+ userSelect: "none",
5342
+ zIndex: 1
5466
5343
  }
5467
- var isAcademy = !!academyDomain || isLearningSpace;
5468
- return Promise.resolve(handleLogin(function () {
5469
- return new Promise(function (resolve, reject) {
5470
- try {
5471
- var _temp3 = _catch(function () {
5472
- return Promise.resolve(isAcademy ? apiLoginGoogle(data, isLearningSpace) : apiLoginGoogleSuperAdmin(data)).then(function (loginResponse) {
5473
- function _temp2() {
5474
- resolve(result);
5475
- }
5476
- var result = loginResponse.data;
5477
- var _temp = function () {
5478
- if (loginResponse.status === 204 && academyDomain) {
5479
- localStorage.removeItem(ACADEMY_DOMAIN);
5480
- localStorage.removeItem(LEARNING_SPACE);
5481
- return Promise.resolve(apiLoginGoogleSuperAdmin(data)).then(function (_apiLoginGoogleSuperA) {
5482
- loginResponse = _apiLoginGoogleSuperA;
5483
- result = loginResponse.data;
5484
- });
5485
- }
5486
- }();
5487
- return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
5488
- });
5489
- }, function (error) {
5490
- !!academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
5491
- localStorage.removeItem(LEARNING_SPACE);
5492
- reject(error);
5493
- });
5494
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
5495
- } catch (e) {
5496
- return Promise.reject(e);
5497
- }
5498
- });
5499
- }, isStudent, isLogout)).then(function () {});
5500
- } catch (e) {
5501
- return Promise.reject(e);
5502
- }
5503
- };
5504
- var handleLoginAccessToken = function handleLoginAccessToken(data, isLearningSpace, domain, isLogout, superAdminRedirectPath) {
5505
- if (isLogout === void 0) {
5506
- isLogout = true;
5507
- }
5508
- try {
5509
- var isStudent = data.role === exports.Role.Student;
5510
- return Promise.resolve(handleLogin(function () {
5511
- return new Promise(function (resolve, reject) {
5512
- try {
5513
- var _temp4 = _catch(function () {
5514
- return Promise.resolve(!isLearningSpace && !domain ? apiLoginSuperAdminWithAccessToken(data) : apiLoginWithAccessToken(data, isLearningSpace, domain)).then(function (loginResponse) {
5515
- var result = loginResponse.data;
5516
- resolve(result);
5517
- });
5518
- }, function (error) {
5519
- reject(error);
5520
- });
5521
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
5522
- } catch (e) {
5523
- return Promise.reject(e);
5524
- }
5525
- });
5526
- }, isStudent, isLogout, superAdminRedirectPath)).then(function () {});
5527
- } catch (e) {
5528
- return Promise.reject(e);
5529
- }
5530
- };
5531
- var handleLogin = function handleLogin(apiLogin, isStudent, isLogout, superAdminRedirectPath) {
5532
- if (isLogout === void 0) {
5533
- isLogout = true;
5534
- }
5535
- try {
5536
- var _temp6 = function _temp6(_result) {
5537
- if (_exit) return _result;
5538
- dispatch(setLoading(false));
5539
- };
5540
- var _exit = false;
5541
- dispatch(setLoading(true));
5542
- var _temp5 = _catch(function () {
5543
- return Promise.resolve(apiLogin()).then(function (loginResponse) {
5544
- var isFirstLogin = loginResponse.isFirstLogin,
5545
- token = loginResponse.token,
5546
- user = loginResponse.user,
5547
- isSuperAdmin = loginResponse.isSuperAdmin;
5548
- var isAcademy = !!(user !== null && user !== void 0 && user.academyDomain) || !!(user !== null && user !== void 0 && user.isLearningSpace);
5549
- var needToRegister = isStudent && isFirstLogin && isAcademy;
5550
- var redirectUrl = getRedirectUrl();
5551
- if (isStudent && !registerUrl) throw new Error("an_unexpected_error_has_occurred");
5552
- if (!redirectUrl) redirectUrl = needToRegister ? registerUrl : isAcademy ? homeAcademyUrl : homeUrl;
5553
- if (superAdminRedirectPath) {
5554
- redirectUrl = superAdminRedirectPath;
5555
- }
5556
- if (!redirectAfterLogin) redirectUrl = undefined;
5557
- redirectLoginUser(_extends({}, user, {
5558
- isNotEnoughStatements: isFirstLogin,
5559
- isSuperAdmin: isSuperAdmin
5560
- }), token, redirectUrl);
5561
- });
5562
- }, function (error) {
5563
- alert(getErrorMessage(t, error));
5564
- isLogout && handleSignOut();
5565
- });
5566
- return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
5567
- } catch (e) {
5568
- return Promise.reject(e);
5569
- }
5570
- };
5571
- var redirectLoginUser = function redirectLoginUser(data, token, redirectUrl) {
5572
- localStorage.setItem(ACCESS_TOKEN, token);
5573
- !data.academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
5574
- !!data.academyDomain && localStorage.setItem(ACADEMY_DOMAIN, data.academyDomain);
5575
- if (data.roles.includes(exports.Role.Student)) data.isLearningSpace ? localStorage.setItem(LEARNING_SPACE, "true") : localStorage.removeItem(LEARNING_SPACE);
5576
- dispatch(setUser(_extends({}, data)));
5577
- if (redirectUrl) {
5578
- pushTo(history, redirectUrl);
5579
- localStorage.removeItem(REDIRECT_URL);
5580
- }
5581
- };
5582
- return {
5583
- handleLoginGoogle: handleLoginGoogle,
5584
- handleLoginAccessToken: handleLoginAccessToken,
5585
- redirectLoginUser: redirectLoginUser
5586
- };
5344
+ }, React__default.createElement(material.Typography, {
5345
+ color: "success",
5346
+ sx: {
5347
+ fontSize: 10,
5348
+ color: "#3DC674",
5349
+ opacity: 0.8
5350
+ }
5351
+ }, t("version"), ": ", React__default.createElement("span", null, version)));
5352
+ }
5587
5353
  };
5588
5354
 
5589
- var ACADEMY_URL = BASE_URL + "/api/academy";
5590
- var SUPER_ADMIN_ACADEMY_URL = SUPER_ADMIN_BASE_URL + "/api/academies";
5591
- var getAcademyList = function getAcademyList(role) {
5592
- return api.get(SUPER_ADMIN_ACADEMY_URL + "/active", {
5593
- params: {
5594
- role: role
5595
- }
5596
- });
5355
+ var ActionButtons = function ActionButtons(_ref) {
5356
+ var _ref$className = _ref.className,
5357
+ className = _ref$className === void 0 ? "" : _ref$className,
5358
+ backText = _ref.backText,
5359
+ saveText = _ref.saveText,
5360
+ altSaveText = _ref.altSaveText,
5361
+ saveDisabled = _ref.saveDisabled,
5362
+ saveIcon = _ref.saveIcon,
5363
+ _ref$hideSave = _ref.hideSave,
5364
+ hideSave = _ref$hideSave === void 0 ? false : _ref$hideSave,
5365
+ onBack = _ref.onBack,
5366
+ onSave = _ref.onSave,
5367
+ onAltSave = _ref.onAltSave,
5368
+ isReadonly = _ref.isReadonly;
5369
+ return React__default.createElement(material.Stack, {
5370
+ direction: "row",
5371
+ spacing: 1,
5372
+ className: "" + className
5373
+ }, React__default.createElement(material.Button, {
5374
+ variant: "contained",
5375
+ className: "bg-secondary",
5376
+ startIcon: React__default.createElement(io.IoMdArrowBack, {
5377
+ size: 16
5378
+ }),
5379
+ onClick: onBack
5380
+ }, backText), !hideSave && React__default.createElement(material.Button, {
5381
+ variant: "contained",
5382
+ color: "success",
5383
+ startIcon: saveIcon != null ? saveIcon : React__default.createElement(fa.FaSave, {
5384
+ size: 16
5385
+ }),
5386
+ onClick: onSave,
5387
+ disabled: saveDisabled || isReadonly
5388
+ }, saveText), !!altSaveText && onAltSave && React__default.createElement(material.Button, {
5389
+ variant: "contained",
5390
+ color: "primary",
5391
+ startIcon: React__default.createElement(fa.FaSave, {
5392
+ size: 16
5393
+ }),
5394
+ onClick: onAltSave,
5395
+ disabled: saveDisabled
5396
+ }, altSaveText));
5597
5397
  };
5598
- var getUserAcademies = function getUserAcademies(role, isLearningSpace) {
5599
- var _headers;
5600
- return api.get("" + ACADEMY_URL, {
5601
- params: {
5602
- role: role
5603
- },
5604
- headers: (_headers = {}, _headers[NoAcademyHeaders] = isLearningSpace, _headers)
5605
- });
5398
+
5399
+ var TITLE = "not_found";
5400
+ var NotFound = function NotFound(_ref) {
5401
+ var history = _ref.history;
5402
+ var _useTranslation = reactI18next.useTranslation(),
5403
+ t = _useTranslation.t;
5404
+ history && useLanguage(history);
5405
+ React.useEffect(function () {
5406
+ document.title = t("study_peak") + " | " + t(TITLE);
5407
+ }, [t]);
5408
+ return React__default.createElement("div", {
5409
+ className: "not-found d-flex justify-content-center"
5410
+ }, React__default.createElement("div", {
5411
+ className: "clearfix pt-5"
5412
+ }, React__default.createElement("h1", {
5413
+ className: "float-left display-3 fw-bold mr-4 text-center"
5414
+ }, "404"), React__default.createElement("div", {
5415
+ className: "float-left"
5416
+ }, React__default.createElement("h4", {
5417
+ className: "pt-3"
5418
+ }, t('oops')), React__default.createElement("p", {
5419
+ className: "text-muted mb-2"
5420
+ }, t('the_page_you_are_looking_for_was_not_found')), React__default.createElement("div", null))));
5606
5421
  };
5607
- var getAcademyByDomainApi = function getAcademyByDomainApi(domain, role) {
5608
- return api.get(SUPER_ADMIN_ACADEMY_URL + "/domain/" + domain, {
5609
- params: {
5610
- role: role
5422
+
5423
+ var CommonDialog = function CommonDialog(_ref) {
5424
+ var open = _ref.open,
5425
+ children = _ref.children,
5426
+ title = _ref.title,
5427
+ _ref$size = _ref.size,
5428
+ size = _ref$size === void 0 ? "xs" : _ref$size,
5429
+ _ref$isShowHeader = _ref.isShowHeader,
5430
+ isShowHeader = _ref$isShowHeader === void 0 ? true : _ref$isShowHeader,
5431
+ titleClassName = _ref.titleClassName,
5432
+ minWidth = _ref.minWidth,
5433
+ onClose = _ref.onClose;
5434
+ return React__default.createElement(material.Dialog, {
5435
+ open: open,
5436
+ onClose: onClose,
5437
+ maxWidth: size,
5438
+ fullWidth: true,
5439
+ scroll: "body",
5440
+ sx: {
5441
+ zIndex: 1102
5442
+ },
5443
+ PaperProps: {
5444
+ sx: {
5445
+ overflowY: "unset",
5446
+ minWidth: minWidth
5447
+ }
5611
5448
  }
5612
- });
5449
+ }, isShowHeader ? React__default.createElement(React.Fragment, null, React__default.createElement(material.DialogTitle, {
5450
+ className: "border border-start-0 border-end-0 border-top-0 border-1 " + titleClassName,
5451
+ sx: {
5452
+ fontSize: "16px!important"
5453
+ }
5454
+ }, title), React__default.createElement(material.IconButton, {
5455
+ "aria-label": "close",
5456
+ onClick: onClose,
5457
+ sx: {
5458
+ position: "absolute",
5459
+ right: 8,
5460
+ top: 8,
5461
+ color: function color(theme) {
5462
+ return theme.palette.grey[500];
5463
+ }
5464
+ }
5465
+ }, React__default.createElement(io5.IoClose, null))) : React__default.createElement(material.Box, {
5466
+ className: "p-3"
5467
+ }, React__default.createElement(material.Typography, {
5468
+ className: "fs-5 text-center fw-bold"
5469
+ }, title)), children);
5613
5470
  };
5614
- var getAcademyDetail = function getAcademyDetail() {
5615
- return api.get(ACADEMY_URL + "/detail");
5471
+
5472
+ var confirmDialogTextStyle = {
5473
+ color: "#363634",
5474
+ fontSize: 16,
5475
+ fontWeight: 700
5616
5476
  };
5617
- var switchAcademy = function switchAcademy(academyId, role, isLearningSpace) {
5618
- if (isLearningSpace === void 0) {
5619
- isLearningSpace = false;
5620
- }
5621
- return api.post(ACADEMY_URL + "/" + academyId + "/switch-academy/" + role, undefined, {
5622
- params: {
5623
- isLearningSpace: isLearningSpace
5624
- }
5625
- });
5477
+ var confirmDialogButtonStyle = {
5478
+ width: "120px",
5479
+ fontSize: 14,
5480
+ fontWeight: 700
5626
5481
  };
5627
- var switchSuperAdminAcademy = function switchSuperAdminAcademy(academyId, role) {
5628
- return api.post(SUPER_ADMIN_ACADEMY_URL + "/" + academyId + "/switch-academy/" + role);
5482
+ var ConfirmDeleteDialogDefaultProps = {
5483
+ titleStyle: confirmDialogTextStyle,
5484
+ contentStyle: {
5485
+ paddingTop: "36px",
5486
+ padding: "36px",
5487
+ width: 363
5488
+ },
5489
+ contentTextStyle: _extends({}, confirmDialogTextStyle, {
5490
+ textAlign: "center"
5491
+ }),
5492
+ actionStyle: {
5493
+ justifyContent: "space-between",
5494
+ padding: "12px"
5495
+ },
5496
+ okButtonStyle: confirmDialogButtonStyle,
5497
+ cancelButtonStyle: _extends({}, confirmDialogButtonStyle, {
5498
+ color: "#3dc674"
5499
+ }),
5500
+ cancelButtonVariant: "text",
5501
+ isDelete: true
5629
5502
  };
5630
5503
 
5631
- var useSwitchAcademy = function useSwitchAcademy(role, history, homeAcademyUrl, homeUrl, registerUrl, canFetchAcademies) {
5632
- var _user$roles;
5633
- if (role === void 0) {
5634
- role = exports.Role.Student;
5635
- }
5636
- if (canFetchAcademies === void 0) {
5637
- canFetchAcademies = false;
5638
- }
5639
- var dispatch = reactRedux.useDispatch();
5640
- var _useLogin = useLogin(history, homeAcademyUrl, homeUrl, registerUrl),
5641
- handleLoginAccessToken = _useLogin.handleLoginAccessToken;
5642
- var academyList = reactRedux.useSelector(function (state) {
5643
- var _state$academies;
5644
- return state === null || state === void 0 ? void 0 : (_state$academies = state.academies) === null || _state$academies === void 0 ? void 0 : _state$academies.items;
5645
- }) || [];
5646
- var _useState = React.useState(false),
5647
- dropdownOpen = _useState[0],
5648
- setDropdownOpen = _useState[1];
5649
- var toggleDropdown = function toggleDropdown() {
5650
- return setDropdownOpen(function (prevState) {
5651
- return !prevState;
5652
- });
5653
- };
5654
- var user = reactRedux.useSelector(function (state) {
5655
- var _state$common;
5656
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
5657
- });
5658
- var isReFetchUserAcademies = reactRedux.useSelector(function (state) {
5659
- var _state$common2;
5660
- return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
5661
- });
5504
+ var ConfirmDialog = function ConfirmDialog(_ref) {
5505
+ var open = _ref.open,
5506
+ text = _ref.text,
5507
+ cancelText = _ref.cancelText,
5508
+ okText = _ref.okText,
5509
+ isDelete = _ref.isDelete,
5510
+ title = _ref.title,
5511
+ confirmText = _ref.confirmText,
5512
+ titleStyle = _ref.titleStyle,
5513
+ titleClassName = _ref.titleClassName,
5514
+ contentStyle = _ref.contentStyle,
5515
+ cancelButtonStyle = _ref.cancelButtonStyle,
5516
+ contentTextStyle = _ref.contentTextStyle,
5517
+ okButtonStyle = _ref.okButtonStyle,
5518
+ actionStyle = _ref.actionStyle,
5519
+ _ref$okButtonVariant = _ref.okButtonVariant,
5520
+ okButtonVariant = _ref$okButtonVariant === void 0 ? "contained" : _ref$okButtonVariant,
5521
+ _ref$cancelButtonVari = _ref.cancelButtonVariant,
5522
+ cancelButtonVariant = _ref$cancelButtonVari === void 0 ? "contained" : _ref$cancelButtonVari,
5523
+ _ref$zIndex = _ref.zIndex,
5524
+ zIndex = _ref$zIndex === void 0 ? 1102 : _ref$zIndex,
5525
+ toggle = _ref.toggle,
5526
+ onConfirm = _ref.onConfirm;
5527
+ var _useState = React.useState(),
5528
+ confirmTextValue = _useState[0],
5529
+ setConfirmTextValue = _useState[1];
5662
5530
  var _useTranslation = reactI18next.useTranslation(),
5663
5531
  t = _useTranslation.t;
5664
- var getAcademies = function getAcademies(isLoading) {
5665
- if (isLoading === void 0) {
5666
- isLoading = true;
5667
- }
5668
- try {
5669
- var _temp3 = function _temp3() {
5670
- isLoading && dispatch(setLoading(false));
5671
- };
5672
- if (!user) return Promise.resolve();
5673
- var isSuperAdminUser = user && !user.academyDomain && !(user !== null && user !== void 0 && user.isLearningSpace);
5674
- var isSuperAdminRole = user.roles.includes(exports.Role.Admin);
5675
- isLoading && dispatch(setLoading(true));
5676
- var _temp2 = _catch(function () {
5677
- return Promise.resolve(isSuperAdminUser ? getAcademyList(role) : getUserAcademies(role, user === null || user === void 0 ? void 0 : user.isLearningSpace)).then(function (res) {
5678
- var items = res.data.items || [];
5679
- if (isReFetchUserAcademies) dispatch(setReFetchUserAcademies(false));
5680
- dispatch(setAcademies(items));
5681
- var _temp = function () {
5682
- if (!isSuperAdminRole && isSuperAdminUser && role == exports.Role.Admin && items.length > 0) {
5683
- return Promise.resolve(handleSwitchAcademy(false, items[0], false)).then(function () {});
5684
- }
5685
- }();
5686
- if (_temp && _temp.then) return _temp.then(function () {});
5687
- });
5688
- }, function (error) {
5689
- reactToastify.toast.error(getErrorMessage(t, error));
5690
- });
5691
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
5692
- } catch (e) {
5693
- return Promise.reject(e);
5694
- }
5532
+ var handleConfirm = function handleConfirm() {
5533
+ onConfirm();
5695
5534
  };
5696
- var handleSwitchAcademy = function handleSwitchAcademy(isLearningSpace, selectedAcademy, isLoading, superAdminRedirectPath) {
5697
- if (isLoading === void 0) {
5698
- isLoading = true;
5535
+ var handleChangeConfirmText = function handleChangeConfirmText(e) {
5536
+ setConfirmTextValue(e.target.value);
5537
+ };
5538
+ var handlePaste = function handlePaste(_) {};
5539
+ React.useEffect(function () {
5540
+ !open && setConfirmTextValue(undefined);
5541
+ }, [open]);
5542
+ var isValid = !!confirmText && !!confirmTextValue && confirmTextValue.trim() === confirmText.trim();
5543
+ var isDisableDelete = !!confirmText && (confirmTextValue === null || confirmTextValue === void 0 ? void 0 : confirmTextValue.trim()) !== confirmText.trim();
5544
+ return React__default.createElement(material.Dialog, {
5545
+ open: open,
5546
+ onClose: toggle,
5547
+ sx: {
5548
+ zIndex: zIndex
5699
5549
  }
5700
- try {
5701
- var _temp5 = function _temp5() {
5702
- isLoading && dispatch(setLoading(false));
5703
- setDropdownOpen(false);
5704
- };
5705
- isLoading && dispatch(setLoading(true));
5706
- var academyId = selectedAcademy ? selectedAcademy.id : 0;
5707
- var academyDomain = selectedAcademy ? selectedAcademy.domain : undefined;
5708
- var isSuperAdminUser = user && !user.academyDomain && !(user !== null && user !== void 0 && user.isLearningSpace);
5709
- var _temp4 = _catch(function () {
5710
- return Promise.resolve(isSuperAdminUser ? switchSuperAdminAcademy(academyId, role) : switchAcademy(academyId, role, isLearningSpace)).then(function (res) {
5711
- var data = res.data;
5712
- var requestBody = {
5713
- accessToken: data.accessToken,
5714
- email: user.email,
5715
- role: role
5716
- };
5717
- return Promise.resolve(handleLoginAccessToken(requestBody, isLearningSpace, academyDomain, false, superAdminRedirectPath)).then(function () {});
5718
- });
5719
- }, function (error) {
5720
- reactToastify.toast.error(getErrorMessage(t, error));
5721
- });
5722
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
5723
- } catch (e) {
5724
- return Promise.reject(e);
5550
+ }, React__default.createElement(React.Fragment, null, React__default.createElement(material.DialogTitle, {
5551
+ className: "border border-start-0 border-end-0 border-top-0 border-1 " + titleClassName,
5552
+ sx: _extends({
5553
+ fontSize: 16
5554
+ }, titleStyle)
5555
+ }, title || t('confirmation')), React__default.createElement(material.IconButton, {
5556
+ "aria-label": "close",
5557
+ onClick: toggle,
5558
+ sx: {
5559
+ position: "absolute",
5560
+ right: 8,
5561
+ top: 8,
5562
+ color: function color(theme) {
5563
+ return theme.palette.grey[500];
5564
+ }
5565
+ }
5566
+ }, React__default.createElement(io5.IoClose, null))), React__default.createElement(material.DialogContent, {
5567
+ sx: _extends({
5568
+ pt: 0.5
5569
+ }, contentStyle)
5570
+ }, React__default.createElement(material.Typography, {
5571
+ className: "mb-1",
5572
+ sx: _extends({
5573
+ fontWeight: 700
5574
+ }, contentTextStyle)
5575
+ }, text), !!confirmText && React__default.createElement("div", {
5576
+ className: "w-100"
5577
+ }, React__default.createElement("p", {
5578
+ className: "mb-3"
5579
+ }, t("enter_text_to_confirm_delete", {
5580
+ text: confirmText
5581
+ })), React__default.createElement(material.TextField, {
5582
+ className: "w-100",
5583
+ sx: {
5584
+ "& input": {
5585
+ py: 1
5586
+ }
5587
+ },
5588
+ value: confirmTextValue,
5589
+ onChange: handleChangeConfirmText,
5590
+ placeholder: t('please_enter'),
5591
+ onPaste: handlePaste,
5592
+ error: !isValid && confirmTextValue !== undefined,
5593
+ color: isValid ? "success" : confirmTextValue !== undefined ? "error" : undefined
5594
+ }))), React__default.createElement(material.DialogActions, {
5595
+ className: "border border-start-0 border-end-0 border-bottom-0 border-1 " + titleClassName,
5596
+ sx: _extends({
5597
+ paddingTop: 1
5598
+ }, actionStyle)
5599
+ }, React__default.createElement(material.Button, {
5600
+ variant: cancelButtonVariant,
5601
+ color: cancelButtonVariant !== "contained" ? "primary" : "secondary",
5602
+ className: "px-3 " + (cancelButtonVariant !== "contained" ? "primary" : "bg-secondary"),
5603
+ onClick: toggle,
5604
+ sx: cancelButtonStyle
5605
+ }, cancelText || t("no")), React__default.createElement(material.Button, {
5606
+ variant: okButtonVariant,
5607
+ color: isDelete ? "error" : "primary",
5608
+ className: "px-3",
5609
+ disabled: isDisableDelete,
5610
+ onClick: handleConfirm,
5611
+ sx: _extends({}, okButtonStyle, isDelete && {
5612
+ backgroundColor: "#db4d4d",
5613
+ color: "#FFFFFF",
5614
+ "&:hover": {
5615
+ backgroundColor: "#C41414"
5616
+ }
5617
+ })
5618
+ }, okText || t('yes'))));
5619
+ };
5620
+
5621
+ var ConfirmDeleteDialog = function ConfirmDeleteDialog(props) {
5622
+ return React__default.createElement(ConfirmDialog, Object.assign({}, ConfirmDeleteDialogDefaultProps, props));
5623
+ };
5624
+
5625
+ var _templateObject;
5626
+ var BorderedTextField = material.styled(material.TextField)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n & .MuiOutlinedInput-root {\n &.Mui-focused fieldset {\n border-width: 1px;\n border-color: ", ";\n }\n }\n & .MuiOutlinedInput-root:hover {\n fieldset {\n border-width: 1px;\n border-color: ", ";\n }\n }\n"])), styles.dark, styles.less_dark);
5627
+ var InputText = function InputText(props) {
5628
+ return React__default.createElement(BorderedTextField, Object.assign({
5629
+ sx: {
5630
+ "& input": {
5631
+ py: "7.5px",
5632
+ px: "12px"
5633
+ },
5634
+ "& > div": {
5635
+ borderColor: "#97A1AF",
5636
+ borderRadius: "4px"
5637
+ }
5725
5638
  }
5639
+ }, props));
5640
+ };
5641
+
5642
+ var PassCodeDialog = function PassCodeDialog(_ref) {
5643
+ var open = _ref.open,
5644
+ onClose = _ref.onClose,
5645
+ onSubmit = _ref.onSubmit,
5646
+ academyDomain = _ref.academyDomain;
5647
+ var _useTranslation = reactI18next.useTranslation(),
5648
+ t = _useTranslation.t;
5649
+ var _useState = React.useState(""),
5650
+ passCode = _useState[0],
5651
+ setPassCode = _useState[1];
5652
+ var handleClose = function handleClose(event, reason) {
5653
+ onClose(event, reason);
5726
5654
  };
5727
- var handleLogOutAcademy = function handleLogOutAcademy(callback) {
5655
+ var handleSubmit = function handleSubmit() {
5728
5656
  try {
5729
- var _temp7 = function _temp7() {
5730
- dispatch(setLoading(false));
5731
- callback();
5657
+ var data = {
5658
+ code: passCode,
5659
+ academyDomain: academyDomain
5732
5660
  };
5733
- dispatch(setLoading(true));
5734
- var _temp6 = _catch(function () {
5735
- return Promise.resolve(switchAcademy(0, role)).then(function (res) {
5736
- var data = res.data;
5737
- var requestBody = {
5738
- accessToken: data.accessToken,
5739
- email: user.email,
5740
- role: role
5741
- };
5742
- return Promise.resolve(handleLoginAccessToken(requestBody, undefined, undefined, false)).then(function () {});
5743
- });
5744
- }, function (error) {
5745
- reactToastify.toast.error(getErrorMessage(t, error));
5746
- });
5747
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6));
5661
+ return Promise.resolve(onSubmit(data, handleClose)).then(function () {});
5748
5662
  } catch (e) {
5749
5663
  return Promise.reject(e);
5750
5664
  }
5751
5665
  };
5752
- React.useEffect(function () {
5753
- canFetchAcademies && getAcademies();
5754
- }, [canFetchAcademies, user === null || user === void 0 ? void 0 : user.academyDomain, user === null || user === void 0 ? void 0 : user.email, user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.join(",")]);
5755
- React.useEffect(function () {
5756
- canFetchAcademies && isReFetchUserAcademies && getAcademies(false);
5757
- }, [canFetchAcademies, isReFetchUserAcademies]);
5758
- var selectedAcademy = React.useMemo(function () {
5759
- return academyList.find(function (i) {
5760
- var _user$academyDomain;
5761
- return i.domain.trim().toLowerCase() === (user === null || user === void 0 ? void 0 : (_user$academyDomain = user.academyDomain) === null || _user$academyDomain === void 0 ? void 0 : _user$academyDomain.trim().toLowerCase());
5762
- });
5763
- }, [user === null || user === void 0 ? void 0 : user.academyDomain, JSON.stringify(academyList)]);
5764
- return {
5765
- selectedAcademy: selectedAcademy,
5766
- dropdownOpen: dropdownOpen,
5767
- academyList: academyList,
5768
- toggleDropdown: toggleDropdown,
5769
- handleSwitchAcademy: handleSwitchAcademy,
5770
- handleLogOutAcademy: handleLogOutAcademy
5666
+ var handleChangePassCode = function handleChangePassCode(e) {
5667
+ setPassCode(e.target.value);
5771
5668
  };
5669
+ var theme = material.useTheme();
5670
+ return React__default.createElement(CommonDialog, {
5671
+ open: open,
5672
+ onClose: handleClose,
5673
+ size: "xs",
5674
+ title: t("join_an_academy")
5675
+ }, React__default.createElement(material.DialogContent, {
5676
+ sx: {
5677
+ overflowY: "unset"
5678
+ }
5679
+ }, React__default.createElement(material.Stack, {
5680
+ direction: "column",
5681
+ spacing: 2,
5682
+ zIndex: 1,
5683
+ position: "relative"
5684
+ }, React__default.createElement(material.FormGroup, null, React__default.createElement(material.FormLabel, {
5685
+ className: "fw-medium mb-1"
5686
+ }, t("pass_code"), React__default.createElement("span", {
5687
+ className: "text-danger"
5688
+ }, "*")), React__default.createElement(InputText, {
5689
+ id: "pass-code",
5690
+ placeholder: t("enter_pass_code"),
5691
+ value: passCode,
5692
+ onChange: handleChangePassCode
5693
+ })))), React__default.createElement(material.DialogActions, {
5694
+ className: ""
5695
+ }, React__default.createElement(material.Button, {
5696
+ variant: "contained",
5697
+ sx: {
5698
+ bgcolor: theme.palette.grey[700]
5699
+ },
5700
+ onClick: handleClose
5701
+ }, t("cancel")), React__default.createElement(material.Button, {
5702
+ variant: "contained",
5703
+ onClick: handleSubmit,
5704
+ disabled: !passCode.trim().length
5705
+ }, t("confirmation"))));
5772
5706
  };
5773
5707
 
5774
- var useVirtualizeList = function useVirtualizeList(totalItems, rowHeight, offsetRow, minRows) {
5775
- if (offsetRow === void 0) {
5776
- offsetRow = 1;
5777
- }
5778
- var _useState = React.useState(-1),
5779
- startIndex = _useState[0],
5780
- setStartIndex = _useState[1];
5781
- var _useState2 = React.useState(-1),
5782
- endIndex = _useState2[0],
5783
- setEndIndex = _useState2[1];
5784
- var containerRef = React.useRef(null);
5785
- var handleScroll = React.useCallback(function () {
5786
- if (containerRef.current) {
5787
- var _containerRef$current = containerRef.current,
5788
- scrollTop = _containerRef$current.scrollTop,
5789
- clientHeight = _containerRef$current.clientHeight;
5790
- var itemsPerPage = Math.ceil(clientHeight / rowHeight);
5791
- var newStartIndex = Math.max(Math.floor(scrollTop / rowHeight) - offsetRow, 0);
5792
- var newEndIndex = Math.min(newStartIndex + itemsPerPage + offsetRow, totalItems - 1);
5793
- if (minRows) {
5794
- if (totalItems <= minRows) {
5795
- newStartIndex = -1;
5796
- newEndIndex = -1;
5797
- } else {
5798
- var total = newEndIndex - newStartIndex;
5799
- var diff = minRows - total;
5800
- if (diff > 0) {
5801
- var valS = diff / 2;
5802
- var valE = diff - valS;
5803
- if (newStartIndex < valS) {
5804
- valE += valS - newStartIndex;
5805
- newStartIndex = 0;
5806
- }
5807
- if (newEndIndex + valE > totalItems - 1) {
5808
- valS += newEndIndex + valE - totalItems + 1;
5809
- }
5810
- newStartIndex = Math.max(newStartIndex - valS, 0);
5811
- newEndIndex = Math.min(newEndIndex + valE, totalItems - 1);
5812
- }
5813
- }
5814
- }
5815
- setStartIndex(newStartIndex);
5816
- setEndIndex(newEndIndex);
5817
- }
5818
- }, [totalItems, rowHeight, offsetRow]);
5819
- React.useEffect(function () {
5820
- var container = containerRef.current;
5821
- if (container) {
5822
- container.addEventListener("scroll", handleScroll);
5823
- }
5824
- return function () {
5825
- if (container) {
5826
- container.removeEventListener("scroll", handleScroll);
5827
- }
5828
- };
5829
- }, [handleScroll]);
5830
- var handleChangeStartIndex = function handleChangeStartIndex(index) {
5831
- setStartIndex(index);
5832
- };
5833
- var handleChangeEndIndex = function handleChangeEndIndex(index) {
5834
- setEndIndex(index);
5835
- };
5836
- return {
5837
- startIndex: startIndex,
5838
- endIndex: endIndex,
5839
- containerRef: containerRef,
5840
- handleChangeStartIndex: handleChangeStartIndex,
5841
- handleChangeEndIndex: handleChangeEndIndex
5708
+ var loadingStyle = {
5709
+ minWidth: "100vw",
5710
+ minHeight: "100vh",
5711
+ position: "fixed",
5712
+ top: 0,
5713
+ left: 0,
5714
+ zIndex: 999999999,
5715
+ backgroundColor: "rgba(0, 0, 0, 0.4)",
5716
+ display: "flex",
5717
+ justifyContent: "center",
5718
+ alignItems: "center"
5719
+ };
5720
+ var Loading = function Loading() {
5721
+ var isLoading = reactRedux.useSelector(function (state) {
5722
+ return state.common.isLoading;
5723
+ });
5724
+ return isLoading ? React__default.createElement("div", {
5725
+ style: loadingStyle
5726
+ }, React__default.createElement("div", {
5727
+ className: "spinner-border text-secondary",
5728
+ role: "status"
5729
+ }, React__default.createElement("span", {
5730
+ className: "sr-only"
5731
+ }))) : null;
5732
+ };
5733
+
5734
+ var loadingStyle$1 = {
5735
+ minWidth: "100vw",
5736
+ minHeight: "100vh",
5737
+ position: "fixed",
5738
+ top: 0,
5739
+ left: 0,
5740
+ zIndex: 999999999,
5741
+ backgroundColor: "rgba(0, 0, 0, 0.4)",
5742
+ display: "flex",
5743
+ justifyContent: "center",
5744
+ alignItems: "center"
5745
+ };
5746
+ var LoadingComponent = function LoadingComponent(_ref) {
5747
+ var isLoading = _ref.isLoading,
5748
+ children = _ref.children,
5749
+ _ref$spinClassName = _ref.spinClassName,
5750
+ spinClassName = _ref$spinClassName === void 0 ? "text-secondary" : _ref$spinClassName,
5751
+ _ref$className = _ref.className,
5752
+ className = _ref$className === void 0 ? "" : _ref$className;
5753
+ return isLoading ? React__default.createElement("div", {
5754
+ style: loadingStyle$1
5755
+ }, React__default.createElement(material.Stack, {
5756
+ direction: "column",
5757
+ justifyContent: "center",
5758
+ alignItems: "center",
5759
+ className: className
5760
+ }, React__default.createElement("div", {
5761
+ className: "spinner-border " + spinClassName,
5762
+ role: "status"
5763
+ }, React__default.createElement("span", {
5764
+ className: "sr-only"
5765
+ })), React__default.createElement("div", null, children))) : null;
5766
+ };
5767
+
5768
+ var CustomPagination = function CustomPagination(_ref) {
5769
+ var currentPage = _ref.currentPage,
5770
+ totalPage = _ref.totalPage,
5771
+ onChangePage = _ref.onChangePage;
5772
+ var handleChangePage = function handleChangePage(_, page) {
5773
+ onChangePage(page);
5842
5774
  };
5775
+ return React__default.createElement(material.Pagination, {
5776
+ className: "w-fit",
5777
+ count: totalPage,
5778
+ page: currentPage,
5779
+ onChange: handleChangePage
5780
+ });
5843
5781
  };
5844
5782
 
5845
- (function (RecentUserActionSortBy) {
5846
- RecentUserActionSortBy["CreatedAt"] = "CreatedAt";
5847
- })(exports.RecentUserActionSortBy || (exports.RecentUserActionSortBy = {}));
5848
- (function (OrderBy) {
5849
- OrderBy["ASC"] = "ASC";
5850
- OrderBy["DESC"] = "DESC";
5851
- })(exports.OrderBy || (exports.OrderBy = {}));
5783
+ var DropdownIndicator = function DropdownIndicator(props) {
5784
+ return React__default.createElement(Select.components.DropdownIndicator, Object.assign({}, props), React__default.createElement(fa.FaCaretDown, {
5785
+ size: 20,
5786
+ color: styles.darker
5787
+ }));
5788
+ };
5789
+ var CustomOption = function CustomOption(props) {
5790
+ return React__default.createElement(Select.components.Option, Object.assign({}, props), React__default.createElement("div", {
5791
+ style: {
5792
+ fontSize: "14px",
5793
+ fontWeight: 500
5794
+ }
5795
+ }, props.data.label));
5796
+ };
5852
5797
 
5853
- var api = axios.create({
5854
- baseURL: BASE_URL,
5855
- timeout: 0,
5856
- headers: {
5857
- "Content-Type": "application/json"
5798
+ var customStyles = {
5799
+ control: function control(baseStyles, state) {
5800
+ return _extends({}, baseStyles, {
5801
+ fontSize: "14px",
5802
+ fontWeight: 700,
5803
+ color: styles.darker,
5804
+ borderColor: state.isFocused || state.hasValue ? styles.dark : styles.less_dark,
5805
+ boxShadow: state.isFocused ? "0 0 0 1px " + styles.dark + "4D" : baseStyles.boxShadow,
5806
+ "&:active": {
5807
+ borderColor: state.isFocused || state.hasValue ? styles.dark : styles.less_dark
5808
+ },
5809
+ "&:hover": {
5810
+ borderColor: state.isFocused || state.hasValue ? styles.dark : styles.less_dark
5811
+ }
5812
+ });
5858
5813
  },
5859
- paramsSerializer: function paramsSerializer(params) {
5860
- return encodeParams(params);
5861
- }
5862
- });
5863
- var apiUpload = axios.create({
5864
- baseURL: BASE_URL,
5865
- timeout: 60000,
5866
- headers: {
5867
- "Content-Type": "multipart/form-data"
5814
+ input: function input(baseStyles, _) {
5815
+ return _extends({}, baseStyles, {
5816
+ fontSize: "14px",
5817
+ fontWeight: 700,
5818
+ color: styles.darker
5819
+ });
5820
+ },
5821
+ singleValue: function singleValue(baseStyles) {
5822
+ return _extends({}, baseStyles, {
5823
+ fontSize: "14px",
5824
+ fontWeight: 700,
5825
+ color: styles.darker
5826
+ });
5827
+ },
5828
+ option: function option(baseStyles, state) {
5829
+ return _extends({}, baseStyles, {
5830
+ backgroundColor: state.isSelected ? styles.dark : state.isFocused ? styles.light : 'white',
5831
+ "&:active": {
5832
+ backgroundColor: state.isSelected ? styles.dark : state.isFocused ? styles.less_dark : baseStyles.backgroundColor
5833
+ }
5834
+ });
5868
5835
  }
5869
- });
5870
- [api, apiUpload].forEach(function (i) {
5871
- return i.interceptors.request.use(function (config) {
5872
- var token = getAccessToken();
5873
- var searchParams = new URLSearchParams(window.location.search);
5874
- var paramLang = searchParams.get('lang');
5875
- var academyDomainStorage = getAcademyDomain();
5876
- var isLearningSpace = getLearningSpace();
5877
- var langStorage = getLanguage();
5878
- var academyDomain = academyDomainStorage;
5879
- var language = paramLang || langStorage;
5880
- if (token) {
5881
- config.headers.Authorization = "Bearer " + token;
5882
- localStorage.setItem("LAST_TIME_REQUEST", moment().utc().format("YYYY-MM-DD HH:mm:ss"));
5883
- }
5884
- if (academyDomain && !isLearningSpace && config.headers[AcademyHeaders] == undefined) config.headers[AcademyHeaders] = "" + academyDomain;
5885
- if (isLearningSpace && config.headers[NoAcademyHeaders] == undefined) config.headers[NoAcademyHeaders] = "" + isLearningSpace;
5886
- if (language) config.headers[LanguageHeaders] = "" + language;
5887
- return config;
5888
- }, function (error) {
5889
- return Promise.reject(error);
5836
+ };
5837
+
5838
+ var _excluded = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
5839
+ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
5840
+ var isDefault = _ref.isDefault,
5841
+ options = _ref.options,
5842
+ isDisabled = _ref.isDisabled,
5843
+ scrollBottom = _ref.scrollBottom,
5844
+ value = _ref.value,
5845
+ isMulti = _ref.isMulti,
5846
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
5847
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
5848
+ return value.includes(i.value);
5849
+ }) : isMulti ? options.filter(function (i) {
5850
+ return i.value == value;
5851
+ }) : options.find(function (i) {
5852
+ return i.value == value;
5890
5853
  });
5891
- });
5892
- [api, apiUpload].forEach(function (i) {
5893
- return i.interceptors.response.use(function (response) {
5894
- return response;
5895
- }, function (error) {
5896
- var _error$response, _error$response2, _error$response3;
5897
- console.log({
5898
- error: error
5899
- });
5900
- if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
5901
- var _window$location = window.location,
5902
- pathname = _window$location.pathname,
5903
- search = _window$location.search;
5904
- var preRedirectUrl = localStorage.getItem(PRE_REDIRECT_URL);
5905
- var newRedirectUrl = "" + pathname + search;
5906
- if (!pathname.startsWith("/login")) {
5907
- if (preRedirectUrl !== newRedirectUrl) {
5908
- localStorage.setItem(REDIRECT_URL, newRedirectUrl);
5909
- localStorage.setItem(PRE_REDIRECT_URL, newRedirectUrl);
5910
- }
5911
- }
5912
- }
5913
- if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 401 || ((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status) == 403) {
5914
- localStorage.removeItem(ACCESS_TOKEN);
5915
- window.location.href = "/login";
5916
- }
5917
- return Promise.reject(error);
5854
+ var _useTranslation = reactI18next.useTranslation(),
5855
+ t = _useTranslation.t;
5856
+ return React__default.createElement(Select__default, Object.assign({
5857
+ isDisabled: isDisabled,
5858
+ options: options,
5859
+ value: !isDefault ? initialValues : undefined,
5860
+ defaultValue: isDefault ? initialValues : undefined,
5861
+ menuPlacement: scrollBottom ? "top" : "auto",
5862
+ isMulti: isMulti,
5863
+ components: {
5864
+ IndicatorSeparator: function IndicatorSeparator() {
5865
+ return null;
5866
+ },
5867
+ DropdownIndicator: DropdownIndicator,
5868
+ Option: CustomOption
5869
+ },
5870
+ styles: customStyles,
5871
+ placeholder: t("select_placeholder")
5872
+ }, rest));
5873
+ };
5874
+
5875
+ var _excluded$1 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
5876
+ var CustomCreatable = function CustomCreatable(_ref) {
5877
+ var options = _ref.options,
5878
+ isDisabled = _ref.isDisabled,
5879
+ scrollBottom = _ref.scrollBottom,
5880
+ value = _ref.value,
5881
+ isMulti = _ref.isMulti,
5882
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
5883
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
5884
+ return value.includes(i.value);
5885
+ }) : isMulti ? options.filter(function (i) {
5886
+ return i.value == value;
5887
+ }) : options.find(function (i) {
5888
+ return i.value == value;
5918
5889
  });
5919
- });
5890
+ var _useTranslation = reactI18next.useTranslation(),
5891
+ t = _useTranslation.t;
5892
+ return React__default.createElement(CreatableSelect, Object.assign({
5893
+ isClearable: true,
5894
+ isDisabled: isDisabled,
5895
+ options: options,
5896
+ value: initialValues,
5897
+ menuPlacement: scrollBottom ? "top" : "auto",
5898
+ isMulti: isMulti,
5899
+ components: {
5900
+ IndicatorSeparator: function IndicatorSeparator() {
5901
+ return null;
5902
+ },
5903
+ DropdownIndicator: DropdownIndicator,
5904
+ Option: CustomOption
5905
+ },
5906
+ styles: customStyles,
5907
+ placeholder: t("select_placeholder")
5908
+ }, rest));
5909
+ };
5920
5910
 
5921
- var PrintState;
5922
- (function (PrintState) {
5923
- PrintState[PrintState["Idling"] = 0] = "Idling";
5924
- PrintState[PrintState["Stopped"] = 1] = "Stopped";
5925
- PrintState[PrintState["Printing"] = 2] = "Printing";
5926
- PrintState[PrintState["Paused"] = 3] = "Paused";
5927
- })(PrintState || (PrintState = {}));
5911
+ var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
5912
+ var CustomSelect = function CustomSelect(_ref) {
5913
+ var isDefault = _ref.isDefault,
5914
+ options = _ref.options,
5915
+ isDisabled = _ref.isDisabled,
5916
+ scrollBottom = _ref.scrollBottom,
5917
+ value = _ref.value,
5918
+ isMulti = _ref.isMulti,
5919
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
5920
+ var _useTranslation = reactI18next.useTranslation(),
5921
+ t = _useTranslation.t;
5922
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
5923
+ return value.includes(i.value);
5924
+ }) : isMulti ? options === null || options === void 0 ? void 0 : options.filter(function (i) {
5925
+ return i.value == value;
5926
+ }) : options === null || options === void 0 ? void 0 : options.find(function (i) {
5927
+ return i.value == value;
5928
+ });
5929
+ return React__default.createElement(Select__default, Object.assign({
5930
+ isDisabled: isDisabled,
5931
+ options: options,
5932
+ value: !isDefault ? initialValues != null ? initialValues : null : undefined,
5933
+ defaultValue: isDefault ? initialValues : undefined,
5934
+ menuPlacement: scrollBottom ? "top" : "auto",
5935
+ isMulti: isMulti,
5936
+ components: {
5937
+ IndicatorSeparator: function IndicatorSeparator() {
5938
+ return null;
5939
+ },
5940
+ DropdownIndicator: DropdownIndicator,
5941
+ Option: CustomOption
5942
+ },
5943
+ styles: customStyles,
5944
+ placeholder: t("select_placeholder")
5945
+ }, rest));
5946
+ };
5928
5947
 
5929
- var TabList = [{
5930
- label: "comprehensive_analysis",
5931
- value: 0
5932
- }, {
5933
- label: "solution_order",
5934
- value: 1
5935
- }, {
5936
- label: "compare_solution",
5937
- value: 2
5938
- }, {
5939
- label: "problem_analysis",
5940
- value: 3
5941
- }];
5948
+ var _excluded$3 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti", "valueById", "isTextbook"];
5949
+ var CustomSelectOption = function CustomSelectOption(_ref) {
5950
+ var defaultValue = _ref.defaultValue,
5951
+ options = _ref.options,
5952
+ isDisabled = _ref.isDisabled,
5953
+ scrollBottom = _ref.scrollBottom,
5954
+ value = _ref.value,
5955
+ isMulti = _ref.isMulti,
5956
+ valueById = _ref.valueById,
5957
+ isTextbook = _ref.isTextbook,
5958
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
5959
+ var _useTranslation = reactI18next.useTranslation(),
5960
+ t = _useTranslation.t;
5961
+ var initialValues = defaultValue !== null && typeof defaultValue !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
5962
+ return option.value === defaultValue;
5963
+ })) || null : null;
5964
+ var optionValue = valueById !== null && typeof valueById !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
5965
+ return option.value == valueById;
5966
+ })) || {
5967
+ label: valueById,
5968
+ value: valueById
5969
+ } : null;
5970
+ return isTextbook ? React__default.createElement(CreatableSelect, Object.assign({
5971
+ isDisabled: isDisabled,
5972
+ options: options,
5973
+ value: optionValue || value,
5974
+ defaultValue: initialValues,
5975
+ menuPlacement: scrollBottom ? "top" : "auto",
5976
+ isMulti: isMulti,
5977
+ components: {
5978
+ IndicatorSeparator: function IndicatorSeparator() {
5979
+ return null;
5980
+ },
5981
+ DropdownIndicator: DropdownIndicator,
5982
+ Option: CustomOption
5983
+ },
5984
+ styles: customStyles,
5985
+ placeholder: t("select_placeholder")
5986
+ }, rest)) : React__default.createElement(Select__default, Object.assign({
5987
+ isDisabled: isDisabled,
5988
+ options: options,
5989
+ value: optionValue || value,
5990
+ defaultValue: initialValues,
5991
+ menuPlacement: scrollBottom ? "top" : "auto",
5992
+ isMulti: isMulti,
5993
+ components: {
5994
+ IndicatorSeparator: function IndicatorSeparator() {
5995
+ return null;
5996
+ },
5997
+ DropdownIndicator: DropdownIndicator,
5998
+ Option: CustomOption
5999
+ },
6000
+ styles: customStyles,
6001
+ placeholder: t("select_placeholder")
6002
+ }, rest));
6003
+ };
5942
6004
 
5943
- var TOTAL = 3;
5944
- var PrintExamView2 = function PrintExamView2(_ref) {
5945
- var history = _ref.history,
5946
- role = _ref.role,
5947
- dataExamSession = _ref.dataExamSession;
6005
+ var SCORE_OPTIONS = Array.from({
6006
+ length: 10
6007
+ }, function (_, i) {
6008
+ return i + 1;
6009
+ });
6010
+ var QUESTION_OPTIONS = Array.from({
6011
+ length: 10
6012
+ }, function (_, i) {
6013
+ return i + 1;
6014
+ });
6015
+ var ANSWER_OPTIONS = Array.from({
6016
+ length: 9
6017
+ }, function (_, i) {
6018
+ return i + 2;
6019
+ });
6020
+ var DEFAULT_SCORE = 2;
6021
+
6022
+ var AnswerCountSelector = function AnswerCountSelector(_ref) {
6023
+ var id = _ref.id,
6024
+ value = _ref.value,
6025
+ onChange = _ref.onChange,
6026
+ isDisabled = _ref.isDisabled;
5948
6027
  var _useTranslation = reactI18next.useTranslation(),
5949
6028
  t = _useTranslation.t;
5950
- var isTeacher = exports.Role.Teacher === role;
5951
- var dataProps = isTeacher ? dataExamSession.map(function (i) {
6029
+ var answerOptions = ANSWER_OPTIONS.map(function (i) {
5952
6030
  return {
5953
- studentId: i === null || i === void 0 ? void 0 : i.studentId,
5954
- examSessionId: i === null || i === void 0 ? void 0 : i.examSessionId
5955
- };
5956
- }) : dataExamSession.map(function (i) {
5957
- return {
5958
- code: i === null || i === void 0 ? void 0 : i.code
6031
+ label: t("number_question", {
6032
+ number: i
6033
+ }),
6034
+ value: i
5959
6035
  };
5960
6036
  });
5961
- useLanguage(history);
5962
- var _useState = React.useState(dataProps),
5963
- data = _useState[0],
5964
- setData = _useState[1];
5965
- var _useState2 = React.useState([]),
5966
- completed = _useState2[0],
5967
- setCompleted = _useState2[1];
5968
- var _useState3 = React.useState([]),
5969
- inprogress = _useState3[0],
5970
- setInProgress = _useState3[1];
5971
- var _useState4 = React.useState(PrintState.Idling),
5972
- state = _useState4[0],
5973
- setState = _useState4[1];
5974
- var _useState5 = React.useState([]),
5975
- errorLinks = _useState5[0],
5976
- setErrorLinks = _useState5[1];
5977
- var _useState6 = React.useState([]),
5978
- status = _useState6[0],
5979
- setStatus = _useState6[1];
5980
- var theme = material.useTheme();
5981
- var handleChangeStatus = function handleChangeStatus(event) {
5982
- if (event.target.checked) {
5983
- setStatus(function (prev) {
5984
- var _event$target;
5985
- return [].concat(prev, [(_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value]);
5986
- });
5987
- } else setStatus(function (prev) {
5988
- return prev === null || prev === void 0 ? void 0 : prev.filter(function (i) {
5989
- var _event$target2;
5990
- return i !== ((_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.value);
5991
- });
5992
- });
5993
- };
5994
- var handleProgressPrint = function handleProgressPrint() {
5995
- setData(dataProps);
5996
- setCompleted([]);
5997
- setInProgress([]);
5998
- setErrorLinks([]);
5999
- setState(PrintState.Printing);
6000
- };
6001
- console.log({
6002
- status: status
6037
+ return React__default.createElement(CustomSelect, {
6038
+ inputId: id,
6039
+ value: value,
6040
+ options: answerOptions,
6041
+ onChange: onChange,
6042
+ isDisabled: isDisabled
6003
6043
  });
6004
- var print = function print(_ref2) {
6005
- var examSessionId = _ref2.examSessionId,
6006
- studentId = _ref2.studentId,
6007
- code = _ref2.code;
6008
- var width = 200;
6009
- var height = 200;
6010
- var left = window.screenX + window.outerWidth / 2 - width / 2;
6011
- var top = window.screenY + window.outerHeight / 2 - height / 2;
6012
- var url = isTeacher ? window.location.origin + "/teacher/exam-results/" + examSessionId + "/students/" + studentId + "/print?status=" + status.join(",") : window.location.origin + "/student/exam-results/" + code + "/print";
6013
- var windowName = isTeacher ? "popup-" + examSessionId + "-" + studentId : "popup-" + code;
6014
- var windowSpecs = "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",location=yes,resizable=yes,scrollbars=yes,status=yes";
6015
- var childWindow = window.open(url, windowName, windowSpecs);
6016
- if (childWindow == null) {
6017
- setErrorLinks(function (prev) {
6018
- return [].concat(prev, [{
6019
- code: code,
6020
- examSessionId: "" + examSessionId,
6021
- studentId: "" + studentId,
6022
- message: isTeacher ? "/teacher/exam-results/" + examSessionId + "/students/" + studentId + "/print" : "/student/exam-results/" + code + "/print"
6023
- }]);
6024
- });
6025
- if (!isTeacher) {
6026
- setData(function (es) {
6027
- return [].concat(es.filter(function (i) {
6028
- return i.code !== code;
6029
- }));
6030
- });
6031
- } else {
6032
- setData(function (es) {
6033
- return [].concat(es.filter(function (i) {
6034
- return i.examSessionId !== examSessionId || i.studentId !== studentId;
6035
- }));
6036
- });
6037
- }
6038
- return;
6039
- }
6040
- if (!isTeacher) {
6041
- setInProgress(function (es) {
6042
- return [].concat(es.filter(function (i) {
6043
- return i.code !== code;
6044
- }), [{
6045
- code: code
6046
- }]);
6047
- });
6048
- setData(function (es) {
6049
- return [].concat(es.filter(function (i) {
6050
- return i.code !== code;
6051
- }));
6052
- });
6053
- } else {
6054
- setInProgress(function (es) {
6055
- return [].concat(es.filter(function (i) {
6056
- return i.examSessionId !== examSessionId || i.studentId !== studentId;
6057
- }), [{
6058
- examSessionId: examSessionId,
6059
- studentId: studentId
6060
- }]);
6061
- });
6062
- setData(function (es) {
6063
- return [].concat(es.filter(function (i) {
6064
- return i.examSessionId !== examSessionId || i.studentId !== studentId;
6065
- }));
6066
- });
6067
- }
6068
- window.addEventListener("message", function (event) {
6069
- var isCheck = isTeacher ? event.data.examSessionId !== "" + examSessionId || event.data.studentId !== "" + studentId : event.data.code !== "" + code;
6070
- if (event.origin !== window.location.origin || isCheck) {
6071
- return;
6072
- }
6073
- if (event.data.succeed) {
6074
- if (!isTeacher) {
6075
- setCompleted(function (es) {
6076
- return [].concat(es.filter(function (i) {
6077
- return i.code !== code;
6078
- }), [{
6079
- code: code
6080
- }]);
6081
- });
6082
- setInProgress(function (es) {
6083
- return [].concat(es.filter(function (i) {
6084
- return i.code !== code;
6085
- }));
6086
- });
6087
- } else {
6088
- setCompleted(function (es) {
6089
- return [].concat(es.filter(function (i) {
6090
- return i.examSessionId !== examSessionId || i.studentId !== studentId;
6091
- }), [{
6092
- examSessionId: examSessionId,
6093
- studentId: studentId
6094
- }]);
6095
- });
6096
- setInProgress(function (es) {
6097
- return [].concat(es.filter(function (i) {
6098
- return i.examSessionId !== examSessionId || i.studentId !== studentId;
6099
- }));
6100
- });
6101
- }
6102
- } else {
6103
- setErrorLinks(function (prev) {
6104
- var _event$data, _event$data2;
6105
- return [].concat(prev, [{
6106
- code: (_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.code,
6107
- examSessionId: (_event$data2 = event.data) === null || _event$data2 === void 0 ? void 0 : _event$data2.examSessionId,
6108
- studentId: "" + studentId,
6109
- message: isTeacher ? "/teacher/exam-results/" + event.data.examSessionId + "/students/" + event.data.studentId + "/print" : "/student/exam-results/" + event.data.code + "/print"
6110
- }]);
6111
- });
6112
- }
6113
- childWindow === null || childWindow === void 0 ? void 0 : childWindow.close();
6114
- });
6115
- };
6116
- React.useEffect(function () {
6117
- if (inprogress.length < TOTAL && data.length > 0 && state === PrintState.Printing) {
6118
- var item = data[0];
6119
- print({
6120
- examSessionId: item === null || item === void 0 ? void 0 : item.examSessionId,
6121
- studentId: item === null || item === void 0 ? void 0 : item.studentId,
6122
- code: item === null || item === void 0 ? void 0 : item.code
6123
- });
6124
- }
6125
- }, [inprogress.length, completed.length, data.length, state, data]);
6126
- return React__default.createElement(material.Container, null, state === PrintState.Idling ? React__default.createElement(material.Typography, null, t("total_number_of_selected_results") + ": ", " ", React__default.createElement("span", {
6127
- className: "fw-bold"
6128
- }, t("number_results", {
6129
- number: ("" + data.length).padStart(2, "0")
6130
- }))) : React__default.createElement(React.Fragment, null, React__default.createElement(material.Typography, null, t("completed") + ": ", React__default.createElement("span", {
6131
- className: "fw-bold"
6132
- }, t("number_results", {
6133
- number: ("" + completed.length).padStart(2, "0")
6134
- }))), React__default.createElement(material.Typography, null, t("in_progress") + ": ", React__default.createElement("span", {
6135
- className: "fw-bold"
6136
- }, t("number_results", {
6137
- number: ("" + inprogress.length).padStart(2, "0")
6138
- }))), React__default.createElement(material.Typography, null, t("remaining") + ": ", React__default.createElement("span", {
6139
- className: "fw-bold"
6140
- }, t("number_results", {
6141
- number: ("" + data.length).padStart(2, "0")
6142
- })))), !!errorLinks.length && React__default.createElement(material.Stack, {
6143
- className: "mt-2"
6144
- }, React__default.createElement(material.Typography, {
6145
- fontWeight: 700
6146
- }, t("download_failed"), ":"), Array.from(new Set(errorLinks)).map(function (i) {
6147
- var _info$createdBy;
6148
- var info = isTeacher ? dataExamSession.find(function (exam) {
6149
- return "" + (exam === null || exam === void 0 ? void 0 : exam.examSessionId) === "" + (i === null || i === void 0 ? void 0 : i.examSessionId) && "" + (exam === null || exam === void 0 ? void 0 : exam.studentId) === "" + (i === null || i === void 0 ? void 0 : i.studentId);
6150
- }) : dataExamSession.find(function (exam) {
6151
- return (exam === null || exam === void 0 ? void 0 : exam.code) === (i === null || i === void 0 ? void 0 : i.code);
6152
- });
6153
- return React__default.createElement(material.Stack, {
6154
- borderBottom: 1,
6155
- borderColor: theme.palette.grey[500]
6156
- }, React__default.createElement("a", {
6157
- href: i.message,
6158
- target: "_blank",
6159
- rel: "noopener noreferrer"
6160
- }, (info === null || info === void 0 ? void 0 : info.studentName) || (info === null || info === void 0 ? void 0 : (_info$createdBy = info.createdBy) === null || _info$createdBy === void 0 ? void 0 : _info$createdBy.fullName)), (info === null || info === void 0 ? void 0 : info.title) && React__default.createElement(material.Typography, null, t("exam") + ": " + (info === null || info === void 0 ? void 0 : info.title)), (info === null || info === void 0 ? void 0 : info.startTime) && React__default.createElement(material.Typography, null, t("start_time") + ": " + utcToLocalTime(info === null || info === void 0 ? void 0 : info.startTime, t("date_time_format"))));
6161
- })), React__default.createElement(material.Stack, {
6162
- direction: "column",
6163
- className: "mt-3"
6164
- }, React__default.createElement(material.Stack, null, React__default.createElement(material.Typography, {
6165
- className: "fw-bold"
6166
- }, React__default.createElement("span", {
6167
- className: "text-danger me-1"
6168
- }, "*"), t("your_browser_must"), ":"), React__default.createElement(material.List, {
6169
- className: "ps-3 pt-0"
6170
- }, React__default.createElement(material.ListItem, {
6171
- disablePadding: true
6172
- }, t("allowed_to_send_pop_ups_and_use_redirects")), React__default.createElement(material.ListItem, {
6173
- disablePadding: true
6174
- }, t("disable_ask_where_to_save_each_file_before_downloading")))), isTeacher && React__default.createElement(material.Stack, null, React__default.createElement(material.Typography, {
6175
- fontWeight: 700
6176
- }, t("choose_to_print"), ":"), React__default.createElement(material.FormGroup, {
6177
- sx: {
6178
- display: "flex",
6179
- flexDirection: "row",
6180
- gap: 1,
6181
- flexWrap: "wrap"
6182
- }
6183
- }, TabList.map(function (_ref3) {
6184
- var label = _ref3.label,
6185
- value = _ref3.value;
6186
- return React__default.createElement(material.FormControlLabel, {
6187
- control: React__default.createElement(material.Checkbox, {
6188
- onChange: handleChangeStatus,
6189
- value: value,
6190
- checked: status.some(function (i) {
6191
- return i === value.toString();
6192
- })
6193
- }),
6194
- label: t(label)
6195
- });
6196
- }))), React__default.createElement(material.Button, {
6197
- className: "mt-3",
6198
- variant: "contained",
6199
- onClick: handleProgressPrint
6200
- }, t("print_pdf"))));
6201
6044
  };
6202
6045
 
6203
- var ReleaseAlert = function ReleaseAlert() {
6204
- var _useTranslation = reactI18next.useTranslation(),
6205
- t = _useTranslation.t;
6206
- var releaseDate = RELEASE_DATE;
6207
- var isInValidDate = !releaseDate || releaseDate === DATE_MIN_VALUE || releaseDate === DATE_TIME_MIN_VALUE;
6208
- var isLoginPage = window.location.pathname === LOGIN_URL;
6209
- if (isInValidDate || !moment.utc(releaseDate).isValid()) return null;else {
6210
- var version = moment(releaseDate).format("HH.mm.YYYY.MM.DD");
6211
- return React__default.createElement(material.Box, {
6212
- sx: {
6213
- position: "fixed",
6214
- right: 10,
6215
- bottom: isLoginPage ? undefined : 5,
6216
- top: isLoginPage ? 10 : undefined,
6217
- userSelect: "none",
6218
- zIndex: 1
6046
+ var _excluded$4 = ["id", "value", "onChange", "isDisabled", "options", "isMulti", "placeholder"];
6047
+ var ArticleCategorySelector = function ArticleCategorySelector(_ref) {
6048
+ var id = _ref.id,
6049
+ value = _ref.value,
6050
+ onChange = _ref.onChange,
6051
+ isDisabled = _ref.isDisabled,
6052
+ options = _ref.options,
6053
+ isMulti = _ref.isMulti,
6054
+ placeholder = _ref.placeholder,
6055
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
6056
+ var _useTranslation = reactI18next.useTranslation(),
6057
+ t = _useTranslation.t;
6058
+ return React__default.createElement(CustomSelect, Object.assign({
6059
+ isMulti: isMulti,
6060
+ inputId: id,
6061
+ value: value,
6062
+ options: options,
6063
+ onChange: onChange,
6064
+ isDisabled: isDisabled,
6065
+ placeholder: placeholder || t("select_category")
6066
+ }, rest));
6067
+ };
6068
+
6069
+ // A type of promise-like that resolves synchronously and supports only one observer
6070
+
6071
+ const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
6072
+
6073
+ const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
6074
+
6075
+ // Asynchronously call a function and send errors to recovery continuation
6076
+ function _catch(body, recover) {
6077
+ try {
6078
+ var result = body();
6079
+ } catch(e) {
6080
+ return recover(e);
6081
+ }
6082
+ if (result && result.then) {
6083
+ return result.then(void 0, recover);
6084
+ }
6085
+ return result;
6086
+ }
6087
+
6088
+ // Asynchronously await a promise and pass the result to a finally continuation
6089
+ function _finallyRethrows(body, finalizer) {
6090
+ try {
6091
+ var result = body();
6092
+ } catch (e) {
6093
+ return finalizer(true, e);
6094
+ }
6095
+ if (result && result.then) {
6096
+ return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
6097
+ }
6098
+ return finalizer(false, result);
6099
+ }
6100
+
6101
+ // Asynchronously await a promise and invoke a finally continuation that always overrides the result
6102
+ function _finally(body, finalizer) {
6103
+ try {
6104
+ var result = body();
6105
+ } catch (e) {
6106
+ return finalizer();
6107
+ }
6108
+ if (result && result.then) {
6109
+ return result.then(finalizer, finalizer);
6110
+ }
6111
+ return finalizer();
6112
+ }
6113
+
6114
+ (function (PreparedType) {
6115
+ PreparedType[PreparedType["csat_past_questions"] = 1] = "csat_past_questions";
6116
+ PreparedType[PreparedType["official_mock_exam"] = 2] = "official_mock_exam";
6117
+ PreparedType[PreparedType["private_mock_exam"] = 3] = "private_mock_exam";
6118
+ })(exports.PreparedType || (exports.PreparedType = {}));
6119
+
6120
+ (function (ExamEvent) {
6121
+ ExamEvent["StartExam"] = "start-exam";
6122
+ ExamEvent["TerminateExam"] = "terminate-exam";
6123
+ ExamEvent["AddExtraDuration"] = "add-extra-duration-exam";
6124
+ ExamEvent["TeacherKickOutStudent"] = "teacher-kick-out-student";
6125
+ })(exports.ExamEvent || (exports.ExamEvent = {}));
6126
+
6127
+ (function (ExamStatus) {
6128
+ ExamStatus[ExamStatus["Default"] = 0] = "Default";
6129
+ ExamStatus[ExamStatus["Pending"] = 1] = "Pending";
6130
+ ExamStatus[ExamStatus["InProgress"] = 2] = "InProgress";
6131
+ ExamStatus[ExamStatus["Completed"] = 3] = "Completed";
6132
+ })(exports.ExamStatus || (exports.ExamStatus = {}));
6133
+ (function (QuestionAnswerType) {
6134
+ QuestionAnswerType[QuestionAnswerType["ChoiceOption"] = 0] = "ChoiceOption";
6135
+ QuestionAnswerType[QuestionAnswerType["Textual"] = 1] = "Textual";
6136
+ })(exports.QuestionAnswerType || (exports.QuestionAnswerType = {}));
6137
+
6138
+ (function (OrderType) {
6139
+ OrderType["ASC"] = "ASC";
6140
+ OrderType["DESC"] = "DESC";
6141
+ })(exports.OrderType || (exports.OrderType = {}));
6142
+
6143
+ (function (RecentUserAction) {
6144
+ RecentUserAction["ViewedUser"] = "ViewedUser";
6145
+ RecentUserAction["ViewedQNA"] = "ViewedQNA";
6146
+ RecentUserAction["ViewedExamResult"] = "ViewedExamResult";
6147
+ RecentUserAction["PrintedExamResult"] = "PrintedExamResult";
6148
+ RecentUserAction["ViewedAttendance"] = "ViewedAttendance";
6149
+ })(exports.RecentUserAction || (exports.RecentUserAction = {}));
6150
+
6151
+ (function (UserSortColumn) {
6152
+ UserSortColumn["CreatedAt"] = "CreatedAt";
6153
+ UserSortColumn["FullName"] = "FullName";
6154
+ UserSortColumn["PhoneNumber"] = "PhoneNumber";
6155
+ UserSortColumn["Email"] = "Email";
6156
+ UserSortColumn["SchoolName"] = "SchoolName";
6157
+ UserSortColumn["Major"] = "Major";
6158
+ UserSortColumn["ParentName"] = "ParentName";
6159
+ UserSortColumn["ParentPhoneNumber"] = "ParentPhoneNumber";
6160
+ UserSortColumn["Grade"] = "Grade";
6161
+ })(exports.UserSortColumn || (exports.UserSortColumn = {}));
6162
+
6163
+ var useAutoAcademyDomain = function useAutoAcademyDomain(_, history, superUrls, homeUrl, homeAcademyUrl, isAuthPage) {
6164
+ if (isAuthPage === void 0) {
6165
+ isAuthPage = true;
6166
+ }
6167
+ var user = reactRedux.useSelector(function (state) {
6168
+ var _state$common;
6169
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
6170
+ });
6171
+ var _ref = user || {},
6172
+ email = _ref.email,
6173
+ academyDomain = _ref.academyDomain,
6174
+ isLearningSpace = _ref.isLearningSpace;
6175
+ var pathname = window.location.pathname;
6176
+ var changeAcademySearchParams = function changeAcademySearchParams() {
6177
+ var isLoginPage = LOGIN_URL === pathname;
6178
+ var search = window.location.search;
6179
+ var searchParams = new URLSearchParams(search);
6180
+ var paramAcademyDomain = searchParams.get("domain");
6181
+ var domain = getAcademyDomain();
6182
+ if (!!email !== isAuthPage) return;
6183
+ var isSuperUrl = checkSuperUrl(superUrls, pathname);
6184
+ if (!academyDomain && !isLearningSpace) {
6185
+ if (!isSuperUrl) {
6186
+ if (isLoginPage) searchParams["delete"]("domain");else if (!paramAcademyDomain && domain) searchParams.set("domain", domain);
6187
+ pushTo(history, {
6188
+ pathname: homeUrl,
6189
+ search: searchParams.toString()
6190
+ });
6191
+ return;
6219
6192
  }
6220
- }, React__default.createElement(material.Typography, {
6221
- color: "success",
6222
- sx: {
6223
- fontSize: 10,
6224
- color: "#3DC674",
6225
- opacity: 0.8
6193
+ if (paramAcademyDomain) {
6194
+ searchParams["delete"]("domain");
6195
+ pushTo(history, _extends({}, window.location, {
6196
+ search: searchParams.toString()
6197
+ }), true);
6198
+ return;
6226
6199
  }
6227
- }, t("version"), ": ", React__default.createElement("span", null, version)));
6228
- }
6229
- };
6230
-
6231
- var ActionButtons = function ActionButtons(_ref) {
6232
- var _ref$className = _ref.className,
6233
- className = _ref$className === void 0 ? "" : _ref$className,
6234
- backText = _ref.backText,
6235
- saveText = _ref.saveText,
6236
- altSaveText = _ref.altSaveText,
6237
- saveDisabled = _ref.saveDisabled,
6238
- saveIcon = _ref.saveIcon,
6239
- _ref$hideSave = _ref.hideSave,
6240
- hideSave = _ref$hideSave === void 0 ? false : _ref$hideSave,
6241
- onBack = _ref.onBack,
6242
- onSave = _ref.onSave,
6243
- onAltSave = _ref.onAltSave,
6244
- isReadonly = _ref.isReadonly;
6245
- return React__default.createElement(material.Stack, {
6246
- direction: "row",
6247
- spacing: 1,
6248
- className: "" + className
6249
- }, React__default.createElement(material.Button, {
6250
- variant: "contained",
6251
- className: "bg-secondary",
6252
- startIcon: React__default.createElement(io.IoMdArrowBack, {
6253
- size: 16
6254
- }),
6255
- onClick: onBack
6256
- }, backText), !hideSave && React__default.createElement(material.Button, {
6257
- variant: "contained",
6258
- color: "success",
6259
- startIcon: saveIcon != null ? saveIcon : React__default.createElement(fa.FaSave, {
6260
- size: 16
6261
- }),
6262
- onClick: onSave,
6263
- disabled: saveDisabled || isReadonly
6264
- }, saveText), !!altSaveText && onAltSave && React__default.createElement(material.Button, {
6265
- variant: "contained",
6266
- color: "primary",
6267
- startIcon: React__default.createElement(fa.FaSave, {
6268
- size: 16
6269
- }),
6270
- onClick: onAltSave,
6271
- disabled: saveDisabled
6272
- }, altSaveText));
6200
+ } else {
6201
+ if (isSuperUrl) {
6202
+ searchParams["delete"]("domain");
6203
+ pushTo(history, {
6204
+ pathname: homeAcademyUrl,
6205
+ search: searchParams.toString()
6206
+ });
6207
+ return;
6208
+ }
6209
+ if (!paramAcademyDomain || academyDomain.trim().toLocaleLowerCase() !== (paramAcademyDomain === null || paramAcademyDomain === void 0 ? void 0 : paramAcademyDomain.trim().toLocaleLowerCase())) {
6210
+ if (isLoginPage || isLearningSpace) searchParams["delete"]("domain");else searchParams.set("domain", academyDomain);
6211
+ pushTo(history, _extends({}, window.location, {
6212
+ search: searchParams.toString()
6213
+ }), true);
6214
+ return;
6215
+ }
6216
+ }
6217
+ };
6218
+ React.useEffect(function () {
6219
+ changeAcademySearchParams();
6220
+ }, [pathname, window.location.search, isAuthPage, email, academyDomain]);
6273
6221
  };
6274
6222
 
6275
- var TITLE = "not_found";
6276
- var NotFound = function NotFound(_ref) {
6277
- var history = _ref.history;
6278
- var _useTranslation = reactI18next.useTranslation(),
6279
- t = _useTranslation.t;
6280
- history && useLanguage(history);
6281
- React.useEffect(function () {
6282
- document.title = t("study_peak") + " | " + t(TITLE);
6283
- }, [t]);
6284
- return React__default.createElement("div", {
6285
- className: "not-found d-flex justify-content-center"
6286
- }, React__default.createElement("div", {
6287
- className: "clearfix pt-5"
6288
- }, React__default.createElement("h1", {
6289
- className: "float-left display-3 fw-bold mr-4 text-center"
6290
- }, "404"), React__default.createElement("div", {
6291
- className: "float-left"
6292
- }, React__default.createElement("h4", {
6293
- className: "pt-3"
6294
- }, t('oops')), React__default.createElement("p", {
6295
- className: "text-muted mb-2"
6296
- }, t('the_page_you_are_looking_for_was_not_found')), React__default.createElement("div", null))));
6223
+ var EXAM_SESSION_URL = BASE_URL + "/api/examSession";
6224
+ var getCheckStatusExam = function getCheckStatusExam(examCode) {
6225
+ return api.get(EXAM_SESSION_URL + "/" + examCode + "/status");
6297
6226
  };
6298
6227
 
6299
- var CommonDialog = function CommonDialog(_ref) {
6300
- var open = _ref.open,
6301
- children = _ref.children,
6302
- title = _ref.title,
6303
- _ref$size = _ref.size,
6304
- size = _ref$size === void 0 ? "xs" : _ref$size,
6305
- _ref$isShowHeader = _ref.isShowHeader,
6306
- isShowHeader = _ref$isShowHeader === void 0 ? true : _ref$isShowHeader,
6307
- titleClassName = _ref.titleClassName,
6308
- minWidth = _ref.minWidth,
6309
- onClose = _ref.onClose;
6310
- return React__default.createElement(material.Dialog, {
6311
- open: open,
6312
- onClose: onClose,
6313
- maxWidth: size,
6314
- fullWidth: true,
6315
- scroll: "body",
6316
- sx: {
6317
- zIndex: 1102
6318
- },
6319
- PaperProps: {
6320
- sx: {
6321
- overflowY: "unset",
6322
- minWidth: minWidth
6228
+ var ONE_SECOND_IN_MILLISECONDS = 1000;
6229
+ var useCountDownTimer = function useCountDownTimer(props) {
6230
+ var startTime = props.startTime,
6231
+ status = props.status,
6232
+ code = props.code,
6233
+ duration = props.duration,
6234
+ onFinish = props.onFinish;
6235
+ var dispatch = reactRedux.useDispatch();
6236
+ var _useState = React.useState(),
6237
+ remainTime = _useState[0],
6238
+ setRemainTime = _useState[1];
6239
+ var checkStatusRef = React.useRef(null);
6240
+ var requestRef = React.useRef(null);
6241
+ var checkLiveExamStatus = React.useCallback(function () {
6242
+ try {
6243
+ !!checkStatusRef.current && clearTimeout(checkStatusRef.current);
6244
+ if (!code || status === exports.ExamStatus.Completed) {
6245
+ return Promise.resolve();
6323
6246
  }
6247
+ var isOk = false;
6248
+ var _temp = _finallyRethrows(function () {
6249
+ return _catch(function () {
6250
+ dispatch(setLoading(true));
6251
+ return Promise.resolve(getCheckStatusExam(code)).then(function (res) {
6252
+ if (res.data.data.status === exports.ExamStatus.Completed) {
6253
+ isOk = true;
6254
+ clearTimeout(checkStatusRef.current);
6255
+ dispatch(setLoading(false));
6256
+ onFinish();
6257
+ } else {
6258
+ checkStatusRef.current = setTimeout(checkLiveExamStatus, ONE_SECOND_IN_MILLISECONDS);
6259
+ }
6260
+ });
6261
+ }, function (error) {
6262
+ console.log({
6263
+ error: error
6264
+ });
6265
+ });
6266
+ }, function (_wasThrown, _result) {
6267
+ if (!isOk) checkStatusRef.current = setTimeout(checkLiveExamStatus, ONE_SECOND_IN_MILLISECONDS);
6268
+ if (_wasThrown) throw _result;
6269
+ return _result;
6270
+ });
6271
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
6272
+ } catch (e) {
6273
+ return Promise.reject(e);
6324
6274
  }
6325
- }, isShowHeader ? React__default.createElement(React.Fragment, null, React__default.createElement(material.DialogTitle, {
6326
- className: "border border-start-0 border-end-0 border-top-0 border-1 " + titleClassName,
6327
- sx: {
6328
- fontSize: "16px!important"
6329
- }
6330
- }, title), React__default.createElement(material.IconButton, {
6331
- "aria-label": "close",
6332
- onClick: onClose,
6333
- sx: {
6334
- position: "absolute",
6335
- right: 8,
6336
- top: 8,
6337
- color: function color(theme) {
6338
- return theme.palette.grey[500];
6275
+ }, [code, status, onFinish]);
6276
+ React.useEffect(function () {
6277
+ if (status !== exports.ExamStatus.InProgress) return;
6278
+ var animate = function animate() {
6279
+ if (!startTime || !duration) return;
6280
+ if (typeof remainTime === "number" && remainTime <= 0) {
6281
+ return;
6339
6282
  }
6340
- }
6341
- }, React__default.createElement(io5.IoClose, null))) : React__default.createElement(material.Box, {
6342
- className: "p-3"
6343
- }, React__default.createElement(material.Typography, {
6344
- className: "fs-5 text-center fw-bold"
6345
- }, title)), children);
6283
+ var remain = getRemainTime(startTime, duration);
6284
+ if (typeof remain !== "number") {
6285
+ setRemainTime(undefined);
6286
+ return;
6287
+ }
6288
+ setRemainTime(remain || 0);
6289
+ requestRef.current = requestAnimationFrame(animate);
6290
+ };
6291
+ requestRef.current = requestAnimationFrame(animate);
6292
+ return function () {
6293
+ !!requestRef.current && cancelAnimationFrame(requestRef.current);
6294
+ setRemainTime(undefined);
6295
+ };
6296
+ }, [startTime, duration]);
6297
+ React.useEffect(function () {
6298
+ if (typeof remainTime === "number" && remainTime <= 0) checkLiveExamStatus();
6299
+ }, [remainTime, checkLiveExamStatus]);
6300
+ return remainTime;
6346
6301
  };
6347
6302
 
6348
- var confirmDialogTextStyle = {
6349
- color: "#363634",
6350
- fontSize: 16,
6351
- fontWeight: 700
6352
- };
6353
- var confirmDialogButtonStyle = {
6354
- width: "120px",
6355
- fontSize: 14,
6356
- fontWeight: 700
6357
- };
6358
- var ConfirmDeleteDialogDefaultProps = {
6359
- titleStyle: confirmDialogTextStyle,
6360
- contentStyle: {
6361
- paddingTop: "36px",
6362
- padding: "36px",
6363
- width: 363
6364
- },
6365
- contentTextStyle: _extends({}, confirmDialogTextStyle, {
6366
- textAlign: "center"
6367
- }),
6368
- actionStyle: {
6369
- justifyContent: "space-between",
6370
- padding: "12px"
6371
- },
6372
- okButtonStyle: confirmDialogButtonStyle,
6373
- cancelButtonStyle: _extends({}, confirmDialogButtonStyle, {
6374
- color: "#3dc674"
6375
- }),
6376
- cancelButtonVariant: "text",
6377
- isDelete: true
6303
+ var useGoogleSignOut = function useGoogleSignOut(props) {
6304
+ var dispatch = reactRedux.useDispatch();
6305
+ var onLogoutSuccess = props.onLogoutSuccess,
6306
+ onFailure = props.onFailure;
6307
+ var handleLogoutSuccess = function handleLogoutSuccess() {
6308
+ onLogoutSuccess === null || onLogoutSuccess === void 0 ? void 0 : onLogoutSuccess();
6309
+ };
6310
+ var handleLogoutFailure = function handleLogoutFailure() {
6311
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure();
6312
+ };
6313
+ var _useGoogleLogout = GoogleLogin.useGoogleLogout({
6314
+ clientId: GOOGLE_CLIENT_ID,
6315
+ onLogoutSuccess: handleLogoutSuccess,
6316
+ onFailure: handleLogoutFailure
6317
+ }),
6318
+ signOut = _useGoogleLogout.signOut,
6319
+ loaded = _useGoogleLogout.loaded;
6320
+ var handleSignOut = function handleSignOut(isRemoveDomainStorage) {
6321
+ if (isRemoveDomainStorage === void 0) {
6322
+ isRemoveDomainStorage = false;
6323
+ }
6324
+ localStorage.removeItem("USER_INFORMATION");
6325
+ localStorage.removeItem(ACCESS_TOKEN);
6326
+ if (isRemoveDomainStorage) {
6327
+ localStorage.removeItem(ACADEMY_DOMAIN);
6328
+ localStorage.removeItem(LEARNING_SPACE);
6329
+ }
6330
+ try {
6331
+ var _window$gapi, _window$gapi$auth, _auth2$signOut;
6332
+ signOut();
6333
+ var auth2 = (_window$gapi = window.gapi) === null || _window$gapi === void 0 ? void 0 : (_window$gapi$auth = _window$gapi.auth2) === null || _window$gapi$auth === void 0 ? void 0 : _window$gapi$auth.getAuthInstance();
6334
+ auth2 === null || auth2 === void 0 ? void 0 : (_auth2$signOut = auth2.signOut) === null || _auth2$signOut === void 0 ? void 0 : _auth2$signOut.call(auth2);
6335
+ } catch (error) {
6336
+ console.log({
6337
+ error: error
6338
+ });
6339
+ }
6340
+ dispatch(reset());
6341
+ window.location.href = "/login";
6342
+ };
6343
+ return {
6344
+ handleSignOut: handleSignOut,
6345
+ loaded: loaded
6346
+ };
6378
6347
  };
6379
6348
 
6380
- var ConfirmDialog = function ConfirmDialog(_ref) {
6381
- var open = _ref.open,
6382
- text = _ref.text,
6383
- cancelText = _ref.cancelText,
6384
- okText = _ref.okText,
6385
- isDelete = _ref.isDelete,
6386
- title = _ref.title,
6387
- confirmText = _ref.confirmText,
6388
- titleStyle = _ref.titleStyle,
6389
- titleClassName = _ref.titleClassName,
6390
- contentStyle = _ref.contentStyle,
6391
- cancelButtonStyle = _ref.cancelButtonStyle,
6392
- contentTextStyle = _ref.contentTextStyle,
6393
- okButtonStyle = _ref.okButtonStyle,
6394
- actionStyle = _ref.actionStyle,
6395
- _ref$okButtonVariant = _ref.okButtonVariant,
6396
- okButtonVariant = _ref$okButtonVariant === void 0 ? "contained" : _ref$okButtonVariant,
6397
- _ref$cancelButtonVari = _ref.cancelButtonVariant,
6398
- cancelButtonVariant = _ref$cancelButtonVari === void 0 ? "contained" : _ref$cancelButtonVari,
6399
- _ref$zIndex = _ref.zIndex,
6400
- zIndex = _ref$zIndex === void 0 ? 1102 : _ref$zIndex,
6401
- toggle = _ref.toggle,
6402
- onConfirm = _ref.onConfirm;
6403
- var _useState = React.useState(),
6404
- confirmTextValue = _useState[0],
6405
- setConfirmTextValue = _useState[1];
6349
+ var useList = function useList(fetchData, defaultQuery) {
6350
+ var dispatch = reactRedux.useDispatch();
6351
+ var _useState = React.useState(defaultQuery),
6352
+ filter = _useState[0],
6353
+ setFilter = _useState[1];
6354
+ var _useState2 = React.useState(DEFAULT_PAGING_RESPONSE),
6355
+ paging = _useState2[0],
6356
+ setPaging = _useState2[1];
6357
+ var _useState3 = React.useState([]),
6358
+ data = _useState3[0],
6359
+ setData = _useState3[1];
6360
+ var _useState4 = React.useState(),
6361
+ selectedItem = _useState4[0],
6362
+ setSelectedItem = _useState4[1];
6363
+ var textSearchRef = React.useRef(null);
6364
+ var isFirstLoadRef = React.useRef(true);
6406
6365
  var _useTranslation = reactI18next.useTranslation(),
6407
6366
  t = _useTranslation.t;
6408
- var handleConfirm = function handleConfirm() {
6409
- onConfirm();
6367
+ var handleChangeSelectedItem = function handleChangeSelectedItem(item) {
6368
+ setSelectedItem(item);
6410
6369
  };
6411
- var handleChangeConfirmText = function handleChangeConfirmText(e) {
6412
- setConfirmTextValue(e.target.value);
6370
+ var getData = function getData(isLoading) {
6371
+ if (isLoading === void 0) {
6372
+ isLoading = false;
6373
+ }
6374
+ try {
6375
+ var _temp2 = function _temp2() {
6376
+ isLoading && dispatch(setLoading(false));
6377
+ };
6378
+ if (!fetchData) return Promise.resolve();
6379
+ if (isFirstLoadRef.current) isFirstLoadRef.current = false;
6380
+ isLoading && dispatch(setLoading(true));
6381
+ var _temp = _catch(function () {
6382
+ return Promise.resolve(fetchData(filter)).then(function (res) {
6383
+ var _res$data$items = res.data.items,
6384
+ items = _res$data$items === void 0 ? [] : _res$data$items;
6385
+ setPaging({
6386
+ limit: res.data.limit || 0,
6387
+ page: res.data.page || 0,
6388
+ totalItems: res.data.totalItems || 0,
6389
+ totalPages: res.data.totalPages || 0
6390
+ });
6391
+ setData(items);
6392
+ });
6393
+ }, function (error) {
6394
+ setPaging(DEFAULT_PAGING_RESPONSE);
6395
+ setData([]);
6396
+ reactToastify.toast.error(getErrorMessage(t, error));
6397
+ });
6398
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
6399
+ } catch (e) {
6400
+ return Promise.reject(e);
6401
+ }
6413
6402
  };
6414
- var handlePaste = function handlePaste(_) {};
6403
+ var handleSort = function handleSort(sortColumnName) {
6404
+ var sortColumnDirection = exports.OrderType.ASC;
6405
+ console.log({
6406
+ sortColumnName: typeof sortColumnName,
6407
+ filter: typeof filter.sortColumnName
6408
+ });
6409
+ if (filter.sortColumnName == sortColumnName && filter.sortColumnDirection === exports.OrderType.ASC) sortColumnDirection = exports.OrderType.DESC;
6410
+ setFilter(_extends({}, filter, {
6411
+ sortColumnName: sortColumnName,
6412
+ sortColumnDirection: sortColumnDirection,
6413
+ currentPage: 1
6414
+ }));
6415
+ };
6416
+ var handleChangeSearchText = function handleChangeSearchText(e) {
6417
+ if (!textSearchRef.current) return;
6418
+ textSearchRef.current.value = e.target.value.trim();
6419
+ debounceSearch();
6420
+ };
6421
+ var handleChangePage = function handleChangePage(_, page) {
6422
+ setFilter(_extends({}, filter, {
6423
+ currentPage: page
6424
+ }));
6425
+ };
6426
+ var calcOrderNumber = function calcOrderNumber(index) {
6427
+ var _paging$page, _paging$limit;
6428
+ return (((_paging$page = paging.page) != null ? _paging$page : 0) - 1) * ((_paging$limit = paging.limit) != null ? _paging$limit : 0) + index + 1;
6429
+ };
6430
+ var debounceSearch = _.debounce(function () {
6431
+ var _textSearchRef$curren;
6432
+ setFilter(_extends({}, filter, {
6433
+ currentPage: 1,
6434
+ textSearch: (_textSearchRef$curren = textSearchRef.current) === null || _textSearchRef$curren === void 0 ? void 0 : _textSearchRef$curren.value
6435
+ }));
6436
+ }, 500);
6415
6437
  React.useEffect(function () {
6416
- !open && setConfirmTextValue(undefined);
6417
- }, [open]);
6418
- var isValid = !!confirmText && !!confirmTextValue && confirmTextValue.trim() === confirmText.trim();
6419
- var isDisableDelete = !!confirmText && (confirmTextValue === null || confirmTextValue === void 0 ? void 0 : confirmTextValue.trim()) !== confirmText.trim();
6420
- return React__default.createElement(material.Dialog, {
6421
- open: open,
6422
- onClose: toggle,
6423
- sx: {
6424
- zIndex: zIndex
6425
- }
6426
- }, React__default.createElement(React.Fragment, null, React__default.createElement(material.DialogTitle, {
6427
- className: "border border-start-0 border-end-0 border-top-0 border-1 " + titleClassName,
6428
- sx: _extends({
6429
- fontSize: 16
6430
- }, titleStyle)
6431
- }, title || t('confirmation')), React__default.createElement(material.IconButton, {
6432
- "aria-label": "close",
6433
- onClick: toggle,
6434
- sx: {
6435
- position: "absolute",
6436
- right: 8,
6437
- top: 8,
6438
- color: function color(theme) {
6439
- return theme.palette.grey[500];
6438
+ getData(isFirstLoadRef.current);
6439
+ }, [JSON.stringify(filter)]);
6440
+ return {
6441
+ filter: filter,
6442
+ textSearchRef: textSearchRef,
6443
+ paging: paging,
6444
+ data: data,
6445
+ selectedItem: selectedItem,
6446
+ handleSort: handleSort,
6447
+ handleChangeSearchText: handleChangeSearchText,
6448
+ handleChangePage: handleChangePage,
6449
+ calcOrderNumber: calcOrderNumber,
6450
+ handleChangeSelectedItem: handleChangeSelectedItem,
6451
+ getData: getData
6452
+ };
6453
+ };
6454
+
6455
+ var useLoadMore = function useLoadMore(props) {
6456
+ var onLoadMore = props.onLoadMore,
6457
+ loading = props.loading;
6458
+ var observerTarget = React.useRef(null);
6459
+ React.useEffect(function () {
6460
+ var currentTarget = observerTarget.current;
6461
+ var observer = new IntersectionObserver(function (entries) {
6462
+ if (entries[0].isIntersecting && !loading) {
6463
+ onLoadMore();
6440
6464
  }
6465
+ }, {
6466
+ threshold: 1
6467
+ });
6468
+ if (observerTarget.current) {
6469
+ observer.observe(observerTarget.current);
6441
6470
  }
6442
- }, React__default.createElement(io5.IoClose, null))), React__default.createElement(material.DialogContent, {
6443
- sx: _extends({
6444
- pt: 0.5
6445
- }, contentStyle)
6446
- }, React__default.createElement(material.Typography, {
6447
- className: "mb-1",
6448
- sx: _extends({
6449
- fontWeight: 700
6450
- }, contentTextStyle)
6451
- }, text), !!confirmText && React__default.createElement("div", {
6452
- className: "w-100"
6453
- }, React__default.createElement("p", {
6454
- className: "mb-3"
6455
- }, t("enter_text_to_confirm_delete", {
6456
- text: confirmText
6457
- })), React__default.createElement(material.TextField, {
6458
- className: "w-100",
6459
- sx: {
6460
- "& input": {
6461
- py: 1
6462
- }
6463
- },
6464
- value: confirmTextValue,
6465
- onChange: handleChangeConfirmText,
6466
- placeholder: t('please_enter'),
6467
- onPaste: handlePaste,
6468
- error: !isValid && confirmTextValue !== undefined,
6469
- color: isValid ? "success" : confirmTextValue !== undefined ? "error" : undefined
6470
- }))), React__default.createElement(material.DialogActions, {
6471
- className: "border border-start-0 border-end-0 border-bottom-0 border-1 " + titleClassName,
6472
- sx: _extends({
6473
- paddingTop: 1
6474
- }, actionStyle)
6475
- }, React__default.createElement(material.Button, {
6476
- variant: cancelButtonVariant,
6477
- color: cancelButtonVariant !== "contained" ? "primary" : "secondary",
6478
- className: "px-3 " + (cancelButtonVariant !== "contained" ? "primary" : "bg-secondary"),
6479
- onClick: toggle,
6480
- sx: cancelButtonStyle
6481
- }, cancelText || t("no")), React__default.createElement(material.Button, {
6482
- variant: okButtonVariant,
6483
- color: isDelete ? "error" : "primary",
6484
- className: "px-3",
6485
- disabled: isDisableDelete,
6486
- onClick: handleConfirm,
6487
- sx: _extends({}, okButtonStyle, isDelete && {
6488
- backgroundColor: "#db4d4d",
6489
- color: "#FFFFFF",
6490
- "&:hover": {
6491
- backgroundColor: "#C41414"
6471
+ return function () {
6472
+ if (currentTarget) {
6473
+ observer.unobserve(currentTarget);
6492
6474
  }
6493
- })
6494
- }, okText || t('yes'))));
6475
+ };
6476
+ }, [observerTarget, loading, onLoadMore]);
6477
+ return {
6478
+ observerTarget: observerTarget
6479
+ };
6495
6480
  };
6496
6481
 
6497
- var ConfirmDeleteDialog = function ConfirmDeleteDialog(props) {
6498
- return React__default.createElement(ConfirmDialog, Object.assign({}, ConfirmDeleteDialogDefaultProps, props));
6482
+ var AUTH_URL = BASE_URL + "/api/auth";
6483
+ var AUTH_SUPER_ADMIN_URL = SUPER_ADMIN_BASE_URL + "/api/auth";
6484
+ var getInfo = function getInfo(role, isLearningSpace) {
6485
+ var _headers;
6486
+ return api.get(AUTH_URL + "/info", {
6487
+ params: {
6488
+ role: role
6489
+ },
6490
+ headers: (_headers = {}, _headers[NoAcademyHeaders] = isLearningSpace, _headers)
6491
+ });
6499
6492
  };
6500
-
6501
- var styles = {"lighter":"#F0FFF6","light":"#89F0B2","less_dark":"#3DC674","dark":"#349056","darker":"#18442A","gray_50":"#FBFBF9","gray_100":"#EAEAE5","gray_300":"#D0D0C8","gray_500":"#9A9A98","gray_700":"#5D5D5B","gray_900":"#363634","red_900":"#DB4D4D","green_support_900":"#3ACB46","yellow_900":"#FEAF06","purple_900":"#C3099A","btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1","btn-primary":"_rd4Uy","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","dropdown-academy":"_3CMVp","image-academy":"_2ibYC","academy-btn":"_1JMRU","switch-icon":"_N4FNf","dropdown-content-academy":"_31Dr0","dropdown-academy-item":"_3bjcz","noGutters":"_31ZQk","custom-col-2":"_3yXyK","custom-col-3":"_1RsJQ","custom-col-5":"_L42CP","custom-col-10":"_2u6eL","custom-row":"_8x7OP","custom-col":"_1JmTh","custom-col-4":"_3HO1e","custom-col-8":"_Oy31M","custom-col-12":"_3aUKo","custom-container":"_39LRs","form-label":"__Ut-u","form-control":"_2k4dX","btn-outline-primary":"_2PWdX","sort-icons":"_mQvLF","active":"_3oAH-","form-select":"_3W3aw","truncate":"_3NJzN","headers":"_3xnI5","logo-container":"_3YG70","tabBox":"_1CQPn","routerBox":"_3hx2T","tabText":"_3UyhW","router-link-active":"_1TGKA","router-link":"_1AqMh","userImg":"_2RI6G","disabled-link":"_3aVHg","line-clamp":"_3fpky"};
6502
-
6503
- var _templateObject;
6504
- var BorderedTextField = material.styled(material.TextField)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n & .MuiOutlinedInput-root {\n &.Mui-focused fieldset {\n border-width: 1px;\n border-color: ", ";\n }\n }\n & .MuiOutlinedInput-root:hover {\n fieldset {\n border-width: 1px;\n border-color: ", ";\n }\n }\n"])), styles.dark, styles.less_dark);
6505
- var InputText = function InputText(props) {
6506
- return React__default.createElement(BorderedTextField, Object.assign({
6507
- sx: {
6508
- "& input": {
6509
- py: "7.5px",
6510
- px: "12px"
6511
- },
6512
- "& > div": {
6513
- borderColor: "#97A1AF",
6514
- borderRadius: "4px"
6515
- }
6516
- }
6517
- }, props));
6493
+ var getSuperAdminInfoFromWeb = function getSuperAdminInfoFromWeb() {
6494
+ return api.get(AUTH_SUPER_ADMIN_URL + "/info");
6495
+ };
6496
+ var apiLoginGoogle = function apiLoginGoogle(body, isLearningSpace) {
6497
+ var _headers2;
6498
+ return api.post(AUTH_URL + "/login", body, {
6499
+ headers: (_headers2 = {}, _headers2[NoAcademyHeaders] = isLearningSpace, _headers2)
6500
+ });
6501
+ };
6502
+ var apiLoginGoogleSuperAdmin = function apiLoginGoogleSuperAdmin(body) {
6503
+ return api.post(AUTH_SUPER_ADMIN_URL + "/login", body);
6504
+ };
6505
+ var apiLoginWithAccessToken = function apiLoginWithAccessToken(body, isLearningSpace, domain) {
6506
+ var _headers3;
6507
+ return api.post(AUTH_URL + "/login/access-token", body, {
6508
+ params: {
6509
+ isLearningSpace: isLearningSpace
6510
+ },
6511
+ headers: (_headers3 = {}, _headers3[AcademyHeaders] = domain, _headers3[NoAcademyHeaders] = isLearningSpace, _headers3)
6512
+ });
6513
+ };
6514
+ var apiLoginSuperAdminWithAccessToken = function apiLoginSuperAdminWithAccessToken(body) {
6515
+ return api.post(AUTH_SUPER_ADMIN_URL + "/login/access-token", body);
6518
6516
  };
6519
6517
 
6520
- var PassCodeDialog = function PassCodeDialog(_ref) {
6521
- var open = _ref.open,
6522
- onClose = _ref.onClose,
6523
- onSubmit = _ref.onSubmit,
6524
- academyDomain = _ref.academyDomain;
6518
+ var useLogin = function useLogin(history, homeAcademyUrl, homeUrl, registerUrl, redirectAfterLogin) {
6519
+ if (redirectAfterLogin === void 0) {
6520
+ redirectAfterLogin = true;
6521
+ }
6522
+ var dispatch = reactRedux.useDispatch();
6525
6523
  var _useTranslation = reactI18next.useTranslation(),
6526
6524
  t = _useTranslation.t;
6527
- var _useState = React.useState(""),
6528
- passCode = _useState[0],
6529
- setPassCode = _useState[1];
6530
- var handleClose = function handleClose(event, reason) {
6531
- onClose(event, reason);
6525
+ var _useGoogleSignOut = useGoogleSignOut({}),
6526
+ handleSignOut = _useGoogleSignOut.handleSignOut;
6527
+ var searchParams = new URLSearchParams(window.location.search);
6528
+ var paramDomain = searchParams.get('domain');
6529
+ var handleLoginGoogle = function handleLoginGoogle(data, isLogout) {
6530
+ if (isLogout === void 0) {
6531
+ isLogout = true;
6532
+ }
6533
+ try {
6534
+ var isStudent = data.role === exports.Role.Student;
6535
+ var academyDomain = paramDomain || getAcademyDomain();
6536
+ var isLearningSpace = getLearningSpace() || isStudent && !academyDomain;
6537
+ if (!isStudent && isLearningSpace) {
6538
+ isLearningSpace = false;
6539
+ localStorage.removeItem(LEARNING_SPACE);
6540
+ }
6541
+ var isAcademy = !!academyDomain || isLearningSpace;
6542
+ return Promise.resolve(handleLogin(function () {
6543
+ return new Promise(function (resolve, reject) {
6544
+ try {
6545
+ var _temp3 = _catch(function () {
6546
+ return Promise.resolve(isAcademy ? apiLoginGoogle(data, isLearningSpace) : apiLoginGoogleSuperAdmin(data)).then(function (loginResponse) {
6547
+ function _temp2() {
6548
+ resolve(result);
6549
+ }
6550
+ var result = loginResponse.data;
6551
+ var _temp = function () {
6552
+ if (loginResponse.status === 204 && academyDomain) {
6553
+ localStorage.removeItem(ACADEMY_DOMAIN);
6554
+ localStorage.removeItem(LEARNING_SPACE);
6555
+ return Promise.resolve(apiLoginGoogleSuperAdmin(data)).then(function (_apiLoginGoogleSuperA) {
6556
+ loginResponse = _apiLoginGoogleSuperA;
6557
+ result = loginResponse.data;
6558
+ });
6559
+ }
6560
+ }();
6561
+ return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
6562
+ });
6563
+ }, function (error) {
6564
+ !!academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
6565
+ localStorage.removeItem(LEARNING_SPACE);
6566
+ reject(error);
6567
+ });
6568
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
6569
+ } catch (e) {
6570
+ return Promise.reject(e);
6571
+ }
6572
+ });
6573
+ }, isStudent, isLogout)).then(function () {});
6574
+ } catch (e) {
6575
+ return Promise.reject(e);
6576
+ }
6532
6577
  };
6533
- var handleSubmit = function handleSubmit() {
6578
+ var handleLoginAccessToken = function handleLoginAccessToken(data, isLearningSpace, domain, isLogout, superAdminRedirectPath) {
6579
+ if (isLogout === void 0) {
6580
+ isLogout = true;
6581
+ }
6534
6582
  try {
6535
- var data = {
6536
- code: passCode,
6537
- academyDomain: academyDomain
6583
+ var isStudent = data.role === exports.Role.Student;
6584
+ return Promise.resolve(handleLogin(function () {
6585
+ return new Promise(function (resolve, reject) {
6586
+ try {
6587
+ var _temp4 = _catch(function () {
6588
+ return Promise.resolve(!isLearningSpace && !domain ? apiLoginSuperAdminWithAccessToken(data) : apiLoginWithAccessToken(data, isLearningSpace, domain)).then(function (loginResponse) {
6589
+ var result = loginResponse.data;
6590
+ resolve(result);
6591
+ });
6592
+ }, function (error) {
6593
+ reject(error);
6594
+ });
6595
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
6596
+ } catch (e) {
6597
+ return Promise.reject(e);
6598
+ }
6599
+ });
6600
+ }, isStudent, isLogout, superAdminRedirectPath)).then(function () {});
6601
+ } catch (e) {
6602
+ return Promise.reject(e);
6603
+ }
6604
+ };
6605
+ var handleLogin = function handleLogin(apiLogin, isStudent, isLogout, superAdminRedirectPath) {
6606
+ if (isLogout === void 0) {
6607
+ isLogout = true;
6608
+ }
6609
+ try {
6610
+ var _temp6 = function _temp6(_result) {
6611
+ if (_exit) return _result;
6612
+ dispatch(setLoading(false));
6538
6613
  };
6539
- return Promise.resolve(onSubmit(data, handleClose)).then(function () {});
6614
+ var _exit = false;
6615
+ dispatch(setLoading(true));
6616
+ var _temp5 = _catch(function () {
6617
+ return Promise.resolve(apiLogin()).then(function (loginResponse) {
6618
+ var isFirstLogin = loginResponse.isFirstLogin,
6619
+ token = loginResponse.token,
6620
+ user = loginResponse.user,
6621
+ isSuperAdmin = loginResponse.isSuperAdmin;
6622
+ var isAcademy = !!(user !== null && user !== void 0 && user.academyDomain) || !!(user !== null && user !== void 0 && user.isLearningSpace);
6623
+ var needToRegister = isStudent && isFirstLogin && isAcademy;
6624
+ var redirectUrl = getRedirectUrl();
6625
+ if (isStudent && !registerUrl) throw new Error("an_unexpected_error_has_occurred");
6626
+ if (!redirectUrl) redirectUrl = needToRegister ? registerUrl : isAcademy ? homeAcademyUrl : homeUrl;
6627
+ if (superAdminRedirectPath) {
6628
+ redirectUrl = superAdminRedirectPath;
6629
+ }
6630
+ if (!redirectAfterLogin) redirectUrl = undefined;
6631
+ redirectLoginUser(_extends({}, user, {
6632
+ isNotEnoughStatements: isFirstLogin,
6633
+ isSuperAdmin: isSuperAdmin
6634
+ }), token, redirectUrl);
6635
+ });
6636
+ }, function (error) {
6637
+ alert(getErrorMessage(t, error));
6638
+ isLogout && handleSignOut();
6639
+ });
6640
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
6540
6641
  } catch (e) {
6541
6642
  return Promise.reject(e);
6542
6643
  }
6543
6644
  };
6544
- var handleChangePassCode = function handleChangePassCode(e) {
6545
- setPassCode(e.target.value);
6546
- };
6547
- var theme = material.useTheme();
6548
- return React__default.createElement(CommonDialog, {
6549
- open: open,
6550
- onClose: handleClose,
6551
- size: "xs",
6552
- title: t("join_an_academy")
6553
- }, React__default.createElement(material.DialogContent, {
6554
- sx: {
6555
- overflowY: "unset"
6645
+ var redirectLoginUser = function redirectLoginUser(data, token, redirectUrl) {
6646
+ localStorage.setItem(ACCESS_TOKEN, token);
6647
+ !data.academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
6648
+ !!data.academyDomain && localStorage.setItem(ACADEMY_DOMAIN, data.academyDomain);
6649
+ if (data.roles.includes(exports.Role.Student)) data.isLearningSpace ? localStorage.setItem(LEARNING_SPACE, "true") : localStorage.removeItem(LEARNING_SPACE);
6650
+ dispatch(setUser(_extends({}, data)));
6651
+ if (redirectUrl) {
6652
+ pushTo(history, redirectUrl);
6653
+ localStorage.removeItem(REDIRECT_URL);
6556
6654
  }
6557
- }, React__default.createElement(material.Stack, {
6558
- direction: "column",
6559
- spacing: 2,
6560
- zIndex: 1,
6561
- position: "relative"
6562
- }, React__default.createElement(material.FormGroup, null, React__default.createElement(material.FormLabel, {
6563
- className: "fw-medium mb-1"
6564
- }, t("pass_code"), React__default.createElement("span", {
6565
- className: "text-danger"
6566
- }, "*")), React__default.createElement(InputText, {
6567
- id: "pass-code",
6568
- placeholder: t("enter_pass_code"),
6569
- value: passCode,
6570
- onChange: handleChangePassCode
6571
- })))), React__default.createElement(material.DialogActions, {
6572
- className: ""
6573
- }, React__default.createElement(material.Button, {
6574
- variant: "contained",
6575
- sx: {
6576
- bgcolor: theme.palette.grey[700]
6577
- },
6578
- onClick: handleClose
6579
- }, t("cancel")), React__default.createElement(material.Button, {
6580
- variant: "contained",
6581
- onClick: handleSubmit,
6582
- disabled: !passCode.trim().length
6583
- }, t("confirmation"))));
6655
+ };
6656
+ return {
6657
+ handleLoginGoogle: handleLoginGoogle,
6658
+ handleLoginAccessToken: handleLoginAccessToken,
6659
+ redirectLoginUser: redirectLoginUser
6660
+ };
6584
6661
  };
6585
6662
 
6586
- var loadingStyle = {
6587
- minWidth: "100vw",
6588
- minHeight: "100vh",
6589
- position: "fixed",
6590
- top: 0,
6591
- left: 0,
6592
- zIndex: 999999999,
6593
- backgroundColor: "rgba(0, 0, 0, 0.4)",
6594
- display: "flex",
6595
- justifyContent: "center",
6596
- alignItems: "center"
6597
- };
6598
- var Loading = function Loading() {
6599
- var isLoading = reactRedux.useSelector(function (state) {
6600
- return state.common.isLoading;
6663
+ var ACADEMY_URL = BASE_URL + "/api/academy";
6664
+ var SUPER_ADMIN_ACADEMY_URL = SUPER_ADMIN_BASE_URL + "/api/academies";
6665
+ var getAcademyList = function getAcademyList(role) {
6666
+ return api.get(SUPER_ADMIN_ACADEMY_URL + "/active", {
6667
+ params: {
6668
+ role: role
6669
+ }
6601
6670
  });
6602
- return isLoading ? React__default.createElement("div", {
6603
- style: loadingStyle
6604
- }, React__default.createElement("div", {
6605
- className: "spinner-border text-secondary",
6606
- role: "status"
6607
- }, React__default.createElement("span", {
6608
- className: "sr-only"
6609
- }))) : null;
6610
- };
6611
-
6612
- var loadingStyle$1 = {
6613
- minWidth: "100vw",
6614
- minHeight: "100vh",
6615
- position: "fixed",
6616
- top: 0,
6617
- left: 0,
6618
- zIndex: 999999999,
6619
- backgroundColor: "rgba(0, 0, 0, 0.4)",
6620
- display: "flex",
6621
- justifyContent: "center",
6622
- alignItems: "center"
6623
- };
6624
- var LoadingComponent = function LoadingComponent(_ref) {
6625
- var isLoading = _ref.isLoading,
6626
- children = _ref.children,
6627
- _ref$spinClassName = _ref.spinClassName,
6628
- spinClassName = _ref$spinClassName === void 0 ? "text-secondary" : _ref$spinClassName,
6629
- _ref$className = _ref.className,
6630
- className = _ref$className === void 0 ? "" : _ref$className;
6631
- return isLoading ? React__default.createElement("div", {
6632
- style: loadingStyle$1
6633
- }, React__default.createElement(material.Stack, {
6634
- direction: "column",
6635
- justifyContent: "center",
6636
- alignItems: "center",
6637
- className: className
6638
- }, React__default.createElement("div", {
6639
- className: "spinner-border " + spinClassName,
6640
- role: "status"
6641
- }, React__default.createElement("span", {
6642
- className: "sr-only"
6643
- })), React__default.createElement("div", null, children))) : null;
6644
6671
  };
6645
-
6646
- var CustomPagination = function CustomPagination(_ref) {
6647
- var currentPage = _ref.currentPage,
6648
- totalPage = _ref.totalPage,
6649
- onChangePage = _ref.onChangePage;
6650
- var handleChangePage = function handleChangePage(_, page) {
6651
- onChangePage(page);
6652
- };
6653
- return React__default.createElement(material.Pagination, {
6654
- className: "w-fit",
6655
- count: totalPage,
6656
- page: currentPage,
6657
- onChange: handleChangePage
6672
+ var getUserAcademies = function getUserAcademies(role, isLearningSpace) {
6673
+ var _headers;
6674
+ return api.get("" + ACADEMY_URL, {
6675
+ params: {
6676
+ role: role
6677
+ },
6678
+ headers: (_headers = {}, _headers[NoAcademyHeaders] = isLearningSpace, _headers)
6658
6679
  });
6659
6680
  };
6660
-
6661
- var DropdownIndicator = function DropdownIndicator(props) {
6662
- return React__default.createElement(Select.components.DropdownIndicator, Object.assign({}, props), React__default.createElement(fa.FaCaretDown, {
6663
- size: 20,
6664
- color: styles.darker
6665
- }));
6666
- };
6667
- var CustomOption = function CustomOption(props) {
6668
- return React__default.createElement(Select.components.Option, Object.assign({}, props), React__default.createElement("div", {
6669
- style: {
6670
- fontSize: "14px",
6671
- fontWeight: 500
6681
+ var getAcademyByDomainApi = function getAcademyByDomainApi(domain, role) {
6682
+ return api.get(SUPER_ADMIN_ACADEMY_URL + "/domain/" + domain, {
6683
+ params: {
6684
+ role: role
6672
6685
  }
6673
- }, props.data.label));
6686
+ });
6674
6687
  };
6675
-
6676
- var customStyles = {
6677
- control: function control(baseStyles, state) {
6678
- return _extends({}, baseStyles, {
6679
- fontSize: "14px",
6680
- fontWeight: 700,
6681
- color: styles.darker,
6682
- borderColor: state.isFocused || state.hasValue ? styles.dark : styles.less_dark,
6683
- boxShadow: state.isFocused ? "0 0 0 1px " + styles.dark + "4D" : baseStyles.boxShadow,
6684
- "&:active": {
6685
- borderColor: state.isFocused || state.hasValue ? styles.dark : styles.less_dark
6686
- },
6687
- "&:hover": {
6688
- borderColor: state.isFocused || state.hasValue ? styles.dark : styles.less_dark
6689
- }
6690
- });
6691
- },
6692
- input: function input(baseStyles, _) {
6693
- return _extends({}, baseStyles, {
6694
- fontSize: "14px",
6695
- fontWeight: 700,
6696
- color: styles.darker
6697
- });
6698
- },
6699
- singleValue: function singleValue(baseStyles) {
6700
- return _extends({}, baseStyles, {
6701
- fontSize: "14px",
6702
- fontWeight: 700,
6703
- color: styles.darker
6704
- });
6705
- },
6706
- option: function option(baseStyles, state) {
6707
- return _extends({}, baseStyles, {
6708
- backgroundColor: state.isSelected ? styles.dark : state.isFocused ? styles.light : 'white',
6709
- "&:active": {
6710
- backgroundColor: state.isSelected ? styles.dark : state.isFocused ? styles.less_dark : baseStyles.backgroundColor
6711
- }
6712
- });
6713
- }
6688
+ var getAcademyDetail = function getAcademyDetail() {
6689
+ return api.get(ACADEMY_URL + "/detail");
6714
6690
  };
6715
-
6716
- var _excluded = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
6717
- var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
6718
- var isDefault = _ref.isDefault,
6719
- options = _ref.options,
6720
- isDisabled = _ref.isDisabled,
6721
- scrollBottom = _ref.scrollBottom,
6722
- value = _ref.value,
6723
- isMulti = _ref.isMulti,
6724
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
6725
- var initialValues = Array.isArray(value) ? options.filter(function (i) {
6726
- return value.includes(i.value);
6727
- }) : isMulti ? options.filter(function (i) {
6728
- return i.value == value;
6729
- }) : options.find(function (i) {
6730
- return i.value == value;
6731
- });
6732
- var _useTranslation = reactI18next.useTranslation(),
6733
- t = _useTranslation.t;
6734
- return React__default.createElement(Select__default, Object.assign({
6735
- isDisabled: isDisabled,
6736
- options: options,
6737
- value: !isDefault ? initialValues : undefined,
6738
- defaultValue: isDefault ? initialValues : undefined,
6739
- menuPlacement: scrollBottom ? "top" : "auto",
6740
- isMulti: isMulti,
6741
- components: {
6742
- IndicatorSeparator: function IndicatorSeparator() {
6743
- return null;
6744
- },
6745
- DropdownIndicator: DropdownIndicator,
6746
- Option: CustomOption
6747
- },
6748
- styles: customStyles,
6749
- placeholder: t("select_placeholder")
6750
- }, rest));
6691
+ var switchAcademy = function switchAcademy(academyId, role, isLearningSpace) {
6692
+ if (isLearningSpace === void 0) {
6693
+ isLearningSpace = false;
6694
+ }
6695
+ return api.post(ACADEMY_URL + "/" + academyId + "/switch-academy/" + role, undefined, {
6696
+ params: {
6697
+ isLearningSpace: isLearningSpace
6698
+ }
6699
+ });
6700
+ };
6701
+ var switchSuperAdminAcademy = function switchSuperAdminAcademy(academyId, role) {
6702
+ return api.post(SUPER_ADMIN_ACADEMY_URL + "/" + academyId + "/switch-academy/" + role);
6751
6703
  };
6752
6704
 
6753
- var _excluded$1 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
6754
- var CustomCreatable = function CustomCreatable(_ref) {
6755
- var options = _ref.options,
6756
- isDisabled = _ref.isDisabled,
6757
- scrollBottom = _ref.scrollBottom,
6758
- value = _ref.value,
6759
- isMulti = _ref.isMulti,
6760
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
6761
- var initialValues = Array.isArray(value) ? options.filter(function (i) {
6762
- return value.includes(i.value);
6763
- }) : isMulti ? options.filter(function (i) {
6764
- return i.value == value;
6765
- }) : options.find(function (i) {
6766
- return i.value == value;
6705
+ var useSwitchAcademy = function useSwitchAcademy(role, history, homeAcademyUrl, homeUrl, registerUrl, canFetchAcademies) {
6706
+ var _user$roles;
6707
+ if (role === void 0) {
6708
+ role = exports.Role.Student;
6709
+ }
6710
+ if (canFetchAcademies === void 0) {
6711
+ canFetchAcademies = false;
6712
+ }
6713
+ var dispatch = reactRedux.useDispatch();
6714
+ var _useLogin = useLogin(history, homeAcademyUrl, homeUrl, registerUrl),
6715
+ handleLoginAccessToken = _useLogin.handleLoginAccessToken;
6716
+ var academyList = reactRedux.useSelector(function (state) {
6717
+ var _state$academies;
6718
+ return state === null || state === void 0 ? void 0 : (_state$academies = state.academies) === null || _state$academies === void 0 ? void 0 : _state$academies.items;
6719
+ }) || [];
6720
+ var _useState = React.useState(false),
6721
+ dropdownOpen = _useState[0],
6722
+ setDropdownOpen = _useState[1];
6723
+ var toggleDropdown = function toggleDropdown() {
6724
+ return setDropdownOpen(function (prevState) {
6725
+ return !prevState;
6726
+ });
6727
+ };
6728
+ var user = reactRedux.useSelector(function (state) {
6729
+ var _state$common;
6730
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
6731
+ });
6732
+ var isReFetchUserAcademies = reactRedux.useSelector(function (state) {
6733
+ var _state$common2;
6734
+ return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
6767
6735
  });
6768
6736
  var _useTranslation = reactI18next.useTranslation(),
6769
6737
  t = _useTranslation.t;
6770
- return React__default.createElement(CreatableSelect, Object.assign({
6771
- isClearable: true,
6772
- isDisabled: isDisabled,
6773
- options: options,
6774
- value: initialValues,
6775
- menuPlacement: scrollBottom ? "top" : "auto",
6776
- isMulti: isMulti,
6777
- components: {
6778
- IndicatorSeparator: function IndicatorSeparator() {
6779
- return null;
6780
- },
6781
- DropdownIndicator: DropdownIndicator,
6782
- Option: CustomOption
6783
- },
6784
- styles: customStyles,
6785
- placeholder: t("select_placeholder")
6786
- }, rest));
6738
+ var getAcademies = function getAcademies(isLoading) {
6739
+ if (isLoading === void 0) {
6740
+ isLoading = true;
6741
+ }
6742
+ try {
6743
+ var _temp3 = function _temp3() {
6744
+ isLoading && dispatch(setLoading(false));
6745
+ };
6746
+ if (!user) return Promise.resolve();
6747
+ var isSuperAdminUser = user && !user.academyDomain && !(user !== null && user !== void 0 && user.isLearningSpace);
6748
+ var isSuperAdminRole = user.roles.includes(exports.Role.Admin);
6749
+ isLoading && dispatch(setLoading(true));
6750
+ var _temp2 = _catch(function () {
6751
+ return Promise.resolve(isSuperAdminUser ? getAcademyList(role) : getUserAcademies(role, user === null || user === void 0 ? void 0 : user.isLearningSpace)).then(function (res) {
6752
+ var items = res.data.items || [];
6753
+ if (isReFetchUserAcademies) dispatch(setReFetchUserAcademies(false));
6754
+ dispatch(setAcademies(items));
6755
+ var _temp = function () {
6756
+ if (!isSuperAdminRole && isSuperAdminUser && role == exports.Role.Admin && items.length > 0) {
6757
+ return Promise.resolve(handleSwitchAcademy(false, items[0], false)).then(function () {});
6758
+ }
6759
+ }();
6760
+ if (_temp && _temp.then) return _temp.then(function () {});
6761
+ });
6762
+ }, function (error) {
6763
+ reactToastify.toast.error(getErrorMessage(t, error));
6764
+ });
6765
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
6766
+ } catch (e) {
6767
+ return Promise.reject(e);
6768
+ }
6769
+ };
6770
+ var handleSwitchAcademy = function handleSwitchAcademy(isLearningSpace, selectedAcademy, isLoading, superAdminRedirectPath) {
6771
+ if (isLoading === void 0) {
6772
+ isLoading = true;
6773
+ }
6774
+ try {
6775
+ var _temp5 = function _temp5() {
6776
+ isLoading && dispatch(setLoading(false));
6777
+ setDropdownOpen(false);
6778
+ };
6779
+ isLoading && dispatch(setLoading(true));
6780
+ var academyId = selectedAcademy ? selectedAcademy.id : 0;
6781
+ var academyDomain = selectedAcademy ? selectedAcademy.domain : undefined;
6782
+ var isSuperAdminUser = user && !user.academyDomain && !(user !== null && user !== void 0 && user.isLearningSpace);
6783
+ var _temp4 = _catch(function () {
6784
+ return Promise.resolve(isSuperAdminUser ? switchSuperAdminAcademy(academyId, role) : switchAcademy(academyId, role, isLearningSpace)).then(function (res) {
6785
+ var data = res.data;
6786
+ var requestBody = {
6787
+ accessToken: data.accessToken,
6788
+ email: user.email,
6789
+ role: role
6790
+ };
6791
+ return Promise.resolve(handleLoginAccessToken(requestBody, isLearningSpace, academyDomain, false, superAdminRedirectPath)).then(function () {});
6792
+ });
6793
+ }, function (error) {
6794
+ reactToastify.toast.error(getErrorMessage(t, error));
6795
+ });
6796
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
6797
+ } catch (e) {
6798
+ return Promise.reject(e);
6799
+ }
6800
+ };
6801
+ var handleLogOutAcademy = function handleLogOutAcademy(callback) {
6802
+ try {
6803
+ var _temp7 = function _temp7() {
6804
+ dispatch(setLoading(false));
6805
+ callback();
6806
+ };
6807
+ dispatch(setLoading(true));
6808
+ var _temp6 = _catch(function () {
6809
+ return Promise.resolve(switchAcademy(0, role)).then(function (res) {
6810
+ var data = res.data;
6811
+ var requestBody = {
6812
+ accessToken: data.accessToken,
6813
+ email: user.email,
6814
+ role: role
6815
+ };
6816
+ return Promise.resolve(handleLoginAccessToken(requestBody, undefined, undefined, false)).then(function () {});
6817
+ });
6818
+ }, function (error) {
6819
+ reactToastify.toast.error(getErrorMessage(t, error));
6820
+ });
6821
+ return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp7) : _temp7(_temp6));
6822
+ } catch (e) {
6823
+ return Promise.reject(e);
6824
+ }
6825
+ };
6826
+ React.useEffect(function () {
6827
+ canFetchAcademies && getAcademies();
6828
+ }, [canFetchAcademies, user === null || user === void 0 ? void 0 : user.academyDomain, user === null || user === void 0 ? void 0 : user.email, user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.join(",")]);
6829
+ React.useEffect(function () {
6830
+ canFetchAcademies && isReFetchUserAcademies && getAcademies(false);
6831
+ }, [canFetchAcademies, isReFetchUserAcademies]);
6832
+ var selectedAcademy = React.useMemo(function () {
6833
+ return academyList.find(function (i) {
6834
+ var _user$academyDomain;
6835
+ return i.domain.trim().toLowerCase() === (user === null || user === void 0 ? void 0 : (_user$academyDomain = user.academyDomain) === null || _user$academyDomain === void 0 ? void 0 : _user$academyDomain.trim().toLowerCase());
6836
+ });
6837
+ }, [user === null || user === void 0 ? void 0 : user.academyDomain, JSON.stringify(academyList)]);
6838
+ return {
6839
+ selectedAcademy: selectedAcademy,
6840
+ dropdownOpen: dropdownOpen,
6841
+ academyList: academyList,
6842
+ toggleDropdown: toggleDropdown,
6843
+ handleSwitchAcademy: handleSwitchAcademy,
6844
+ handleLogOutAcademy: handleLogOutAcademy
6845
+ };
6787
6846
  };
6788
6847
 
6789
- var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
6790
- var CustomSelect = function CustomSelect(_ref) {
6791
- var isDefault = _ref.isDefault,
6792
- options = _ref.options,
6793
- isDisabled = _ref.isDisabled,
6794
- scrollBottom = _ref.scrollBottom,
6795
- value = _ref.value,
6796
- isMulti = _ref.isMulti,
6797
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
6798
- var _useTranslation = reactI18next.useTranslation(),
6799
- t = _useTranslation.t;
6800
- var initialValues = Array.isArray(value) ? options.filter(function (i) {
6801
- return value.includes(i.value);
6802
- }) : isMulti ? options === null || options === void 0 ? void 0 : options.filter(function (i) {
6803
- return i.value == value;
6804
- }) : options === null || options === void 0 ? void 0 : options.find(function (i) {
6805
- return i.value == value;
6806
- });
6807
- return React__default.createElement(Select__default, Object.assign({
6808
- isDisabled: isDisabled,
6809
- options: options,
6810
- value: !isDefault ? initialValues != null ? initialValues : null : undefined,
6811
- defaultValue: isDefault ? initialValues : undefined,
6812
- menuPlacement: scrollBottom ? "top" : "auto",
6813
- isMulti: isMulti,
6814
- components: {
6815
- IndicatorSeparator: function IndicatorSeparator() {
6816
- return null;
6817
- },
6818
- DropdownIndicator: DropdownIndicator,
6819
- Option: CustomOption
6820
- },
6821
- styles: customStyles,
6822
- placeholder: t("select_placeholder")
6823
- }, rest));
6848
+ var useVirtualizeList = function useVirtualizeList(totalItems, rowHeight, offsetRow, minRows) {
6849
+ if (offsetRow === void 0) {
6850
+ offsetRow = 1;
6851
+ }
6852
+ var _useState = React.useState(-1),
6853
+ startIndex = _useState[0],
6854
+ setStartIndex = _useState[1];
6855
+ var _useState2 = React.useState(-1),
6856
+ endIndex = _useState2[0],
6857
+ setEndIndex = _useState2[1];
6858
+ var containerRef = React.useRef(null);
6859
+ var handleScroll = React.useCallback(function () {
6860
+ if (containerRef.current) {
6861
+ var _containerRef$current = containerRef.current,
6862
+ scrollTop = _containerRef$current.scrollTop,
6863
+ clientHeight = _containerRef$current.clientHeight;
6864
+ var itemsPerPage = Math.ceil(clientHeight / rowHeight);
6865
+ var newStartIndex = Math.max(Math.floor(scrollTop / rowHeight) - offsetRow, 0);
6866
+ var newEndIndex = Math.min(newStartIndex + itemsPerPage + offsetRow, totalItems - 1);
6867
+ if (minRows) {
6868
+ if (totalItems <= minRows) {
6869
+ newStartIndex = -1;
6870
+ newEndIndex = -1;
6871
+ } else {
6872
+ var total = newEndIndex - newStartIndex;
6873
+ var diff = minRows - total;
6874
+ if (diff > 0) {
6875
+ var valS = diff / 2;
6876
+ var valE = diff - valS;
6877
+ if (newStartIndex < valS) {
6878
+ valE += valS - newStartIndex;
6879
+ newStartIndex = 0;
6880
+ }
6881
+ if (newEndIndex + valE > totalItems - 1) {
6882
+ valS += newEndIndex + valE - totalItems + 1;
6883
+ }
6884
+ newStartIndex = Math.max(newStartIndex - valS, 0);
6885
+ newEndIndex = Math.min(newEndIndex + valE, totalItems - 1);
6886
+ }
6887
+ }
6888
+ }
6889
+ setStartIndex(newStartIndex);
6890
+ setEndIndex(newEndIndex);
6891
+ }
6892
+ }, [totalItems, rowHeight, offsetRow]);
6893
+ React.useEffect(function () {
6894
+ var container = containerRef.current;
6895
+ if (container) {
6896
+ container.addEventListener("scroll", handleScroll);
6897
+ }
6898
+ return function () {
6899
+ if (container) {
6900
+ container.removeEventListener("scroll", handleScroll);
6901
+ }
6902
+ };
6903
+ }, [handleScroll]);
6904
+ var handleChangeStartIndex = function handleChangeStartIndex(index) {
6905
+ setStartIndex(index);
6906
+ };
6907
+ var handleChangeEndIndex = function handleChangeEndIndex(index) {
6908
+ setEndIndex(index);
6909
+ };
6910
+ return {
6911
+ startIndex: startIndex,
6912
+ endIndex: endIndex,
6913
+ containerRef: containerRef,
6914
+ handleChangeStartIndex: handleChangeStartIndex,
6915
+ handleChangeEndIndex: handleChangeEndIndex
6916
+ };
6824
6917
  };
6825
6918
 
6826
- var _excluded$3 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti", "valueById", "isTextbook"];
6827
- var CustomSelectOption = function CustomSelectOption(_ref) {
6828
- var defaultValue = _ref.defaultValue,
6829
- options = _ref.options,
6830
- isDisabled = _ref.isDisabled,
6831
- scrollBottom = _ref.scrollBottom,
6832
- value = _ref.value,
6833
- isMulti = _ref.isMulti,
6834
- valueById = _ref.valueById,
6835
- isTextbook = _ref.isTextbook,
6836
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
6837
- var _useTranslation = reactI18next.useTranslation(),
6838
- t = _useTranslation.t;
6839
- var initialValues = defaultValue !== null && typeof defaultValue !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
6840
- return option.value === defaultValue;
6841
- })) || null : null;
6842
- var optionValue = valueById !== null && typeof valueById !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
6843
- return option.value == valueById;
6844
- })) || {
6845
- label: valueById,
6846
- value: valueById
6847
- } : null;
6848
- return isTextbook ? React__default.createElement(CreatableSelect, Object.assign({
6849
- isDisabled: isDisabled,
6850
- options: options,
6851
- value: optionValue || value,
6852
- defaultValue: initialValues,
6853
- menuPlacement: scrollBottom ? "top" : "auto",
6854
- isMulti: isMulti,
6855
- components: {
6856
- IndicatorSeparator: function IndicatorSeparator() {
6857
- return null;
6858
- },
6859
- DropdownIndicator: DropdownIndicator,
6860
- Option: CustomOption
6861
- },
6862
- styles: customStyles,
6863
- placeholder: t("select_placeholder")
6864
- }, rest)) : React__default.createElement(Select__default, Object.assign({
6865
- isDisabled: isDisabled,
6866
- options: options,
6867
- value: optionValue || value,
6868
- defaultValue: initialValues,
6869
- menuPlacement: scrollBottom ? "top" : "auto",
6870
- isMulti: isMulti,
6871
- components: {
6872
- IndicatorSeparator: function IndicatorSeparator() {
6873
- return null;
6874
- },
6875
- DropdownIndicator: DropdownIndicator,
6876
- Option: CustomOption
6877
- },
6878
- styles: customStyles,
6879
- placeholder: t("select_placeholder")
6880
- }, rest));
6881
- };
6919
+ (function (RecentUserActionSortBy) {
6920
+ RecentUserActionSortBy["CreatedAt"] = "CreatedAt";
6921
+ })(exports.RecentUserActionSortBy || (exports.RecentUserActionSortBy = {}));
6922
+ (function (OrderBy) {
6923
+ OrderBy["ASC"] = "ASC";
6924
+ OrderBy["DESC"] = "DESC";
6925
+ })(exports.OrderBy || (exports.OrderBy = {}));
6882
6926
 
6883
- var SCORE_OPTIONS = Array.from({
6884
- length: 10
6885
- }, function (_, i) {
6886
- return i + 1;
6887
- });
6888
- var QUESTION_OPTIONS = Array.from({
6889
- length: 10
6890
- }, function (_, i) {
6891
- return i + 1;
6927
+ var api = axios.create({
6928
+ baseURL: BASE_URL,
6929
+ timeout: 0,
6930
+ headers: {
6931
+ "Content-Type": "application/json"
6932
+ },
6933
+ paramsSerializer: function paramsSerializer(params) {
6934
+ return encodeParams(params);
6935
+ }
6892
6936
  });
6893
- var ANSWER_OPTIONS = Array.from({
6894
- length: 9
6895
- }, function (_, i) {
6896
- return i + 2;
6937
+ var apiUpload = axios.create({
6938
+ baseURL: BASE_URL,
6939
+ timeout: 60000,
6940
+ headers: {
6941
+ "Content-Type": "multipart/form-data"
6942
+ }
6897
6943
  });
6898
- var DEFAULT_SCORE = 2;
6899
-
6900
- var AnswerCountSelector = function AnswerCountSelector(_ref) {
6901
- var id = _ref.id,
6902
- value = _ref.value,
6903
- onChange = _ref.onChange,
6904
- isDisabled = _ref.isDisabled;
6905
- var _useTranslation = reactI18next.useTranslation(),
6906
- t = _useTranslation.t;
6907
- var answerOptions = ANSWER_OPTIONS.map(function (i) {
6908
- return {
6909
- label: t("number_question", {
6910
- number: i
6911
- }),
6912
- value: i
6913
- };
6944
+ [api, apiUpload].forEach(function (i) {
6945
+ return i.interceptors.request.use(function (config) {
6946
+ var token = getAccessToken();
6947
+ var searchParams = new URLSearchParams(window.location.search);
6948
+ var paramLang = searchParams.get('lang');
6949
+ var academyDomainStorage = getAcademyDomain();
6950
+ var isLearningSpace = getLearningSpace();
6951
+ var langStorage = getLanguage();
6952
+ var academyDomain = academyDomainStorage;
6953
+ var language = paramLang || langStorage;
6954
+ if (token) {
6955
+ config.headers.Authorization = "Bearer " + token;
6956
+ localStorage.setItem("LAST_TIME_REQUEST", moment().utc().format("YYYY-MM-DD HH:mm:ss"));
6957
+ }
6958
+ if (academyDomain && !isLearningSpace && config.headers[AcademyHeaders] == undefined) config.headers[AcademyHeaders] = "" + academyDomain;
6959
+ if (isLearningSpace && config.headers[NoAcademyHeaders] == undefined) config.headers[NoAcademyHeaders] = "" + isLearningSpace;
6960
+ if (language) config.headers[LanguageHeaders] = "" + language;
6961
+ return config;
6962
+ }, function (error) {
6963
+ return Promise.reject(error);
6914
6964
  });
6915
- return React__default.createElement(CustomSelect, {
6916
- inputId: id,
6917
- value: value,
6918
- options: answerOptions,
6919
- onChange: onChange,
6920
- isDisabled: isDisabled
6965
+ });
6966
+ [api, apiUpload].forEach(function (i) {
6967
+ return i.interceptors.response.use(function (response) {
6968
+ return response;
6969
+ }, function (error) {
6970
+ var _error$response, _error$response2, _error$response3;
6971
+ console.log({
6972
+ error: error
6973
+ });
6974
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
6975
+ var _window$location = window.location,
6976
+ pathname = _window$location.pathname,
6977
+ search = _window$location.search;
6978
+ var preRedirectUrl = localStorage.getItem(PRE_REDIRECT_URL);
6979
+ var newRedirectUrl = "" + pathname + search;
6980
+ if (!pathname.startsWith("/login")) {
6981
+ if (preRedirectUrl !== newRedirectUrl) {
6982
+ localStorage.setItem(REDIRECT_URL, newRedirectUrl);
6983
+ localStorage.setItem(PRE_REDIRECT_URL, newRedirectUrl);
6984
+ }
6985
+ }
6986
+ }
6987
+ if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 401 || ((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status) == 403) {
6988
+ localStorage.removeItem(ACCESS_TOKEN);
6989
+ window.location.href = "/login";
6990
+ }
6991
+ return Promise.reject(error);
6921
6992
  });
6922
- };
6923
-
6924
- var _excluded$4 = ["id", "value", "onChange", "isDisabled", "options", "isMulti", "placeholder"];
6925
- var ArticleCategorySelector = function ArticleCategorySelector(_ref) {
6926
- var id = _ref.id,
6927
- value = _ref.value,
6928
- onChange = _ref.onChange,
6929
- isDisabled = _ref.isDisabled,
6930
- options = _ref.options,
6931
- isMulti = _ref.isMulti,
6932
- placeholder = _ref.placeholder,
6933
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
6934
- var _useTranslation = reactI18next.useTranslation(),
6935
- t = _useTranslation.t;
6936
- return React__default.createElement(CustomSelect, Object.assign({
6937
- isMulti: isMulti,
6938
- inputId: id,
6939
- value: value,
6940
- options: options,
6941
- onChange: onChange,
6942
- isDisabled: isDisabled,
6943
- placeholder: placeholder || t("select_category")
6944
- }, rest));
6945
- };
6993
+ });
6946
6994
 
6947
6995
  var COURSE_URL = BASE_URL + "/api/course";
6948
6996
  var getClassesApi = function getClassesApi(textSearch) {
@@ -9162,7 +9210,7 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
9162
9210
  return {};
9163
9211
  };
9164
9212
 
9165
- var config = {
9213
+ var config$1 = {
9166
9214
  height: 300,
9167
9215
  allowedContent: true,
9168
9216
  toolbar: ["/", {
@@ -9194,13 +9242,16 @@ var config = {
9194
9242
  filebrowserUploadUrl: BASE_URL + "/api/file/support-files?"
9195
9243
  };
9196
9244
 
9245
+ var _excluded$6 = ["ref", "value", "option", "onBlur", "onFocus", "onChange", "onAfterInsertHtml", "onInsertElement", "onInsertHtml", "onInsertText", "onDataReady", "onSelectionChange", "disabled"];
9197
9246
  var CkEditor = function CkEditor(_ref) {
9198
9247
  var ref = _ref.ref,
9199
9248
  value = _ref.value,
9200
- onChange = _ref.onChange,
9201
9249
  option = _ref.option,
9250
+ onChange = _ref.onChange,
9251
+ onDataReady = _ref.onDataReady,
9202
9252
  _ref$disabled = _ref.disabled,
9203
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
9253
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
9254
+ action = _objectWithoutPropertiesLoose(_ref, _excluded$6);
9204
9255
  var _React$useState = React__default.useState(null),
9205
9256
  editor = _React$useState[0],
9206
9257
  setEditor = _React$useState[1];
@@ -9212,19 +9263,20 @@ var CkEditor = function CkEditor(_ref) {
9212
9263
  editor.setData(value);
9213
9264
  }
9214
9265
  }, [value, editor]);
9215
- return React__default.createElement(ckeditor4React.CKEditor, {
9266
+ return React__default.createElement(ckeditor4React.CKEditor, Object.assign({
9216
9267
  ref: ref,
9217
9268
  initData: value,
9218
9269
  readOnly: disabled,
9219
- onChange: onChange,
9220
9270
  onInstanceReady: handleInstanceReady,
9221
- config: !!option ? option : config,
9271
+ config: !!option ? option : config$1,
9272
+ onDataReady: onDataReady,
9273
+ onChange: onChange,
9222
9274
  onBeforeLoad: function onBeforeLoad(CKEDITOR) {
9223
9275
  CKEDITOR.disableAutoInline = true;
9224
9276
  CKEDITOR.config.height = 300;
9225
9277
  CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
9226
9278
  }
9227
- });
9279
+ }, action));
9228
9280
  };
9229
9281
 
9230
9282
  var ListView = function ListView(_ref) {
@@ -10793,10 +10845,10 @@ var LoginQRCode = function LoginQRCode(props) {
10793
10845
  }));
10794
10846
  };
10795
10847
 
10796
- var _excluded$6 = ["history"];
10848
+ var _excluded$7 = ["history"];
10797
10849
  var Login = function Login(_ref) {
10798
10850
  var history = _ref.history,
10799
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
10851
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
10800
10852
  var _useLogin = useLogin$1({
10801
10853
  homeAcademyUrl: rest.homeAcademyUrl,
10802
10854
  homeUrl: rest.homeUrl,
@@ -11750,11 +11802,11 @@ var DEFAULT_USER_FILTERS = {
11750
11802
 
11751
11803
  var styles$2 = {"avatar":"_2rJkZ","date-picker":"_1iqE2","time-picker":"_20xtc","teacher-selector-wrapper":"_3L1Oj"};
11752
11804
 
11753
- var _excluded$7 = ["teachers", "value"];
11805
+ var _excluded$8 = ["teachers", "value"];
11754
11806
  var TeacherSelector = function TeacherSelector(_ref) {
11755
11807
  var teachers = _ref.teachers,
11756
11808
  value = _ref.value,
11757
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
11809
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
11758
11810
  var teacherOptions = teachers.map(function (i) {
11759
11811
  return {
11760
11812
  label: i.teacherName + "/" + i.teacherEmail,
@@ -13045,7 +13097,7 @@ var useTeacherList = function useTeacherList() {
13045
13097
  };
13046
13098
  };
13047
13099
 
13048
- var _excluded$8 = ["getStudents"],
13100
+ var _excluded$9 = ["getStudents"],
13049
13101
  _excluded2 = ["getTeachers"],
13050
13102
  _excluded3 = ["getLessons"];
13051
13103
  var PAGE_TITLE$4 = "classes";
@@ -13096,7 +13148,7 @@ var useClassDetail = function useClassDetail(_ref) {
13096
13148
  };
13097
13149
  var _useStudentClassList = useStudentClassList(classId),
13098
13150
  getStudents = _useStudentClassList.getStudents,
13099
- studentListProps = _objectWithoutPropertiesLoose(_useStudentClassList, _excluded$8);
13151
+ studentListProps = _objectWithoutPropertiesLoose(_useStudentClassList, _excluded$9);
13100
13152
  var _useTeacherClassList = useTeacherClassList(classId),
13101
13153
  getTeachers = _useTeacherClassList.getTeachers,
13102
13154
  teacherListProps = _objectWithoutPropertiesLoose(_useTeacherClassList, _excluded2);
@@ -13846,12 +13898,12 @@ var LessonList = function LessonList(_ref) {
13846
13898
  }));
13847
13899
  };
13848
13900
 
13849
- var _excluded$9 = ["children", "value", "index"];
13901
+ var _excluded$a = ["children", "value", "index"];
13850
13902
  var CustomTabPanel = function CustomTabPanel(props) {
13851
13903
  var children = props.children,
13852
13904
  value = props.value,
13853
13905
  index = props.index,
13854
- other = _objectWithoutPropertiesLoose(props, _excluded$9);
13906
+ other = _objectWithoutPropertiesLoose(props, _excluded$a);
13855
13907
  return React__default.createElement("div", Object.assign({
13856
13908
  role: "tabpanel",
13857
13909
  hidden: value !== index,
@@ -15957,23 +16009,29 @@ var CompareGrass = function CompareGrass(_ref2) {
15957
16009
  textAlign: "center",
15958
16010
  color: "#202B37"
15959
16011
  }
15960
- }, t("number_question", {
16012
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
16013
+ content: item === null || item === void 0 ? void 0 : item.correctAnswers
16014
+ }) : t("number_question", {
15961
16015
  number: item.correctAnswers
15962
16016
  })), React__default.createElement("td", {
15963
16017
  className: styles$3["tdcolumn3"],
15964
16018
  style: {
15965
16019
  color: item.isCorrect ? styles$3.green_support_900 : styles$3.red_900
15966
16020
  }
15967
- }, item.selectedAnswers ? t("number_question", {
16021
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
16022
+ content: item === null || item === void 0 ? void 0 : item.selectedAnswers
16023
+ }) : t("number_question", {
15968
16024
  number: item.selectedAnswers
15969
- }) : ""), React__default.createElement("td", {
16025
+ })), React__default.createElement("td", {
15970
16026
  style: {
15971
16027
  textAlign: "center",
15972
16028
  color: "#414E62"
15973
16029
  }
15974
- }, item.mostSelectedAnswers ? t("number_question", {
16030
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
16031
+ content: item === null || item === void 0 ? void 0 : item.mostSelectedAnswers
16032
+ }) : t("number_question", {
15975
16033
  number: item.mostSelectedAnswers
15976
- }) : ""), React__default.createElement("td", {
16034
+ })), React__default.createElement("td", {
15977
16035
  className: "" + printStyles["avoid-break-inside"]
15978
16036
  }, React__default.createElement("div", {
15979
16037
  className: styles$3["classification"] + " " + printStyles["avoid-break-inside"]
@@ -16360,16 +16418,20 @@ var Vulnerable = function Vulnerable(_ref) {
16360
16418
  fontSize: "13px",
16361
16419
  fontWeight: 500
16362
16420
  }
16363
- }, item.selectedAnswers ? t("number_answer", {
16421
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
16422
+ content: item === null || item === void 0 ? void 0 : item.selectedAnswers
16423
+ }) : t("number_question", {
16364
16424
  number: item.selectedAnswers
16365
- }) : ""), React__default.createElement("td", {
16425
+ })), React__default.createElement("td", {
16366
16426
  style: {
16367
16427
  textAlign: "center",
16368
16428
  color: styles$3.gray_700
16369
16429
  }
16370
- }, item.correctAnswers ? t("number_answer", {
16430
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
16431
+ content: item === null || item === void 0 ? void 0 : item.correctAnswers
16432
+ }) : t("number_question", {
16371
16433
  number: item.correctAnswers
16372
- }) : ""), React__default.createElement("td", {
16434
+ })), React__default.createElement("td", {
16373
16435
  style: {
16374
16436
  textAlign: "center",
16375
16437
  color: styles$3.gray_700
@@ -18203,16 +18265,20 @@ var TextbookVulnerable = function TextbookVulnerable(_ref) {
18203
18265
  fontSize: "13px",
18204
18266
  fontWeight: 500
18205
18267
  }
18206
- }, item.selectedAnswers ? t("number_answer", {
18268
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
18269
+ content: item === null || item === void 0 ? void 0 : item.selectedAnswers
18270
+ }) : t("number_question", {
18207
18271
  number: item.selectedAnswers
18208
- }) : ""), React__default.createElement("td", {
18272
+ })), React__default.createElement("td", {
18209
18273
  style: {
18210
18274
  textAlign: "center",
18211
18275
  color: styles$3.gray_700
18212
18276
  }
18213
- }, item.correctAnswers ? t("number_answer", {
18277
+ }, (item === null || item === void 0 ? void 0 : item.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement(MathJaxContainer, {
18278
+ content: item === null || item === void 0 ? void 0 : item.correctAnswers
18279
+ }) : t("number_question", {
18214
18280
  number: item.correctAnswers
18215
- }) : ""), React__default.createElement("td", {
18281
+ })), React__default.createElement("td", {
18216
18282
  style: {
18217
18283
  textAlign: "center",
18218
18284
  color: styles$3.gray_700
@@ -18250,7 +18316,13 @@ var TextbookVulnerable = function TextbookVulnerable(_ref) {
18250
18316
  className: styles$3["span2"]
18251
18317
  }, t("my_wrong_answer"))), React__default.createElement("div", null, React__default.createElement("span", {
18252
18318
  className: styles$3["overallCorrectRate"]
18253
- }, question.overallCorrectRate.toFixed(2), "%"), React__default.createElement("span", {
18319
+ }, question.overallCorrectRate.toFixed(2), "%"), (question === null || question === void 0 ? void 0 : question.questionAnswerType) === exports.QuestionAnswerType.Textual ? React__default.createElement("span", {
18320
+ className: styles$3["answer"]
18321
+ }, React__default.createElement(MathJaxContainer, {
18322
+ content: question === null || question === void 0 ? void 0 : question.selectedAnswers
18323
+ }), " ", React__default.createElement(MathJaxContainer, {
18324
+ content: question === null || question === void 0 ? void 0 : question.correctAnswers
18325
+ })) : React__default.createElement("span", {
18254
18326
  className: styles$3["answer"]
18255
18327
  }, t("number_question", {
18256
18328
  number: question.selectedAnswers
@@ -20037,16 +20109,24 @@ var usePrintExamResult = function usePrintExamResult(isDataFetching, fileName, t
20037
20109
  setPrintState(PrintState$1.Printing);
20038
20110
  setTimeout(function () {
20039
20111
  try {
20040
- var _temp2 = function _temp2() {
20112
+ var _temp4 = function _temp4() {
20041
20113
  setPrintState(PrintState$1.Printed);
20042
20114
  };
20043
- var _temp = _catch(function () {
20115
+ var _temp3 = _catch(function () {
20116
+ function _temp2() {
20117
+ html2pdf().from(element).set(options).save();
20118
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
20119
+ }
20044
20120
  var element = contentRef.current;
20045
20121
  var options = {
20046
20122
  margin: 5,
20047
20123
  filename: name + ".pdf",
20124
+ image: {
20125
+ type: "jpeg",
20126
+ quality: 1
20127
+ },
20048
20128
  html2canvas: {
20049
- scale: 2
20129
+ scale: 4
20050
20130
  },
20051
20131
  jsPDF: {
20052
20132
  format: 'a4',
@@ -20056,14 +20136,18 @@ var usePrintExamResult = function usePrintExamResult(isDataFetching, fileName, t
20056
20136
  mode: ['css', 'legacy']
20057
20137
  }
20058
20138
  };
20059
- return Promise.resolve(html2pdf().from(element).set(options).save()).then(function () {
20060
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
20061
- });
20139
+ var _temp = function (_window) {
20140
+ if ((_window = window) !== null && _window !== void 0 && _window.MathJax) {
20141
+ var _window2, _window2$MathJax, _window2$MathJax$type;
20142
+ return Promise.resolve((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$MathJax = _window2.MathJax) === null || _window2$MathJax === void 0 ? void 0 : (_window2$MathJax$type = _window2$MathJax.typesetPromise) === null || _window2$MathJax$type === void 0 ? void 0 : _window2$MathJax$type.call(_window2$MathJax)).then(function () {});
20143
+ }
20144
+ }();
20145
+ return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
20062
20146
  }, function (error) {
20063
20147
  !window.opener && reactToastify.toast.error(getErrorMessage(t, error));
20064
20148
  onError === null || onError === void 0 ? void 0 : onError(error === null || error === void 0 ? void 0 : error.message);
20065
20149
  });
20066
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
20150
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
20067
20151
  } catch (e) {
20068
20152
  return Promise.reject(e);
20069
20153
  }
@@ -21081,14 +21165,14 @@ var CSV_PREFIX = "data:text/csv;charset=utf-8,";
21081
21165
 
21082
21166
  var styles$5 = {"action-btn":"_1jXbz","action-btn--pencil":"_at4xP","icon-rotate-180":"_12gv9","drop-area":"_R4bn5"};
21083
21167
 
21084
- var _excluded$a = ["text", "isRequired", "className"];
21168
+ var _excluded$b = ["text", "isRequired", "className"];
21085
21169
  var LabelRequired = function LabelRequired(_ref) {
21086
21170
  var text = _ref.text,
21087
21171
  _ref$isRequired = _ref.isRequired,
21088
21172
  isRequired = _ref$isRequired === void 0 ? true : _ref$isRequired,
21089
21173
  _ref$className = _ref.className,
21090
21174
  className = _ref$className === void 0 ? "" : _ref$className,
21091
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
21175
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
21092
21176
  return React__default.createElement(material.FormLabel, Object.assign({
21093
21177
  className: "fw-medium mb-1 " + className
21094
21178
  }, rest), text, isRequired && React__default.createElement("span", {
@@ -21142,7 +21226,7 @@ var deleteUserApi = function deleteUserApi(id) {
21142
21226
  return api["delete"](USER_URL + "/delete/" + id);
21143
21227
  };
21144
21228
 
21145
- var _excluded$b = ["ref"],
21229
+ var _excluded$c = ["ref"],
21146
21230
  _excluded2$1 = ["ref"],
21147
21231
  _excluded3$1 = ["ref"],
21148
21232
  _excluded4 = ["ref"],
@@ -21172,7 +21256,7 @@ var UserDialog = function UserDialog(_ref) {
21172
21256
  t = _useTranslation.t;
21173
21257
  var _register = register("fullName"),
21174
21258
  fullNameRef = _register.ref,
21175
- fullNameBio = _objectWithoutPropertiesLoose(_register, _excluded$b);
21259
+ fullNameBio = _objectWithoutPropertiesLoose(_register, _excluded$c);
21176
21260
  var _register2 = register("email"),
21177
21261
  emailRef = _register2.ref,
21178
21262
  emailBio = _objectWithoutPropertiesLoose(_register2, _excluded2$1);
@@ -24958,12 +25042,12 @@ var ArticleDialog = function ArticleDialog(_ref) {
24958
25042
 
24959
25043
  var styles$7 = {"drawer":"_11aYm","open":"_3Ydwm","drawer-overlay":"_3SQDf","drawer-header":"_2BwOx","drawer-form":"_2Zo7R","dropdown-content-academy":"_1lzjD","dropdown-change":"_1y7K9","dropdown-academy-item":"_1Y-55","dropdown-content-language":"_1fBXY","dropdown-item-language":"_3Szun","dropdown-item-language-active":"_2HhLb","item-address":"_3WYHC","item-logout":"_2-9ix","title-address":"_1r4pn","image-academy":"_2ZozT"};
24960
25044
 
24961
- var _excluded$c = ["isOpen", "onClose", "handleSaveExam"];
25045
+ var _excluded$d = ["isOpen", "onClose", "handleSaveExam"];
24962
25046
  var CreateExamDrawer = function CreateExamDrawer(props) {
24963
25047
  var isOpen = props.isOpen,
24964
25048
  onClose = props.onClose,
24965
25049
  handleSaveExam = props.handleSaveExam,
24966
- examDetailViewProps = _objectWithoutPropertiesLoose(props, _excluded$c);
25050
+ examDetailViewProps = _objectWithoutPropertiesLoose(props, _excluded$d);
24967
25051
  var _useTranslation = reactI18next.useTranslation(),
24968
25052
  t = _useTranslation.t;
24969
25053
  var theme = material.useTheme();
@@ -26031,12 +26115,12 @@ var useNotificationDetail = function useNotificationDetail(_ref) {
26031
26115
 
26032
26116
  var styles$8 = {"avatar":"_8niRT"};
26033
26117
 
26034
- var _excluded$d = ["value", "disabled", "optionTypeNotification"];
26118
+ var _excluded$e = ["value", "disabled", "optionTypeNotification"];
26035
26119
  var TypeSelector = function TypeSelector(_ref) {
26036
26120
  var value = _ref.value,
26037
26121
  disabled = _ref.disabled,
26038
26122
  optionTypeNotification = _ref.optionTypeNotification,
26039
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
26123
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
26040
26124
  return React__default.createElement(CustomAsyncSelect, Object.assign({
26041
26125
  options: optionTypeNotification,
26042
26126
  value: value
@@ -26428,11 +26512,11 @@ var useNotificationList = function useNotificationList(_ref) {
26428
26512
  };
26429
26513
  };
26430
26514
 
26431
- var _excluded$e = ["value", "optionTypeNotification"];
26515
+ var _excluded$f = ["value", "optionTypeNotification"];
26432
26516
  var SelectFilterType = function SelectFilterType(_ref) {
26433
26517
  var value = _ref.value,
26434
26518
  optionTypeNotification = _ref.optionTypeNotification,
26435
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
26519
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$f);
26436
26520
  return React__default.createElement(CustomAsyncSelect, Object.assign({
26437
26521
  options: optionTypeNotification,
26438
26522
  value: value
@@ -26654,7 +26738,9 @@ var DefaultQuestion = {
26654
26738
  title: "",
26655
26739
  author: "",
26656
26740
  subjectId: null,
26657
- preparedType: null
26741
+ preparedType: null,
26742
+ questionAnswerType: exports.QuestionAnswerType.ChoiceOption,
26743
+ textualAnswer: ""
26658
26744
  };
26659
26745
  var DefaultArticle = {
26660
26746
  answerCount: 5,
@@ -28007,7 +28093,7 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
28007
28093
  };
28008
28094
  };
28009
28095
 
28010
- var _excluded$f = ["value"],
28096
+ var _excluded$g = ["value"],
28011
28097
  _excluded2$2 = ["onChange"],
28012
28098
  _excluded3$2 = ["onChange"];
28013
28099
  var VisuallyHiddenInput = material.styled("input")({
@@ -28272,7 +28358,7 @@ var PreparedTextbook = function PreparedTextbook(_ref) {
28272
28358
  render: function render(_ref4) {
28273
28359
  var _ref4$field = _ref4.field,
28274
28360
  value = _ref4$field.value,
28275
- action = _objectWithoutPropertiesLoose(_ref4$field, _excluded$f);
28361
+ action = _objectWithoutPropertiesLoose(_ref4$field, _excluded$g);
28276
28362
  return React__default.createElement(xDatePickers.LocalizationProvider, {
28277
28363
  dateAdapter: AdapterMoment.AdapterMoment
28278
28364
  }, React__default.createElement(xDatePickers.DatePicker, Object.assign({}, action, {
@@ -28483,10 +28569,22 @@ var PreparedTextbook = function PreparedTextbook(_ref) {
28483
28569
  fontSize: "16px"
28484
28570
  }, t("chapter_number", {
28485
28571
  number: chapterIndex + 1
28486
- })), React__default.createElement(material.Typography, {
28572
+ })), React__default.createElement(material.Stack, {
28573
+ flexDirection: "row",
28574
+ gap: "8px"
28575
+ }, React__default.createElement(material.Typography, {
28487
28576
  fontWeight: 700,
28488
28577
  fontSize: "16px"
28489
- }, chapter.pageFrom + " - " + chapter.pageTo)));
28578
+ }, chapter.pageFrom + " - " + chapter.pageTo), React__default.createElement(material.IconButton, {
28579
+ onClick: function onClick(e) {
28580
+ e.stopPropagation();
28581
+ arrayHelpers.remove(chapterIndex);
28582
+ },
28583
+ color: "default",
28584
+ className: " bg-danger text-white"
28585
+ }, React__default.createElement(fa6.FaTrashCan, {
28586
+ size: 12
28587
+ })))));
28490
28588
  }));
28491
28589
  }
28492
28590
  }), textbookState.position === TextbookState.Chapter && React__default.createElement(Chapter, {
@@ -29757,7 +29855,7 @@ var ChapterProblemSolvingResultsDialog = function ChapterProblemSolvingResultsDi
29757
29855
  }, t("cancel"))))));
29758
29856
  };
29759
29857
 
29760
- var _excluded$g = ["onChange"];
29858
+ var _excluded$h = ["onChange"];
29761
29859
  var StartPageDialog = function StartPageDialog(_ref) {
29762
29860
  var t = _ref.t,
29763
29861
  onClose = _ref.onClose,
@@ -29818,7 +29916,7 @@ var StartPageDialog = function StartPageDialog(_ref) {
29818
29916
  }, t("page_to_start_with")), React__default.createElement(formik.Field, {
29819
29917
  name: "startPage",
29820
29918
  render: function render(_ref3) {
29821
- var field = _objectWithoutPropertiesLoose(_ref3, _excluded$g);
29919
+ var field = _objectWithoutPropertiesLoose(_ref3, _excluded$h);
29822
29920
  return React__default.createElement(CustomSelectOption, Object.assign({
29823
29921
  menuPosition: "fixed",
29824
29922
  onChange: function onChange(option) {
@@ -32367,7 +32465,18 @@ Object.defineProperty(exports, 'useTranslation', {
32367
32465
  return reactI18next.useTranslation;
32368
32466
  }
32369
32467
  });
32370
- exports.moment = moment;
32468
+ Object.defineProperty(exports, 'MathJax', {
32469
+ enumerable: true,
32470
+ get: function () {
32471
+ return betterReactMathjax.MathJax;
32472
+ }
32473
+ });
32474
+ Object.defineProperty(exports, 'MathJaxContext', {
32475
+ enumerable: true,
32476
+ get: function () {
32477
+ return betterReactMathjax.MathJaxContext;
32478
+ }
32479
+ });
32371
32480
  Object.defineProperty(exports, 'DateCalendar', {
32372
32481
  enumerable: true,
32373
32482
  get: function () {
@@ -32416,6 +32525,7 @@ Object.defineProperty(exports, 'DemoContainer', {
32416
32525
  return demo.DemoContainer;
32417
32526
  }
32418
32527
  });
32528
+ exports.moment = moment;
32419
32529
  exports.ACADEMY_DOMAIN = ACADEMY_DOMAIN;
32420
32530
  exports.ACCESS_TOKEN = ACCESS_TOKEN;
32421
32531
  exports.AcademyHeaders = AcademyHeaders;
@@ -32470,6 +32580,7 @@ exports.Login = Login;
32470
32580
  exports.LoginQRCode = LoginQRCode;
32471
32581
  exports.LoginWithEmail = LoginWithEmail;
32472
32582
  exports.LoginWithPassword = SignIn;
32583
+ exports.MathJaxContainer = MathJaxContainer;
32473
32584
  exports.NewNoteButton = NewNoteButton;
32474
32585
  exports.NoAcademyHeaders = NoAcademyHeaders;
32475
32586
  exports.NotFound = NotFound;