touchstudy-core 0.1.137 → 0.1.139

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.
@@ -3599,7 +3599,7 @@ var elementary_school_2nd_grade$1 = "Elementary school 2nd grade";
3599
3599
  var elementary_school_3rd_grade$1 = "Elementary school 3rd grade";
3600
3600
  var elementary_school_4th_grade$1 = "Elementary school 4th grade";
3601
3601
  var elementary_school_5th_grade$1 = "Elementary school 5th grade";
3602
- var elementary_school_6th_grade$1 = "Elementary school th grade";
3602
+ var elementary_school_6th_grade$1 = "Elementary school 6th grade";
3603
3603
  var middle_school_1st_grade$1 = "Middle school 1st grade";
3604
3604
  var middle_school_2nd_grade$1 = "Middle school 2nd grade";
3605
3605
  var middle_school_3rd_grade$1 = "Middle school 3rd grade";
@@ -6562,7 +6562,10 @@ var useGoogleSignOut = function useGoogleSignOut(props) {
6562
6562
  };
6563
6563
  };
6564
6564
 
6565
- var useLanguage = function useLanguage(history) {
6565
+ var useLanguage = function useLanguage(history, init) {
6566
+ if (init === void 0) {
6567
+ init = true;
6568
+ }
6566
6569
  var language = useSelector(function (state) {
6567
6570
  var _state$common;
6568
6571
  return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.language;
@@ -6570,17 +6573,6 @@ var useLanguage = function useLanguage(history) {
6570
6573
  var dispatch = useDispatch();
6571
6574
  var _useTranslation = useTranslation(),
6572
6575
  i18n = _useTranslation.i18n;
6573
- var _useState = useState(false),
6574
- dropdownOpen = _useState[0],
6575
- setDropdownOpen = _useState[1];
6576
- var _useState2 = useState(),
6577
- currentLanguage = _useState2[0],
6578
- setCurrentLanguage = _useState2[1];
6579
- var toggle = function toggle() {
6580
- return setDropdownOpen(function (prevState) {
6581
- return !prevState;
6582
- });
6583
- };
6584
6576
  var changeLanguageApp = function changeLanguageApp(languageItem) {
6585
6577
  var search = window.location.search;
6586
6578
  var searchParams = new URLSearchParams(search);
@@ -6591,13 +6583,13 @@ var useLanguage = function useLanguage(history) {
6591
6583
  var defaultLanguageCode = storedLanguage || browserLanguage;
6592
6584
  languageItem = LANGUAGES.find(function (i) {
6593
6585
  return i.code === defaultLanguageCode;
6594
- }) || currentLanguage || DEFAULT_LANGUAGE;
6586
+ }) || DEFAULT_LANGUAGE;
6595
6587
  }
6596
- setCurrentLanguage(languageItem);
6597
6588
  i18n.changeLanguage(languageItem.code);
6598
6589
  moment.locale(languageItem.momentLangCode);
6599
6590
  localStorage.setItem(LANGUAGE, languageItem.code);
6600
6591
  dispatch(setLanguage(languageItem.code));
6592
+ if (!history) return;
6601
6593
  if (window.location.pathname === LOGIN_URL) searchParams["delete"]("lang");else searchParams.set("lang", languageItem.code);
6602
6594
  pushTo(history, _extends({}, window.location, {
6603
6595
  search: searchParams.toString()
@@ -6623,13 +6615,10 @@ var useLanguage = function useLanguage(history) {
6623
6615
  changeLanguageApp(languageItem);
6624
6616
  };
6625
6617
  useEffect(function () {
6626
- handleChangeLanguageParam();
6627
- }, [window.location.pathname, window.location.search]);
6618
+ init && handleChangeLanguageParam();
6619
+ }, [window.location.pathname, window.location.search, init]);
6628
6620
  return {
6629
6621
  language: language,
6630
- dropdownOpen: dropdownOpen,
6631
- currentLanguage: currentLanguage,
6632
- toggle: toggle,
6633
6622
  handleChangeItemLanguage: handleChangeItemLanguage
6634
6623
  };
6635
6624
  };
@@ -23818,9 +23807,6 @@ var useExamDetailView = function useExamDetailView(props) {
23818
23807
  useEffect(function () {
23819
23808
  getCategoryList();
23820
23809
  }, [exam.subjectId]);
23821
- console.log({
23822
- exam: exam
23823
- });
23824
23810
  var examGroupByArticle = useMemo(function () {
23825
23811
  if (!exam) return [];
23826
23812
  var articles = [];
@@ -28857,17 +28843,22 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
28857
28843
  setOpen(groupIndex === open ? undefined : groupIndex);
28858
28844
  };
28859
28845
  var handleGetNewQuestionGroup = function handleGetNewQuestionGroup() {
28860
- var questionGroup = isMath ? DEFAULT_MATH_QUESTION_GROUP : DEFAULT_QUESTION_GROUP;
28846
+ var newQuestionGroup = isMath ? DEFAULT_MATH_QUESTION_GROUP : DEFAULT_QUESTION_GROUP;
28861
28847
  var lastQuestionGroups = questionGroups.length ? questionGroups[questionGroups.length - 1] : undefined;
28862
- if (!lastQuestionGroups) return questionGroup;else {
28848
+ newQuestionGroup.questions = newQuestionGroup.questions.map(function (i, index) {
28849
+ return _extends({}, i, {
28850
+ questionOrder: index
28851
+ });
28852
+ });
28853
+ if (!lastQuestionGroups) return newQuestionGroup;else {
28863
28854
  var _lastQuestionGroups$q, _lastQuestionGroups$q2, _lastQuestionGroups$q3;
28864
28855
  var lastOrder = (_lastQuestionGroups$q = (_lastQuestionGroups$q2 = lastQuestionGroups.questions) === null || _lastQuestionGroups$q2 === void 0 ? void 0 : (_lastQuestionGroups$q3 = _lastQuestionGroups$q2[lastQuestionGroups.questions.length - 1]) === null || _lastQuestionGroups$q3 === void 0 ? void 0 : _lastQuestionGroups$q3.questionOrder) != null ? _lastQuestionGroups$q : 0;
28865
- questionGroup.questions = questionGroup.questions.map(function (q, index) {
28856
+ newQuestionGroup.questions = newQuestionGroup.questions.map(function (q, index) {
28866
28857
  return _extends({}, q, {
28867
28858
  questionOrder: lastOrder + index + 1
28868
28859
  });
28869
28860
  });
28870
- return questionGroup;
28861
+ return newQuestionGroup;
28871
28862
  }
28872
28863
  };
28873
28864
  var handelChanngeQuestionCount = function handelChanngeQuestionCount(questionCount, index) {
@@ -29006,7 +28997,8 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29006
28997
  startIcon: React__default.createElement(IoIosAdd, null),
29007
28998
  onClick: function onClick() {
29008
28999
  var length = questionGroups.length;
29009
- arrayHelpers.push(handleGetNewQuestionGroup());
29000
+ var addedGroup = handleGetNewQuestionGroup();
29001
+ arrayHelpers.push(addedGroup);
29010
29002
  handleToggle(length);
29011
29003
  }
29012
29004
  }, t("question_group"))));
@@ -30435,10 +30427,6 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30435
30427
  dirty = formikProps.dirty,
30436
30428
  submitCount = formikProps.submitCount,
30437
30429
  setValues = formikProps.setValues;
30438
- console.log({
30439
- values: values,
30440
- errors: errors
30441
- });
30442
30430
  useEffect(function () {
30443
30431
  var handleBeforeUnload = function handleBeforeUnload(event) {
30444
30432
  var message = t$1("are_you_sure_you_want_to_quit_yours_changes_may_not_be_saved");
@@ -31698,6 +31686,7 @@ var ChapterDetail = function ChapterDetail(_ref) {
31698
31686
  theme = _ref.theme,
31699
31687
  isEnglish = _ref.isEnglish,
31700
31688
  chapter = _ref.chapter,
31689
+ isStudying = _ref.isStudying,
31701
31690
  handleOpenChapterDialog = _ref.handleOpenChapterDialog;
31702
31691
  var _useExpand = useExpand(),
31703
31692
  expanded = _useExpand.expanded,
@@ -31812,6 +31801,7 @@ var ChapterDetail = function ChapterDetail(_ref) {
31812
31801
  },
31813
31802
  variant: "contained",
31814
31803
  startIcon: React__default.createElement(IoReceiptSharp, null),
31804
+ disabled: !isStudying,
31815
31805
  onClick: function onClick() {
31816
31806
  return handleOpenChapterDialog(chapter);
31817
31807
  }
@@ -32126,6 +32116,7 @@ var Statistic = function Statistic(_ref) {
32126
32116
  };
32127
32117
 
32128
32118
  var TextbookDrawer = function TextbookDrawer(_ref) {
32119
+ var _textbook$chapters, _textbook$chapters2;
32129
32120
  var isOpen = _ref.isOpen,
32130
32121
  onClose = _ref.onClose,
32131
32122
  textbookId = _ref.textbookId,
@@ -32364,12 +32355,13 @@ var TextbookDrawer = function TextbookDrawer(_ref) {
32364
32355
  sx: {
32365
32356
  gap: "16px"
32366
32357
  }
32367
- }, textbook === null || textbook === void 0 ? void 0 : textbook.chapters.map(function (chapter) {
32358
+ }, textbook === null || textbook === void 0 ? void 0 : (_textbook$chapters = textbook.chapters) === null || _textbook$chapters === void 0 ? void 0 : _textbook$chapters.map(function (chapter) {
32368
32359
  return React__default.createElement(ChapterDetail, {
32369
32360
  t: t,
32370
32361
  isEnglish: isEnglish,
32371
32362
  theme: theme,
32372
32363
  chapter: chapter,
32364
+ isStudying: !!(textbook !== null && textbook !== void 0 && textbook.isStudying),
32373
32365
  handleOpenChapterDialog: handleOpenChapterDialog
32374
32366
  });
32375
32367
  })))), React__default.createElement(CustomTabPanel, {
@@ -32385,7 +32377,7 @@ var TextbookDrawer = function TextbookDrawer(_ref) {
32385
32377
  m: "24px",
32386
32378
  gap: "8px"
32387
32379
  }
32388
- }, textbook === null || textbook === void 0 ? void 0 : textbook.chapters.map(function (chapter) {
32380
+ }, textbook === null || textbook === void 0 ? void 0 : (_textbook$chapters2 = textbook.chapters) === null || _textbook$chapters2 === void 0 ? void 0 : _textbook$chapters2.map(function (chapter) {
32389
32381
  return React__default.createElement(Statistic, {
32390
32382
  t: t,
32391
32383
  isEnglish: isEnglish,
@@ -33794,10 +33786,9 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
33794
33786
  }, t("logout"))))));
33795
33787
  };
33796
33788
 
33797
- var TheLanguageDropdown = function TheLanguageDropdown(_ref) {
33798
- var history = _ref.history;
33799
- var _useLanguage = useLanguage(history),
33800
- currentLanguage = _useLanguage.currentLanguage,
33789
+ var TheLanguageDropdown = function TheLanguageDropdown() {
33790
+ var _useLanguage = useLanguage(null, false),
33791
+ language = _useLanguage.language,
33801
33792
  handleChangeItemLanguage = _useLanguage.handleChangeItemLanguage;
33802
33793
  var _useState = useState(null),
33803
33794
  open = _useState[0],
@@ -33818,6 +33809,11 @@ var TheLanguageDropdown = function TheLanguageDropdown(_ref) {
33818
33809
  mx: 1,
33819
33810
  bgcolor: open ? "action.selected" : undefined
33820
33811
  };
33812
+ var currentLanguage = useMemo(function () {
33813
+ return LANGUAGES.find(function (i) {
33814
+ return i.code === language;
33815
+ });
33816
+ }, [language]);
33821
33817
  return React__default.createElement(Fragment$1, null, React__default.createElement(IconButton$1, {
33822
33818
  onClick: handleOpen,
33823
33819
  sx: _extends({}, popoverStyle)
@@ -34312,9 +34308,7 @@ var Header = function Header(_ref) {
34312
34308
  }, React__default.createElement(singleLogo, null))), React__default.createElement(Stack, {
34313
34309
  className: "me-2",
34314
34310
  display: "none"
34315
- }, React__default.createElement(TheLanguageDropdown, {
34316
- history: history
34317
- }))));
34311
+ }, React__default.createElement(TheLanguageDropdown, null))));
34318
34312
  };
34319
34313
  var HeaderLink = function HeaderLink(_ref3) {
34320
34314
  var data = _ref3.data,