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.
@@ -6,7 +6,8 @@ declare type Props = {
6
6
  theme: Theme;
7
7
  isEnglish: boolean;
8
8
  chapter: ChapterResponse;
9
+ isStudying: boolean;
9
10
  handleOpenChapterDialog: (chapter: ChapterResponse) => void;
10
11
  };
11
- declare const ChapterDetail: ({ t, theme, isEnglish, chapter, handleOpenChapterDialog }: Props) => React.JSX.Element;
12
+ declare const ChapterDetail: ({ t, theme, isEnglish, chapter, isStudying, handleOpenChapterDialog }: Props) => React.JSX.Element;
12
13
  export default ChapterDetail;
package/dist/index.js CHANGED
@@ -3596,7 +3596,7 @@ var elementary_school_2nd_grade$1 = "Elementary school 2nd grade";
3596
3596
  var elementary_school_3rd_grade$1 = "Elementary school 3rd grade";
3597
3597
  var elementary_school_4th_grade$1 = "Elementary school 4th grade";
3598
3598
  var elementary_school_5th_grade$1 = "Elementary school 5th grade";
3599
- var elementary_school_6th_grade$1 = "Elementary school th grade";
3599
+ var elementary_school_6th_grade$1 = "Elementary school 6th grade";
3600
3600
  var middle_school_1st_grade$1 = "Middle school 1st grade";
3601
3601
  var middle_school_2nd_grade$1 = "Middle school 2nd grade";
3602
3602
  var middle_school_3rd_grade$1 = "Middle school 3rd grade";
@@ -6549,7 +6549,10 @@ var useGoogleSignOut = function useGoogleSignOut(props) {
6549
6549
  };
6550
6550
  };
6551
6551
 
6552
- var useLanguage = function useLanguage(history) {
6552
+ var useLanguage = function useLanguage(history, init) {
6553
+ if (init === void 0) {
6554
+ init = true;
6555
+ }
6553
6556
  var language = reactRedux.useSelector(function (state) {
6554
6557
  var _state$common;
6555
6558
  return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.language;
@@ -6557,17 +6560,6 @@ var useLanguage = function useLanguage(history) {
6557
6560
  var dispatch = reactRedux.useDispatch();
6558
6561
  var _useTranslation = reactI18next.useTranslation(),
6559
6562
  i18n = _useTranslation.i18n;
6560
- var _useState = React.useState(false),
6561
- dropdownOpen = _useState[0],
6562
- setDropdownOpen = _useState[1];
6563
- var _useState2 = React.useState(),
6564
- currentLanguage = _useState2[0],
6565
- setCurrentLanguage = _useState2[1];
6566
- var toggle = function toggle() {
6567
- return setDropdownOpen(function (prevState) {
6568
- return !prevState;
6569
- });
6570
- };
6571
6563
  var changeLanguageApp = function changeLanguageApp(languageItem) {
6572
6564
  var search = window.location.search;
6573
6565
  var searchParams = new URLSearchParams(search);
@@ -6578,13 +6570,13 @@ var useLanguage = function useLanguage(history) {
6578
6570
  var defaultLanguageCode = storedLanguage || browserLanguage;
6579
6571
  languageItem = LANGUAGES.find(function (i) {
6580
6572
  return i.code === defaultLanguageCode;
6581
- }) || currentLanguage || DEFAULT_LANGUAGE;
6573
+ }) || DEFAULT_LANGUAGE;
6582
6574
  }
6583
- setCurrentLanguage(languageItem);
6584
6575
  i18n.changeLanguage(languageItem.code);
6585
6576
  moment.locale(languageItem.momentLangCode);
6586
6577
  localStorage.setItem(LANGUAGE, languageItem.code);
6587
6578
  dispatch(setLanguage(languageItem.code));
6579
+ if (!history) return;
6588
6580
  if (window.location.pathname === LOGIN_URL) searchParams["delete"]("lang");else searchParams.set("lang", languageItem.code);
6589
6581
  pushTo(history, _extends({}, window.location, {
6590
6582
  search: searchParams.toString()
@@ -6610,13 +6602,10 @@ var useLanguage = function useLanguage(history) {
6610
6602
  changeLanguageApp(languageItem);
6611
6603
  };
6612
6604
  React.useEffect(function () {
6613
- handleChangeLanguageParam();
6614
- }, [window.location.pathname, window.location.search]);
6605
+ init && handleChangeLanguageParam();
6606
+ }, [window.location.pathname, window.location.search, init]);
6615
6607
  return {
6616
6608
  language: language,
6617
- dropdownOpen: dropdownOpen,
6618
- currentLanguage: currentLanguage,
6619
- toggle: toggle,
6620
6609
  handleChangeItemLanguage: handleChangeItemLanguage
6621
6610
  };
6622
6611
  };
@@ -23803,9 +23792,6 @@ var useExamDetailView = function useExamDetailView(props) {
23803
23792
  React.useEffect(function () {
23804
23793
  getCategoryList();
23805
23794
  }, [exam.subjectId]);
23806
- console.log({
23807
- exam: exam
23808
- });
23809
23795
  var examGroupByArticle = React.useMemo(function () {
23810
23796
  if (!exam) return [];
23811
23797
  var articles = [];
@@ -28842,17 +28828,22 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
28842
28828
  setOpen(groupIndex === open ? undefined : groupIndex);
28843
28829
  };
28844
28830
  var handleGetNewQuestionGroup = function handleGetNewQuestionGroup() {
28845
- var questionGroup = isMath ? DEFAULT_MATH_QUESTION_GROUP : DEFAULT_QUESTION_GROUP;
28831
+ var newQuestionGroup = isMath ? DEFAULT_MATH_QUESTION_GROUP : DEFAULT_QUESTION_GROUP;
28846
28832
  var lastQuestionGroups = questionGroups.length ? questionGroups[questionGroups.length - 1] : undefined;
28847
- if (!lastQuestionGroups) return questionGroup;else {
28833
+ newQuestionGroup.questions = newQuestionGroup.questions.map(function (i, index) {
28834
+ return _extends({}, i, {
28835
+ questionOrder: index
28836
+ });
28837
+ });
28838
+ if (!lastQuestionGroups) return newQuestionGroup;else {
28848
28839
  var _lastQuestionGroups$q, _lastQuestionGroups$q2, _lastQuestionGroups$q3;
28849
28840
  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;
28850
- questionGroup.questions = questionGroup.questions.map(function (q, index) {
28841
+ newQuestionGroup.questions = newQuestionGroup.questions.map(function (q, index) {
28851
28842
  return _extends({}, q, {
28852
28843
  questionOrder: lastOrder + index + 1
28853
28844
  });
28854
28845
  });
28855
- return questionGroup;
28846
+ return newQuestionGroup;
28856
28847
  }
28857
28848
  };
28858
28849
  var handelChanngeQuestionCount = function handelChanngeQuestionCount(questionCount, index) {
@@ -28991,7 +28982,8 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
28991
28982
  startIcon: React__default.createElement(io.IoIosAdd, null),
28992
28983
  onClick: function onClick() {
28993
28984
  var length = questionGroups.length;
28994
- arrayHelpers.push(handleGetNewQuestionGroup());
28985
+ var addedGroup = handleGetNewQuestionGroup();
28986
+ arrayHelpers.push(addedGroup);
28995
28987
  handleToggle(length);
28996
28988
  }
28997
28989
  }, t("question_group"))));
@@ -30420,10 +30412,6 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30420
30412
  dirty = formikProps.dirty,
30421
30413
  submitCount = formikProps.submitCount,
30422
30414
  setValues = formikProps.setValues;
30423
- console.log({
30424
- values: values,
30425
- errors: errors
30426
- });
30427
30415
  React.useEffect(function () {
30428
30416
  var handleBeforeUnload = function handleBeforeUnload(event) {
30429
30417
  var message = i18n.t("are_you_sure_you_want_to_quit_yours_changes_may_not_be_saved");
@@ -31683,6 +31671,7 @@ var ChapterDetail = function ChapterDetail(_ref) {
31683
31671
  theme = _ref.theme,
31684
31672
  isEnglish = _ref.isEnglish,
31685
31673
  chapter = _ref.chapter,
31674
+ isStudying = _ref.isStudying,
31686
31675
  handleOpenChapterDialog = _ref.handleOpenChapterDialog;
31687
31676
  var _useExpand = useExpand(),
31688
31677
  expanded = _useExpand.expanded,
@@ -31797,6 +31786,7 @@ var ChapterDetail = function ChapterDetail(_ref) {
31797
31786
  },
31798
31787
  variant: "contained",
31799
31788
  startIcon: React__default.createElement(io5.IoReceiptSharp, null),
31789
+ disabled: !isStudying,
31800
31790
  onClick: function onClick() {
31801
31791
  return handleOpenChapterDialog(chapter);
31802
31792
  }
@@ -32111,6 +32101,7 @@ var Statistic = function Statistic(_ref) {
32111
32101
  };
32112
32102
 
32113
32103
  var TextbookDrawer = function TextbookDrawer(_ref) {
32104
+ var _textbook$chapters, _textbook$chapters2;
32114
32105
  var isOpen = _ref.isOpen,
32115
32106
  onClose = _ref.onClose,
32116
32107
  textbookId = _ref.textbookId,
@@ -32349,12 +32340,13 @@ var TextbookDrawer = function TextbookDrawer(_ref) {
32349
32340
  sx: {
32350
32341
  gap: "16px"
32351
32342
  }
32352
- }, textbook === null || textbook === void 0 ? void 0 : textbook.chapters.map(function (chapter) {
32343
+ }, textbook === null || textbook === void 0 ? void 0 : (_textbook$chapters = textbook.chapters) === null || _textbook$chapters === void 0 ? void 0 : _textbook$chapters.map(function (chapter) {
32353
32344
  return React__default.createElement(ChapterDetail, {
32354
32345
  t: t,
32355
32346
  isEnglish: isEnglish,
32356
32347
  theme: theme,
32357
32348
  chapter: chapter,
32349
+ isStudying: !!(textbook !== null && textbook !== void 0 && textbook.isStudying),
32358
32350
  handleOpenChapterDialog: handleOpenChapterDialog
32359
32351
  });
32360
32352
  })))), React__default.createElement(CustomTabPanel, {
@@ -32370,7 +32362,7 @@ var TextbookDrawer = function TextbookDrawer(_ref) {
32370
32362
  m: "24px",
32371
32363
  gap: "8px"
32372
32364
  }
32373
- }, textbook === null || textbook === void 0 ? void 0 : textbook.chapters.map(function (chapter) {
32365
+ }, textbook === null || textbook === void 0 ? void 0 : (_textbook$chapters2 = textbook.chapters) === null || _textbook$chapters2 === void 0 ? void 0 : _textbook$chapters2.map(function (chapter) {
32374
32366
  return React__default.createElement(Statistic, {
32375
32367
  t: t,
32376
32368
  isEnglish: isEnglish,
@@ -33779,10 +33771,9 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
33779
33771
  }, t("logout"))))));
33780
33772
  };
33781
33773
 
33782
- var TheLanguageDropdown = function TheLanguageDropdown(_ref) {
33783
- var history = _ref.history;
33784
- var _useLanguage = useLanguage(history),
33785
- currentLanguage = _useLanguage.currentLanguage,
33774
+ var TheLanguageDropdown = function TheLanguageDropdown() {
33775
+ var _useLanguage = useLanguage(null, false),
33776
+ language = _useLanguage.language,
33786
33777
  handleChangeItemLanguage = _useLanguage.handleChangeItemLanguage;
33787
33778
  var _useState = React.useState(null),
33788
33779
  open = _useState[0],
@@ -33803,6 +33794,11 @@ var TheLanguageDropdown = function TheLanguageDropdown(_ref) {
33803
33794
  mx: 1,
33804
33795
  bgcolor: open ? "action.selected" : undefined
33805
33796
  };
33797
+ var currentLanguage = React.useMemo(function () {
33798
+ return LANGUAGES.find(function (i) {
33799
+ return i.code === language;
33800
+ });
33801
+ }, [language]);
33806
33802
  return React__default.createElement(React.Fragment, null, React__default.createElement(IconButton, {
33807
33803
  onClick: handleOpen,
33808
33804
  sx: _extends({}, popoverStyle)
@@ -34297,9 +34293,7 @@ var Header = function Header(_ref) {
34297
34293
  }, React__default.createElement(singleLogo, null))), React__default.createElement(material.Stack, {
34298
34294
  className: "me-2",
34299
34295
  display: "none"
34300
- }, React__default.createElement(TheLanguageDropdown, {
34301
- history: history
34302
- }))));
34296
+ }, React__default.createElement(TheLanguageDropdown, null))));
34303
34297
  };
34304
34298
  var HeaderLink = function HeaderLink(_ref3) {
34305
34299
  var data = _ref3.data,