touchstudy-core 0.1.141 → 0.1.142

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 (30) hide show
  1. package/dist/components/Selects/CustomSelect.d.ts +1 -1
  2. package/dist/containers/PreparedTextbook/components/AcademySelector.d.ts +0 -1
  3. package/dist/containers/PreparedTextbook/components/ArticleBlock.d.ts +1 -0
  4. package/dist/containers/PreparedTextbook/components/ChapterBlock.d.ts +1 -0
  5. package/dist/containers/PreparedTextbook/components/ChapterBlockBody.d.ts +1 -0
  6. package/dist/containers/PreparedTextbook/components/CourseSelector.d.ts +1 -1
  7. package/dist/containers/PreparedTextbook/components/OwnerSelector.d.ts +2 -1
  8. package/dist/containers/PreparedTextbook/components/PreparedTextbookForm.d.ts +4 -0
  9. package/dist/containers/PreparedTextbook/components/QuestionBlock.d.ts +1 -1
  10. package/dist/containers/PreparedTextbook/components/QuestionGroupBlock.d.ts +1 -1
  11. package/dist/containers/PreparedTextbook/components/QuestionGroupBlockBody.d.ts +1 -0
  12. package/dist/containers/PreparedTextbook/components/TextbookContentsTab.d.ts +1 -0
  13. package/dist/containers/PreparedTextbook/components/TextbookInfoTab.d.ts +3 -1
  14. package/dist/containers/PreparedTextbook/components/TextbookOwnersTab.d.ts +2 -1
  15. package/dist/containers/PreparedTextbook/configs/constants.d.ts +2 -0
  16. package/dist/containers/PreparedTextbook/configs/enums.d.ts +5 -0
  17. package/dist/containers/PreparedTextbook/configs/functions.d.ts +17 -3
  18. package/dist/containers/PreparedTextbook/configs/interfaces.d.ts +2 -0
  19. package/dist/containers/PreparedTextbook/configs/types.d.ts +4 -0
  20. package/dist/containers/PreparedTextbook/hooks/useTextbookManagement.d.ts +8 -1
  21. package/dist/containers/Textbooks/components/TextbookRow.d.ts +17 -0
  22. package/dist/containers/Textbooks/configs/types.d.ts +2 -0
  23. package/dist/containers/Textbooks/hooks/useTextbookList.d.ts +5 -2
  24. package/dist/containers/Textbooks/hooks/useTextbookShare.d.ts +0 -2
  25. package/dist/index.css +3 -3
  26. package/dist/index.js +599 -317
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.modern.js +600 -318
  29. package/dist/index.modern.js.map +1 -1
  30. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1243,7 +1243,7 @@ var number_of_participants = "참가자 수";
1243
1243
  var chapter = "챕터";
1244
1244
  var published = "Published";
1245
1245
  var privated = "Privated";
1246
- var solution_results = "버튼 텍스트";
1246
+ var solution_results = "풀이 결과";
1247
1247
  var do_you_want_to_reset_your_search_criteria = "검색 조건을 초기화 하시겠습니까?";
1248
1248
  var the_search_keywords_you_enter_will_be_saved = "입력한 검색 키워드는 저장됩니다.";
1249
1249
  var no_search_results = "검색 결과가 없어요.";
@@ -1456,6 +1456,11 @@ var text_group_n = "지문 그룹 {{n}}";
1456
1456
  var text_detail_n = "지문 상세 {{n}}";
1457
1457
  var question_group_n = "문제 그룹 {{n}}";
1458
1458
  var placeholder_teacher_selector = "선생님을 검색하려면 최소 2글자를 입력하세요.";
1459
+ var teacher_personal_textbook = "교사의 개인 교과서";
1460
+ var textbook_owner_email_is_required = "교재 소유자의 이메일은 필수입니다";
1461
+ var invalid_textbook_owner_email_address = "유효하지 않은 교재 소유자 이메일 주소입니다";
1462
+ var textbook_owner_academy_is_required = "교재 소유자의 학원은 필수입니다";
1463
+ var textbook_owner_course_is_required = "교재 소유자의 수업은 필수입니다";
1459
1464
  var lang_ko = {
1460
1465
  problem_solving: problem_solving,
1461
1466
  my_story: my_story,
@@ -2549,7 +2554,12 @@ var lang_ko = {
2549
2554
  text_group_n: text_group_n,
2550
2555
  text_detail_n: text_detail_n,
2551
2556
  question_group_n: question_group_n,
2552
- placeholder_teacher_selector: placeholder_teacher_selector
2557
+ placeholder_teacher_selector: placeholder_teacher_selector,
2558
+ teacher_personal_textbook: teacher_personal_textbook,
2559
+ textbook_owner_email_is_required: textbook_owner_email_is_required,
2560
+ invalid_textbook_owner_email_address: invalid_textbook_owner_email_address,
2561
+ textbook_owner_academy_is_required: textbook_owner_academy_is_required,
2562
+ textbook_owner_course_is_required: textbook_owner_course_is_required
2553
2563
  };
2554
2564
 
2555
2565
  var problem_solving$1 = "Problem Solving";
@@ -3666,6 +3676,11 @@ var text_group_n$1 = "Text group {{n}}";
3666
3676
  var text_detail_n$1 = "Text details {{n}}";
3667
3677
  var question_group_n$1 = "Question group {{n}}";
3668
3678
  var placeholder_teacher_selector$1 = "Type at least 2 characters to search teacher";
3679
+ var teacher_personal_textbook$1 = "Teacher personal textbook";
3680
+ var textbook_owner_email_is_required$1 = "Textbook owner email is required";
3681
+ var invalid_textbook_owner_email_address$1 = "Invalid textbook owner email address";
3682
+ var textbook_owner_academy_is_required$1 = "Textbook owner academy is required";
3683
+ var textbook_owner_course_is_required$1 = "Textbook owner class is required";
3669
3684
  var lang_en = {
3670
3685
  problem_solving: problem_solving$1,
3671
3686
  my_story: my_story$1,
@@ -4761,7 +4776,12 @@ var lang_en = {
4761
4776
  text_group_n: text_group_n$1,
4762
4777
  text_detail_n: text_detail_n$1,
4763
4778
  question_group_n: question_group_n$1,
4764
- placeholder_teacher_selector: placeholder_teacher_selector$1
4779
+ placeholder_teacher_selector: placeholder_teacher_selector$1,
4780
+ teacher_personal_textbook: teacher_personal_textbook$1,
4781
+ textbook_owner_email_is_required: textbook_owner_email_is_required$1,
4782
+ invalid_textbook_owner_email_address: invalid_textbook_owner_email_address$1,
4783
+ textbook_owner_academy_is_required: textbook_owner_academy_is_required$1,
4784
+ textbook_owner_course_is_required: textbook_owner_course_is_required$1
4765
4785
  };
4766
4786
 
4767
4787
  i18n__default.use(reactI18next.initReactI18next).init({
@@ -5875,7 +5895,7 @@ var CustomCreatable = function CustomCreatable(_ref) {
5875
5895
  }, rest));
5876
5896
  };
5877
5897
 
5878
- var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti", "optionValue"];
5898
+ var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti", "optionValue", "styles"];
5879
5899
  var CustomSelect = function CustomSelect(_ref) {
5880
5900
  var isDefault = _ref.isDefault,
5881
5901
  options = _ref.options,
@@ -5884,6 +5904,7 @@ var CustomSelect = function CustomSelect(_ref) {
5884
5904
  value = _ref.value,
5885
5905
  isMulti = _ref.isMulti,
5886
5906
  optionValue = _ref.optionValue,
5907
+ styles = _ref.styles,
5887
5908
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
5888
5909
  var _useTranslation = reactI18next.useTranslation(),
5889
5910
  t = _useTranslation.t;
@@ -5908,7 +5929,7 @@ var CustomSelect = function CustomSelect(_ref) {
5908
5929
  DropdownIndicator: DropdownIndicator,
5909
5930
  Option: CustomOption
5910
5931
  },
5911
- styles: customStyles,
5932
+ styles: _extends({}, customStyles, styles),
5912
5933
  placeholder: t("select_placeholder")
5913
5934
  }, rest));
5914
5935
  };
@@ -26298,9 +26319,11 @@ var TextbookViewDetail = function TextbookViewDetail(props) {
26298
26319
 
26299
26320
  var PAGE_TITLE$7 = "textbooks";
26300
26321
  var useTextbookList = function useTextbookList(props) {
26322
+ var _user$roles, _user$roles2;
26301
26323
  var onNavigateCreate = props.onNavigateCreate,
26302
26324
  onNavigateDetail = props.onNavigateDetail,
26303
- isSuperAdmin = props.isSuperAdmin;
26325
+ isSuperAdmin = props.isSuperAdmin,
26326
+ role = props.role;
26304
26327
  var _useList = useList(function (search) {
26305
26328
  return getTextbookListApi(search, isSuperAdmin);
26306
26329
  }, TextbookDefaultQuery),
@@ -26315,14 +26338,21 @@ var useTextbookList = function useTextbookList(props) {
26315
26338
  calcOrderNumber = _useList.calcOrderNumber,
26316
26339
  handleChangeSelectedItem = _useList.handleChangeSelectedItem,
26317
26340
  getData = _useList.getData;
26341
+ var user = reactRedux.useSelector(function (state) {
26342
+ var _state$common;
26343
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
26344
+ });
26345
+ var isTeacherSite = role === exports.Role.Teacher;
26346
+ var isAdmin = !!user && ((_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Admin));
26347
+ var isTeacher = !!user && ((_user$roles2 = user.roles) === null || _user$roles2 === void 0 ? void 0 : _user$roles2.includes(exports.Role.Teacher)) && !isAdmin;
26318
26348
  var _useTranslation = reactI18next.useTranslation(),
26319
26349
  t = _useTranslation.t;
26320
26350
  var dispatch = reactRedux.useDispatch();
26321
26351
  var handleViewTextbook = function handleViewTextbook(data) {
26322
- onNavigateDetail(data, true, true);
26352
+ onNavigateDetail(data, true, false);
26323
26353
  };
26324
26354
  var handleUpdateTextbook = function handleUpdateTextbook(data) {
26325
- onNavigateDetail(data, false, true);
26355
+ onNavigateDetail(data, false, false);
26326
26356
  };
26327
26357
  var handleCreateTextbook = function handleCreateTextbook() {
26328
26358
  onNavigateCreate === null || onNavigateCreate === void 0 ? void 0 : onNavigateCreate();
@@ -26358,6 +26388,9 @@ var useTextbookList = function useTextbookList(props) {
26358
26388
  document.title = t("study_peak") + " | " + t(PAGE_TITLE$7);
26359
26389
  }, [t]);
26360
26390
  return {
26391
+ user: user,
26392
+ isTeacherSite: isTeacherSite,
26393
+ isTeacher: isTeacher,
26361
26394
  filter: filter,
26362
26395
  textSearchRef: textSearchRef,
26363
26396
  getData: getData,
@@ -26596,8 +26629,6 @@ var useTextbookShare = function useTextbookShare(props) {
26596
26629
  });
26597
26630
  var isAdmin = infoUser && (infoUser === null || infoUser === void 0 ? void 0 : (_infoUser$roles = infoUser.roles) === null || _infoUser$roles === void 0 ? void 0 : _infoUser$roles.includes(exports.Role.Admin));
26598
26631
  var isAdminSite = role === exports.Role.Admin;
26599
- var onAcademy = !!infoUser.academyDomain;
26600
- var isSuperAdminUser = infoUser && infoUser.isSuperAdmin;
26601
26632
  React.useEffect(function () {
26602
26633
  if (!isUpdate) {
26603
26634
  filterTeacherNotShared(currentModel);
@@ -26688,12 +26719,6 @@ var useTextbookShare = function useTextbookShare(props) {
26688
26719
  });
26689
26720
  setShared(existsTeachers);
26690
26721
  };
26691
- var enabledSave = function enabledSave(textbook) {
26692
- return onAcademy && (isAdminSite || isSuperAdmin || isSuperAdminUser || !isAdmin && textbook.isShared && textbook.createdBy.id === infoUser.id);
26693
- };
26694
- var enabledShare = function enabledShare(textbook) {
26695
- return textbook.isShared && onAcademy && (isAdminSite || isSuperAdminUser || !isAdmin && textbook.createdBy.id === infoUser.id);
26696
- };
26697
26722
  var handleShareTextbook = function handleShareTextbook(teacherIds, textbookId) {
26698
26723
  try {
26699
26724
  var _temp2 = function _temp2() {
@@ -26770,19 +26795,117 @@ var useTextbookShare = function useTextbookShare(props) {
26770
26795
  isUpdate: isUpdate,
26771
26796
  handleUpdateSharedTextbook: handleUpdateSharedTextbook,
26772
26797
  currentModel: currentModel,
26773
- enabledSave: enabledSave,
26774
- enabledShare: enabledShare,
26775
26798
  isAdmin: isAdmin,
26776
26799
  isAdminSite: isAdminSite
26777
26800
  };
26778
26801
  };
26779
26802
 
26803
+ var TextbookRow = function TextbookRow(_ref) {
26804
+ var _infoUser$roles, _infoUser$roles2, _data$createdBy, _data$textbookOwners, _data$createdBy2, _data$createdBy3;
26805
+ var index = _ref.index,
26806
+ data = _ref.data,
26807
+ role = _ref.role,
26808
+ isSuperAdmin = _ref.isSuperAdmin,
26809
+ calcOrderNumber = _ref.calcOrderNumber,
26810
+ onUpdateTextbook = _ref.onUpdateTextbook,
26811
+ onDeleteTextbook = _ref.onDeleteTextbook,
26812
+ onViewTextbook = _ref.onViewTextbook,
26813
+ onShareTextbook = _ref.onShareTextbook,
26814
+ onUpdateShareTextbook = _ref.onUpdateShareTextbook;
26815
+ var infoUser = reactRedux.useSelector(function (state) {
26816
+ var _state$common;
26817
+ return (state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user) || {};
26818
+ });
26819
+ var isAdmin = infoUser && (infoUser === null || infoUser === void 0 ? void 0 : (_infoUser$roles = infoUser.roles) === null || _infoUser$roles === void 0 ? void 0 : _infoUser$roles.includes(exports.Role.Admin));
26820
+ var isTeacherSite = role === exports.Role.Teacher;
26821
+ var isTeacher = !!infoUser && ((_infoUser$roles2 = infoUser.roles) === null || _infoUser$roles2 === void 0 ? void 0 : _infoUser$roles2.includes(exports.Role.Teacher)) && !isAdmin;
26822
+ var isAdminSite = role === exports.Role.Admin;
26823
+ var onAcademy = !!infoUser.academyDomain;
26824
+ var isSuperAdminUser = infoUser && infoUser.isSuperAdmin;
26825
+ var academy = reactRedux.useSelector(function (state) {
26826
+ var _state$common2;
26827
+ return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.academy;
26828
+ });
26829
+ var _useTranslation = reactI18next.useTranslation(),
26830
+ t = _useTranslation.t;
26831
+ var isEditable = !onAcademy || isAdminSite || isSuperAdmin || isSuperAdminUser || !isAdmin && data.isShared && (((_data$createdBy = data.createdBy) === null || _data$createdBy === void 0 ? void 0 : _data$createdBy.id) === (infoUser === null || infoUser === void 0 ? void 0 : infoUser.id) || ((_data$textbookOwners = data.textbookOwners) === null || _data$textbookOwners === void 0 ? void 0 : _data$textbookOwners.some(function (i) {
26832
+ var _infoUser$email, _infoUser$email$trim;
26833
+ return (i === null || i === void 0 ? void 0 : i.email.trim().toUpperCase()) === (infoUser === null || infoUser === void 0 ? void 0 : (_infoUser$email = infoUser.email) === null || _infoUser$email === void 0 ? void 0 : (_infoUser$email$trim = _infoUser$email.trim()) === null || _infoUser$email$trim === void 0 ? void 0 : _infoUser$email$trim.toUpperCase()) && (i === null || i === void 0 ? void 0 : i.academyId) === (academy === null || academy === void 0 ? void 0 : academy.id);
26834
+ })));
26835
+ var isDeleteAble = !onAcademy || isAdminSite || isSuperAdmin || isSuperAdminUser || !isAdmin && data.isShared && ((_data$createdBy2 = data.createdBy) === null || _data$createdBy2 === void 0 ? void 0 : _data$createdBy2.id) === (infoUser === null || infoUser === void 0 ? void 0 : infoUser.id);
26836
+ var isSharable = !data.isPublic && data.isShared && onAcademy && (isAdminSite || isSuperAdminUser || !isAdmin && data.createdBy.id === infoUser.id);
26837
+ var handleUpdateTextbook = function handleUpdateTextbook() {
26838
+ onUpdateTextbook(data);
26839
+ };
26840
+ var handleDeleteTextbook = function handleDeleteTextbook() {
26841
+ onDeleteTextbook(data);
26842
+ };
26843
+ var handleViewTextbook = function handleViewTextbook() {
26844
+ onViewTextbook(data);
26845
+ };
26846
+ var handleShareTextbook = function handleShareTextbook() {
26847
+ onShareTextbook(data);
26848
+ };
26849
+ var handleUpdateShareTextbook = function handleUpdateShareTextbook() {
26850
+ onUpdateShareTextbook(data);
26851
+ };
26852
+ return React__default.createElement(material.TableRow, {
26853
+ key: data.id
26854
+ }, React__default.createElement(material.TableCell, null, calcOrderNumber(index)), React__default.createElement(material.TableCell, null, data.name), React__default.createElement(material.TableCell, null, data.subject.name), React__default.createElement(material.TableCell, null, utcToLocalTime(data.createdAt, t("date_format"))), React__default.createElement(material.TableCell, null, data.totalChapters), isTeacher && isTeacherSite && React__default.createElement(material.TableCell, null, (infoUser === null || infoUser === void 0 ? void 0 : infoUser.id) === ((_data$createdBy3 = data.createdBy) === null || _data$createdBy3 === void 0 ? void 0 : _data$createdBy3.id) && data.isShared && React__default.createElement(fa.FaCheckCircle, {
26855
+ color: green[700]
26856
+ })), React__default.createElement(material.TableCell, null, !data.isPublic && data.sharedUsers.map(function (email, index) {
26857
+ return index > 2 ? null : index === 2 ? React__default.createElement("div", null, "(+", data.sharedUsers.length - 2, ")") : React__default.createElement("div", {
26858
+ key: index
26859
+ }, email.toLowerCase());
26860
+ })), React__default.createElement(material.TableCell, null, React__default.createElement(material.Stack, {
26861
+ direction: "row",
26862
+ spacing: 1,
26863
+ alignItems: "center"
26864
+ }, React__default.createElement(material.IconButton, {
26865
+ color: "default",
26866
+ className: (!isEditable ? "bg-secondary" : "bg-warning") + " text-white",
26867
+ onClick: handleUpdateTextbook,
26868
+ disabled: !isEditable
26869
+ }, React__default.createElement(fa6.FaPencil, {
26870
+ size: 12
26871
+ })), React__default.createElement(material.IconButton, {
26872
+ color: "default",
26873
+ className: "bg-primary text-white",
26874
+ onClick: handleViewTextbook
26875
+ }, React__default.createElement(fa.FaEye, {
26876
+ size: 12
26877
+ })), React__default.createElement(material.IconButton, {
26878
+ disabled: !isSharable,
26879
+ className: (!isSharable ? "bg-secondary" : "bg-info") + " text-white me-1",
26880
+ onClick: handleShareTextbook
26881
+ }, React__default.createElement(fa.FaShare, {
26882
+ size: 12
26883
+ })), React__default.createElement(material.IconButton, {
26884
+ disabled: !isSharable,
26885
+ className: (!isSharable ? "bg-secondary" : "bg-success") + " text-white me-1",
26886
+ onClick: handleUpdateShareTextbook
26887
+ }, React__default.createElement(fa.FaExchangeAlt, {
26888
+ size: 12
26889
+ })), React__default.createElement(material.IconButton, {
26890
+ color: "default",
26891
+ className: (!isDeleteAble ? "bg-secondary" : "bg-danger") + " text-white mr-1",
26892
+ onClick: handleDeleteTextbook,
26893
+ disabled: !isDeleteAble
26894
+ }, React__default.createElement(fa.FaTrash, {
26895
+ size: 12
26896
+ })))));
26897
+ };
26898
+
26780
26899
  var TextbookList = function TextbookList(props) {
26781
26900
  var _props$createable = props.createable,
26782
- createable = _props$createable === void 0 ? true : _props$createable;
26901
+ createable = _props$createable === void 0 ? true : _props$createable,
26902
+ isSuperAdmin = props.isSuperAdmin,
26903
+ role = props.role;
26783
26904
  var _useTranslation = reactI18next.useTranslation(),
26784
26905
  t = _useTranslation.t;
26785
26906
  var _useTextbookList = useTextbookList(props),
26907
+ isTeacherSite = _useTextbookList.isTeacherSite,
26908
+ isTeacher = _useTextbookList.isTeacher,
26786
26909
  filter = _useTextbookList.filter,
26787
26910
  textbooks = _useTextbookList.textbooks,
26788
26911
  paging = _useTextbookList.paging,
@@ -26824,9 +26947,14 @@ var TextbookList = function TextbookList(props) {
26824
26947
  handleOpenUpdateShareDialog = _useTextbookShare.handleOpenUpdateShareDialog,
26825
26948
  isUpdate = _useTextbookShare.isUpdate,
26826
26949
  handleUpdateSharedTextbook = _useTextbookShare.handleUpdateSharedTextbook,
26827
- currentModel = _useTextbookShare.currentModel,
26828
- enabledSave = _useTextbookShare.enabledSave,
26829
- enabledShare = _useTextbookShare.enabledShare;
26950
+ currentModel = _useTextbookShare.currentModel;
26951
+ var textbookHeaders = React.useMemo(function () {
26952
+ var headers = _$5.clone(TEXTBOOK_HEADERS);
26953
+ if (isTeacher && isTeacherSite) headers.splice(5, 0, {
26954
+ title: "teacher_personal_textbook"
26955
+ });
26956
+ return headers;
26957
+ }, [isTeacher, isTeacherSite]);
26830
26958
  return React__default.createElement(LayoutList, {
26831
26959
  title: t(TEXTBOOK_PAGE_TITLE)
26832
26960
  }, React__default.createElement(material.Grid, {
@@ -26861,63 +26989,26 @@ var TextbookList = function TextbookList(props) {
26861
26989
  xs: 12,
26862
26990
  className: "mt-3"
26863
26991
  }, React__default.createElement(material.Table, null, React__default.createElement(TableHeader, {
26864
- headerTemplates: TEXTBOOK_HEADERS,
26992
+ headerTemplates: textbookHeaders,
26865
26993
  filter: filter,
26866
26994
  onSort: handleSort
26867
- }), React__default.createElement(material.TableBody, null, textbooks.map(function (i, index) {
26868
- return React__default.createElement(material.TableRow, {
26869
- key: i.id
26870
- }, React__default.createElement(material.TableCell, null, calcOrderNumber(index)), React__default.createElement(material.TableCell, null, i.name), React__default.createElement(material.TableCell, null, i.subject.name), React__default.createElement(material.TableCell, null, utcToLocalTime(i.createdAt, t("date_format"))), React__default.createElement(material.TableCell, null, i.totalChapters), React__default.createElement(material.TableCell, null, i.sharedUsers.map(function (email, index) {
26871
- return index > 2 ? null : index === 2 ? React__default.createElement("div", null, "(+", i.sharedUsers.length - 2, ")") : React__default.createElement("div", {
26872
- key: index
26873
- }, email.toLowerCase());
26874
- })), React__default.createElement(material.TableCell, null, React__default.createElement(material.Stack, {
26875
- direction: "row",
26876
- spacing: 1,
26877
- alignItems: "center"
26878
- }, React__default.createElement(material.IconButton, {
26879
- color: "default",
26880
- className: (!enabledSave(i) ? "bg-secondary" : "bg-warning") + " text-white",
26881
- onClick: function onClick() {
26882
- return handleUpdateTextbook(i);
26883
- },
26884
- disabled: !enabledSave(i)
26885
- }, React__default.createElement(fa6.FaPencil, {
26886
- size: 12
26887
- })), React__default.createElement(material.IconButton, {
26888
- color: "default",
26889
- className: "bg-primary text-white",
26890
- onClick: function onClick() {
26891
- return handleViewTextbook(i);
26892
- }
26893
- }, React__default.createElement(fa.FaEye, {
26894
- size: 12
26895
- })), React__default.createElement(material.IconButton, {
26896
- disabled: !enabledShare(i),
26897
- className: (!enabledShare(i) ? "bg-secondary" : "bg-info") + " text-white me-1",
26898
- onClick: function onClick() {
26899
- return handleOpenShareDialog(i);
26900
- }
26901
- }, React__default.createElement(fa.FaShare, {
26902
- size: 12
26903
- })), React__default.createElement(material.IconButton, {
26904
- disabled: !enabledShare(i),
26905
- className: (!enabledShare(i) ? "bg-secondary" : "bg-success") + " text-white me-1",
26906
- onClick: function onClick() {
26907
- return handleOpenUpdateShareDialog(i);
26908
- }
26909
- }, React__default.createElement(fa.FaExchangeAlt, {
26910
- size: 12
26911
- })), React__default.createElement(material.IconButton, {
26912
- color: "default",
26913
- className: (!enabledSave(i) ? "bg-secondary" : "bg-danger") + " text-white mr-1",
26914
- onClick: function onClick() {
26915
- return handleSelectDeleteTextbook(i);
26916
- },
26917
- disabled: !enabledSave(i)
26918
- }, React__default.createElement(fa.FaTrash, {
26919
- size: 12
26920
- })))));
26995
+ }), React__default.createElement(material.TableBody, null, React__default.createElement(ListView, {
26996
+ data: textbooks,
26997
+ render: function render(data, index) {
26998
+ return React__default.createElement(TextbookRow, {
26999
+ key: index,
27000
+ index: index,
27001
+ data: data,
27002
+ isSuperAdmin: isSuperAdmin,
27003
+ calcOrderNumber: calcOrderNumber,
27004
+ onDeleteTextbook: handleSelectDeleteTextbook,
27005
+ onShareTextbook: handleOpenShareDialog,
27006
+ onUpdateShareTextbook: handleOpenUpdateShareDialog,
27007
+ onUpdateTextbook: handleUpdateTextbook,
27008
+ onViewTextbook: handleViewTextbook,
27009
+ role: role
27010
+ });
27011
+ }
26921
27012
  }), !textbooks.length && React__default.createElement(EmptyRow, null))), React__default.createElement("div", {
26922
27013
  className: "d-flex justify-content-end mt-3"
26923
27014
  }, !!paging.totalPages && React__default.createElement(material.Pagination, {
@@ -27570,7 +27661,8 @@ var NotificationList = function NotificationList(_ref) {
27570
27661
  startIcon: React__default.createElement(fa.FaPlus, {
27571
27662
  size: 12
27572
27663
  }),
27573
- onClick: handleCreateNotification
27664
+ onClick: handleCreateNotification,
27665
+ disabled: !isAdmin && isTeacherAdmin
27574
27666
  }, t("new_notification"))), React__default.createElement(material.Grid, {
27575
27667
  container: true
27576
27668
  }, React__default.createElement(material.Grid, {
@@ -27709,8 +27801,9 @@ var deleteTextbookApi$1 = function deleteTextbookApi(textbookId, isAdmin) {
27709
27801
  };
27710
27802
 
27711
27803
  var useTextbookManagement = function useTextbookManagement(_ref) {
27712
- var _user$roles;
27804
+ var _user$roles, _user$roles2, _selectedTextbook$cre, _selectedTextbook$cre2;
27713
27805
  var textbookId = _ref.textbookId,
27806
+ role = _ref.role,
27714
27807
  onNavigateList = _ref.onNavigateList;
27715
27808
  var _useTranslation = reactI18next.useTranslation(),
27716
27809
  t = _useTranslation.t;
@@ -27727,13 +27820,28 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
27727
27820
  var _useState4 = React.useState(false),
27728
27821
  selectedChapter = _useState4[0],
27729
27822
  setSelectedChapter = _useState4[1];
27823
+ var searchParams = new URLSearchParams(location.search);
27824
+ var isReadonly = searchParams.get('readonly') === "true";
27730
27825
  var dispatch = reactRedux.useDispatch();
27731
27826
  var user = reactRedux.useSelector(function (state) {
27732
27827
  var _state$common;
27733
27828
  return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
27734
27829
  });
27735
- var isAdmin = user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Admin);
27830
+ var academy = reactRedux.useSelector(function (state) {
27831
+ var _state$common2;
27832
+ return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.academy;
27833
+ });
27834
+ var isAdmin = user && (user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Admin));
27835
+ var isTeacher = user && (user === null || user === void 0 ? void 0 : (_user$roles2 = user.roles) === null || _user$roles2 === void 0 ? void 0 : _user$roles2.includes(exports.Role.Teacher)) && !isAdmin;
27736
27836
  var isSuperAdmin = !!user && !user.academyDomain;
27837
+ var isAdminSite = role === exports.Role.Admin;
27838
+ var onAcademy = !!(user !== null && user !== void 0 && user.academyDomain);
27839
+ var isSuperAdminUser = !!user && user.isSuperAdmin;
27840
+ var isEditable = !selectedTextbook || !onAcademy || isAdminSite || isSuperAdmin || isSuperAdminUser || !isAdmin && selectedTextbook.isShared && (((_selectedTextbook$cre = selectedTextbook.createdBy) === null || _selectedTextbook$cre === void 0 ? void 0 : _selectedTextbook$cre.id) === (user === null || user === void 0 ? void 0 : user.id) || selectedTextbook.textbookOwners.some(function (i) {
27841
+ var _user$email, _user$email$trim;
27842
+ return i.email.trim().toUpperCase() === (user === null || user === void 0 ? void 0 : (_user$email = user.email) === null || _user$email === void 0 ? void 0 : (_user$email$trim = _user$email.trim()) === null || _user$email$trim === void 0 ? void 0 : _user$email$trim.toUpperCase()) && i.academyId === (academy === null || academy === void 0 ? void 0 : academy.id);
27843
+ }));
27844
+ var disabledTextbookOwners = !selectedTextbook && isAdmin || selectedTextbook && (!isEditable || isTeacher && ((_selectedTextbook$cre2 = selectedTextbook.createdBy) === null || _selectedTextbook$cre2 === void 0 ? void 0 : _selectedTextbook$cre2.id) !== (user === null || user === void 0 ? void 0 : user.id) || isAdmin && !isSuperAdminUser);
27737
27845
  var handleOpenConfirmDeleteChapterDialog = function handleOpenConfirmDeleteChapterDialog(chapter) {
27738
27846
  setSelectedChapter(chapter);
27739
27847
  };
@@ -27788,6 +27896,7 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
27788
27896
  var _temp3 = function _temp3() {
27789
27897
  dispatch(setLoading(false));
27790
27898
  };
27899
+ if (isReadonly || !isEditable) return Promise.resolve();
27791
27900
  if (!coverImage && !(values !== null && values !== void 0 && values.coverImage)) {
27792
27901
  reactToastify.toast.error(t("please_select_image_file"));
27793
27902
  return Promise.resolve();
@@ -27839,11 +27948,16 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
27839
27948
  }, [textbookId]);
27840
27949
  return {
27841
27950
  t: t,
27951
+ isAdminSite: isAdminSite,
27952
+ disabledTextbookOwners: disabledTextbookOwners,
27953
+ isReadonly: isReadonly,
27954
+ isEditable: isEditable,
27842
27955
  isAdmin: isAdmin,
27843
27956
  theme: theme,
27844
27957
  history: history,
27845
27958
  coverImage: coverImage,
27846
27959
  isSuperAdmin: isSuperAdmin,
27960
+ isSuperAdminUser: isSuperAdminUser,
27847
27961
  openDialog: openDialog,
27848
27962
  handleSubmit: handleSubmit,
27849
27963
  selectedTextbook: selectedTextbook,
@@ -27874,6 +27988,12 @@ var HighSchoolGrade;
27874
27988
  HighSchoolGrade[HighSchoolGrade["ProbabilityAndStatistics"] = 6] = "ProbabilityAndStatistics";
27875
27989
  HighSchoolGrade[HighSchoolGrade["Geometry"] = 7] = "Geometry";
27876
27990
  })(HighSchoolGrade || (HighSchoolGrade = {}));
27991
+ var TextbookEditorType;
27992
+ (function (TextbookEditorType) {
27993
+ TextbookEditorType[TextbookEditorType["Default"] = 0] = "Default";
27994
+ TextbookEditorType[TextbookEditorType["Korea"] = 1] = "Korea";
27995
+ TextbookEditorType[TextbookEditorType["Math"] = 2] = "Math";
27996
+ })(TextbookEditorType || (TextbookEditorType = {}));
27877
27997
 
27878
27998
  var TextbookSortBy$1;
27879
27999
  (function (TextbookSortBy) {
@@ -28013,6 +28133,11 @@ var preparedTextbookSchema = function preparedTextbookSchema(t) {
28013
28133
  isbn: yup.string().required(t("isbn_required")),
28014
28134
  grade: yup.number().required(t("grade_required")).notOneOf([0], t("subject_required")),
28015
28135
  type: yup.number(),
28136
+ textbookOwners: yup.array().of(yup.object().shape({
28137
+ email: yup.string().trim().email(t("invalid_textbook_owner_email_address")).required(t("textbook_owner_email_is_required")),
28138
+ academyId: yup.number().required(t("textbook_owner_academy_is_required")),
28139
+ courseId: yup.number().required(t("textbook_owner_course_is_required"))
28140
+ })),
28016
28141
  chapters: yup.array().of(yup.object().shape({
28017
28142
  pageFrom: yup.number().required(t("page_from_required")).integer().typeError(t("must_be_number")).min(1, t("min_is_1")),
28018
28143
  pageTo: yup.number().required(t("page_to_required")).integer().typeError(t("must_be_number")).test("is-greater", t("page_to_must_be_greater_than_or_equal_to_page_from"), function (value) {
@@ -28085,7 +28210,7 @@ var DEFAULT_TEXTBOOK_REQUEST = {
28085
28210
  grade: "",
28086
28211
  textbookOwners: [],
28087
28212
  isPrepared: true,
28088
- type: 0
28213
+ type: TextbookEditorType.Korea
28089
28214
  };
28090
28215
  var DEFAULT_CHAPTER = {
28091
28216
  name: "",
@@ -28135,6 +28260,171 @@ var CustomTextbookTab = function CustomTextbookTab(props) {
28135
28260
  }, children));
28136
28261
  };
28137
28262
 
28263
+ var _reduceToMathArticles = function reduceToMathArticles(textbook, isMath) {
28264
+ var values = isMath !== undefined ? _$5.cloneDeep(textbook) : textbook;
28265
+ if (isMath !== undefined) values.type = isMath;
28266
+ for (var key in values) {
28267
+ if (values.hasOwnProperty(key)) {
28268
+ if (key === "articles") {
28269
+ var _values$key;
28270
+ values[key] = (_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.length ? [values[key][0]] : [DEFAULT_ARTICLE];
28271
+ } else if (typeof values[key] === "object" && values[key] !== null) {
28272
+ _reduceToMathArticles(values[key]);
28273
+ }
28274
+ }
28275
+ }
28276
+ return values;
28277
+ };
28278
+ var _resetAllCategoriesAndQuestionTypesBySubject = function resetAllCategoriesAndQuestionTypesBySubject(textbook, subject) {
28279
+ var values = subject ? _$5.cloneDeep(textbook) : textbook;
28280
+ if (subject) {
28281
+ values.subjectId = subject === null || subject === void 0 ? void 0 : subject.value;
28282
+ values.subject = subject;
28283
+ }
28284
+ for (var key in values) {
28285
+ if (values.hasOwnProperty(key)) {
28286
+ if (key === "categories" || key === "categoryOptions") {
28287
+ values[key] = [];
28288
+ } else if (key === "questionType" || key === "questionTypeId") {
28289
+ values[key] = null;
28290
+ } else if (typeof values[key] === "object" && values[key] !== null) {
28291
+ _resetAllCategoriesAndQuestionTypesBySubject(values[key]);
28292
+ }
28293
+ }
28294
+ }
28295
+ return values;
28296
+ };
28297
+ var convertResponseToRequest = function convertResponseToRequest(selectedTextbook) {
28298
+ var _selectedTextbook$sub;
28299
+ if (!selectedTextbook) return DEFAULT_TEXTBOOK_REQUEST;
28300
+ return {
28301
+ name: selectedTextbook.name || "",
28302
+ subjectId: ((_selectedTextbook$sub = selectedTextbook.subject) === null || _selectedTextbook$sub === void 0 ? void 0 : _selectedTextbook$sub.id) || 0,
28303
+ subject: selectedTextbook.subject ? {
28304
+ label: selectedTextbook.subject.name,
28305
+ value: selectedTextbook.subject.id
28306
+ } : null,
28307
+ preparedType: selectedTextbook.preparedType || 0,
28308
+ grade: selectedTextbook.grade || "1",
28309
+ publicationDate: (selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.publicationDate) || "",
28310
+ publisher: selectedTextbook.publisher || "",
28311
+ isbn: selectedTextbook.isbn || "",
28312
+ coverImage: selectedTextbook.coverImage || "",
28313
+ textbookOwners: selectedTextbook.textbookOwners.map(function (to) {
28314
+ return _extends({}, to, {
28315
+ academy: to.academy ? {
28316
+ label: to.academy.name,
28317
+ value: to.academy.id
28318
+ } : null,
28319
+ course: to.course ? {
28320
+ label: to.course.name,
28321
+ value: to.course.id
28322
+ } : null
28323
+ });
28324
+ }),
28325
+ isPublic: selectedTextbook.isPublic || false,
28326
+ isShared: selectedTextbook.isShared || false,
28327
+ isPrepared: true,
28328
+ type: selectedTextbook.type,
28329
+ chapters: selectedTextbook.chapters.map(function (c) {
28330
+ var _c$questionGroups;
28331
+ return {
28332
+ name: c.name,
28333
+ pageFrom: c.pageFrom || 0,
28334
+ pageTo: c.pageTo || 0,
28335
+ id: c.id,
28336
+ questionGroups: ((_c$questionGroups = c.questionGroups) === null || _c$questionGroups === void 0 ? void 0 : _c$questionGroups.map(function (g) {
28337
+ var _g$questions, _g$questions$find;
28338
+ return {
28339
+ id: g.id,
28340
+ chapterId: c.id,
28341
+ questions: g.questions.map(function (q) {
28342
+ var _q$questionType;
28343
+ return _extends({}, q, {
28344
+ questionTypeId: q.questionTypeId || q.questionType.id,
28345
+ questionType: (_q$questionType = q.questionType) !== null && _q$questionType !== void 0 && _q$questionType.id ? {
28346
+ label: q.questionType.name,
28347
+ value: q.questionType.id
28348
+ } : null
28349
+ });
28350
+ }),
28351
+ articles: g.articles.map(function (a) {
28352
+ return _extends({}, a, {
28353
+ categoryOptions: a.categories.map(function (cat) {
28354
+ return {
28355
+ label: cat.name,
28356
+ value: cat.id
28357
+ };
28358
+ }),
28359
+ categories: a.categories.filter(function (cat) {
28360
+ return !!cat.id;
28361
+ }).map(function (cat) {
28362
+ return cat.id;
28363
+ })
28364
+ });
28365
+ }),
28366
+ questionCount: g.questions.length,
28367
+ answerCount: ((_g$questions = g.questions) === null || _g$questions === void 0 ? void 0 : (_g$questions$find = _g$questions.find(function (q) {
28368
+ return q.questionAnswerType !== exports.QuestionAnswerType.ShortAnswer;
28369
+ })) === null || _g$questions$find === void 0 ? void 0 : _g$questions$find.numberOfAnswers) || DEFAULT_ANSWER_COUNT$2
28370
+ };
28371
+ })) || [],
28372
+ subChapters: c.subChapters.map(function (sub) {
28373
+ var _sub$questionGroups;
28374
+ return {
28375
+ name: sub.name,
28376
+ pageFrom: sub.pageFrom || 0,
28377
+ pageTo: sub.pageTo || 0,
28378
+ id: sub.id,
28379
+ questionGroups: ((_sub$questionGroups = sub.questionGroups) === null || _sub$questionGroups === void 0 ? void 0 : _sub$questionGroups.map(function (g) {
28380
+ var _g$questions2, _g$questions2$find;
28381
+ return {
28382
+ id: g.id,
28383
+ chapterId: c.id,
28384
+ questions: g.questions.map(function (q) {
28385
+ var _q$questionType2;
28386
+ return _extends({}, q, {
28387
+ questionTypeId: q.questionTypeId || q.questionType.id,
28388
+ questionType: (_q$questionType2 = q.questionType) !== null && _q$questionType2 !== void 0 && _q$questionType2.id ? {
28389
+ label: q.questionType.name,
28390
+ value: q.questionType.id
28391
+ } : null
28392
+ });
28393
+ }),
28394
+ articles: g.articles.map(function (a) {
28395
+ return _extends({}, a, {
28396
+ categoryOptions: a.categories.map(function (cat) {
28397
+ return {
28398
+ label: cat.name,
28399
+ value: cat.id
28400
+ };
28401
+ }),
28402
+ categories: a.categories.filter(function (cat) {
28403
+ return !!cat.id;
28404
+ }).map(function (cat) {
28405
+ return cat.id;
28406
+ })
28407
+ });
28408
+ }),
28409
+ questionCount: g.questions.length,
28410
+ answerCount: ((_g$questions2 = g.questions) === null || _g$questions2 === void 0 ? void 0 : (_g$questions2$find = _g$questions2.find(function (q) {
28411
+ return q.questionAnswerType !== exports.QuestionAnswerType.ShortAnswer;
28412
+ })) === null || _g$questions2$find === void 0 ? void 0 : _g$questions2$find.numberOfAnswers) || DEFAULT_ANSWER_COUNT$2
28413
+ };
28414
+ })) || [],
28415
+ subChapters: []
28416
+ };
28417
+ })
28418
+ };
28419
+ })
28420
+ };
28421
+ };
28422
+ var handleKeyDown = function handleKeyDown(e) {
28423
+ if (e.key === 'Enter') {
28424
+ e.preventDefault();
28425
+ }
28426
+ };
28427
+
28138
28428
  var ArticleBlock = function ArticleBlock(_ref) {
28139
28429
  var expandedIndex = _ref.expandedIndex,
28140
28430
  data = _ref.data,
@@ -28142,6 +28432,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28142
28432
  path = _ref.path,
28143
28433
  isLoadingCategories = _ref.isLoadingCategories,
28144
28434
  optionKey = _ref.optionKey,
28435
+ disabled = _ref.disabled,
28145
28436
  setFieldValue = _ref.setFieldValue,
28146
28437
  onDuplicate = _ref.onDuplicate,
28147
28438
  onDelete = _ref.onDelete,
@@ -28243,6 +28534,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28243
28534
  onMenuClose: onCloseCategoryMenu
28244
28535
  },
28245
28536
  onChange: handleChangeCategory,
28537
+ isDisabled: disabled,
28246
28538
  placeholder: t("select_category")
28247
28539
  });
28248
28540
  }
@@ -28280,7 +28572,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28280
28572
  onMenuClose: onCloseCategoryMenu
28281
28573
  },
28282
28574
  onChange: handleChangeSubCategory,
28283
- isDisabled: !data.categories[0],
28575
+ isDisabled: disabled || !data.categories[0],
28284
28576
  placeholder: t("select_category")
28285
28577
  });
28286
28578
  }
@@ -28301,7 +28593,9 @@ var ArticleBlock = function ArticleBlock(_ref) {
28301
28593
  return React__default.createElement(material.TextField, Object.assign({
28302
28594
  placeholder: t("title")
28303
28595
  }, field, {
28304
- size: "small"
28596
+ size: "small",
28597
+ onKeyDown: handleKeyDown,
28598
+ disabled: disabled
28305
28599
  }));
28306
28600
  }
28307
28601
  }))), React__default.createElement(material.Grid, {
@@ -28321,7 +28615,9 @@ var ArticleBlock = function ArticleBlock(_ref) {
28321
28615
  return React__default.createElement(material.TextField, Object.assign({
28322
28616
  placeholder: t("author")
28323
28617
  }, field, {
28324
- size: "small"
28618
+ size: "small",
28619
+ onKeyDown: handleKeyDown,
28620
+ disabled: disabled
28325
28621
  }));
28326
28622
  }
28327
28623
  }))), React__default.createElement(material.Grid, {
@@ -28341,7 +28637,9 @@ var ArticleBlock = function ArticleBlock(_ref) {
28341
28637
  return React__default.createElement(material.TextField, Object.assign({
28342
28638
  placeholder: t("subject")
28343
28639
  }, field, {
28344
- size: "small"
28640
+ size: "small",
28641
+ onKeyDown: handleKeyDown,
28642
+ disabled: disabled
28345
28643
  }));
28346
28644
  }
28347
28645
  })))), React__default.createElement(material.Stack, {
@@ -28354,6 +28652,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28354
28652
  }, t("copy_items")), React__default.createElement(material.Button, {
28355
28653
  variant: "contained",
28356
28654
  color: "success",
28655
+ disabled: disabled,
28357
28656
  onClick: handleDuplicateArticle,
28358
28657
  sx: {
28359
28658
  whiteSpace: "nowrap"
@@ -28369,7 +28668,7 @@ var isEqual = function isEqual(prev, next) {
28369
28668
  var nextIsLoadingCategories = isNextMatched ? next.isLoadingCategories : undefined;
28370
28669
  var prevCategories = isPrevMatched ? prev.categories : undefined;
28371
28670
  var nextCategories = isNextMatched ? next.categories : undefined;
28372
- return prevOptionKey === nextOptionKey && prevIsLoadingCategories === nextIsLoadingCategories && JSON.stringify(prev.data) === JSON.stringify(next.data) && JSON.stringify(prevCategories) === JSON.stringify(nextCategories) && prev.path === next.path && prev.expandedIndex == next.expandedIndex && prev.onOpenCategoryMenu == next.onOpenCategoryMenu && prev.onOpenSubCategoryMenu == next.onOpenSubCategoryMenu;
28671
+ return prevOptionKey === nextOptionKey && prevIsLoadingCategories === nextIsLoadingCategories && JSON.stringify(prev.data) === JSON.stringify(next.data) && JSON.stringify(prevCategories) === JSON.stringify(nextCategories) && prev.path === next.path && prev.expandedIndex == next.expandedIndex && prev.disabled === next.disabled && prev.onOpenCategoryMenu == next.onOpenCategoryMenu && prev.onOpenSubCategoryMenu == next.onOpenSubCategoryMenu;
28373
28672
  };
28374
28673
  var ArticleBlock$1 = React.memo(ArticleBlock, isEqual);
28375
28674
 
@@ -28415,7 +28714,7 @@ var BpCheckedIcon$1 = material.styled(BpIcon$1)({
28415
28714
  var QuestionBlock = function QuestionBlock(_ref2) {
28416
28715
  var answerCount = _ref2.answerCount,
28417
28716
  isMath = _ref2.isMath,
28418
- isDisabled = _ref2.isDisabled,
28717
+ disabled = _ref2.disabled,
28419
28718
  path = _ref2.path,
28420
28719
  data = _ref2.data,
28421
28720
  questionTitleStyle = _ref2.questionTitleStyle,
@@ -28460,7 +28759,8 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28460
28759
  var field = _ref3.field;
28461
28760
  return React__default.createElement(material.TextField, Object.assign({}, field, {
28462
28761
  size: "small",
28463
- placeholder: t("textual_answer")
28762
+ placeholder: t("textual_answer"),
28763
+ onKeyDown: handleKeyDown
28464
28764
  }));
28465
28765
  }
28466
28766
  }));
@@ -28479,7 +28779,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28479
28779
  className: styles$9["question-label"] + " w-fit",
28480
28780
  labelPlacement: "top",
28481
28781
  value: i,
28482
- disabled: isDisabled,
28782
+ disabled: disabled,
28483
28783
  control: React__default.createElement(material.Checkbox, {
28484
28784
  checked: data.correctAnswers.includes(i),
28485
28785
  onChange: function onChange(e) {
@@ -28515,7 +28815,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28515
28815
  onChange: function onChange(e) {
28516
28816
  return setFieldValue(path + ".correctAnswers", [+e.target.value]);
28517
28817
  },
28518
- disabled: isDisabled,
28818
+ disabled: disabled,
28519
28819
  control: React__default.createElement(material.Radio, {
28520
28820
  size: "small",
28521
28821
  checked: +i === data.correctAnswers[0],
@@ -28588,7 +28888,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28588
28888
  render: function render(_ref4) {
28589
28889
  var field = _ref4.field;
28590
28890
  return React__default.createElement(ScoreSelector, Object.assign({}, field, {
28591
- isDisabled: isDisabled,
28891
+ isDisabled: disabled,
28592
28892
  onChange: function onChange(value) {
28593
28893
  setFieldValue(path + ".score", (value === null || value === void 0 ? void 0 : value.value) || 0);
28594
28894
  }
@@ -28609,7 +28909,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28609
28909
  var _ref5$field = _ref5.field,
28610
28910
  field = _objectWithoutPropertiesLoose(_ref5$field, _excluded$f);
28611
28911
  return React__default.createElement(CustomSelectOption, Object.assign({}, field, {
28612
- isDisabled: isDisabled,
28912
+ isDisabled: disabled,
28613
28913
  value: data.questionType,
28614
28914
  options: questionTypes,
28615
28915
  isLoading: optionKey === path + ".questionTypeId" ? isLoadingQuestionTypes : false,
@@ -28634,7 +28934,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28634
28934
  var field = _ref6.field;
28635
28935
  return React__default.createElement(CustomSelect, Object.assign({}, field, {
28636
28936
  value: data.questionAnswerType,
28637
- isDisabled: isDisabled,
28937
+ isDisabled: disabled,
28638
28938
  options: answerTypeOptions,
28639
28939
  onChange: handleChangeQuestionAnswerType
28640
28940
  }));
@@ -28650,11 +28950,11 @@ var isEqual$1 = function isEqual(prev, next) {
28650
28950
  var nextIsLoadingQuestionTypes = isNextMatched ? next.isLoadingQuestionTypes : undefined;
28651
28951
  var prevQuestionTypes = isPrevMatched ? prev.questionTypes : undefined;
28652
28952
  var nextQuestionTypes = isNextMatched ? next.questionTypes : undefined;
28653
- return prevOptionKey === nextOptionKey && prevIsLoadingQuestionTypes === nextIsLoadingQuestionTypes && JSON.stringify(prev.data) === JSON.stringify(next.data) && JSON.stringify(prevQuestionTypes) === JSON.stringify(nextQuestionTypes) && prev.path === next.path && prev.isMath == next.isMath && prev.answerCount == next.answerCount && prev.isDisabled == next.isDisabled && JSON.stringify(prev.questionTitleStyle) === JSON.stringify(next.questionTitleStyle) && prev.onOpenQuestionTypeMenu == next.onOpenQuestionTypeMenu;
28953
+ return prevOptionKey === nextOptionKey && prevIsLoadingQuestionTypes === nextIsLoadingQuestionTypes && JSON.stringify(prev.data) === JSON.stringify(next.data) && JSON.stringify(prevQuestionTypes) === JSON.stringify(nextQuestionTypes) && prev.path === next.path && prev.isMath == next.isMath && prev.answerCount == next.answerCount && prev.disabled == next.disabled && JSON.stringify(prev.questionTitleStyle) === JSON.stringify(next.questionTitleStyle) && prev.onOpenQuestionTypeMenu == next.onOpenQuestionTypeMenu;
28654
28954
  };
28655
28955
  var QuestionBlock$1 = React.memo(QuestionBlock, isEqual$1);
28656
28956
 
28657
- var _excluded$g = ["data", "path", "isMath", "open", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "categories", "questionTypes", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28957
+ var _excluded$g = ["data", "path", "isMath", "open", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "categories", "questionTypes", "disabled", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28658
28958
  var _ = _$5;
28659
28959
  var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28660
28960
  var _data$articles$3, _data$articles$3$cate, _data$articles$4, _data$articles$4$cate;
@@ -28667,6 +28967,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28667
28967
  optionKey = _ref.optionKey,
28668
28968
  categories = _ref.categories,
28669
28969
  questionTypes = _ref.questionTypes,
28970
+ disabled = _ref.disabled,
28670
28971
  onDelete = _ref.onDelete,
28671
28972
  onOpenSubCategoryMenu = _ref.onOpenSubCategoryMenu,
28672
28973
  onOpenCategoryMenu = _ref.onOpenCategoryMenu,
@@ -28710,6 +29011,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28710
29011
  expandedIndex: index,
28711
29012
  data: article,
28712
29013
  path: path + ".articles[" + index + "]",
29014
+ disabled: disabled,
28713
29015
  onDuplicate: handleDuplicateArticle,
28714
29016
  onDelete: onDelete,
28715
29017
  optionKey: optionKey,
@@ -28725,6 +29027,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28725
29027
  width: "fit-content"
28726
29028
  },
28727
29029
  variant: "contained",
29030
+ disabled: disabled,
28728
29031
  startIcon: React__default.createElement(io.IoIosAdd, null),
28729
29032
  onClick: function onClick() {
28730
29033
  arrayHelpers.push(DEFAULT_ARTICLE);
@@ -28744,6 +29047,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28744
29047
  questionTypes: questionTypes,
28745
29048
  isLoadingQuestionTypes: isLoadingQuestionTypes,
28746
29049
  optionKey: optionKey,
29050
+ disabled: disabled,
28747
29051
  onOpenQuestionTypeMenu: handleOpenQuestionTypeMenu,
28748
29052
  onCloseQuestionTypeMenu: onCloseQuestionTypeMenu
28749
29053
  }, formikProps));
@@ -28773,11 +29077,11 @@ var isEqual$2 = function isEqual(prev, next) {
28773
29077
  var nextOnOpenSubCategoryMenu = next.onOpenSubCategoryMenu;
28774
29078
  var prevOnOpenQuestionTypeMenu = prev.onOpenQuestionTypeMenu;
28775
29079
  var nextOnOpenQuestionTypeMenu = next.onOpenQuestionTypeMenu;
28776
- return prevOptionKey === nextOptionKey && prevIsLoadingCategories === nextIsLoadingCategories && JSON.stringify(prevCategories) === JSON.stringify(nextCategories) && prevIsLoadingQuestionTypes === nextIsLoadingQuestionTypes && JSON.stringify(prevQuestionTypes) === JSON.stringify(nextQuestionTypes) && prev.path === next.path && prev.isMath === next.isMath && prev.open === next.open && JSON.stringify(prev.data) === JSON.stringify(next.data) && JSON.stringify(prevBlockErrors) === JSON.stringify(nextBlockErrors) && prevOnOpenCategoryMenu === nextOnOpenCategoryMenu && prevOnOpenSubCategoryMenu === nextOnOpenSubCategoryMenu && prevOnOpenQuestionTypeMenu === nextOnOpenQuestionTypeMenu;
29080
+ return prevOptionKey === nextOptionKey && prevIsLoadingCategories === nextIsLoadingCategories && JSON.stringify(prevCategories) === JSON.stringify(nextCategories) && prevIsLoadingQuestionTypes === nextIsLoadingQuestionTypes && JSON.stringify(prevQuestionTypes) === JSON.stringify(nextQuestionTypes) && prev.path === next.path && prev.isMath === next.isMath && prev.open === next.open && prev.disabled === next.disabled && JSON.stringify(prev.data) === JSON.stringify(next.data) && JSON.stringify(prevBlockErrors) === JSON.stringify(nextBlockErrors) && prevOnOpenCategoryMenu === nextOnOpenCategoryMenu && prevOnOpenSubCategoryMenu === nextOnOpenSubCategoryMenu && prevOnOpenQuestionTypeMenu === nextOnOpenQuestionTypeMenu;
28777
29081
  };
28778
29082
  var QuestionGroupBlockBody$1 = React.memo(QuestionGroupBlockBody, isEqual$2);
28779
29083
 
28780
- var _excluded$h = ["expandedIndex", "open", "paths", "path", "isMath", "data", "categories", "isLoadingCategories", "isLoadingQuestionTypes", "questionTypes", "optionKey", "isDisabled", "onToggle", "onQuestionCountChange", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
29084
+ var _excluded$h = ["expandedIndex", "open", "paths", "path", "isMath", "data", "categories", "isLoadingCategories", "isLoadingQuestionTypes", "questionTypes", "optionKey", "disabled", "onToggle", "onQuestionCountChange", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28781
29085
  var _$1 = _$5;
28782
29086
  var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28783
29087
  var _data$articles$2, _data$articles$2$cate, _data$articles$2$cate2, _data$articles$3, _data$articles$3$cate, _data$articles$3$cate2;
@@ -28792,7 +29096,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28792
29096
  isLoadingQuestionTypes = _ref.isLoadingQuestionTypes,
28793
29097
  questionTypes = _ref.questionTypes,
28794
29098
  optionKey = _ref.optionKey,
28795
- isDisabled = _ref.isDisabled,
29099
+ disabled = _ref.disabled,
28796
29100
  onToggle = _ref.onToggle,
28797
29101
  onQuestionCountChange = _ref.onQuestionCountChange,
28798
29102
  onDelete = _ref.onDelete,
@@ -28951,7 +29255,8 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28951
29255
  render: function render(_ref2) {
28952
29256
  var field = _ref2.field;
28953
29257
  return React__default.createElement(QuestionCountSelector, Object.assign({}, field, {
28954
- onChange: handleChangeQuestionCount
29258
+ onChange: handleChangeQuestionCount,
29259
+ isDisabled: disabled
28955
29260
  }));
28956
29261
  }
28957
29262
  }))), isMath && React__default.createElement(material.Grid, {
@@ -28989,6 +29294,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28989
29294
  onMenuClose: onCloseCategoryMenu
28990
29295
  },
28991
29296
  onChange: handleChangeCategory,
29297
+ isDisabled: disabled,
28992
29298
  placeholder: t("select_category")
28993
29299
  });
28994
29300
  }
@@ -29029,7 +29335,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29029
29335
  onMenuClose: onCloseCategoryMenu
29030
29336
  },
29031
29337
  onChange: handleChangeSubCategory,
29032
- isDisabled: isDisabled || !((_data$articles$4 = data.articles[0]) !== null && _data$articles$4 !== void 0 && (_data$articles$4$cate = _data$articles$4.categories) !== null && _data$articles$4$cate !== void 0 && _data$articles$4$cate[0]),
29338
+ isDisabled: disabled || !((_data$articles$4 = data.articles[0]) !== null && _data$articles$4 !== void 0 && (_data$articles$4$cate = _data$articles$4.categories) !== null && _data$articles$4$cate !== void 0 && _data$articles$4$cate[0]),
29033
29339
  placeholder: t("select_category")
29034
29340
  });
29035
29341
  }
@@ -29048,7 +29354,8 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29048
29354
  render: function render(_ref5) {
29049
29355
  var field = _ref5.field;
29050
29356
  return React__default.createElement(AnswerCountSelector, Object.assign({}, field, {
29051
- onChange: handleChangeAnswerCount
29357
+ onChange: handleChangeAnswerCount,
29358
+ isDisabled: disabled
29052
29359
  }));
29053
29360
  }
29054
29361
  })))), isMath && React__default.createElement(material.Box, {
@@ -29061,6 +29368,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29061
29368
  }, React__default.createElement(material.Button, {
29062
29369
  variant: "contained",
29063
29370
  color: "success",
29371
+ disabled: disabled,
29064
29372
  onClick: handleCopyCategories,
29065
29373
  sx: {
29066
29374
  whiteSpace: "nowrap"
@@ -29086,6 +29394,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29086
29394
  isLoadingCategories: isLoadingCategories,
29087
29395
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29088
29396
  optionKey: optionKey,
29397
+ disabled: disabled,
29089
29398
  onDelete: onDelete,
29090
29399
  onOpenSubCategoryMenu: onOpenSubCategoryMenu,
29091
29400
  onOpenCategoryMenu: onOpenCategoryMenu,
@@ -29095,7 +29404,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29095
29404
  }, formikProps)))));
29096
29405
  };
29097
29406
 
29098
- var _excluded$i = ["path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "questionGroups", "subChapters", "categories", "questionTypes", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
29407
+ var _excluded$i = ["path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "questionGroups", "subChapters", "categories", "questionTypes", "disabled", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
29099
29408
  var ChapterBlockBody = function ChapterBlockBody(_ref) {
29100
29409
  var path = _ref.path,
29101
29410
  paths = _ref.paths,
@@ -29107,6 +29416,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29107
29416
  subChapters = _ref.subChapters,
29108
29417
  categories = _ref.categories,
29109
29418
  questionTypes = _ref.questionTypes,
29419
+ disabled = _ref.disabled,
29110
29420
  onDelete = _ref.onDelete,
29111
29421
  onOpenSubCategoryMenu = _ref.onOpenSubCategoryMenu,
29112
29422
  onOpenCategoryMenu = _ref.onOpenCategoryMenu,
@@ -29218,6 +29528,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29218
29528
  categories: categories,
29219
29529
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29220
29530
  questionTypes: questionTypes,
29531
+ disabled: disabled,
29221
29532
  onToggle: handleToggle,
29222
29533
  onDelete: onDelete,
29223
29534
  onOpenCategoryMenu: onOpenCategoryMenu,
@@ -29232,6 +29543,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29232
29543
  },
29233
29544
  variant: "contained",
29234
29545
  startIcon: React__default.createElement(io.IoIosAdd, null),
29546
+ disabled: disabled,
29235
29547
  onClick: function onClick() {
29236
29548
  {
29237
29549
  var length = subChapters.length;
@@ -29262,6 +29574,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29262
29574
  optionKey: optionKey,
29263
29575
  isLoadingCategories: isLoadingCategories,
29264
29576
  categories: categories,
29577
+ disabled: disabled,
29265
29578
  onOpenCategoryMenu: onOpenCategoryMenu,
29266
29579
  onOpenSubCategoryMenu: onOpenSubCategoryMenu,
29267
29580
  onCloseCategoryMenu: onCloseCategoryMenu,
@@ -29277,6 +29590,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29277
29590
  },
29278
29591
  variant: "contained",
29279
29592
  startIcon: React__default.createElement(io.IoIosAdd, null),
29593
+ disabled: disabled,
29280
29594
  onClick: function onClick() {
29281
29595
  var length = questionGroups.length;
29282
29596
  var addedGroup = handleGetNewQuestionGroup();
@@ -29288,7 +29602,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29288
29602
  }));
29289
29603
  };
29290
29604
 
29291
- var _excluded$j = ["data", "expandedIndex", "open", "path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "categories", "questionTypes", "optionKey", "onToggle", "onDelete", "onCopiedPrevQuestionGroup", "onCloseCategoryMenu", "onOpenCategoryMenu", "onOpenSubCategoryMenu", "onOpenQuestionTypeMenu", "onCloseQuestionTypeMenu"];
29605
+ var _excluded$j = ["data", "expandedIndex", "open", "path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "categories", "questionTypes", "optionKey", "disabled", "onToggle", "onDelete", "onCopiedPrevQuestionGroup", "onCloseCategoryMenu", "onOpenCategoryMenu", "onOpenSubCategoryMenu", "onOpenQuestionTypeMenu", "onCloseQuestionTypeMenu"];
29292
29606
  var _$2 = _$5;
29293
29607
  var ChapterBlock = function ChapterBlock(_ref) {
29294
29608
  var data = _ref.data,
@@ -29302,6 +29616,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
29302
29616
  categories = _ref.categories,
29303
29617
  questionTypes = _ref.questionTypes,
29304
29618
  optionKey = _ref.optionKey,
29619
+ disabled = _ref.disabled,
29305
29620
  onToggle = _ref.onToggle,
29306
29621
  onDelete = _ref.onDelete,
29307
29622
  onCopiedPrevQuestionGroup = _ref.onCopiedPrevQuestionGroup,
@@ -29359,6 +29674,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
29359
29674
  color: "default",
29360
29675
  size: "small",
29361
29676
  className: "bg-danger text-white",
29677
+ disabled: disabled,
29362
29678
  onClick: handleClickDeleteChapter
29363
29679
  }, React__default.createElement(fa6.FaTrashCan, {
29364
29680
  size: 12
@@ -29385,7 +29701,9 @@ var ChapterBlock = function ChapterBlock(_ref) {
29385
29701
  return React__default.createElement(material.TextField, Object.assign({
29386
29702
  placeholder: t("name")
29387
29703
  }, field, {
29388
- size: "small"
29704
+ size: "small",
29705
+ onKeyDown: handleKeyDown,
29706
+ disabled: disabled
29389
29707
  }));
29390
29708
  }
29391
29709
  }), !!pageNameError && React__default.createElement(material.Typography, {
@@ -29406,7 +29724,9 @@ var ChapterBlock = function ChapterBlock(_ref) {
29406
29724
  placeholder: t("page_from"),
29407
29725
  type: "number"
29408
29726
  }, field, {
29409
- size: "small"
29727
+ size: "small",
29728
+ onKeyDown: handleKeyDown,
29729
+ disabled: disabled
29410
29730
  }));
29411
29731
  }
29412
29732
  }), !!pageFromError && React__default.createElement(material.Typography, {
@@ -29427,7 +29747,9 @@ var ChapterBlock = function ChapterBlock(_ref) {
29427
29747
  placeholder: t("page_to"),
29428
29748
  type: "number"
29429
29749
  }, field, {
29430
- size: "small"
29750
+ size: "small",
29751
+ onKeyDown: handleKeyDown,
29752
+ disabled: disabled
29431
29753
  }));
29432
29754
  }
29433
29755
  }), !!pageToError && React__default.createElement(material.Typography, {
@@ -29446,6 +29768,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
29446
29768
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29447
29769
  isLoadingCategories: isLoadingCategories,
29448
29770
  optionKey: optionKey,
29771
+ disabled: disabled,
29449
29772
  onDelete: onDelete,
29450
29773
  onCopiedPrevQuestionGroup: onCopiedPrevQuestionGroup,
29451
29774
  onOpenSubCategoryMenu: onOpenSubCategoryMenu,
@@ -29577,7 +29900,8 @@ var QuestionTypeFilter = function QuestionTypeFilter(_ref) {
29577
29900
  }, React__default.createElement(material.FormLabel, null, t("search")), React__default.createElement(material.TextField, {
29578
29901
  placeholder: t("question_type_search_keyword"),
29579
29902
  size: "small",
29580
- inputRef: inputRef
29903
+ inputRef: inputRef,
29904
+ onKeyDown: handleKeyDown
29581
29905
  })), React__default.createElement(material.FormGroup, {
29582
29906
  sx: {
29583
29907
  display: "flex",
@@ -29816,9 +30140,10 @@ var useTextbookOptions = function useTextbookOptions(subjectId, isMath, filter,
29816
30140
 
29817
30141
  var _$3 = _$5;
29818
30142
  var TextbookContentsTab = function TextbookContentsTab(props) {
29819
- var values = props.values,
30143
+ var disabled = props.disabled,
30144
+ values = props.values,
29820
30145
  setFieldValue = props.setFieldValue;
29821
- var isMath = values.type === 2;
30146
+ var isMath = values.type === TextbookEditorType.Math;
29822
30147
  var _useTranslation = reactI18next.useTranslation(),
29823
30148
  t = _useTranslation.t;
29824
30149
  var _useState = React.useState(""),
@@ -29929,7 +30254,7 @@ var TextbookContentsTab = function TextbookContentsTab(props) {
29929
30254
  return React__default.createElement(material.Stack, {
29930
30255
  direction: "column",
29931
30256
  gap: 3
29932
- }, isMath && React__default.createElement(material.Box, null, React__default.createElement(QuestionTypeFilter, {
30257
+ }, isMath && !disabled && React__default.createElement(material.Box, null, React__default.createElement(QuestionTypeFilter, {
29933
30258
  filter: filter,
29934
30259
  setFilter: setFilter,
29935
30260
  inputRef: inputRef,
@@ -29950,6 +30275,7 @@ var TextbookContentsTab = function TextbookContentsTab(props) {
29950
30275
  categories: categories,
29951
30276
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29952
30277
  questionTypes: questionTypes,
30278
+ disabled: disabled,
29953
30279
  onToggle: handleToggleBlock,
29954
30280
  onDelete: handleOpenConfirmDelete,
29955
30281
  onCopiedPrevQuestionGroup: handleCopiedPrevQuestionGroup,
@@ -29965,6 +30291,7 @@ var TextbookContentsTab = function TextbookContentsTab(props) {
29965
30291
  width: "fit-content"
29966
30292
  },
29967
30293
  variant: "contained",
30294
+ disabled: disabled,
29968
30295
  startIcon: React__default.createElement(io.IoIosAdd, null),
29969
30296
  onClick: function onClick() {
29970
30297
  var length = values.chapters.length;
@@ -29994,16 +30321,49 @@ var VisuallyHiddenInput = material.styled("input")({
29994
30321
  whiteSpace: "nowrap",
29995
30322
  width: "100%"
29996
30323
  });
30324
+ var customSelectStyles = {
30325
+ control: function control(baseStyles, state) {
30326
+ return _extends({}, baseStyles, {
30327
+ fontSize: "16px",
30328
+ fontWeight: baseStyles.fontWeight,
30329
+ color: styles.darker,
30330
+ borderColor: state.isFocused ? styles.dark : baseStyles.borderColor,
30331
+ boxShadow: state.isFocused ? "0 0 0 1px " + styles.dark + "4D" : baseStyles.boxShadow,
30332
+ "&:active": {
30333
+ borderColor: state.isFocused ? styles.dark : baseStyles.borderColor
30334
+ },
30335
+ "&:hover": {
30336
+ borderColor: state.isFocused ? styles.dark : baseStyles.borderColor
30337
+ },
30338
+ paddingBlock: '8px'
30339
+ });
30340
+ },
30341
+ singleValue: function singleValue(baseStyles) {
30342
+ return _extends({}, baseStyles, {
30343
+ fontSize: "16px",
30344
+ fontWeight: baseStyles.fontWeight,
30345
+ color: styles.darker
30346
+ });
30347
+ }
30348
+ };
29997
30349
  var TextbookInfoTab = function TextbookInfoTab(_ref) {
29998
- var setFieldValue = _ref.setFieldValue,
30350
+ var _user$roles;
30351
+ var isCreatedByAdmin = _ref.isCreatedByAdmin,
30352
+ setFieldValue = _ref.setFieldValue,
29999
30353
  values = _ref.values,
30000
30354
  errors = _ref.errors,
30001
30355
  coverImage = _ref.coverImage,
30002
- isAdmin = _ref.isAdmin,
30356
+ isSuperAdminUser = _ref.isSuperAdminUser,
30003
30357
  textbookId = _ref.textbookId,
30358
+ disabled = _ref.disabled,
30004
30359
  handleUploadImage = _ref.handleUploadImage;
30005
30360
  var _useTranslation = reactI18next.useTranslation(),
30006
30361
  t = _useTranslation.t;
30362
+ var user = reactRedux.useSelector(function (state) {
30363
+ var _state$common;
30364
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
30365
+ });
30366
+ var isTeacher = user && (user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Teacher));
30007
30367
  var gradeOptions = GRADE_OPTIONS.map(function (i) {
30008
30368
  return {
30009
30369
  label: t(i.label),
@@ -30021,6 +30381,7 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30021
30381
  value: value
30022
30382
  };
30023
30383
  });
30384
+ var hidePublicField = !textbookId && isSuperAdminUser || textbookId && isCreatedByAdmin;
30024
30385
  return React__default.createElement(material.Grid, {
30025
30386
  padding: 3,
30026
30387
  container: true,
@@ -30050,24 +30411,26 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30050
30411
  style: {
30051
30412
  padding: 4,
30052
30413
  color: "#fff",
30053
- background: styles.less_dark,
30414
+ background: !disabled ? styles.less_dark : styles.light,
30054
30415
  width: "150px",
30055
30416
  borderRadius: "6px",
30056
30417
  alignItems: "center",
30057
30418
  justifyContent: "center",
30058
30419
  position: "relative",
30059
30420
  display: "flex",
30060
- cursor: "pointer"
30421
+ cursor: disabled ? undefined : "pointer"
30061
30422
  }
30062
30423
  }, t("change_file"), React__default.createElement(VisuallyHiddenInput, {
30063
30424
  id: "coverImage",
30064
30425
  type: "file",
30065
30426
  accept: "image/*",
30066
30427
  onChange: function onChange(event) {
30067
- return handleUploadImage(event);
30428
+ return !disabled && handleUploadImage(event);
30068
30429
  },
30069
30430
  onClick: function onClick(e) {
30070
- e.target.value = "";
30431
+ if (!disabled) {
30432
+ e.target.value = "";
30433
+ }
30071
30434
  }
30072
30435
  }))) : React__default.createElement("label", {
30073
30436
  htmlFor: "coverImage",
@@ -30080,17 +30443,19 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30080
30443
  justifyContent: "center",
30081
30444
  position: "relative",
30082
30445
  display: "flex",
30083
- cursor: "pointer"
30446
+ cursor: disabled ? undefined : "pointer"
30084
30447
  }
30085
30448
  }, React__default.createElement(io.IoIosAdd, null), React__default.createElement(VisuallyHiddenInput, {
30086
30449
  id: "coverImage",
30087
30450
  type: "file",
30088
30451
  accept: "image/*",
30089
30452
  onChange: function onChange(event) {
30090
- return handleUploadImage(event);
30453
+ return !disabled && handleUploadImage(event);
30091
30454
  },
30092
30455
  onClick: function onClick(e) {
30093
- e.target.value = "";
30456
+ if (!disabled) {
30457
+ e.target.value = "";
30458
+ }
30094
30459
  }
30095
30460
  })))), React__default.createElement(material.Grid, {
30096
30461
  item: true,
@@ -30124,7 +30489,8 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30124
30489
  value: moment(value),
30125
30490
  onChange: function onChange(value) {
30126
30491
  return setFieldValue("publicationDate", moment(value).format(DATE_FORMAT));
30127
- }
30492
+ },
30493
+ disabled: disabled
30128
30494
  })));
30129
30495
  }
30130
30496
  }), !!(errors !== null && errors !== void 0 && errors.publicationDate) && React__default.createElement(material.Typography, {
@@ -30144,7 +30510,10 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30144
30510
  name: "publisher",
30145
30511
  render: function render(_ref5) {
30146
30512
  var field = _ref5.field;
30147
- return React__default.createElement(material.TextField, Object.assign({}, field));
30513
+ return React__default.createElement(material.TextField, Object.assign({}, field, {
30514
+ onKeyDown: handleKeyDown,
30515
+ disabled: disabled
30516
+ }));
30148
30517
  }
30149
30518
  }), !!(errors !== null && errors !== void 0 && errors.publisher) && React__default.createElement(material.Typography, {
30150
30519
  fontWeight: 500,
@@ -30169,6 +30538,8 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30169
30538
  onChange: function onChange(val) {
30170
30539
  setFieldValue(field.name, !(val !== null && val !== void 0 && val.value) ? 0 : Number(val.value));
30171
30540
  },
30541
+ styles: customSelectStyles,
30542
+ isDisabled: disabled || isTeacher && !textbookId,
30172
30543
  isClearable: true
30173
30544
  }));
30174
30545
  }
@@ -30189,17 +30560,20 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30189
30560
  name: "isbn",
30190
30561
  render: function render(_ref7) {
30191
30562
  var field = _ref7.field;
30192
- return React__default.createElement(material.TextField, Object.assign({}, field));
30563
+ return React__default.createElement(material.TextField, Object.assign({}, field, {
30564
+ onKeyDown: handleKeyDown,
30565
+ disabled: disabled
30566
+ }));
30193
30567
  }
30194
30568
  }), !!(errors !== null && errors !== void 0 && errors.isbn) && React__default.createElement(material.Typography, {
30195
30569
  fontWeight: 500,
30196
30570
  fontSize: "10px",
30197
30571
  lineHeight: "11.93px",
30198
30572
  color: !(errors !== null && errors !== void 0 && errors.isbn) ? "#97A1AF" : "#F34B4B"
30199
- }, errors === null || errors === void 0 ? void 0 : errors.isbn))), !(isAdmin && !textbookId) && React__default.createElement(material.Grid, {
30573
+ }, errors === null || errors === void 0 ? void 0 : errors.isbn))), React__default.createElement(material.Grid, {
30200
30574
  item: true,
30201
30575
  xs: 6
30202
- }, React__default.createElement(material.Stack, {
30576
+ }, !hidePublicField && React__default.createElement(material.Stack, {
30203
30577
  flexDirection: "column",
30204
30578
  gap: 1,
30205
30579
  alignItems: "start"
@@ -30211,7 +30585,13 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30211
30585
  var field = _ref8.field;
30212
30586
  return React__default.createElement(material.Checkbox, Object.assign({
30213
30587
  checked: field === null || field === void 0 ? void 0 : field.value
30214
- }, field));
30588
+ }, field, {
30589
+ onChange: function onChange(e, checked) {
30590
+ field.onChange(e, checked);
30591
+ if (checked) setFieldValue("textbookOwners", []);
30592
+ },
30593
+ disabled: disabled
30594
+ }));
30215
30595
  }
30216
30596
  }), !!(errors !== null && errors !== void 0 && errors.isPublic) && React__default.createElement(material.Typography, {
30217
30597
  fontWeight: 500,
@@ -30233,9 +30613,11 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30233
30613
  return React__default.createElement(CustomSelect, Object.assign({}, field, {
30234
30614
  options: gradeOptions,
30235
30615
  value: values.grade,
30616
+ styles: customSelectStyles,
30236
30617
  onChange: function onChange(val) {
30237
30618
  setFieldValue(field.name, String(val.value));
30238
- }
30619
+ },
30620
+ isDisabled: disabled
30239
30621
  }));
30240
30622
  }
30241
30623
  }), !!(errors !== null && errors !== void 0 && errors.grade) && React__default.createElement(material.Typography, {
@@ -30252,7 +30634,6 @@ var AcademySelector = function AcademySelector(_ref) {
30252
30634
  title = _ref.title,
30253
30635
  options = _ref.options,
30254
30636
  isLoading = _ref.isLoading,
30255
- valueById = _ref.valueById,
30256
30637
  isMultiple = _ref.isMultiple,
30257
30638
  _ref$isClearable = _ref.isClearable,
30258
30639
  isClearable = _ref$isClearable === void 0 ? true : _ref$isClearable,
@@ -30263,9 +30644,6 @@ var AcademySelector = function AcademySelector(_ref) {
30263
30644
  setSearchString = _useState[1];
30264
30645
  var _useTranslation = reactI18next.useTranslation(),
30265
30646
  t = _useTranslation.t;
30266
- var valueOption = valueById !== null && typeof valueById !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
30267
- return option.value == valueById;
30268
- })) || null : null;
30269
30647
  return React__default.createElement(material.FormGroup, null, !!title && React__default.createElement("label", {
30270
30648
  className: "text-muted"
30271
30649
  }, title), React__default.createElement(CustomSelectOption, {
@@ -30277,7 +30655,7 @@ var AcademySelector = function AcademySelector(_ref) {
30277
30655
  isLoading: isLoading,
30278
30656
  placeholder: t('please_select'),
30279
30657
  isMulti: isMultiple,
30280
- value: valueOption || value,
30658
+ value: value,
30281
30659
  onChange: onChange,
30282
30660
  isDisabled: disabled,
30283
30661
  isClearable: isClearable,
@@ -30295,15 +30673,12 @@ var CourseSelector = function CourseSelector(_ref) {
30295
30673
  minimumTextSearchLength = _ref.minimumTextSearchLength,
30296
30674
  placeholder = _ref.placeholder,
30297
30675
  isClearable = _ref.isClearable,
30298
- valueById = _ref.valueById;
30676
+ isDisabled = _ref.isDisabled;
30299
30677
  var _useState = React.useState(""),
30300
30678
  searchString = _useState[0],
30301
30679
  setSearchString = _useState[1];
30302
30680
  var _useTranslation = reactI18next.useTranslation(),
30303
30681
  t = _useTranslation.t;
30304
- var valueOption = valueById !== null && typeof valueById !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
30305
- return option.value == valueById;
30306
- })) || null : null;
30307
30682
  return React__default.createElement(material.FormGroup, null, !!title && React__default.createElement("label", null, title), React__default.createElement(CustomSelectOption, {
30308
30683
  options: options,
30309
30684
  inputValue: searchString,
@@ -30315,9 +30690,10 @@ var CourseSelector = function CourseSelector(_ref) {
30315
30690
  number: minimumTextSearchLength
30316
30691
  }) : t("select_class_placeholder")),
30317
30692
  isMulti: isMulti,
30318
- value: valueOption || value,
30693
+ value: value,
30319
30694
  onChange: onChange,
30320
- isClearable: isClearable
30695
+ isClearable: isClearable,
30696
+ isDisabled: isDisabled
30321
30697
  }));
30322
30698
  };
30323
30699
 
@@ -30341,7 +30717,7 @@ var useSelect = function useSelect(_ref) {
30341
30717
  isLoading = _useState2[0],
30342
30718
  setLoading = _useState2[1];
30343
30719
  React.useEffect(function () {
30344
- if (!email) return;
30720
+ if (!email || !academy) return;
30345
30721
  var fetchData = _$5.debounce(function () {
30346
30722
  try {
30347
30723
  var _temp2 = function _temp2() {
@@ -30381,12 +30757,13 @@ var useSelect = function useSelect(_ref) {
30381
30757
  };
30382
30758
 
30383
30759
  var OwnerSelector = function OwnerSelector(_ref) {
30384
- var _values$textbookOwner, _errors$textbookOwner, _errors$textbookOwner2, _values$textbookOwner2, _errors$textbookOwner3, _errors$textbookOwner4;
30760
+ var _values$textbookOwner, _errors$textbookOwner, _errors$textbookOwner2, _values$textbookOwner3, _errors$textbookOwner3, _errors$textbookOwner4;
30385
30761
  var values = _ref.values,
30386
30762
  errors = _ref.errors,
30387
30763
  index = _ref.index,
30388
30764
  email = _ref.email,
30389
- onChangeFieldValue = _ref.onChangeFieldValue;
30765
+ onChangeFieldValue = _ref.onChangeFieldValue,
30766
+ disabled = _ref.disabled;
30390
30767
  var _useSelect = useSelect({
30391
30768
  email: email
30392
30769
  }),
@@ -30394,6 +30771,14 @@ var OwnerSelector = function OwnerSelector(_ref) {
30394
30771
  isLoading = _useSelect.isLoading,
30395
30772
  academies = _useSelect.academies,
30396
30773
  courses = _useSelect.courses;
30774
+ var handleChangeAcademy = function handleChangeAcademy(val) {
30775
+ onChangeFieldValue("textbookOwners[" + index + "].academyId", val === null || val === void 0 ? void 0 : val.value);
30776
+ onChangeFieldValue("textbookOwners[" + index + "].academy", val);
30777
+ };
30778
+ var handleChangeCourse = function handleChangeCourse(val) {
30779
+ onChangeFieldValue("textbookOwners[" + index + "].courseId", val === null || val === void 0 ? void 0 : val.value);
30780
+ onChangeFieldValue("textbookOwners[" + index + "].course", val);
30781
+ };
30397
30782
  return React__default.createElement(React__default.Fragment, null, (values === null || values === void 0 ? void 0 : (_values$textbookOwner = values.textbookOwners) === null || _values$textbookOwner === void 0 ? void 0 : _values$textbookOwner[index].email) && React__default.createElement(material.Stack, {
30398
30783
  flexDirection: "column",
30399
30784
  gap: 1,
@@ -30403,16 +30788,16 @@ var OwnerSelector = function OwnerSelector(_ref) {
30403
30788
  }, t("academy")), React__default.createElement(formik.Field, {
30404
30789
  name: "textbookOwners[" + index + "].academyId",
30405
30790
  render: function render(_ref2) {
30791
+ var _values$textbookOwner2;
30406
30792
  var field = _ref2.field;
30407
30793
  return React__default.createElement(AcademySelector, Object.assign({}, field, {
30408
30794
  options: academies,
30409
30795
  disabled: true,
30410
- defaultValue: academies.length > 0 ? academies[0].value : undefined,
30796
+ value: (_values$textbookOwner2 = values.textbookOwners[index]) === null || _values$textbookOwner2 === void 0 ? void 0 : _values$textbookOwner2.academy,
30411
30797
  isLoading: isLoading,
30412
30798
  valueById: field === null || field === void 0 ? void 0 : field.value,
30413
- onChange: function onChange(val) {
30414
- return onChangeFieldValue("textbookOwners[" + index + "].academyId", val === null || val === void 0 ? void 0 : val.value);
30415
- }
30799
+ onChange: handleChangeAcademy,
30800
+ isDisabled: disabled
30416
30801
  }));
30417
30802
  }
30418
30803
  }), !!(errors !== null && errors !== void 0 && (_errors$textbookOwner = errors.textbookOwners) !== null && _errors$textbookOwner !== void 0 && (_errors$textbookOwner2 = _errors$textbookOwner[index]) !== null && _errors$textbookOwner2 !== void 0 && _errors$textbookOwner2.academyId) && React__default.createElement(material.Typography, {
@@ -30420,7 +30805,7 @@ var OwnerSelector = function OwnerSelector(_ref) {
30420
30805
  fontSize: "10px",
30421
30806
  lineHeight: "11.93px",
30422
30807
  color: !(errors !== null && errors !== void 0 && errors.textbookOwners[index].academyId) ? "#97A1AF" : "#F34B4B"
30423
- }, errors === null || errors === void 0 ? void 0 : errors.textbookOwners[index].academyId)), (values === null || values === void 0 ? void 0 : (_values$textbookOwner2 = values.textbookOwners) === null || _values$textbookOwner2 === void 0 ? void 0 : _values$textbookOwner2[index].email) && React__default.createElement(material.Stack, {
30808
+ }, errors === null || errors === void 0 ? void 0 : errors.textbookOwners[index].academyId)), (values === null || values === void 0 ? void 0 : (_values$textbookOwner3 = values.textbookOwners) === null || _values$textbookOwner3 === void 0 ? void 0 : _values$textbookOwner3[index].email) && React__default.createElement(material.Stack, {
30424
30809
  flexDirection: "column",
30425
30810
  gap: 1,
30426
30811
  width: 1
@@ -30429,14 +30814,14 @@ var OwnerSelector = function OwnerSelector(_ref) {
30429
30814
  }, t("class")), React__default.createElement(formik.Field, {
30430
30815
  name: "textbookOwners[" + index + "].courseId",
30431
30816
  render: function render(_ref3) {
30817
+ var _values$textbookOwner4;
30432
30818
  var field = _ref3.field;
30433
30819
  return React__default.createElement(CourseSelector, Object.assign({}, field, {
30434
30820
  options: courses,
30435
30821
  isLoading: isLoading,
30436
- valueById: field === null || field === void 0 ? void 0 : field.value,
30437
- onChange: function onChange(val) {
30438
- return onChangeFieldValue("textbookOwners[" + index + "].courseId", val === null || val === void 0 ? void 0 : val.value);
30439
- }
30822
+ value: (_values$textbookOwner4 = values.textbookOwners[index]) === null || _values$textbookOwner4 === void 0 ? void 0 : _values$textbookOwner4.course,
30823
+ onChange: handleChangeCourse,
30824
+ isDisabled: disabled
30440
30825
  }));
30441
30826
  }
30442
30827
  }), !!(errors !== null && errors !== void 0 && (_errors$textbookOwner3 = errors.textbookOwners) !== null && _errors$textbookOwner3 !== void 0 && (_errors$textbookOwner4 = _errors$textbookOwner3[index]) !== null && _errors$textbookOwner4 !== void 0 && _errors$textbookOwner4.courseId) && React__default.createElement(material.Typography, {
@@ -30451,10 +30836,16 @@ var _$4 = _$5;
30451
30836
  var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30452
30837
  var errors = _ref.errors,
30453
30838
  values = _ref.values,
30839
+ disabled = _ref.disabled,
30454
30840
  setFieldValue = _ref.setFieldValue;
30455
30841
  var textbookOwners = values.textbookOwners;
30842
+ var academy = reactRedux.useSelector(function (state) {
30843
+ var _state$common;
30844
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.academy;
30845
+ });
30456
30846
  var _useTranslation = reactI18next.useTranslation(),
30457
30847
  t = _useTranslation.t;
30848
+ var hasErrors = errors.textbookOwners;
30458
30849
  return React__default.createElement(material.Box, {
30459
30850
  className: "bg-white mt-2",
30460
30851
  sx: {
@@ -30467,15 +30858,15 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30467
30858
  return React__default.createElement(material.Grid, {
30468
30859
  container: true,
30469
30860
  spacing: "16px"
30470
- }, textbookOwners === null || textbookOwners === void 0 ? void 0 : textbookOwners.map(function (_val, index) {
30471
- var _values$textbookOwner, _values$textbookOwner2;
30861
+ }, textbookOwners === null || textbookOwners === void 0 ? void 0 : textbookOwners.map(function (val, index) {
30862
+ var _errors$textbookOwner, _values$textbookOwner, _values$textbookOwner2;
30472
30863
  return React__default.createElement(material.Grid, {
30473
30864
  item: true,
30474
30865
  xs: 6,
30475
- lg: 2
30866
+ lg: 3
30476
30867
  }, React__default.createElement(material.Stack, {
30477
30868
  sx: {
30478
- border: "1px solid " + styles.gray_300,
30869
+ border: "1px solid " + ((_errors$textbookOwner = errors.textbookOwners) !== null && _errors$textbookOwner !== void 0 && _errors$textbookOwner[index] ? styles.red_900 : styles.gray_300),
30479
30870
  borderRadius: "6px",
30480
30871
  width: "100%",
30481
30872
  height: "350px",
@@ -30493,6 +30884,7 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30493
30884
  top: 8,
30494
30885
  color: styles.gray_500
30495
30886
  },
30887
+ disabled: disabled || !!val.academyId && val.academyId !== (academy === null || academy === void 0 ? void 0 : academy.id),
30496
30888
  onClick: function onClick() {
30497
30889
  arrayHelpers.remove(index);
30498
30890
  }
@@ -30508,24 +30900,28 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30508
30900
  var field = _ref2.field;
30509
30901
  return React__default.createElement(material.TextField, Object.assign({
30510
30902
  fullWidth: true
30511
- }, field));
30903
+ }, field, {
30904
+ onKeyDown: handleKeyDown,
30905
+ disabled: disabled || !!val.academyId && val.academyId !== (academy === null || academy === void 0 ? void 0 : academy.id)
30906
+ }));
30512
30907
  }
30513
30908
  }), _$4.get(errors, "textbookOwners[" + index + "].email") && React__default.createElement(material.Typography, {
30514
30909
  fontWeight: 500,
30515
30910
  fontSize: "10px",
30516
30911
  lineHeight: "11.93px",
30517
- color: _$4.get(errors, "textbookOwners[" + index + "].email") ? "#97A1AF" : "#F34B4B"
30912
+ color: "#F34B4B"
30518
30913
  }, _$4.get(errors, "textbookOwners[" + index + "].email"))), !!(values !== null && values !== void 0 && (_values$textbookOwner = values.textbookOwners) !== null && _values$textbookOwner !== void 0 && _values$textbookOwner[index].email) && React__default.createElement(OwnerSelector, {
30519
30914
  values: values,
30520
30915
  errors: errors,
30521
30916
  index: index,
30522
30917
  email: values === null || values === void 0 ? void 0 : (_values$textbookOwner2 = values.textbookOwners) === null || _values$textbookOwner2 === void 0 ? void 0 : _values$textbookOwner2[index].email,
30523
- onChangeFieldValue: setFieldValue
30918
+ onChangeFieldValue: setFieldValue,
30919
+ disabled: disabled || !!val.academyId && val.academyId !== (academy === null || academy === void 0 ? void 0 : academy.id)
30524
30920
  })));
30525
- }), React__default.createElement(material.Grid, {
30921
+ }), !hasErrors && !disabled && academy && React__default.createElement(material.Grid, {
30526
30922
  item: true,
30527
30923
  xs: 6,
30528
- lg: 2
30924
+ lg: 3
30529
30925
  }, React__default.createElement("div", {
30530
30926
  style: {
30531
30927
  display: "flex",
@@ -30539,7 +30935,14 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30539
30935
  background: styles.gray_50
30540
30936
  },
30541
30937
  onClick: function onClick() {
30542
- return arrayHelpers.push(DefaultTextbookOwner);
30938
+ var _academy$id;
30939
+ arrayHelpers.push(_extends({}, DefaultTextbookOwner, {
30940
+ academy: academy ? {
30941
+ label: academy.name,
30942
+ value: academy.id
30943
+ } : null,
30944
+ academyId: (_academy$id = academy === null || academy === void 0 ? void 0 : academy.id) != null ? _academy$id : null
30945
+ }));
30543
30946
  }
30544
30947
  }, React__default.createElement(material.Stack, null, React__default.createElement(io.IoMdAdd, {
30545
30948
  size: 24
@@ -30548,158 +30951,17 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30548
30951
  }));
30549
30952
  };
30550
30953
 
30551
- var _reduceToMathArticles = function reduceToMathArticles(textbook, isMath) {
30552
- var values = isMath !== undefined ? _$5.cloneDeep(textbook) : textbook;
30553
- if (isMath !== undefined) values.type = isMath;
30554
- for (var key in values) {
30555
- if (values.hasOwnProperty(key)) {
30556
- if (key === "articles") {
30557
- var _values$key;
30558
- values[key] = (_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.length ? [values[key][0]] : [DEFAULT_ARTICLE];
30559
- } else if (typeof values[key] === "object" && values[key] !== null) {
30560
- _reduceToMathArticles(values[key]);
30561
- }
30562
- }
30563
- }
30564
- return values;
30565
- };
30566
- var _resetAllCategoriesAndQuestionTypesBySubject = function resetAllCategoriesAndQuestionTypesBySubject(textbook, subject) {
30567
- var values = subject ? _$5.cloneDeep(textbook) : textbook;
30568
- if (subject) {
30569
- values.subjectId = subject === null || subject === void 0 ? void 0 : subject.value;
30570
- values.subject = subject;
30571
- }
30572
- for (var key in values) {
30573
- if (values.hasOwnProperty(key)) {
30574
- if (key === "categories" || key === "categoryOptions") {
30575
- values[key] = [];
30576
- } else if (key === "questionType" || key === "questionTypeId") {
30577
- values[key] = null;
30578
- } else if (typeof values[key] === "object" && values[key] !== null) {
30579
- _resetAllCategoriesAndQuestionTypesBySubject(values[key]);
30580
- }
30581
- }
30582
- }
30583
- return values;
30584
- };
30585
- var convertResponseToRequest = function convertResponseToRequest(selectedTextbook) {
30586
- var _selectedTextbook$sub;
30587
- if (!selectedTextbook) return DEFAULT_TEXTBOOK_REQUEST;
30588
- return {
30589
- name: selectedTextbook.name || "",
30590
- subjectId: ((_selectedTextbook$sub = selectedTextbook.subject) === null || _selectedTextbook$sub === void 0 ? void 0 : _selectedTextbook$sub.id) || 0,
30591
- subject: selectedTextbook.subject ? {
30592
- label: selectedTextbook.subject.name,
30593
- value: selectedTextbook.subject.id
30594
- } : null,
30595
- preparedType: selectedTextbook.preparedType || 0,
30596
- grade: selectedTextbook.grade || "1",
30597
- publicationDate: (selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.publicationDate) || "",
30598
- publisher: selectedTextbook.publisher || "",
30599
- isbn: selectedTextbook.isbn || "",
30600
- coverImage: selectedTextbook.coverImage || "",
30601
- textbookOwners: selectedTextbook.textbookOwners,
30602
- isPublic: selectedTextbook.isPublic || false,
30603
- isShared: selectedTextbook.isShared || false,
30604
- isPrepared: true,
30605
- type: selectedTextbook.type,
30606
- chapters: selectedTextbook.chapters.map(function (c) {
30607
- var _c$questionGroups;
30608
- return {
30609
- name: c.name,
30610
- pageFrom: c.pageFrom || 0,
30611
- pageTo: c.pageTo || 0,
30612
- id: c.id,
30613
- questionGroups: ((_c$questionGroups = c.questionGroups) === null || _c$questionGroups === void 0 ? void 0 : _c$questionGroups.map(function (g) {
30614
- var _g$questions$;
30615
- return {
30616
- id: g.id,
30617
- chapterId: c.id,
30618
- questions: g.questions.map(function (q) {
30619
- var _q$questionType;
30620
- return _extends({}, q, {
30621
- questionTypeId: q.questionTypeId || q.questionType.id,
30622
- questionType: (_q$questionType = q.questionType) !== null && _q$questionType !== void 0 && _q$questionType.id ? {
30623
- label: q.questionType.name,
30624
- value: q.questionType.id
30625
- } : null
30626
- });
30627
- }),
30628
- articles: g.articles.map(function (a) {
30629
- return _extends({}, a, {
30630
- categoryOptions: a.categories.map(function (cat) {
30631
- return {
30632
- label: cat.name,
30633
- value: cat.id
30634
- };
30635
- }),
30636
- categories: a.categories.filter(function (cat) {
30637
- return !!cat.id;
30638
- }).map(function (cat) {
30639
- return cat.id;
30640
- })
30641
- });
30642
- }),
30643
- questionCount: g.questions.length,
30644
- answerCount: ((_g$questions$ = g.questions[0]) === null || _g$questions$ === void 0 ? void 0 : _g$questions$.numberOfAnswers) || 5
30645
- };
30646
- })) || [],
30647
- subChapters: c.subChapters.map(function (sub) {
30648
- var _sub$questionGroups;
30649
- return {
30650
- name: sub.name,
30651
- pageFrom: sub.pageFrom || 0,
30652
- pageTo: sub.pageTo || 0,
30653
- id: sub.id,
30654
- questionGroups: ((_sub$questionGroups = sub.questionGroups) === null || _sub$questionGroups === void 0 ? void 0 : _sub$questionGroups.map(function (g) {
30655
- var _g$questions$2;
30656
- return {
30657
- id: g.id,
30658
- chapterId: c.id,
30659
- questions: g.questions.map(function (q) {
30660
- var _q$questionType2;
30661
- return _extends({}, q, {
30662
- questionTypeId: q.questionTypeId || q.questionType.id,
30663
- questionType: (_q$questionType2 = q.questionType) !== null && _q$questionType2 !== void 0 && _q$questionType2.id ? {
30664
- label: q.questionType.name,
30665
- value: q.questionType.id
30666
- } : null
30667
- });
30668
- }),
30669
- articles: g.articles.map(function (a) {
30670
- return _extends({}, a, {
30671
- categoryOptions: a.categories.map(function (cat) {
30672
- return {
30673
- label: cat.name,
30674
- value: cat.id
30675
- };
30676
- }),
30677
- categories: a.categories.filter(function (cat) {
30678
- return !!cat.id;
30679
- }).map(function (cat) {
30680
- return cat.id;
30681
- })
30682
- });
30683
- }),
30684
- questionCount: g.questions.length,
30685
- answerCount: ((_g$questions$2 = g.questions[0]) === null || _g$questions$2 === void 0 ? void 0 : _g$questions$2.numberOfAnswers) || 5
30686
- };
30687
- })) || [],
30688
- subChapters: []
30689
- };
30690
- })
30691
- };
30692
- })
30693
- };
30694
- };
30695
-
30696
- var _excluded$l = ["isSuperAdmin", "isAdmin", "textbookId", "selected", "coverImage", "onChangeTab", "onUploadImage"];
30954
+ var _excluded$l = ["isCreatedByAdmin", "isSuperAdminUser", "isSuperAdmin", "isAdmin", "textbookId", "selected", "coverImage", "disabled", "ownersDisabled", "onChangeTab", "onUploadImage"];
30697
30955
  var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30698
- var isSuperAdmin = _ref.isSuperAdmin,
30956
+ var isCreatedByAdmin = _ref.isCreatedByAdmin,
30957
+ isSuperAdminUser = _ref.isSuperAdminUser,
30958
+ isSuperAdmin = _ref.isSuperAdmin,
30699
30959
  isAdmin = _ref.isAdmin,
30700
30960
  textbookId = _ref.textbookId,
30701
30961
  selected = _ref.selected,
30702
30962
  coverImage = _ref.coverImage,
30963
+ disabled = _ref.disabled,
30964
+ ownersDisabled = _ref.ownersDisabled,
30703
30965
  onChangeTab = _ref.onChangeTab,
30704
30966
  onUploadImage = _ref.onUploadImage,
30705
30967
  formikProps = _objectWithoutPropertiesLoose(_ref, _excluded$l);
@@ -30720,7 +30982,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30720
30982
  };
30721
30983
  }, [dirty, i18n.t]);
30722
30984
  var handleChangeTextbookType = function handleChangeTextbookType() {
30723
- var isMath = values.type === 2 ? 1 : 2;
30985
+ var isMath = values.type === TextbookEditorType.Math ? TextbookEditorType.Korea : TextbookEditorType.Math;
30724
30986
  var newValues = _reduceToMathArticles(values, isMath);
30725
30987
  setValues(newValues);
30726
30988
  };
@@ -30757,7 +31019,9 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30757
31019
  return React__default.createElement(material.TextField, Object.assign({
30758
31020
  placeholder: i18n.t("title")
30759
31021
  }, field, {
30760
- size: "small"
31022
+ size: "small",
31023
+ disabled: disabled,
31024
+ onKeyDown: handleKeyDown
30761
31025
  }));
30762
31026
  }
30763
31027
  }), !!(errors !== null && errors !== void 0 && errors.name) && React__default.createElement(material.Typography, {
@@ -30777,7 +31041,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30777
31041
  var field = _ref3.field;
30778
31042
  return React__default.createElement(SubjectSelector, Object.assign({}, field, {
30779
31043
  value: values.subject,
30780
- isDisabled: !!textbookId,
31044
+ isDisabled: !!textbookId || disabled,
30781
31045
  onChange: handleChangeSubject
30782
31046
  }));
30783
31047
  }
@@ -30799,7 +31063,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30799
31063
  var field = _ref4.field;
30800
31064
  return React__default.createElement(material.Switch, Object.assign({}, field, {
30801
31065
  color: "success",
30802
- disabled: !!textbookId,
31066
+ disabled: !!textbookId || disabled,
30803
31067
  checked: values.type === 2,
30804
31068
  onChange: handleChangeTextbookType
30805
31069
  }));
@@ -30810,6 +31074,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30810
31074
  width: "fit-content"
30811
31075
  },
30812
31076
  variant: "contained",
31077
+ disabled: disabled,
30813
31078
  onClick: function onClick() {
30814
31079
  if (!_$5.isEmpty(errors)) {
30815
31080
  reactToastify.toast.error(i18n.t("please_fill_in_the_blank_fields"));
@@ -30852,7 +31117,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30852
31117
  sx: {
30853
31118
  color: contentsErrors && submitCount ? error.main + "!important" : "gray"
30854
31119
  }
30855
- }, a11yProps(1))), !(values !== null && values !== void 0 && values.isPublic) && (!isSuperAdmin || textbookId) && (!textbookId || (values === null || values === void 0 ? void 0 : values.isShared)) && React__default.createElement(material.Tab, Object.assign({
31120
+ }, a11yProps(1))), !(values !== null && values !== void 0 && values.isPublic) && (!isSuperAdmin || textbookId) && (!textbookId && !isAdmin || (values === null || values === void 0 ? void 0 : values.isShared)) && React__default.createElement(material.Tab, Object.assign({
30856
31121
  label: i18n.t("textbook.owners"),
30857
31122
  sx: {
30858
31123
  color: textbookOwnersErrors && submitCount ? error.main + "!important" : "gray"
@@ -30864,14 +31129,20 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30864
31129
  coverImage: coverImage,
30865
31130
  handleUploadImage: onUploadImage,
30866
31131
  textbookId: textbookId,
30867
- isAdmin: isAdmin
31132
+ disabled: disabled,
31133
+ isCreatedByAdmin: isCreatedByAdmin,
31134
+ isSuperAdminUser: isSuperAdminUser
30868
31135
  }))), React__default.createElement(CustomTextbookTab, {
30869
31136
  value: selected,
30870
31137
  index: 1
30871
- }, React__default.createElement(TextbookContentsTab, Object.assign({}, formikProps))), React__default.createElement(CustomTextbookTab, {
31138
+ }, React__default.createElement(TextbookContentsTab, Object.assign({}, formikProps, {
31139
+ disabled: disabled
31140
+ }))), React__default.createElement(CustomTextbookTab, {
30872
31141
  value: selected,
30873
31142
  index: 2
30874
- }, React__default.createElement(TextbookOwnersTab, Object.assign({}, formikProps))))));
31143
+ }, React__default.createElement(TextbookOwnersTab, Object.assign({}, formikProps, {
31144
+ disabled: ownersDisabled
31145
+ }))))));
30875
31146
  };
30876
31147
  var a11yProps = function a11yProps(index) {
30877
31148
  return {
@@ -30881,7 +31152,8 @@ var a11yProps = function a11yProps(index) {
30881
31152
  };
30882
31153
 
30883
31154
  var PreparedTextbookView = function PreparedTextbookView(_ref) {
30884
- var notFoundView = _ref.notFoundView,
31155
+ var role = _ref.role,
31156
+ notFoundView = _ref.notFoundView,
30885
31157
  onBackToList = _ref.onBackToList,
30886
31158
  textbookId = _ref.textbookId;
30887
31159
  var _useState = React.useState(0),
@@ -30892,10 +31164,15 @@ var PreparedTextbookView = function PreparedTextbookView(_ref) {
30892
31164
  };
30893
31165
  var _useTextbookManagemen = useTextbookManagement({
30894
31166
  onNavigateList: onBackToList,
30895
- textbookId: textbookId
31167
+ textbookId: textbookId,
31168
+ role: role
30896
31169
  }),
30897
31170
  t = _useTextbookManagemen.t,
31171
+ disabledTextbookOwners = _useTextbookManagemen.disabledTextbookOwners,
31172
+ isReadonly = _useTextbookManagemen.isReadonly,
31173
+ isEditable = _useTextbookManagemen.isEditable,
30898
31174
  isSuperAdmin = _useTextbookManagemen.isSuperAdmin,
31175
+ isSuperAdminUser = _useTextbookManagemen.isSuperAdminUser,
30899
31176
  isAdmin = _useTextbookManagemen.isAdmin,
30900
31177
  coverImage = _useTextbookManagemen.coverImage,
30901
31178
  selectedTextbook = _useTextbookManagemen.selectedTextbook,
@@ -30904,6 +31181,7 @@ var PreparedTextbookView = function PreparedTextbookView(_ref) {
30904
31181
  var textbookRequest = React.useMemo(function () {
30905
31182
  return convertResponseToRequest(selectedTextbook);
30906
31183
  }, [JSON.stringify(selectedTextbook)]);
31184
+ var isCreatedByAdmin = selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.isCreatedByAdmin;
30907
31185
  if (textbookId && selectedTextbook && !selectedTextbook.isPrepared) return notFoundView;
30908
31186
  return React__default.createElement(material.Box, null, React__default.createElement(formik.Formik, {
30909
31187
  initialValues: textbookRequest,
@@ -30914,13 +31192,17 @@ var PreparedTextbookView = function PreparedTextbookView(_ref) {
30914
31192
  onSubmit: handleSubmit
30915
31193
  }, function (props) {
30916
31194
  return React__default.createElement(PreparedTextbookForm, Object.assign({
31195
+ isCreatedByAdmin: isCreatedByAdmin,
31196
+ isSuperAdminUser: isSuperAdminUser,
30917
31197
  isAdmin: isAdmin,
30918
31198
  isSuperAdmin: isSuperAdmin,
30919
31199
  selected: selected,
30920
31200
  textbookId: textbookId,
30921
31201
  onChangeTab: handleChangeTab,
30922
31202
  onUploadImage: handleUploadImage,
30923
- coverImage: coverImage
31203
+ coverImage: coverImage,
31204
+ disabled: isReadonly || !isEditable,
31205
+ ownersDisabled: isReadonly || disabledTextbookOwners
30924
31206
  }, props));
30925
31207
  }));
30926
31208
  };