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
@@ -16,7 +16,7 @@ import React__default, { useState, useEffect, Fragment as Fragment$1, useRef, us
16
16
  import { useTheme, Container, Typography, Stack, List, ListItem, FormGroup, FormControlLabel, Checkbox, Button, Box, Dialog, DialogTitle, IconButton, DialogContent, TextField, DialogActions, styled, FormLabel, Pagination, Paper, InputBase, Tooltip, tooltipClasses, Grid, ClickAwayListener, useMediaQuery, CircularProgress, InputAdornment, Card as Card$1, Avatar, Table, TableHead, TableRow, TableCell, TableBody, TableContainer, RadioGroup, Radio, FormControl, InputLabel, Chip, Accordion, AccordionSummary, AccordionDetails, Switch, Tabs, Tab, Divider, CardMedia as CardMedia$1, MenuList } from '@mui/material';
17
17
  import moment from 'moment';
18
18
  export { default as moment } from 'moment';
19
- import { FaSave, FaCaretDown, FaTimes, FaTrash, FaSortUp, FaSortDown, FaPlus, FaPlusCircle, FaUpload, FaEye as FaEye$1, FaPencilAlt, FaShare, FaExchangeAlt, FaBookOpen } from 'react-icons/fa';
19
+ import { FaSave, FaCaretDown, FaTimes, FaTrash, FaSortUp, FaSortDown, FaPlus, FaPlusCircle, FaUpload, FaEye as FaEye$1, FaPencilAlt, FaCheckCircle, FaShare, FaExchangeAlt, FaBookOpen } from 'react-icons/fa';
20
20
  import { IoMdArrowBack, IoIosAdd, IoMdAdd, IoIosAlert, IoIosArrowDown, IoIosSearch, IoIosArrowUp } from 'react-icons/io';
21
21
  import { IoClose, IoSearch, IoCloseOutline, IoChevronUp, IoChevronDown, IoChatbubbleEllipsesSharp, IoPrint, IoWarning, IoCheckmarkCircle, IoChevronUpOutline, IoChevronDownOutline, IoReceiptSharp, IoBook, IoCalendarClear, IoPerson, IoInformationCircle, IoTrash, IoAddCircle, IoCloseCircle, IoLogOut } from 'react-icons/io5';
22
22
  import { useSelector, useDispatch } from 'react-redux';
@@ -1247,7 +1247,7 @@ var number_of_participants = "참가자 수";
1247
1247
  var chapter = "챕터";
1248
1248
  var published = "Published";
1249
1249
  var privated = "Privated";
1250
- var solution_results = "버튼 텍스트";
1250
+ var solution_results = "풀이 결과";
1251
1251
  var do_you_want_to_reset_your_search_criteria = "검색 조건을 초기화 하시겠습니까?";
1252
1252
  var the_search_keywords_you_enter_will_be_saved = "입력한 검색 키워드는 저장됩니다.";
1253
1253
  var no_search_results = "검색 결과가 없어요.";
@@ -1460,6 +1460,11 @@ var text_group_n = "지문 그룹 {{n}}";
1460
1460
  var text_detail_n = "지문 상세 {{n}}";
1461
1461
  var question_group_n = "문제 그룹 {{n}}";
1462
1462
  var placeholder_teacher_selector = "선생님을 검색하려면 최소 2글자를 입력하세요.";
1463
+ var teacher_personal_textbook = "교사의 개인 교과서";
1464
+ var textbook_owner_email_is_required = "교재 소유자의 이메일은 필수입니다";
1465
+ var invalid_textbook_owner_email_address = "유효하지 않은 교재 소유자 이메일 주소입니다";
1466
+ var textbook_owner_academy_is_required = "교재 소유자의 학원은 필수입니다";
1467
+ var textbook_owner_course_is_required = "교재 소유자의 수업은 필수입니다";
1463
1468
  var lang_ko = {
1464
1469
  problem_solving: problem_solving,
1465
1470
  my_story: my_story,
@@ -2553,7 +2558,12 @@ var lang_ko = {
2553
2558
  text_group_n: text_group_n,
2554
2559
  text_detail_n: text_detail_n,
2555
2560
  question_group_n: question_group_n,
2556
- placeholder_teacher_selector: placeholder_teacher_selector
2561
+ placeholder_teacher_selector: placeholder_teacher_selector,
2562
+ teacher_personal_textbook: teacher_personal_textbook,
2563
+ textbook_owner_email_is_required: textbook_owner_email_is_required,
2564
+ invalid_textbook_owner_email_address: invalid_textbook_owner_email_address,
2565
+ textbook_owner_academy_is_required: textbook_owner_academy_is_required,
2566
+ textbook_owner_course_is_required: textbook_owner_course_is_required
2557
2567
  };
2558
2568
 
2559
2569
  var problem_solving$1 = "Problem Solving";
@@ -3670,6 +3680,11 @@ var text_group_n$1 = "Text group {{n}}";
3670
3680
  var text_detail_n$1 = "Text details {{n}}";
3671
3681
  var question_group_n$1 = "Question group {{n}}";
3672
3682
  var placeholder_teacher_selector$1 = "Type at least 2 characters to search teacher";
3683
+ var teacher_personal_textbook$1 = "Teacher personal textbook";
3684
+ var textbook_owner_email_is_required$1 = "Textbook owner email is required";
3685
+ var invalid_textbook_owner_email_address$1 = "Invalid textbook owner email address";
3686
+ var textbook_owner_academy_is_required$1 = "Textbook owner academy is required";
3687
+ var textbook_owner_course_is_required$1 = "Textbook owner class is required";
3673
3688
  var lang_en = {
3674
3689
  problem_solving: problem_solving$1,
3675
3690
  my_story: my_story$1,
@@ -4765,7 +4780,12 @@ var lang_en = {
4765
4780
  text_group_n: text_group_n$1,
4766
4781
  text_detail_n: text_detail_n$1,
4767
4782
  question_group_n: question_group_n$1,
4768
- placeholder_teacher_selector: placeholder_teacher_selector$1
4783
+ placeholder_teacher_selector: placeholder_teacher_selector$1,
4784
+ teacher_personal_textbook: teacher_personal_textbook$1,
4785
+ textbook_owner_email_is_required: textbook_owner_email_is_required$1,
4786
+ invalid_textbook_owner_email_address: invalid_textbook_owner_email_address$1,
4787
+ textbook_owner_academy_is_required: textbook_owner_academy_is_required$1,
4788
+ textbook_owner_course_is_required: textbook_owner_course_is_required$1
4769
4789
  };
4770
4790
 
4771
4791
  i18n.use(initReactI18next).init({
@@ -5881,7 +5901,7 @@ var CustomCreatable = function CustomCreatable(_ref) {
5881
5901
  }, rest));
5882
5902
  };
5883
5903
 
5884
- var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti", "optionValue"];
5904
+ var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti", "optionValue", "styles"];
5885
5905
  var CustomSelect = function CustomSelect(_ref) {
5886
5906
  var isDefault = _ref.isDefault,
5887
5907
  options = _ref.options,
@@ -5890,6 +5910,7 @@ var CustomSelect = function CustomSelect(_ref) {
5890
5910
  value = _ref.value,
5891
5911
  isMulti = _ref.isMulti,
5892
5912
  optionValue = _ref.optionValue,
5913
+ styles = _ref.styles,
5893
5914
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
5894
5915
  var _useTranslation = useTranslation(),
5895
5916
  t = _useTranslation.t;
@@ -5914,7 +5935,7 @@ var CustomSelect = function CustomSelect(_ref) {
5914
5935
  DropdownIndicator: DropdownIndicator,
5915
5936
  Option: CustomOption
5916
5937
  },
5917
- styles: customStyles,
5938
+ styles: _extends({}, customStyles, styles),
5918
5939
  placeholder: t("select_placeholder")
5919
5940
  }, rest));
5920
5941
  };
@@ -26314,9 +26335,11 @@ var TextbookViewDetail = function TextbookViewDetail(props) {
26314
26335
 
26315
26336
  var PAGE_TITLE$7 = "textbooks";
26316
26337
  var useTextbookList = function useTextbookList(props) {
26338
+ var _user$roles, _user$roles2;
26317
26339
  var onNavigateCreate = props.onNavigateCreate,
26318
26340
  onNavigateDetail = props.onNavigateDetail,
26319
- isSuperAdmin = props.isSuperAdmin;
26341
+ isSuperAdmin = props.isSuperAdmin,
26342
+ role = props.role;
26320
26343
  var _useList = useList(function (search) {
26321
26344
  return getTextbookListApi(search, isSuperAdmin);
26322
26345
  }, TextbookDefaultQuery),
@@ -26331,14 +26354,21 @@ var useTextbookList = function useTextbookList(props) {
26331
26354
  calcOrderNumber = _useList.calcOrderNumber,
26332
26355
  handleChangeSelectedItem = _useList.handleChangeSelectedItem,
26333
26356
  getData = _useList.getData;
26357
+ var user = useSelector(function (state) {
26358
+ var _state$common;
26359
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
26360
+ });
26361
+ var isTeacherSite = role === Role.Teacher;
26362
+ var isAdmin = !!user && ((_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(Role.Admin));
26363
+ var isTeacher = !!user && ((_user$roles2 = user.roles) === null || _user$roles2 === void 0 ? void 0 : _user$roles2.includes(Role.Teacher)) && !isAdmin;
26334
26364
  var _useTranslation = useTranslation(),
26335
26365
  t = _useTranslation.t;
26336
26366
  var dispatch = useDispatch();
26337
26367
  var handleViewTextbook = function handleViewTextbook(data) {
26338
- onNavigateDetail(data, true, true);
26368
+ onNavigateDetail(data, true, false);
26339
26369
  };
26340
26370
  var handleUpdateTextbook = function handleUpdateTextbook(data) {
26341
- onNavigateDetail(data, false, true);
26371
+ onNavigateDetail(data, false, false);
26342
26372
  };
26343
26373
  var handleCreateTextbook = function handleCreateTextbook() {
26344
26374
  onNavigateCreate === null || onNavigateCreate === void 0 ? void 0 : onNavigateCreate();
@@ -26374,6 +26404,9 @@ var useTextbookList = function useTextbookList(props) {
26374
26404
  document.title = t("study_peak") + " | " + t(PAGE_TITLE$7);
26375
26405
  }, [t]);
26376
26406
  return {
26407
+ user: user,
26408
+ isTeacherSite: isTeacherSite,
26409
+ isTeacher: isTeacher,
26377
26410
  filter: filter,
26378
26411
  textSearchRef: textSearchRef,
26379
26412
  getData: getData,
@@ -26612,8 +26645,6 @@ var useTextbookShare = function useTextbookShare(props) {
26612
26645
  });
26613
26646
  var isAdmin = infoUser && (infoUser === null || infoUser === void 0 ? void 0 : (_infoUser$roles = infoUser.roles) === null || _infoUser$roles === void 0 ? void 0 : _infoUser$roles.includes(Role.Admin));
26614
26647
  var isAdminSite = role === Role.Admin;
26615
- var onAcademy = !!infoUser.academyDomain;
26616
- var isSuperAdminUser = infoUser && infoUser.isSuperAdmin;
26617
26648
  useEffect(function () {
26618
26649
  if (!isUpdate) {
26619
26650
  filterTeacherNotShared(currentModel);
@@ -26704,12 +26735,6 @@ var useTextbookShare = function useTextbookShare(props) {
26704
26735
  });
26705
26736
  setShared(existsTeachers);
26706
26737
  };
26707
- var enabledSave = function enabledSave(textbook) {
26708
- return onAcademy && (isAdminSite || isSuperAdmin || isSuperAdminUser || !isAdmin && textbook.isShared && textbook.createdBy.id === infoUser.id);
26709
- };
26710
- var enabledShare = function enabledShare(textbook) {
26711
- return textbook.isShared && onAcademy && (isAdminSite || isSuperAdminUser || !isAdmin && textbook.createdBy.id === infoUser.id);
26712
- };
26713
26738
  var handleShareTextbook = function handleShareTextbook(teacherIds, textbookId) {
26714
26739
  try {
26715
26740
  var _temp2 = function _temp2() {
@@ -26786,19 +26811,117 @@ var useTextbookShare = function useTextbookShare(props) {
26786
26811
  isUpdate: isUpdate,
26787
26812
  handleUpdateSharedTextbook: handleUpdateSharedTextbook,
26788
26813
  currentModel: currentModel,
26789
- enabledSave: enabledSave,
26790
- enabledShare: enabledShare,
26791
26814
  isAdmin: isAdmin,
26792
26815
  isAdminSite: isAdminSite
26793
26816
  };
26794
26817
  };
26795
26818
 
26819
+ var TextbookRow = function TextbookRow(_ref) {
26820
+ var _infoUser$roles, _infoUser$roles2, _data$createdBy, _data$textbookOwners, _data$createdBy2, _data$createdBy3;
26821
+ var index = _ref.index,
26822
+ data = _ref.data,
26823
+ role = _ref.role,
26824
+ isSuperAdmin = _ref.isSuperAdmin,
26825
+ calcOrderNumber = _ref.calcOrderNumber,
26826
+ onUpdateTextbook = _ref.onUpdateTextbook,
26827
+ onDeleteTextbook = _ref.onDeleteTextbook,
26828
+ onViewTextbook = _ref.onViewTextbook,
26829
+ onShareTextbook = _ref.onShareTextbook,
26830
+ onUpdateShareTextbook = _ref.onUpdateShareTextbook;
26831
+ var infoUser = useSelector(function (state) {
26832
+ var _state$common;
26833
+ return (state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user) || {};
26834
+ });
26835
+ var isAdmin = infoUser && (infoUser === null || infoUser === void 0 ? void 0 : (_infoUser$roles = infoUser.roles) === null || _infoUser$roles === void 0 ? void 0 : _infoUser$roles.includes(Role.Admin));
26836
+ var isTeacherSite = role === Role.Teacher;
26837
+ var isTeacher = !!infoUser && ((_infoUser$roles2 = infoUser.roles) === null || _infoUser$roles2 === void 0 ? void 0 : _infoUser$roles2.includes(Role.Teacher)) && !isAdmin;
26838
+ var isAdminSite = role === Role.Admin;
26839
+ var onAcademy = !!infoUser.academyDomain;
26840
+ var isSuperAdminUser = infoUser && infoUser.isSuperAdmin;
26841
+ var academy = useSelector(function (state) {
26842
+ var _state$common2;
26843
+ return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.academy;
26844
+ });
26845
+ var _useTranslation = useTranslation(),
26846
+ t = _useTranslation.t;
26847
+ 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) {
26848
+ var _infoUser$email, _infoUser$email$trim;
26849
+ 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);
26850
+ })));
26851
+ 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);
26852
+ var isSharable = !data.isPublic && data.isShared && onAcademy && (isAdminSite || isSuperAdminUser || !isAdmin && data.createdBy.id === infoUser.id);
26853
+ var handleUpdateTextbook = function handleUpdateTextbook() {
26854
+ onUpdateTextbook(data);
26855
+ };
26856
+ var handleDeleteTextbook = function handleDeleteTextbook() {
26857
+ onDeleteTextbook(data);
26858
+ };
26859
+ var handleViewTextbook = function handleViewTextbook() {
26860
+ onViewTextbook(data);
26861
+ };
26862
+ var handleShareTextbook = function handleShareTextbook() {
26863
+ onShareTextbook(data);
26864
+ };
26865
+ var handleUpdateShareTextbook = function handleUpdateShareTextbook() {
26866
+ onUpdateShareTextbook(data);
26867
+ };
26868
+ return React__default.createElement(TableRow, {
26869
+ key: data.id
26870
+ }, React__default.createElement(TableCell, null, calcOrderNumber(index)), React__default.createElement(TableCell, null, data.name), React__default.createElement(TableCell, null, data.subject.name), React__default.createElement(TableCell, null, utcToLocalTime(data.createdAt, t("date_format"))), React__default.createElement(TableCell, null, data.totalChapters), isTeacher && isTeacherSite && React__default.createElement(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(FaCheckCircle, {
26871
+ color: green[700]
26872
+ })), React__default.createElement(TableCell, null, !data.isPublic && data.sharedUsers.map(function (email, index) {
26873
+ return index > 2 ? null : index === 2 ? React__default.createElement("div", null, "(+", data.sharedUsers.length - 2, ")") : React__default.createElement("div", {
26874
+ key: index
26875
+ }, email.toLowerCase());
26876
+ })), React__default.createElement(TableCell, null, React__default.createElement(Stack, {
26877
+ direction: "row",
26878
+ spacing: 1,
26879
+ alignItems: "center"
26880
+ }, React__default.createElement(IconButton, {
26881
+ color: "default",
26882
+ className: (!isEditable ? "bg-secondary" : "bg-warning") + " text-white",
26883
+ onClick: handleUpdateTextbook,
26884
+ disabled: !isEditable
26885
+ }, React__default.createElement(FaPencil, {
26886
+ size: 12
26887
+ })), React__default.createElement(IconButton, {
26888
+ color: "default",
26889
+ className: "bg-primary text-white",
26890
+ onClick: handleViewTextbook
26891
+ }, React__default.createElement(FaEye$1, {
26892
+ size: 12
26893
+ })), React__default.createElement(IconButton, {
26894
+ disabled: !isSharable,
26895
+ className: (!isSharable ? "bg-secondary" : "bg-info") + " text-white me-1",
26896
+ onClick: handleShareTextbook
26897
+ }, React__default.createElement(FaShare, {
26898
+ size: 12
26899
+ })), React__default.createElement(IconButton, {
26900
+ disabled: !isSharable,
26901
+ className: (!isSharable ? "bg-secondary" : "bg-success") + " text-white me-1",
26902
+ onClick: handleUpdateShareTextbook
26903
+ }, React__default.createElement(FaExchangeAlt, {
26904
+ size: 12
26905
+ })), React__default.createElement(IconButton, {
26906
+ color: "default",
26907
+ className: (!isDeleteAble ? "bg-secondary" : "bg-danger") + " text-white mr-1",
26908
+ onClick: handleDeleteTextbook,
26909
+ disabled: !isDeleteAble
26910
+ }, React__default.createElement(FaTrash, {
26911
+ size: 12
26912
+ })))));
26913
+ };
26914
+
26796
26915
  var TextbookList = function TextbookList(props) {
26797
26916
  var _props$createable = props.createable,
26798
- createable = _props$createable === void 0 ? true : _props$createable;
26917
+ createable = _props$createable === void 0 ? true : _props$createable,
26918
+ isSuperAdmin = props.isSuperAdmin,
26919
+ role = props.role;
26799
26920
  var _useTranslation = useTranslation(),
26800
26921
  t = _useTranslation.t;
26801
26922
  var _useTextbookList = useTextbookList(props),
26923
+ isTeacherSite = _useTextbookList.isTeacherSite,
26924
+ isTeacher = _useTextbookList.isTeacher,
26802
26925
  filter = _useTextbookList.filter,
26803
26926
  textbooks = _useTextbookList.textbooks,
26804
26927
  paging = _useTextbookList.paging,
@@ -26840,9 +26963,14 @@ var TextbookList = function TextbookList(props) {
26840
26963
  handleOpenUpdateShareDialog = _useTextbookShare.handleOpenUpdateShareDialog,
26841
26964
  isUpdate = _useTextbookShare.isUpdate,
26842
26965
  handleUpdateSharedTextbook = _useTextbookShare.handleUpdateSharedTextbook,
26843
- currentModel = _useTextbookShare.currentModel,
26844
- enabledSave = _useTextbookShare.enabledSave,
26845
- enabledShare = _useTextbookShare.enabledShare;
26966
+ currentModel = _useTextbookShare.currentModel;
26967
+ var textbookHeaders = useMemo(function () {
26968
+ var headers = _$5.clone(TEXTBOOK_HEADERS);
26969
+ if (isTeacher && isTeacherSite) headers.splice(5, 0, {
26970
+ title: "teacher_personal_textbook"
26971
+ });
26972
+ return headers;
26973
+ }, [isTeacher, isTeacherSite]);
26846
26974
  return React__default.createElement(LayoutList, {
26847
26975
  title: t(TEXTBOOK_PAGE_TITLE)
26848
26976
  }, React__default.createElement(Grid, {
@@ -26877,63 +27005,26 @@ var TextbookList = function TextbookList(props) {
26877
27005
  xs: 12,
26878
27006
  className: "mt-3"
26879
27007
  }, React__default.createElement(Table, null, React__default.createElement(TableHeader, {
26880
- headerTemplates: TEXTBOOK_HEADERS,
27008
+ headerTemplates: textbookHeaders,
26881
27009
  filter: filter,
26882
27010
  onSort: handleSort
26883
- }), React__default.createElement(TableBody, null, textbooks.map(function (i, index) {
26884
- return React__default.createElement(TableRow, {
26885
- key: i.id
26886
- }, React__default.createElement(TableCell, null, calcOrderNumber(index)), React__default.createElement(TableCell, null, i.name), React__default.createElement(TableCell, null, i.subject.name), React__default.createElement(TableCell, null, utcToLocalTime(i.createdAt, t("date_format"))), React__default.createElement(TableCell, null, i.totalChapters), React__default.createElement(TableCell, null, i.sharedUsers.map(function (email, index) {
26887
- return index > 2 ? null : index === 2 ? React__default.createElement("div", null, "(+", i.sharedUsers.length - 2, ")") : React__default.createElement("div", {
26888
- key: index
26889
- }, email.toLowerCase());
26890
- })), React__default.createElement(TableCell, null, React__default.createElement(Stack, {
26891
- direction: "row",
26892
- spacing: 1,
26893
- alignItems: "center"
26894
- }, React__default.createElement(IconButton, {
26895
- color: "default",
26896
- className: (!enabledSave(i) ? "bg-secondary" : "bg-warning") + " text-white",
26897
- onClick: function onClick() {
26898
- return handleUpdateTextbook(i);
26899
- },
26900
- disabled: !enabledSave(i)
26901
- }, React__default.createElement(FaPencil, {
26902
- size: 12
26903
- })), React__default.createElement(IconButton, {
26904
- color: "default",
26905
- className: "bg-primary text-white",
26906
- onClick: function onClick() {
26907
- return handleViewTextbook(i);
26908
- }
26909
- }, React__default.createElement(FaEye$1, {
26910
- size: 12
26911
- })), React__default.createElement(IconButton, {
26912
- disabled: !enabledShare(i),
26913
- className: (!enabledShare(i) ? "bg-secondary" : "bg-info") + " text-white me-1",
26914
- onClick: function onClick() {
26915
- return handleOpenShareDialog(i);
26916
- }
26917
- }, React__default.createElement(FaShare, {
26918
- size: 12
26919
- })), React__default.createElement(IconButton, {
26920
- disabled: !enabledShare(i),
26921
- className: (!enabledShare(i) ? "bg-secondary" : "bg-success") + " text-white me-1",
26922
- onClick: function onClick() {
26923
- return handleOpenUpdateShareDialog(i);
26924
- }
26925
- }, React__default.createElement(FaExchangeAlt, {
26926
- size: 12
26927
- })), React__default.createElement(IconButton, {
26928
- color: "default",
26929
- className: (!enabledSave(i) ? "bg-secondary" : "bg-danger") + " text-white mr-1",
26930
- onClick: function onClick() {
26931
- return handleSelectDeleteTextbook(i);
26932
- },
26933
- disabled: !enabledSave(i)
26934
- }, React__default.createElement(FaTrash, {
26935
- size: 12
26936
- })))));
27011
+ }), React__default.createElement(TableBody, null, React__default.createElement(ListView, {
27012
+ data: textbooks,
27013
+ render: function render(data, index) {
27014
+ return React__default.createElement(TextbookRow, {
27015
+ key: index,
27016
+ index: index,
27017
+ data: data,
27018
+ isSuperAdmin: isSuperAdmin,
27019
+ calcOrderNumber: calcOrderNumber,
27020
+ onDeleteTextbook: handleSelectDeleteTextbook,
27021
+ onShareTextbook: handleOpenShareDialog,
27022
+ onUpdateShareTextbook: handleOpenUpdateShareDialog,
27023
+ onUpdateTextbook: handleUpdateTextbook,
27024
+ onViewTextbook: handleViewTextbook,
27025
+ role: role
27026
+ });
27027
+ }
26937
27028
  }), !textbooks.length && React__default.createElement(EmptyRow, null))), React__default.createElement("div", {
26938
27029
  className: "d-flex justify-content-end mt-3"
26939
27030
  }, !!paging.totalPages && React__default.createElement(Pagination, {
@@ -27586,7 +27677,8 @@ var NotificationList = function NotificationList(_ref) {
27586
27677
  startIcon: React__default.createElement(FaPlus, {
27587
27678
  size: 12
27588
27679
  }),
27589
- onClick: handleCreateNotification
27680
+ onClick: handleCreateNotification,
27681
+ disabled: !isAdmin && isTeacherAdmin
27590
27682
  }, t("new_notification"))), React__default.createElement(Grid, {
27591
27683
  container: true
27592
27684
  }, React__default.createElement(Grid, {
@@ -27725,8 +27817,9 @@ var deleteTextbookApi$1 = function deleteTextbookApi(textbookId, isAdmin) {
27725
27817
  };
27726
27818
 
27727
27819
  var useTextbookManagement = function useTextbookManagement(_ref) {
27728
- var _user$roles;
27820
+ var _user$roles, _user$roles2, _selectedTextbook$cre, _selectedTextbook$cre2;
27729
27821
  var textbookId = _ref.textbookId,
27822
+ role = _ref.role,
27730
27823
  onNavigateList = _ref.onNavigateList;
27731
27824
  var _useTranslation = useTranslation(),
27732
27825
  t = _useTranslation.t;
@@ -27743,13 +27836,28 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
27743
27836
  var _useState4 = useState(false),
27744
27837
  selectedChapter = _useState4[0],
27745
27838
  setSelectedChapter = _useState4[1];
27839
+ var searchParams = new URLSearchParams(location.search);
27840
+ var isReadonly = searchParams.get('readonly') === "true";
27746
27841
  var dispatch = useDispatch();
27747
27842
  var user = useSelector(function (state) {
27748
27843
  var _state$common;
27749
27844
  return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
27750
27845
  });
27751
- var isAdmin = user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(Role.Admin);
27846
+ var academy = useSelector(function (state) {
27847
+ var _state$common2;
27848
+ return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.academy;
27849
+ });
27850
+ var isAdmin = user && (user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(Role.Admin));
27851
+ var isTeacher = user && (user === null || user === void 0 ? void 0 : (_user$roles2 = user.roles) === null || _user$roles2 === void 0 ? void 0 : _user$roles2.includes(Role.Teacher)) && !isAdmin;
27752
27852
  var isSuperAdmin = !!user && !user.academyDomain;
27853
+ var isAdminSite = role === Role.Admin;
27854
+ var onAcademy = !!(user !== null && user !== void 0 && user.academyDomain);
27855
+ var isSuperAdminUser = !!user && user.isSuperAdmin;
27856
+ 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) {
27857
+ var _user$email, _user$email$trim;
27858
+ 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);
27859
+ }));
27860
+ 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);
27753
27861
  var handleOpenConfirmDeleteChapterDialog = function handleOpenConfirmDeleteChapterDialog(chapter) {
27754
27862
  setSelectedChapter(chapter);
27755
27863
  };
@@ -27804,6 +27912,7 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
27804
27912
  var _temp3 = function _temp3() {
27805
27913
  dispatch(setLoading(false));
27806
27914
  };
27915
+ if (isReadonly || !isEditable) return Promise.resolve();
27807
27916
  if (!coverImage && !(values !== null && values !== void 0 && values.coverImage)) {
27808
27917
  toast.error(t("please_select_image_file"));
27809
27918
  return Promise.resolve();
@@ -27855,11 +27964,16 @@ var useTextbookManagement = function useTextbookManagement(_ref) {
27855
27964
  }, [textbookId]);
27856
27965
  return {
27857
27966
  t: t,
27967
+ isAdminSite: isAdminSite,
27968
+ disabledTextbookOwners: disabledTextbookOwners,
27969
+ isReadonly: isReadonly,
27970
+ isEditable: isEditable,
27858
27971
  isAdmin: isAdmin,
27859
27972
  theme: theme,
27860
27973
  history: history,
27861
27974
  coverImage: coverImage,
27862
27975
  isSuperAdmin: isSuperAdmin,
27976
+ isSuperAdminUser: isSuperAdminUser,
27863
27977
  openDialog: openDialog,
27864
27978
  handleSubmit: handleSubmit,
27865
27979
  selectedTextbook: selectedTextbook,
@@ -27890,6 +28004,12 @@ var HighSchoolGrade;
27890
28004
  HighSchoolGrade[HighSchoolGrade["ProbabilityAndStatistics"] = 6] = "ProbabilityAndStatistics";
27891
28005
  HighSchoolGrade[HighSchoolGrade["Geometry"] = 7] = "Geometry";
27892
28006
  })(HighSchoolGrade || (HighSchoolGrade = {}));
28007
+ var TextbookEditorType;
28008
+ (function (TextbookEditorType) {
28009
+ TextbookEditorType[TextbookEditorType["Default"] = 0] = "Default";
28010
+ TextbookEditorType[TextbookEditorType["Korea"] = 1] = "Korea";
28011
+ TextbookEditorType[TextbookEditorType["Math"] = 2] = "Math";
28012
+ })(TextbookEditorType || (TextbookEditorType = {}));
27893
28013
 
27894
28014
  var TextbookSortBy$1;
27895
28015
  (function (TextbookSortBy) {
@@ -28029,6 +28149,11 @@ var preparedTextbookSchema = function preparedTextbookSchema(t) {
28029
28149
  isbn: string().required(t("isbn_required")),
28030
28150
  grade: number().required(t("grade_required")).notOneOf([0], t("subject_required")),
28031
28151
  type: number(),
28152
+ textbookOwners: array().of(object().shape({
28153
+ email: string().trim().email(t("invalid_textbook_owner_email_address")).required(t("textbook_owner_email_is_required")),
28154
+ academyId: number().required(t("textbook_owner_academy_is_required")),
28155
+ courseId: number().required(t("textbook_owner_course_is_required"))
28156
+ })),
28032
28157
  chapters: array().of(object().shape({
28033
28158
  pageFrom: number().required(t("page_from_required")).integer().typeError(t("must_be_number")).min(1, t("min_is_1")),
28034
28159
  pageTo: 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) {
@@ -28101,7 +28226,7 @@ var DEFAULT_TEXTBOOK_REQUEST = {
28101
28226
  grade: "",
28102
28227
  textbookOwners: [],
28103
28228
  isPrepared: true,
28104
- type: 0
28229
+ type: TextbookEditorType.Korea
28105
28230
  };
28106
28231
  var DEFAULT_CHAPTER = {
28107
28232
  name: "",
@@ -28151,6 +28276,171 @@ var CustomTextbookTab = function CustomTextbookTab(props) {
28151
28276
  }, children));
28152
28277
  };
28153
28278
 
28279
+ var _reduceToMathArticles = function reduceToMathArticles(textbook, isMath) {
28280
+ var values = isMath !== undefined ? _$5.cloneDeep(textbook) : textbook;
28281
+ if (isMath !== undefined) values.type = isMath;
28282
+ for (var key in values) {
28283
+ if (values.hasOwnProperty(key)) {
28284
+ if (key === "articles") {
28285
+ var _values$key;
28286
+ values[key] = (_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.length ? [values[key][0]] : [DEFAULT_ARTICLE];
28287
+ } else if (typeof values[key] === "object" && values[key] !== null) {
28288
+ _reduceToMathArticles(values[key]);
28289
+ }
28290
+ }
28291
+ }
28292
+ return values;
28293
+ };
28294
+ var _resetAllCategoriesAndQuestionTypesBySubject = function resetAllCategoriesAndQuestionTypesBySubject(textbook, subject) {
28295
+ var values = subject ? _$5.cloneDeep(textbook) : textbook;
28296
+ if (subject) {
28297
+ values.subjectId = subject === null || subject === void 0 ? void 0 : subject.value;
28298
+ values.subject = subject;
28299
+ }
28300
+ for (var key in values) {
28301
+ if (values.hasOwnProperty(key)) {
28302
+ if (key === "categories" || key === "categoryOptions") {
28303
+ values[key] = [];
28304
+ } else if (key === "questionType" || key === "questionTypeId") {
28305
+ values[key] = null;
28306
+ } else if (typeof values[key] === "object" && values[key] !== null) {
28307
+ _resetAllCategoriesAndQuestionTypesBySubject(values[key]);
28308
+ }
28309
+ }
28310
+ }
28311
+ return values;
28312
+ };
28313
+ var convertResponseToRequest = function convertResponseToRequest(selectedTextbook) {
28314
+ var _selectedTextbook$sub;
28315
+ if (!selectedTextbook) return DEFAULT_TEXTBOOK_REQUEST;
28316
+ return {
28317
+ name: selectedTextbook.name || "",
28318
+ subjectId: ((_selectedTextbook$sub = selectedTextbook.subject) === null || _selectedTextbook$sub === void 0 ? void 0 : _selectedTextbook$sub.id) || 0,
28319
+ subject: selectedTextbook.subject ? {
28320
+ label: selectedTextbook.subject.name,
28321
+ value: selectedTextbook.subject.id
28322
+ } : null,
28323
+ preparedType: selectedTextbook.preparedType || 0,
28324
+ grade: selectedTextbook.grade || "1",
28325
+ publicationDate: (selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.publicationDate) || "",
28326
+ publisher: selectedTextbook.publisher || "",
28327
+ isbn: selectedTextbook.isbn || "",
28328
+ coverImage: selectedTextbook.coverImage || "",
28329
+ textbookOwners: selectedTextbook.textbookOwners.map(function (to) {
28330
+ return _extends({}, to, {
28331
+ academy: to.academy ? {
28332
+ label: to.academy.name,
28333
+ value: to.academy.id
28334
+ } : null,
28335
+ course: to.course ? {
28336
+ label: to.course.name,
28337
+ value: to.course.id
28338
+ } : null
28339
+ });
28340
+ }),
28341
+ isPublic: selectedTextbook.isPublic || false,
28342
+ isShared: selectedTextbook.isShared || false,
28343
+ isPrepared: true,
28344
+ type: selectedTextbook.type,
28345
+ chapters: selectedTextbook.chapters.map(function (c) {
28346
+ var _c$questionGroups;
28347
+ return {
28348
+ name: c.name,
28349
+ pageFrom: c.pageFrom || 0,
28350
+ pageTo: c.pageTo || 0,
28351
+ id: c.id,
28352
+ questionGroups: ((_c$questionGroups = c.questionGroups) === null || _c$questionGroups === void 0 ? void 0 : _c$questionGroups.map(function (g) {
28353
+ var _g$questions, _g$questions$find;
28354
+ return {
28355
+ id: g.id,
28356
+ chapterId: c.id,
28357
+ questions: g.questions.map(function (q) {
28358
+ var _q$questionType;
28359
+ return _extends({}, q, {
28360
+ questionTypeId: q.questionTypeId || q.questionType.id,
28361
+ questionType: (_q$questionType = q.questionType) !== null && _q$questionType !== void 0 && _q$questionType.id ? {
28362
+ label: q.questionType.name,
28363
+ value: q.questionType.id
28364
+ } : null
28365
+ });
28366
+ }),
28367
+ articles: g.articles.map(function (a) {
28368
+ return _extends({}, a, {
28369
+ categoryOptions: a.categories.map(function (cat) {
28370
+ return {
28371
+ label: cat.name,
28372
+ value: cat.id
28373
+ };
28374
+ }),
28375
+ categories: a.categories.filter(function (cat) {
28376
+ return !!cat.id;
28377
+ }).map(function (cat) {
28378
+ return cat.id;
28379
+ })
28380
+ });
28381
+ }),
28382
+ questionCount: g.questions.length,
28383
+ answerCount: ((_g$questions = g.questions) === null || _g$questions === void 0 ? void 0 : (_g$questions$find = _g$questions.find(function (q) {
28384
+ return q.questionAnswerType !== QuestionAnswerType.ShortAnswer;
28385
+ })) === null || _g$questions$find === void 0 ? void 0 : _g$questions$find.numberOfAnswers) || DEFAULT_ANSWER_COUNT$2
28386
+ };
28387
+ })) || [],
28388
+ subChapters: c.subChapters.map(function (sub) {
28389
+ var _sub$questionGroups;
28390
+ return {
28391
+ name: sub.name,
28392
+ pageFrom: sub.pageFrom || 0,
28393
+ pageTo: sub.pageTo || 0,
28394
+ id: sub.id,
28395
+ questionGroups: ((_sub$questionGroups = sub.questionGroups) === null || _sub$questionGroups === void 0 ? void 0 : _sub$questionGroups.map(function (g) {
28396
+ var _g$questions2, _g$questions2$find;
28397
+ return {
28398
+ id: g.id,
28399
+ chapterId: c.id,
28400
+ questions: g.questions.map(function (q) {
28401
+ var _q$questionType2;
28402
+ return _extends({}, q, {
28403
+ questionTypeId: q.questionTypeId || q.questionType.id,
28404
+ questionType: (_q$questionType2 = q.questionType) !== null && _q$questionType2 !== void 0 && _q$questionType2.id ? {
28405
+ label: q.questionType.name,
28406
+ value: q.questionType.id
28407
+ } : null
28408
+ });
28409
+ }),
28410
+ articles: g.articles.map(function (a) {
28411
+ return _extends({}, a, {
28412
+ categoryOptions: a.categories.map(function (cat) {
28413
+ return {
28414
+ label: cat.name,
28415
+ value: cat.id
28416
+ };
28417
+ }),
28418
+ categories: a.categories.filter(function (cat) {
28419
+ return !!cat.id;
28420
+ }).map(function (cat) {
28421
+ return cat.id;
28422
+ })
28423
+ });
28424
+ }),
28425
+ questionCount: g.questions.length,
28426
+ answerCount: ((_g$questions2 = g.questions) === null || _g$questions2 === void 0 ? void 0 : (_g$questions2$find = _g$questions2.find(function (q) {
28427
+ return q.questionAnswerType !== QuestionAnswerType.ShortAnswer;
28428
+ })) === null || _g$questions2$find === void 0 ? void 0 : _g$questions2$find.numberOfAnswers) || DEFAULT_ANSWER_COUNT$2
28429
+ };
28430
+ })) || [],
28431
+ subChapters: []
28432
+ };
28433
+ })
28434
+ };
28435
+ })
28436
+ };
28437
+ };
28438
+ var handleKeyDown = function handleKeyDown(e) {
28439
+ if (e.key === 'Enter') {
28440
+ e.preventDefault();
28441
+ }
28442
+ };
28443
+
28154
28444
  var ArticleBlock = function ArticleBlock(_ref) {
28155
28445
  var expandedIndex = _ref.expandedIndex,
28156
28446
  data = _ref.data,
@@ -28158,6 +28448,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28158
28448
  path = _ref.path,
28159
28449
  isLoadingCategories = _ref.isLoadingCategories,
28160
28450
  optionKey = _ref.optionKey,
28451
+ disabled = _ref.disabled,
28161
28452
  setFieldValue = _ref.setFieldValue,
28162
28453
  onDuplicate = _ref.onDuplicate,
28163
28454
  onDelete = _ref.onDelete,
@@ -28259,6 +28550,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28259
28550
  onMenuClose: onCloseCategoryMenu
28260
28551
  },
28261
28552
  onChange: handleChangeCategory,
28553
+ isDisabled: disabled,
28262
28554
  placeholder: t("select_category")
28263
28555
  });
28264
28556
  }
@@ -28296,7 +28588,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28296
28588
  onMenuClose: onCloseCategoryMenu
28297
28589
  },
28298
28590
  onChange: handleChangeSubCategory,
28299
- isDisabled: !data.categories[0],
28591
+ isDisabled: disabled || !data.categories[0],
28300
28592
  placeholder: t("select_category")
28301
28593
  });
28302
28594
  }
@@ -28317,7 +28609,9 @@ var ArticleBlock = function ArticleBlock(_ref) {
28317
28609
  return React__default.createElement(TextField, Object.assign({
28318
28610
  placeholder: t("title")
28319
28611
  }, field, {
28320
- size: "small"
28612
+ size: "small",
28613
+ onKeyDown: handleKeyDown,
28614
+ disabled: disabled
28321
28615
  }));
28322
28616
  }
28323
28617
  }))), React__default.createElement(Grid, {
@@ -28337,7 +28631,9 @@ var ArticleBlock = function ArticleBlock(_ref) {
28337
28631
  return React__default.createElement(TextField, Object.assign({
28338
28632
  placeholder: t("author")
28339
28633
  }, field, {
28340
- size: "small"
28634
+ size: "small",
28635
+ onKeyDown: handleKeyDown,
28636
+ disabled: disabled
28341
28637
  }));
28342
28638
  }
28343
28639
  }))), React__default.createElement(Grid, {
@@ -28357,7 +28653,9 @@ var ArticleBlock = function ArticleBlock(_ref) {
28357
28653
  return React__default.createElement(TextField, Object.assign({
28358
28654
  placeholder: t("subject")
28359
28655
  }, field, {
28360
- size: "small"
28656
+ size: "small",
28657
+ onKeyDown: handleKeyDown,
28658
+ disabled: disabled
28361
28659
  }));
28362
28660
  }
28363
28661
  })))), React__default.createElement(Stack, {
@@ -28370,6 +28668,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
28370
28668
  }, t("copy_items")), React__default.createElement(Button, {
28371
28669
  variant: "contained",
28372
28670
  color: "success",
28671
+ disabled: disabled,
28373
28672
  onClick: handleDuplicateArticle,
28374
28673
  sx: {
28375
28674
  whiteSpace: "nowrap"
@@ -28385,7 +28684,7 @@ var isEqual = function isEqual(prev, next) {
28385
28684
  var nextIsLoadingCategories = isNextMatched ? next.isLoadingCategories : undefined;
28386
28685
  var prevCategories = isPrevMatched ? prev.categories : undefined;
28387
28686
  var nextCategories = isNextMatched ? next.categories : undefined;
28388
- 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;
28687
+ 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;
28389
28688
  };
28390
28689
  var ArticleBlock$1 = memo(ArticleBlock, isEqual);
28391
28690
 
@@ -28431,7 +28730,7 @@ var BpCheckedIcon$1 = styled(BpIcon$1)({
28431
28730
  var QuestionBlock = function QuestionBlock(_ref2) {
28432
28731
  var answerCount = _ref2.answerCount,
28433
28732
  isMath = _ref2.isMath,
28434
- isDisabled = _ref2.isDisabled,
28733
+ disabled = _ref2.disabled,
28435
28734
  path = _ref2.path,
28436
28735
  data = _ref2.data,
28437
28736
  questionTitleStyle = _ref2.questionTitleStyle,
@@ -28476,7 +28775,8 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28476
28775
  var field = _ref3.field;
28477
28776
  return React__default.createElement(TextField, Object.assign({}, field, {
28478
28777
  size: "small",
28479
- placeholder: t("textual_answer")
28778
+ placeholder: t("textual_answer"),
28779
+ onKeyDown: handleKeyDown
28480
28780
  }));
28481
28781
  }
28482
28782
  }));
@@ -28495,7 +28795,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28495
28795
  className: styles$9["question-label"] + " w-fit",
28496
28796
  labelPlacement: "top",
28497
28797
  value: i,
28498
- disabled: isDisabled,
28798
+ disabled: disabled,
28499
28799
  control: React__default.createElement(Checkbox, {
28500
28800
  checked: data.correctAnswers.includes(i),
28501
28801
  onChange: function onChange(e) {
@@ -28531,7 +28831,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28531
28831
  onChange: function onChange(e) {
28532
28832
  return setFieldValue(path + ".correctAnswers", [+e.target.value]);
28533
28833
  },
28534
- disabled: isDisabled,
28834
+ disabled: disabled,
28535
28835
  control: React__default.createElement(Radio, {
28536
28836
  size: "small",
28537
28837
  checked: +i === data.correctAnswers[0],
@@ -28604,7 +28904,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28604
28904
  render: function render(_ref4) {
28605
28905
  var field = _ref4.field;
28606
28906
  return React__default.createElement(ScoreSelector, Object.assign({}, field, {
28607
- isDisabled: isDisabled,
28907
+ isDisabled: disabled,
28608
28908
  onChange: function onChange(value) {
28609
28909
  setFieldValue(path + ".score", (value === null || value === void 0 ? void 0 : value.value) || 0);
28610
28910
  }
@@ -28625,7 +28925,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28625
28925
  var _ref5$field = _ref5.field,
28626
28926
  field = _objectWithoutPropertiesLoose(_ref5$field, _excluded$f);
28627
28927
  return React__default.createElement(CustomSelectOption, Object.assign({}, field, {
28628
- isDisabled: isDisabled,
28928
+ isDisabled: disabled,
28629
28929
  value: data.questionType,
28630
28930
  options: questionTypes,
28631
28931
  isLoading: optionKey === path + ".questionTypeId" ? isLoadingQuestionTypes : false,
@@ -28650,7 +28950,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28650
28950
  var field = _ref6.field;
28651
28951
  return React__default.createElement(CustomSelect, Object.assign({}, field, {
28652
28952
  value: data.questionAnswerType,
28653
- isDisabled: isDisabled,
28953
+ isDisabled: disabled,
28654
28954
  options: answerTypeOptions,
28655
28955
  onChange: handleChangeQuestionAnswerType
28656
28956
  }));
@@ -28666,11 +28966,11 @@ var isEqual$1 = function isEqual(prev, next) {
28666
28966
  var nextIsLoadingQuestionTypes = isNextMatched ? next.isLoadingQuestionTypes : undefined;
28667
28967
  var prevQuestionTypes = isPrevMatched ? prev.questionTypes : undefined;
28668
28968
  var nextQuestionTypes = isNextMatched ? next.questionTypes : undefined;
28669
- 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;
28969
+ 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;
28670
28970
  };
28671
28971
  var QuestionBlock$1 = memo(QuestionBlock, isEqual$1);
28672
28972
 
28673
- var _excluded$g = ["data", "path", "isMath", "open", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "categories", "questionTypes", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28973
+ var _excluded$g = ["data", "path", "isMath", "open", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "categories", "questionTypes", "disabled", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28674
28974
  var _ = _$5;
28675
28975
  var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28676
28976
  var _data$articles$3, _data$articles$3$cate, _data$articles$4, _data$articles$4$cate;
@@ -28683,6 +28983,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28683
28983
  optionKey = _ref.optionKey,
28684
28984
  categories = _ref.categories,
28685
28985
  questionTypes = _ref.questionTypes,
28986
+ disabled = _ref.disabled,
28686
28987
  onDelete = _ref.onDelete,
28687
28988
  onOpenSubCategoryMenu = _ref.onOpenSubCategoryMenu,
28688
28989
  onOpenCategoryMenu = _ref.onOpenCategoryMenu,
@@ -28726,6 +29027,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28726
29027
  expandedIndex: index,
28727
29028
  data: article,
28728
29029
  path: path + ".articles[" + index + "]",
29030
+ disabled: disabled,
28729
29031
  onDuplicate: handleDuplicateArticle,
28730
29032
  onDelete: onDelete,
28731
29033
  optionKey: optionKey,
@@ -28741,6 +29043,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28741
29043
  width: "fit-content"
28742
29044
  },
28743
29045
  variant: "contained",
29046
+ disabled: disabled,
28744
29047
  startIcon: React__default.createElement(IoIosAdd, null),
28745
29048
  onClick: function onClick() {
28746
29049
  arrayHelpers.push(DEFAULT_ARTICLE);
@@ -28760,6 +29063,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28760
29063
  questionTypes: questionTypes,
28761
29064
  isLoadingQuestionTypes: isLoadingQuestionTypes,
28762
29065
  optionKey: optionKey,
29066
+ disabled: disabled,
28763
29067
  onOpenQuestionTypeMenu: handleOpenQuestionTypeMenu,
28764
29068
  onCloseQuestionTypeMenu: onCloseQuestionTypeMenu
28765
29069
  }, formikProps));
@@ -28789,11 +29093,11 @@ var isEqual$2 = function isEqual(prev, next) {
28789
29093
  var nextOnOpenSubCategoryMenu = next.onOpenSubCategoryMenu;
28790
29094
  var prevOnOpenQuestionTypeMenu = prev.onOpenQuestionTypeMenu;
28791
29095
  var nextOnOpenQuestionTypeMenu = next.onOpenQuestionTypeMenu;
28792
- 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;
29096
+ 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;
28793
29097
  };
28794
29098
  var QuestionGroupBlockBody$1 = memo(QuestionGroupBlockBody, isEqual$2);
28795
29099
 
28796
- var _excluded$h = ["expandedIndex", "open", "paths", "path", "isMath", "data", "categories", "isLoadingCategories", "isLoadingQuestionTypes", "questionTypes", "optionKey", "isDisabled", "onToggle", "onQuestionCountChange", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
29100
+ var _excluded$h = ["expandedIndex", "open", "paths", "path", "isMath", "data", "categories", "isLoadingCategories", "isLoadingQuestionTypes", "questionTypes", "optionKey", "disabled", "onToggle", "onQuestionCountChange", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28797
29101
  var _$1 = _$5;
28798
29102
  var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28799
29103
  var _data$articles$2, _data$articles$2$cate, _data$articles$2$cate2, _data$articles$3, _data$articles$3$cate, _data$articles$3$cate2;
@@ -28808,7 +29112,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28808
29112
  isLoadingQuestionTypes = _ref.isLoadingQuestionTypes,
28809
29113
  questionTypes = _ref.questionTypes,
28810
29114
  optionKey = _ref.optionKey,
28811
- isDisabled = _ref.isDisabled,
29115
+ disabled = _ref.disabled,
28812
29116
  onToggle = _ref.onToggle,
28813
29117
  onQuestionCountChange = _ref.onQuestionCountChange,
28814
29118
  onDelete = _ref.onDelete,
@@ -28967,7 +29271,8 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28967
29271
  render: function render(_ref2) {
28968
29272
  var field = _ref2.field;
28969
29273
  return React__default.createElement(QuestionCountSelector, Object.assign({}, field, {
28970
- onChange: handleChangeQuestionCount
29274
+ onChange: handleChangeQuestionCount,
29275
+ isDisabled: disabled
28971
29276
  }));
28972
29277
  }
28973
29278
  }))), isMath && React__default.createElement(Grid, {
@@ -29005,6 +29310,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29005
29310
  onMenuClose: onCloseCategoryMenu
29006
29311
  },
29007
29312
  onChange: handleChangeCategory,
29313
+ isDisabled: disabled,
29008
29314
  placeholder: t("select_category")
29009
29315
  });
29010
29316
  }
@@ -29045,7 +29351,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29045
29351
  onMenuClose: onCloseCategoryMenu
29046
29352
  },
29047
29353
  onChange: handleChangeSubCategory,
29048
- 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]),
29354
+ 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]),
29049
29355
  placeholder: t("select_category")
29050
29356
  });
29051
29357
  }
@@ -29064,7 +29370,8 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29064
29370
  render: function render(_ref5) {
29065
29371
  var field = _ref5.field;
29066
29372
  return React__default.createElement(AnswerCountSelector, Object.assign({}, field, {
29067
- onChange: handleChangeAnswerCount
29373
+ onChange: handleChangeAnswerCount,
29374
+ isDisabled: disabled
29068
29375
  }));
29069
29376
  }
29070
29377
  })))), isMath && React__default.createElement(Box, {
@@ -29077,6 +29384,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29077
29384
  }, React__default.createElement(Button, {
29078
29385
  variant: "contained",
29079
29386
  color: "success",
29387
+ disabled: disabled,
29080
29388
  onClick: handleCopyCategories,
29081
29389
  sx: {
29082
29390
  whiteSpace: "nowrap"
@@ -29102,6 +29410,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29102
29410
  isLoadingCategories: isLoadingCategories,
29103
29411
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29104
29412
  optionKey: optionKey,
29413
+ disabled: disabled,
29105
29414
  onDelete: onDelete,
29106
29415
  onOpenSubCategoryMenu: onOpenSubCategoryMenu,
29107
29416
  onOpenCategoryMenu: onOpenCategoryMenu,
@@ -29111,7 +29420,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
29111
29420
  }, formikProps)))));
29112
29421
  };
29113
29422
 
29114
- var _excluded$i = ["path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "questionGroups", "subChapters", "categories", "questionTypes", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
29423
+ var _excluded$i = ["path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "questionGroups", "subChapters", "categories", "questionTypes", "disabled", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCopiedPrevQuestionGroup", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
29115
29424
  var ChapterBlockBody = function ChapterBlockBody(_ref) {
29116
29425
  var path = _ref.path,
29117
29426
  paths = _ref.paths,
@@ -29123,6 +29432,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29123
29432
  subChapters = _ref.subChapters,
29124
29433
  categories = _ref.categories,
29125
29434
  questionTypes = _ref.questionTypes,
29435
+ disabled = _ref.disabled,
29126
29436
  onDelete = _ref.onDelete,
29127
29437
  onOpenSubCategoryMenu = _ref.onOpenSubCategoryMenu,
29128
29438
  onOpenCategoryMenu = _ref.onOpenCategoryMenu,
@@ -29234,6 +29544,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29234
29544
  categories: categories,
29235
29545
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29236
29546
  questionTypes: questionTypes,
29547
+ disabled: disabled,
29237
29548
  onToggle: handleToggle,
29238
29549
  onDelete: onDelete,
29239
29550
  onOpenCategoryMenu: onOpenCategoryMenu,
@@ -29248,6 +29559,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29248
29559
  },
29249
29560
  variant: "contained",
29250
29561
  startIcon: React__default.createElement(IoIosAdd, null),
29562
+ disabled: disabled,
29251
29563
  onClick: function onClick() {
29252
29564
  {
29253
29565
  var length = subChapters.length;
@@ -29278,6 +29590,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29278
29590
  optionKey: optionKey,
29279
29591
  isLoadingCategories: isLoadingCategories,
29280
29592
  categories: categories,
29593
+ disabled: disabled,
29281
29594
  onOpenCategoryMenu: onOpenCategoryMenu,
29282
29595
  onOpenSubCategoryMenu: onOpenSubCategoryMenu,
29283
29596
  onCloseCategoryMenu: onCloseCategoryMenu,
@@ -29293,6 +29606,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29293
29606
  },
29294
29607
  variant: "contained",
29295
29608
  startIcon: React__default.createElement(IoIosAdd, null),
29609
+ disabled: disabled,
29296
29610
  onClick: function onClick() {
29297
29611
  var length = questionGroups.length;
29298
29612
  var addedGroup = handleGetNewQuestionGroup();
@@ -29304,7 +29618,7 @@ var ChapterBlockBody = function ChapterBlockBody(_ref) {
29304
29618
  }));
29305
29619
  };
29306
29620
 
29307
- var _excluded$j = ["data", "expandedIndex", "open", "path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "categories", "questionTypes", "optionKey", "onToggle", "onDelete", "onCopiedPrevQuestionGroup", "onCloseCategoryMenu", "onOpenCategoryMenu", "onOpenSubCategoryMenu", "onOpenQuestionTypeMenu", "onCloseQuestionTypeMenu"];
29621
+ var _excluded$j = ["data", "expandedIndex", "open", "path", "paths", "isMath", "isLoadingCategories", "isLoadingQuestionTypes", "categories", "questionTypes", "optionKey", "disabled", "onToggle", "onDelete", "onCopiedPrevQuestionGroup", "onCloseCategoryMenu", "onOpenCategoryMenu", "onOpenSubCategoryMenu", "onOpenQuestionTypeMenu", "onCloseQuestionTypeMenu"];
29308
29622
  var _$2 = _$5;
29309
29623
  var ChapterBlock = function ChapterBlock(_ref) {
29310
29624
  var data = _ref.data,
@@ -29318,6 +29632,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
29318
29632
  categories = _ref.categories,
29319
29633
  questionTypes = _ref.questionTypes,
29320
29634
  optionKey = _ref.optionKey,
29635
+ disabled = _ref.disabled,
29321
29636
  onToggle = _ref.onToggle,
29322
29637
  onDelete = _ref.onDelete,
29323
29638
  onCopiedPrevQuestionGroup = _ref.onCopiedPrevQuestionGroup,
@@ -29375,6 +29690,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
29375
29690
  color: "default",
29376
29691
  size: "small",
29377
29692
  className: "bg-danger text-white",
29693
+ disabled: disabled,
29378
29694
  onClick: handleClickDeleteChapter
29379
29695
  }, React__default.createElement(FaTrashCan, {
29380
29696
  size: 12
@@ -29401,7 +29717,9 @@ var ChapterBlock = function ChapterBlock(_ref) {
29401
29717
  return React__default.createElement(TextField, Object.assign({
29402
29718
  placeholder: t("name")
29403
29719
  }, field, {
29404
- size: "small"
29720
+ size: "small",
29721
+ onKeyDown: handleKeyDown,
29722
+ disabled: disabled
29405
29723
  }));
29406
29724
  }
29407
29725
  }), !!pageNameError && React__default.createElement(Typography, {
@@ -29422,7 +29740,9 @@ var ChapterBlock = function ChapterBlock(_ref) {
29422
29740
  placeholder: t("page_from"),
29423
29741
  type: "number"
29424
29742
  }, field, {
29425
- size: "small"
29743
+ size: "small",
29744
+ onKeyDown: handleKeyDown,
29745
+ disabled: disabled
29426
29746
  }));
29427
29747
  }
29428
29748
  }), !!pageFromError && React__default.createElement(Typography, {
@@ -29443,7 +29763,9 @@ var ChapterBlock = function ChapterBlock(_ref) {
29443
29763
  placeholder: t("page_to"),
29444
29764
  type: "number"
29445
29765
  }, field, {
29446
- size: "small"
29766
+ size: "small",
29767
+ onKeyDown: handleKeyDown,
29768
+ disabled: disabled
29447
29769
  }));
29448
29770
  }
29449
29771
  }), !!pageToError && React__default.createElement(Typography, {
@@ -29462,6 +29784,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
29462
29784
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29463
29785
  isLoadingCategories: isLoadingCategories,
29464
29786
  optionKey: optionKey,
29787
+ disabled: disabled,
29465
29788
  onDelete: onDelete,
29466
29789
  onCopiedPrevQuestionGroup: onCopiedPrevQuestionGroup,
29467
29790
  onOpenSubCategoryMenu: onOpenSubCategoryMenu,
@@ -29593,7 +29916,8 @@ var QuestionTypeFilter = function QuestionTypeFilter(_ref) {
29593
29916
  }, React__default.createElement(FormLabel, null, t("search")), React__default.createElement(TextField, {
29594
29917
  placeholder: t("question_type_search_keyword"),
29595
29918
  size: "small",
29596
- inputRef: inputRef
29919
+ inputRef: inputRef,
29920
+ onKeyDown: handleKeyDown
29597
29921
  })), React__default.createElement(FormGroup, {
29598
29922
  sx: {
29599
29923
  display: "flex",
@@ -29832,9 +30156,10 @@ var useTextbookOptions = function useTextbookOptions(subjectId, isMath, filter,
29832
30156
 
29833
30157
  var _$3 = _$5;
29834
30158
  var TextbookContentsTab = function TextbookContentsTab(props) {
29835
- var values = props.values,
30159
+ var disabled = props.disabled,
30160
+ values = props.values,
29836
30161
  setFieldValue = props.setFieldValue;
29837
- var isMath = values.type === 2;
30162
+ var isMath = values.type === TextbookEditorType.Math;
29838
30163
  var _useTranslation = useTranslation(),
29839
30164
  t = _useTranslation.t;
29840
30165
  var _useState = useState(""),
@@ -29945,7 +30270,7 @@ var TextbookContentsTab = function TextbookContentsTab(props) {
29945
30270
  return React__default.createElement(Stack, {
29946
30271
  direction: "column",
29947
30272
  gap: 3
29948
- }, isMath && React__default.createElement(Box, null, React__default.createElement(QuestionTypeFilter, {
30273
+ }, isMath && !disabled && React__default.createElement(Box, null, React__default.createElement(QuestionTypeFilter, {
29949
30274
  filter: filter,
29950
30275
  setFilter: setFilter,
29951
30276
  inputRef: inputRef,
@@ -29966,6 +30291,7 @@ var TextbookContentsTab = function TextbookContentsTab(props) {
29966
30291
  categories: categories,
29967
30292
  isLoadingQuestionTypes: isLoadingQuestionTypes,
29968
30293
  questionTypes: questionTypes,
30294
+ disabled: disabled,
29969
30295
  onToggle: handleToggleBlock,
29970
30296
  onDelete: handleOpenConfirmDelete,
29971
30297
  onCopiedPrevQuestionGroup: handleCopiedPrevQuestionGroup,
@@ -29981,6 +30307,7 @@ var TextbookContentsTab = function TextbookContentsTab(props) {
29981
30307
  width: "fit-content"
29982
30308
  },
29983
30309
  variant: "contained",
30310
+ disabled: disabled,
29984
30311
  startIcon: React__default.createElement(IoIosAdd, null),
29985
30312
  onClick: function onClick() {
29986
30313
  var length = values.chapters.length;
@@ -30010,16 +30337,49 @@ var VisuallyHiddenInput = styled("input")({
30010
30337
  whiteSpace: "nowrap",
30011
30338
  width: "100%"
30012
30339
  });
30340
+ var customSelectStyles = {
30341
+ control: function control(baseStyles, state) {
30342
+ return _extends({}, baseStyles, {
30343
+ fontSize: "16px",
30344
+ fontWeight: baseStyles.fontWeight,
30345
+ color: styles.darker,
30346
+ borderColor: state.isFocused ? styles.dark : baseStyles.borderColor,
30347
+ boxShadow: state.isFocused ? "0 0 0 1px " + styles.dark + "4D" : baseStyles.boxShadow,
30348
+ "&:active": {
30349
+ borderColor: state.isFocused ? styles.dark : baseStyles.borderColor
30350
+ },
30351
+ "&:hover": {
30352
+ borderColor: state.isFocused ? styles.dark : baseStyles.borderColor
30353
+ },
30354
+ paddingBlock: '8px'
30355
+ });
30356
+ },
30357
+ singleValue: function singleValue(baseStyles) {
30358
+ return _extends({}, baseStyles, {
30359
+ fontSize: "16px",
30360
+ fontWeight: baseStyles.fontWeight,
30361
+ color: styles.darker
30362
+ });
30363
+ }
30364
+ };
30013
30365
  var TextbookInfoTab = function TextbookInfoTab(_ref) {
30014
- var setFieldValue = _ref.setFieldValue,
30366
+ var _user$roles;
30367
+ var isCreatedByAdmin = _ref.isCreatedByAdmin,
30368
+ setFieldValue = _ref.setFieldValue,
30015
30369
  values = _ref.values,
30016
30370
  errors = _ref.errors,
30017
30371
  coverImage = _ref.coverImage,
30018
- isAdmin = _ref.isAdmin,
30372
+ isSuperAdminUser = _ref.isSuperAdminUser,
30019
30373
  textbookId = _ref.textbookId,
30374
+ disabled = _ref.disabled,
30020
30375
  handleUploadImage = _ref.handleUploadImage;
30021
30376
  var _useTranslation = useTranslation(),
30022
30377
  t = _useTranslation.t;
30378
+ var user = useSelector(function (state) {
30379
+ var _state$common;
30380
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
30381
+ });
30382
+ var isTeacher = user && (user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(Role.Teacher));
30023
30383
  var gradeOptions = GRADE_OPTIONS.map(function (i) {
30024
30384
  return {
30025
30385
  label: t(i.label),
@@ -30037,6 +30397,7 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30037
30397
  value: value
30038
30398
  };
30039
30399
  });
30400
+ var hidePublicField = !textbookId && isSuperAdminUser || textbookId && isCreatedByAdmin;
30040
30401
  return React__default.createElement(Grid, {
30041
30402
  padding: 3,
30042
30403
  container: true,
@@ -30066,24 +30427,26 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30066
30427
  style: {
30067
30428
  padding: 4,
30068
30429
  color: "#fff",
30069
- background: styles.less_dark,
30430
+ background: !disabled ? styles.less_dark : styles.light,
30070
30431
  width: "150px",
30071
30432
  borderRadius: "6px",
30072
30433
  alignItems: "center",
30073
30434
  justifyContent: "center",
30074
30435
  position: "relative",
30075
30436
  display: "flex",
30076
- cursor: "pointer"
30437
+ cursor: disabled ? undefined : "pointer"
30077
30438
  }
30078
30439
  }, t("change_file"), React__default.createElement(VisuallyHiddenInput, {
30079
30440
  id: "coverImage",
30080
30441
  type: "file",
30081
30442
  accept: "image/*",
30082
30443
  onChange: function onChange(event) {
30083
- return handleUploadImage(event);
30444
+ return !disabled && handleUploadImage(event);
30084
30445
  },
30085
30446
  onClick: function onClick(e) {
30086
- e.target.value = "";
30447
+ if (!disabled) {
30448
+ e.target.value = "";
30449
+ }
30087
30450
  }
30088
30451
  }))) : React__default.createElement("label", {
30089
30452
  htmlFor: "coverImage",
@@ -30096,17 +30459,19 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30096
30459
  justifyContent: "center",
30097
30460
  position: "relative",
30098
30461
  display: "flex",
30099
- cursor: "pointer"
30462
+ cursor: disabled ? undefined : "pointer"
30100
30463
  }
30101
30464
  }, React__default.createElement(IoIosAdd, null), React__default.createElement(VisuallyHiddenInput, {
30102
30465
  id: "coverImage",
30103
30466
  type: "file",
30104
30467
  accept: "image/*",
30105
30468
  onChange: function onChange(event) {
30106
- return handleUploadImage(event);
30469
+ return !disabled && handleUploadImage(event);
30107
30470
  },
30108
30471
  onClick: function onClick(e) {
30109
- e.target.value = "";
30472
+ if (!disabled) {
30473
+ e.target.value = "";
30474
+ }
30110
30475
  }
30111
30476
  })))), React__default.createElement(Grid, {
30112
30477
  item: true,
@@ -30140,7 +30505,8 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30140
30505
  value: moment(value),
30141
30506
  onChange: function onChange(value) {
30142
30507
  return setFieldValue("publicationDate", moment(value).format(DATE_FORMAT));
30143
- }
30508
+ },
30509
+ disabled: disabled
30144
30510
  })));
30145
30511
  }
30146
30512
  }), !!(errors !== null && errors !== void 0 && errors.publicationDate) && React__default.createElement(Typography, {
@@ -30160,7 +30526,10 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30160
30526
  name: "publisher",
30161
30527
  render: function render(_ref5) {
30162
30528
  var field = _ref5.field;
30163
- return React__default.createElement(TextField, Object.assign({}, field));
30529
+ return React__default.createElement(TextField, Object.assign({}, field, {
30530
+ onKeyDown: handleKeyDown,
30531
+ disabled: disabled
30532
+ }));
30164
30533
  }
30165
30534
  }), !!(errors !== null && errors !== void 0 && errors.publisher) && React__default.createElement(Typography, {
30166
30535
  fontWeight: 500,
@@ -30185,6 +30554,8 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30185
30554
  onChange: function onChange(val) {
30186
30555
  setFieldValue(field.name, !(val !== null && val !== void 0 && val.value) ? 0 : Number(val.value));
30187
30556
  },
30557
+ styles: customSelectStyles,
30558
+ isDisabled: disabled || isTeacher && !textbookId,
30188
30559
  isClearable: true
30189
30560
  }));
30190
30561
  }
@@ -30205,17 +30576,20 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30205
30576
  name: "isbn",
30206
30577
  render: function render(_ref7) {
30207
30578
  var field = _ref7.field;
30208
- return React__default.createElement(TextField, Object.assign({}, field));
30579
+ return React__default.createElement(TextField, Object.assign({}, field, {
30580
+ onKeyDown: handleKeyDown,
30581
+ disabled: disabled
30582
+ }));
30209
30583
  }
30210
30584
  }), !!(errors !== null && errors !== void 0 && errors.isbn) && React__default.createElement(Typography, {
30211
30585
  fontWeight: 500,
30212
30586
  fontSize: "10px",
30213
30587
  lineHeight: "11.93px",
30214
30588
  color: !(errors !== null && errors !== void 0 && errors.isbn) ? "#97A1AF" : "#F34B4B"
30215
- }, errors === null || errors === void 0 ? void 0 : errors.isbn))), !(isAdmin && !textbookId) && React__default.createElement(Grid, {
30589
+ }, errors === null || errors === void 0 ? void 0 : errors.isbn))), React__default.createElement(Grid, {
30216
30590
  item: true,
30217
30591
  xs: 6
30218
- }, React__default.createElement(Stack, {
30592
+ }, !hidePublicField && React__default.createElement(Stack, {
30219
30593
  flexDirection: "column",
30220
30594
  gap: 1,
30221
30595
  alignItems: "start"
@@ -30227,7 +30601,13 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30227
30601
  var field = _ref8.field;
30228
30602
  return React__default.createElement(Checkbox, Object.assign({
30229
30603
  checked: field === null || field === void 0 ? void 0 : field.value
30230
- }, field));
30604
+ }, field, {
30605
+ onChange: function onChange(e, checked) {
30606
+ field.onChange(e, checked);
30607
+ if (checked) setFieldValue("textbookOwners", []);
30608
+ },
30609
+ disabled: disabled
30610
+ }));
30231
30611
  }
30232
30612
  }), !!(errors !== null && errors !== void 0 && errors.isPublic) && React__default.createElement(Typography, {
30233
30613
  fontWeight: 500,
@@ -30249,9 +30629,11 @@ var TextbookInfoTab = function TextbookInfoTab(_ref) {
30249
30629
  return React__default.createElement(CustomSelect, Object.assign({}, field, {
30250
30630
  options: gradeOptions,
30251
30631
  value: values.grade,
30632
+ styles: customSelectStyles,
30252
30633
  onChange: function onChange(val) {
30253
30634
  setFieldValue(field.name, String(val.value));
30254
- }
30635
+ },
30636
+ isDisabled: disabled
30255
30637
  }));
30256
30638
  }
30257
30639
  }), !!(errors !== null && errors !== void 0 && errors.grade) && React__default.createElement(Typography, {
@@ -30268,7 +30650,6 @@ var AcademySelector = function AcademySelector(_ref) {
30268
30650
  title = _ref.title,
30269
30651
  options = _ref.options,
30270
30652
  isLoading = _ref.isLoading,
30271
- valueById = _ref.valueById,
30272
30653
  isMultiple = _ref.isMultiple,
30273
30654
  _ref$isClearable = _ref.isClearable,
30274
30655
  isClearable = _ref$isClearable === void 0 ? true : _ref$isClearable,
@@ -30279,9 +30660,6 @@ var AcademySelector = function AcademySelector(_ref) {
30279
30660
  setSearchString = _useState[1];
30280
30661
  var _useTranslation = useTranslation(),
30281
30662
  t = _useTranslation.t;
30282
- var valueOption = valueById !== null && typeof valueById !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
30283
- return option.value == valueById;
30284
- })) || null : null;
30285
30663
  return React__default.createElement(FormGroup, null, !!title && React__default.createElement("label", {
30286
30664
  className: "text-muted"
30287
30665
  }, title), React__default.createElement(CustomSelectOption, {
@@ -30293,7 +30671,7 @@ var AcademySelector = function AcademySelector(_ref) {
30293
30671
  isLoading: isLoading,
30294
30672
  placeholder: t('please_select'),
30295
30673
  isMulti: isMultiple,
30296
- value: valueOption || value,
30674
+ value: value,
30297
30675
  onChange: onChange,
30298
30676
  isDisabled: disabled,
30299
30677
  isClearable: isClearable,
@@ -30311,15 +30689,12 @@ var CourseSelector = function CourseSelector(_ref) {
30311
30689
  minimumTextSearchLength = _ref.minimumTextSearchLength,
30312
30690
  placeholder = _ref.placeholder,
30313
30691
  isClearable = _ref.isClearable,
30314
- valueById = _ref.valueById;
30692
+ isDisabled = _ref.isDisabled;
30315
30693
  var _useState = useState(""),
30316
30694
  searchString = _useState[0],
30317
30695
  setSearchString = _useState[1];
30318
30696
  var _useTranslation = useTranslation(),
30319
30697
  t = _useTranslation.t;
30320
- var valueOption = valueById !== null && typeof valueById !== "undefined" ? (options === null || options === void 0 ? void 0 : options.find(function (option) {
30321
- return option.value == valueById;
30322
- })) || null : null;
30323
30698
  return React__default.createElement(FormGroup, null, !!title && React__default.createElement("label", null, title), React__default.createElement(CustomSelectOption, {
30324
30699
  options: options,
30325
30700
  inputValue: searchString,
@@ -30331,9 +30706,10 @@ var CourseSelector = function CourseSelector(_ref) {
30331
30706
  number: minimumTextSearchLength
30332
30707
  }) : t("select_class_placeholder")),
30333
30708
  isMulti: isMulti,
30334
- value: valueOption || value,
30709
+ value: value,
30335
30710
  onChange: onChange,
30336
- isClearable: isClearable
30711
+ isClearable: isClearable,
30712
+ isDisabled: isDisabled
30337
30713
  }));
30338
30714
  };
30339
30715
 
@@ -30357,7 +30733,7 @@ var useSelect = function useSelect(_ref) {
30357
30733
  isLoading = _useState2[0],
30358
30734
  setLoading = _useState2[1];
30359
30735
  useEffect(function () {
30360
- if (!email) return;
30736
+ if (!email || !academy) return;
30361
30737
  var fetchData = _$5.debounce(function () {
30362
30738
  try {
30363
30739
  var _temp2 = function _temp2() {
@@ -30397,12 +30773,13 @@ var useSelect = function useSelect(_ref) {
30397
30773
  };
30398
30774
 
30399
30775
  var OwnerSelector = function OwnerSelector(_ref) {
30400
- var _values$textbookOwner, _errors$textbookOwner, _errors$textbookOwner2, _values$textbookOwner2, _errors$textbookOwner3, _errors$textbookOwner4;
30776
+ var _values$textbookOwner, _errors$textbookOwner, _errors$textbookOwner2, _values$textbookOwner3, _errors$textbookOwner3, _errors$textbookOwner4;
30401
30777
  var values = _ref.values,
30402
30778
  errors = _ref.errors,
30403
30779
  index = _ref.index,
30404
30780
  email = _ref.email,
30405
- onChangeFieldValue = _ref.onChangeFieldValue;
30781
+ onChangeFieldValue = _ref.onChangeFieldValue,
30782
+ disabled = _ref.disabled;
30406
30783
  var _useSelect = useSelect({
30407
30784
  email: email
30408
30785
  }),
@@ -30410,6 +30787,14 @@ var OwnerSelector = function OwnerSelector(_ref) {
30410
30787
  isLoading = _useSelect.isLoading,
30411
30788
  academies = _useSelect.academies,
30412
30789
  courses = _useSelect.courses;
30790
+ var handleChangeAcademy = function handleChangeAcademy(val) {
30791
+ onChangeFieldValue("textbookOwners[" + index + "].academyId", val === null || val === void 0 ? void 0 : val.value);
30792
+ onChangeFieldValue("textbookOwners[" + index + "].academy", val);
30793
+ };
30794
+ var handleChangeCourse = function handleChangeCourse(val) {
30795
+ onChangeFieldValue("textbookOwners[" + index + "].courseId", val === null || val === void 0 ? void 0 : val.value);
30796
+ onChangeFieldValue("textbookOwners[" + index + "].course", val);
30797
+ };
30413
30798
  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(Stack, {
30414
30799
  flexDirection: "column",
30415
30800
  gap: 1,
@@ -30419,16 +30804,16 @@ var OwnerSelector = function OwnerSelector(_ref) {
30419
30804
  }, t("academy")), React__default.createElement(Field, {
30420
30805
  name: "textbookOwners[" + index + "].academyId",
30421
30806
  render: function render(_ref2) {
30807
+ var _values$textbookOwner2;
30422
30808
  var field = _ref2.field;
30423
30809
  return React__default.createElement(AcademySelector, Object.assign({}, field, {
30424
30810
  options: academies,
30425
30811
  disabled: true,
30426
- defaultValue: academies.length > 0 ? academies[0].value : undefined,
30812
+ value: (_values$textbookOwner2 = values.textbookOwners[index]) === null || _values$textbookOwner2 === void 0 ? void 0 : _values$textbookOwner2.academy,
30427
30813
  isLoading: isLoading,
30428
30814
  valueById: field === null || field === void 0 ? void 0 : field.value,
30429
- onChange: function onChange(val) {
30430
- return onChangeFieldValue("textbookOwners[" + index + "].academyId", val === null || val === void 0 ? void 0 : val.value);
30431
- }
30815
+ onChange: handleChangeAcademy,
30816
+ isDisabled: disabled
30432
30817
  }));
30433
30818
  }
30434
30819
  }), !!(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(Typography, {
@@ -30436,7 +30821,7 @@ var OwnerSelector = function OwnerSelector(_ref) {
30436
30821
  fontSize: "10px",
30437
30822
  lineHeight: "11.93px",
30438
30823
  color: !(errors !== null && errors !== void 0 && errors.textbookOwners[index].academyId) ? "#97A1AF" : "#F34B4B"
30439
- }, 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(Stack, {
30824
+ }, 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(Stack, {
30440
30825
  flexDirection: "column",
30441
30826
  gap: 1,
30442
30827
  width: 1
@@ -30445,14 +30830,14 @@ var OwnerSelector = function OwnerSelector(_ref) {
30445
30830
  }, t("class")), React__default.createElement(Field, {
30446
30831
  name: "textbookOwners[" + index + "].courseId",
30447
30832
  render: function render(_ref3) {
30833
+ var _values$textbookOwner4;
30448
30834
  var field = _ref3.field;
30449
30835
  return React__default.createElement(CourseSelector, Object.assign({}, field, {
30450
30836
  options: courses,
30451
30837
  isLoading: isLoading,
30452
- valueById: field === null || field === void 0 ? void 0 : field.value,
30453
- onChange: function onChange(val) {
30454
- return onChangeFieldValue("textbookOwners[" + index + "].courseId", val === null || val === void 0 ? void 0 : val.value);
30455
- }
30838
+ value: (_values$textbookOwner4 = values.textbookOwners[index]) === null || _values$textbookOwner4 === void 0 ? void 0 : _values$textbookOwner4.course,
30839
+ onChange: handleChangeCourse,
30840
+ isDisabled: disabled
30456
30841
  }));
30457
30842
  }
30458
30843
  }), !!(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(Typography, {
@@ -30467,10 +30852,16 @@ var _$4 = _$5;
30467
30852
  var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30468
30853
  var errors = _ref.errors,
30469
30854
  values = _ref.values,
30855
+ disabled = _ref.disabled,
30470
30856
  setFieldValue = _ref.setFieldValue;
30471
30857
  var textbookOwners = values.textbookOwners;
30858
+ var academy = useSelector(function (state) {
30859
+ var _state$common;
30860
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.academy;
30861
+ });
30472
30862
  var _useTranslation = useTranslation(),
30473
30863
  t = _useTranslation.t;
30864
+ var hasErrors = errors.textbookOwners;
30474
30865
  return React__default.createElement(Box, {
30475
30866
  className: "bg-white mt-2",
30476
30867
  sx: {
@@ -30483,15 +30874,15 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30483
30874
  return React__default.createElement(Grid, {
30484
30875
  container: true,
30485
30876
  spacing: "16px"
30486
- }, textbookOwners === null || textbookOwners === void 0 ? void 0 : textbookOwners.map(function (_val, index) {
30487
- var _values$textbookOwner, _values$textbookOwner2;
30877
+ }, textbookOwners === null || textbookOwners === void 0 ? void 0 : textbookOwners.map(function (val, index) {
30878
+ var _errors$textbookOwner, _values$textbookOwner, _values$textbookOwner2;
30488
30879
  return React__default.createElement(Grid, {
30489
30880
  item: true,
30490
30881
  xs: 6,
30491
- lg: 2
30882
+ lg: 3
30492
30883
  }, React__default.createElement(Stack, {
30493
30884
  sx: {
30494
- border: "1px solid " + styles.gray_300,
30885
+ border: "1px solid " + ((_errors$textbookOwner = errors.textbookOwners) !== null && _errors$textbookOwner !== void 0 && _errors$textbookOwner[index] ? styles.red_900 : styles.gray_300),
30495
30886
  borderRadius: "6px",
30496
30887
  width: "100%",
30497
30888
  height: "350px",
@@ -30509,6 +30900,7 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30509
30900
  top: 8,
30510
30901
  color: styles.gray_500
30511
30902
  },
30903
+ disabled: disabled || !!val.academyId && val.academyId !== (academy === null || academy === void 0 ? void 0 : academy.id),
30512
30904
  onClick: function onClick() {
30513
30905
  arrayHelpers.remove(index);
30514
30906
  }
@@ -30524,24 +30916,28 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30524
30916
  var field = _ref2.field;
30525
30917
  return React__default.createElement(TextField, Object.assign({
30526
30918
  fullWidth: true
30527
- }, field));
30919
+ }, field, {
30920
+ onKeyDown: handleKeyDown,
30921
+ disabled: disabled || !!val.academyId && val.academyId !== (academy === null || academy === void 0 ? void 0 : academy.id)
30922
+ }));
30528
30923
  }
30529
30924
  }), _$4.get(errors, "textbookOwners[" + index + "].email") && React__default.createElement(Typography, {
30530
30925
  fontWeight: 500,
30531
30926
  fontSize: "10px",
30532
30927
  lineHeight: "11.93px",
30533
- color: _$4.get(errors, "textbookOwners[" + index + "].email") ? "#97A1AF" : "#F34B4B"
30928
+ color: "#F34B4B"
30534
30929
  }, _$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, {
30535
30930
  values: values,
30536
30931
  errors: errors,
30537
30932
  index: index,
30538
30933
  email: values === null || values === void 0 ? void 0 : (_values$textbookOwner2 = values.textbookOwners) === null || _values$textbookOwner2 === void 0 ? void 0 : _values$textbookOwner2[index].email,
30539
- onChangeFieldValue: setFieldValue
30934
+ onChangeFieldValue: setFieldValue,
30935
+ disabled: disabled || !!val.academyId && val.academyId !== (academy === null || academy === void 0 ? void 0 : academy.id)
30540
30936
  })));
30541
- }), React__default.createElement(Grid, {
30937
+ }), !hasErrors && !disabled && academy && React__default.createElement(Grid, {
30542
30938
  item: true,
30543
30939
  xs: 6,
30544
- lg: 2
30940
+ lg: 3
30545
30941
  }, React__default.createElement("div", {
30546
30942
  style: {
30547
30943
  display: "flex",
@@ -30555,7 +30951,14 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30555
30951
  background: styles.gray_50
30556
30952
  },
30557
30953
  onClick: function onClick() {
30558
- return arrayHelpers.push(DefaultTextbookOwner);
30954
+ var _academy$id;
30955
+ arrayHelpers.push(_extends({}, DefaultTextbookOwner, {
30956
+ academy: academy ? {
30957
+ label: academy.name,
30958
+ value: academy.id
30959
+ } : null,
30960
+ academyId: (_academy$id = academy === null || academy === void 0 ? void 0 : academy.id) != null ? _academy$id : null
30961
+ }));
30559
30962
  }
30560
30963
  }, React__default.createElement(Stack, null, React__default.createElement(IoMdAdd, {
30561
30964
  size: 24
@@ -30564,158 +30967,17 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30564
30967
  }));
30565
30968
  };
30566
30969
 
30567
- var _reduceToMathArticles = function reduceToMathArticles(textbook, isMath) {
30568
- var values = isMath !== undefined ? _$5.cloneDeep(textbook) : textbook;
30569
- if (isMath !== undefined) values.type = isMath;
30570
- for (var key in values) {
30571
- if (values.hasOwnProperty(key)) {
30572
- if (key === "articles") {
30573
- var _values$key;
30574
- values[key] = (_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.length ? [values[key][0]] : [DEFAULT_ARTICLE];
30575
- } else if (typeof values[key] === "object" && values[key] !== null) {
30576
- _reduceToMathArticles(values[key]);
30577
- }
30578
- }
30579
- }
30580
- return values;
30581
- };
30582
- var _resetAllCategoriesAndQuestionTypesBySubject = function resetAllCategoriesAndQuestionTypesBySubject(textbook, subject) {
30583
- var values = subject ? _$5.cloneDeep(textbook) : textbook;
30584
- if (subject) {
30585
- values.subjectId = subject === null || subject === void 0 ? void 0 : subject.value;
30586
- values.subject = subject;
30587
- }
30588
- for (var key in values) {
30589
- if (values.hasOwnProperty(key)) {
30590
- if (key === "categories" || key === "categoryOptions") {
30591
- values[key] = [];
30592
- } else if (key === "questionType" || key === "questionTypeId") {
30593
- values[key] = null;
30594
- } else if (typeof values[key] === "object" && values[key] !== null) {
30595
- _resetAllCategoriesAndQuestionTypesBySubject(values[key]);
30596
- }
30597
- }
30598
- }
30599
- return values;
30600
- };
30601
- var convertResponseToRequest = function convertResponseToRequest(selectedTextbook) {
30602
- var _selectedTextbook$sub;
30603
- if (!selectedTextbook) return DEFAULT_TEXTBOOK_REQUEST;
30604
- return {
30605
- name: selectedTextbook.name || "",
30606
- subjectId: ((_selectedTextbook$sub = selectedTextbook.subject) === null || _selectedTextbook$sub === void 0 ? void 0 : _selectedTextbook$sub.id) || 0,
30607
- subject: selectedTextbook.subject ? {
30608
- label: selectedTextbook.subject.name,
30609
- value: selectedTextbook.subject.id
30610
- } : null,
30611
- preparedType: selectedTextbook.preparedType || 0,
30612
- grade: selectedTextbook.grade || "1",
30613
- publicationDate: (selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.publicationDate) || "",
30614
- publisher: selectedTextbook.publisher || "",
30615
- isbn: selectedTextbook.isbn || "",
30616
- coverImage: selectedTextbook.coverImage || "",
30617
- textbookOwners: selectedTextbook.textbookOwners,
30618
- isPublic: selectedTextbook.isPublic || false,
30619
- isShared: selectedTextbook.isShared || false,
30620
- isPrepared: true,
30621
- type: selectedTextbook.type,
30622
- chapters: selectedTextbook.chapters.map(function (c) {
30623
- var _c$questionGroups;
30624
- return {
30625
- name: c.name,
30626
- pageFrom: c.pageFrom || 0,
30627
- pageTo: c.pageTo || 0,
30628
- id: c.id,
30629
- questionGroups: ((_c$questionGroups = c.questionGroups) === null || _c$questionGroups === void 0 ? void 0 : _c$questionGroups.map(function (g) {
30630
- var _g$questions$;
30631
- return {
30632
- id: g.id,
30633
- chapterId: c.id,
30634
- questions: g.questions.map(function (q) {
30635
- var _q$questionType;
30636
- return _extends({}, q, {
30637
- questionTypeId: q.questionTypeId || q.questionType.id,
30638
- questionType: (_q$questionType = q.questionType) !== null && _q$questionType !== void 0 && _q$questionType.id ? {
30639
- label: q.questionType.name,
30640
- value: q.questionType.id
30641
- } : null
30642
- });
30643
- }),
30644
- articles: g.articles.map(function (a) {
30645
- return _extends({}, a, {
30646
- categoryOptions: a.categories.map(function (cat) {
30647
- return {
30648
- label: cat.name,
30649
- value: cat.id
30650
- };
30651
- }),
30652
- categories: a.categories.filter(function (cat) {
30653
- return !!cat.id;
30654
- }).map(function (cat) {
30655
- return cat.id;
30656
- })
30657
- });
30658
- }),
30659
- questionCount: g.questions.length,
30660
- answerCount: ((_g$questions$ = g.questions[0]) === null || _g$questions$ === void 0 ? void 0 : _g$questions$.numberOfAnswers) || 5
30661
- };
30662
- })) || [],
30663
- subChapters: c.subChapters.map(function (sub) {
30664
- var _sub$questionGroups;
30665
- return {
30666
- name: sub.name,
30667
- pageFrom: sub.pageFrom || 0,
30668
- pageTo: sub.pageTo || 0,
30669
- id: sub.id,
30670
- questionGroups: ((_sub$questionGroups = sub.questionGroups) === null || _sub$questionGroups === void 0 ? void 0 : _sub$questionGroups.map(function (g) {
30671
- var _g$questions$2;
30672
- return {
30673
- id: g.id,
30674
- chapterId: c.id,
30675
- questions: g.questions.map(function (q) {
30676
- var _q$questionType2;
30677
- return _extends({}, q, {
30678
- questionTypeId: q.questionTypeId || q.questionType.id,
30679
- questionType: (_q$questionType2 = q.questionType) !== null && _q$questionType2 !== void 0 && _q$questionType2.id ? {
30680
- label: q.questionType.name,
30681
- value: q.questionType.id
30682
- } : null
30683
- });
30684
- }),
30685
- articles: g.articles.map(function (a) {
30686
- return _extends({}, a, {
30687
- categoryOptions: a.categories.map(function (cat) {
30688
- return {
30689
- label: cat.name,
30690
- value: cat.id
30691
- };
30692
- }),
30693
- categories: a.categories.filter(function (cat) {
30694
- return !!cat.id;
30695
- }).map(function (cat) {
30696
- return cat.id;
30697
- })
30698
- });
30699
- }),
30700
- questionCount: g.questions.length,
30701
- answerCount: ((_g$questions$2 = g.questions[0]) === null || _g$questions$2 === void 0 ? void 0 : _g$questions$2.numberOfAnswers) || 5
30702
- };
30703
- })) || [],
30704
- subChapters: []
30705
- };
30706
- })
30707
- };
30708
- })
30709
- };
30710
- };
30711
-
30712
- var _excluded$l = ["isSuperAdmin", "isAdmin", "textbookId", "selected", "coverImage", "onChangeTab", "onUploadImage"];
30970
+ var _excluded$l = ["isCreatedByAdmin", "isSuperAdminUser", "isSuperAdmin", "isAdmin", "textbookId", "selected", "coverImage", "disabled", "ownersDisabled", "onChangeTab", "onUploadImage"];
30713
30971
  var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30714
- var isSuperAdmin = _ref.isSuperAdmin,
30972
+ var isCreatedByAdmin = _ref.isCreatedByAdmin,
30973
+ isSuperAdminUser = _ref.isSuperAdminUser,
30974
+ isSuperAdmin = _ref.isSuperAdmin,
30715
30975
  isAdmin = _ref.isAdmin,
30716
30976
  textbookId = _ref.textbookId,
30717
30977
  selected = _ref.selected,
30718
30978
  coverImage = _ref.coverImage,
30979
+ disabled = _ref.disabled,
30980
+ ownersDisabled = _ref.ownersDisabled,
30719
30981
  onChangeTab = _ref.onChangeTab,
30720
30982
  onUploadImage = _ref.onUploadImage,
30721
30983
  formikProps = _objectWithoutPropertiesLoose(_ref, _excluded$l);
@@ -30736,7 +30998,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30736
30998
  };
30737
30999
  }, [dirty, t$1]);
30738
31000
  var handleChangeTextbookType = function handleChangeTextbookType() {
30739
- var isMath = values.type === 2 ? 1 : 2;
31001
+ var isMath = values.type === TextbookEditorType.Math ? TextbookEditorType.Korea : TextbookEditorType.Math;
30740
31002
  var newValues = _reduceToMathArticles(values, isMath);
30741
31003
  setValues(newValues);
30742
31004
  };
@@ -30773,7 +31035,9 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30773
31035
  return React__default.createElement(TextField, Object.assign({
30774
31036
  placeholder: t$1("title")
30775
31037
  }, field, {
30776
- size: "small"
31038
+ size: "small",
31039
+ disabled: disabled,
31040
+ onKeyDown: handleKeyDown
30777
31041
  }));
30778
31042
  }
30779
31043
  }), !!(errors !== null && errors !== void 0 && errors.name) && React__default.createElement(Typography, {
@@ -30793,7 +31057,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30793
31057
  var field = _ref3.field;
30794
31058
  return React__default.createElement(SubjectSelector, Object.assign({}, field, {
30795
31059
  value: values.subject,
30796
- isDisabled: !!textbookId,
31060
+ isDisabled: !!textbookId || disabled,
30797
31061
  onChange: handleChangeSubject
30798
31062
  }));
30799
31063
  }
@@ -30815,7 +31079,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30815
31079
  var field = _ref4.field;
30816
31080
  return React__default.createElement(Switch, Object.assign({}, field, {
30817
31081
  color: "success",
30818
- disabled: !!textbookId,
31082
+ disabled: !!textbookId || disabled,
30819
31083
  checked: values.type === 2,
30820
31084
  onChange: handleChangeTextbookType
30821
31085
  }));
@@ -30826,6 +31090,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30826
31090
  width: "fit-content"
30827
31091
  },
30828
31092
  variant: "contained",
31093
+ disabled: disabled,
30829
31094
  onClick: function onClick() {
30830
31095
  if (!_$5.isEmpty(errors)) {
30831
31096
  toast.error(t$1("please_fill_in_the_blank_fields"));
@@ -30868,7 +31133,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30868
31133
  sx: {
30869
31134
  color: contentsErrors && submitCount ? error.main + "!important" : "gray"
30870
31135
  }
30871
- }, a11yProps(1))), !(values !== null && values !== void 0 && values.isPublic) && (!isSuperAdmin || textbookId) && (!textbookId || (values === null || values === void 0 ? void 0 : values.isShared)) && React__default.createElement(Tab, Object.assign({
31136
+ }, 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(Tab, Object.assign({
30872
31137
  label: t$1("textbook.owners"),
30873
31138
  sx: {
30874
31139
  color: textbookOwnersErrors && submitCount ? error.main + "!important" : "gray"
@@ -30880,14 +31145,20 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30880
31145
  coverImage: coverImage,
30881
31146
  handleUploadImage: onUploadImage,
30882
31147
  textbookId: textbookId,
30883
- isAdmin: isAdmin
31148
+ disabled: disabled,
31149
+ isCreatedByAdmin: isCreatedByAdmin,
31150
+ isSuperAdminUser: isSuperAdminUser
30884
31151
  }))), React__default.createElement(CustomTextbookTab, {
30885
31152
  value: selected,
30886
31153
  index: 1
30887
- }, React__default.createElement(TextbookContentsTab, Object.assign({}, formikProps))), React__default.createElement(CustomTextbookTab, {
31154
+ }, React__default.createElement(TextbookContentsTab, Object.assign({}, formikProps, {
31155
+ disabled: disabled
31156
+ }))), React__default.createElement(CustomTextbookTab, {
30888
31157
  value: selected,
30889
31158
  index: 2
30890
- }, React__default.createElement(TextbookOwnersTab, Object.assign({}, formikProps))))));
31159
+ }, React__default.createElement(TextbookOwnersTab, Object.assign({}, formikProps, {
31160
+ disabled: ownersDisabled
31161
+ }))))));
30891
31162
  };
30892
31163
  var a11yProps = function a11yProps(index) {
30893
31164
  return {
@@ -30897,7 +31168,8 @@ var a11yProps = function a11yProps(index) {
30897
31168
  };
30898
31169
 
30899
31170
  var PreparedTextbookView = function PreparedTextbookView(_ref) {
30900
- var notFoundView = _ref.notFoundView,
31171
+ var role = _ref.role,
31172
+ notFoundView = _ref.notFoundView,
30901
31173
  onBackToList = _ref.onBackToList,
30902
31174
  textbookId = _ref.textbookId;
30903
31175
  var _useState = useState(0),
@@ -30908,10 +31180,15 @@ var PreparedTextbookView = function PreparedTextbookView(_ref) {
30908
31180
  };
30909
31181
  var _useTextbookManagemen = useTextbookManagement({
30910
31182
  onNavigateList: onBackToList,
30911
- textbookId: textbookId
31183
+ textbookId: textbookId,
31184
+ role: role
30912
31185
  }),
30913
31186
  t = _useTextbookManagemen.t,
31187
+ disabledTextbookOwners = _useTextbookManagemen.disabledTextbookOwners,
31188
+ isReadonly = _useTextbookManagemen.isReadonly,
31189
+ isEditable = _useTextbookManagemen.isEditable,
30914
31190
  isSuperAdmin = _useTextbookManagemen.isSuperAdmin,
31191
+ isSuperAdminUser = _useTextbookManagemen.isSuperAdminUser,
30915
31192
  isAdmin = _useTextbookManagemen.isAdmin,
30916
31193
  coverImage = _useTextbookManagemen.coverImage,
30917
31194
  selectedTextbook = _useTextbookManagemen.selectedTextbook,
@@ -30920,6 +31197,7 @@ var PreparedTextbookView = function PreparedTextbookView(_ref) {
30920
31197
  var textbookRequest = useMemo(function () {
30921
31198
  return convertResponseToRequest(selectedTextbook);
30922
31199
  }, [JSON.stringify(selectedTextbook)]);
31200
+ var isCreatedByAdmin = selectedTextbook === null || selectedTextbook === void 0 ? void 0 : selectedTextbook.isCreatedByAdmin;
30923
31201
  if (textbookId && selectedTextbook && !selectedTextbook.isPrepared) return notFoundView;
30924
31202
  return React__default.createElement(Box, null, React__default.createElement(Formik, {
30925
31203
  initialValues: textbookRequest,
@@ -30930,13 +31208,17 @@ var PreparedTextbookView = function PreparedTextbookView(_ref) {
30930
31208
  onSubmit: handleSubmit
30931
31209
  }, function (props) {
30932
31210
  return React__default.createElement(PreparedTextbookForm, Object.assign({
31211
+ isCreatedByAdmin: isCreatedByAdmin,
31212
+ isSuperAdminUser: isSuperAdminUser,
30933
31213
  isAdmin: isAdmin,
30934
31214
  isSuperAdmin: isSuperAdmin,
30935
31215
  selected: selected,
30936
31216
  textbookId: textbookId,
30937
31217
  onChangeTab: handleChangeTab,
30938
31218
  onUploadImage: handleUploadImage,
30939
- coverImage: coverImage
31219
+ coverImage: coverImage,
31220
+ disabled: isReadonly || !isEditable,
31221
+ ownersDisabled: isReadonly || disabledTextbookOwners
30940
31222
  }, props));
30941
31223
  }));
30942
31224
  };