touchstudy-core 0.1.130 → 0.1.131

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.
@@ -1426,6 +1426,7 @@ var subjective_answer = "주관식 정답";
1426
1426
  var current_correct_answer_entered = "현재 입력한 정답";
1427
1427
  var correct_answer_is_required = "정답은 필수입니다.";
1428
1428
  var cancel_2 = "취소하기";
1429
+ var article_required = "기사가 필요합니다";
1429
1430
  var lang_ko = {
1430
1431
  problem_solving: problem_solving,
1431
1432
  my_story: my_story,
@@ -2485,7 +2486,8 @@ var lang_ko = {
2485
2486
  subjective_answer: subjective_answer,
2486
2487
  current_correct_answer_entered: current_correct_answer_entered,
2487
2488
  correct_answer_is_required: correct_answer_is_required,
2488
- cancel_2: cancel_2
2489
+ cancel_2: cancel_2,
2490
+ article_required: article_required
2489
2491
  };
2490
2492
 
2491
2493
  var problem_solving$1 = "Problem Solving";
@@ -3568,6 +3570,7 @@ var subjective_answer$1 = "Subjective answer";
3568
3570
  var current_correct_answer_entered$1 = "Current correct answer entered";
3569
3571
  var correct_answer_is_required$1 = "Correct answer is required";
3570
3572
  var cancel_2$1 = "Cancel";
3573
+ var article_required$1 = "Article is required";
3571
3574
  var lang_en = {
3572
3575
  problem_solving: problem_solving$1,
3573
3576
  my_story: my_story$1,
@@ -4629,7 +4632,8 @@ var lang_en = {
4629
4632
  subjective_answer: subjective_answer$1,
4630
4633
  current_correct_answer_entered: current_correct_answer_entered$1,
4631
4634
  correct_answer_is_required: correct_answer_is_required$1,
4632
- cancel_2: cancel_2$1
4635
+ cancel_2: cancel_2$1,
4636
+ article_required: article_required$1
4633
4637
  };
4634
4638
 
4635
4639
  i18n.use(initReactI18next).init({
@@ -5976,6 +5980,11 @@ var customStyles = {
5976
5980
  color: styles.darker
5977
5981
  });
5978
5982
  },
5983
+ placeholder: function placeholder(baseStyles, _) {
5984
+ return _extends({}, baseStyles, {
5985
+ whiteSpace: "nowrap"
5986
+ });
5987
+ },
5979
5988
  singleValue: function singleValue(baseStyles) {
5980
5989
  return _extends({}, baseStyles, {
5981
5990
  fontSize: "14px",
@@ -5993,7 +6002,7 @@ var customStyles = {
5993
6002
  },
5994
6003
  menuPortal: function menuPortal(base) {
5995
6004
  return _extends({}, base, {
5996
- zIndex: 1
6005
+ zIndex: 99
5997
6006
  });
5998
6007
  }
5999
6008
  };
@@ -27485,6 +27494,9 @@ var preparedTextbookSchema = function preparedTextbookSchema(t) {
27485
27494
  },
27486
27495
  then: function then(schema) {
27487
27496
  return schema.min(1, t("category_required"));
27497
+ },
27498
+ otherwise: function otherwise(schema) {
27499
+ return schema.min(1, t("article_required"));
27488
27500
  }
27489
27501
  }),
27490
27502
  questions: array().of(object())
@@ -27503,7 +27515,17 @@ var preparedTextbookSchema = function preparedTextbookSchema(t) {
27503
27515
  title: string().notRequired(),
27504
27516
  author: string().notRequired(),
27505
27517
  subject: string().notRequired()
27506
- })),
27518
+ })).when("$type", {
27519
+ is: function is(type) {
27520
+ return type === 2;
27521
+ },
27522
+ then: function then(schema) {
27523
+ return schema.min(1, t("category_required"));
27524
+ },
27525
+ otherwise: function otherwise(schema) {
27526
+ return schema.min(1, t("article_required"));
27527
+ }
27528
+ }),
27507
27529
  questions: array().of(object())
27508
27530
  }))
27509
27531
  }))
@@ -27739,6 +27761,14 @@ var ArticleBlock = function ArticleBlock(_ref) {
27739
27761
  var handleOpenCategoryMenu = function handleOpenCategoryMenu() {
27740
27762
  onOpenCategoryMenu(path + ".categories[0]");
27741
27763
  };
27764
+ var handleChangeCategory = function handleChangeCategory(val) {
27765
+ setFieldValue(path + ".categoryOptions", [val]);
27766
+ setFieldValue(path + ".categories", [val === null || val === void 0 ? void 0 : val.value]);
27767
+ };
27768
+ var handleChangeSubCategory = function handleChangeSubCategory(val) {
27769
+ setFieldValue(path + ".categoryOptions[1]", [val]);
27770
+ setFieldValue(path + ".categories[1]", [val === null || val === void 0 ? void 0 : val.value]);
27771
+ };
27742
27772
  return React__default.createElement(Stack, {
27743
27773
  direction: "row",
27744
27774
  alignItems: "center",
@@ -27805,10 +27835,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
27805
27835
  onMenuOpen: handleOpenCategoryMenu,
27806
27836
  onMenuClose: onCloseCategoryMenu
27807
27837
  },
27808
- onChange: function onChange(val) {
27809
- setFieldValue(path + ".categories[0]", val === null || val === void 0 ? void 0 : val.value);
27810
- setFieldValue(path + ".categoryOptions[0]", val);
27811
- },
27838
+ onChange: handleChangeCategory,
27812
27839
  placeholder: t("select_category")
27813
27840
  });
27814
27841
  }
@@ -27845,10 +27872,7 @@ var ArticleBlock = function ArticleBlock(_ref) {
27845
27872
  onMenuOpen: handleOpenSubCategoryMenu,
27846
27873
  onMenuClose: onCloseCategoryMenu
27847
27874
  },
27848
- onChange: function onChange(val) {
27849
- setFieldValue(path + ".categories[1]", val === null || val === void 0 ? void 0 : val.value);
27850
- setFieldValue(path + ".categoryOptions[1]", val);
27851
- },
27875
+ onChange: handleChangeSubCategory,
27852
27876
  isDisabled: !data.categories[0],
27853
27877
  placeholder: t("select_category")
27854
27878
  });
@@ -27944,15 +27968,14 @@ var ArticleBlock$1 = memo(ArticleBlock, isEqual);
27944
27968
 
27945
27969
  var styles$9 = {"question":"_1_ONI","question-article":"_2FdrR","question-title":"_3mgRf","question-label":"_2h0kA","question-input":"_exAl-","question-btn":"_2ksp8"};
27946
27970
 
27971
+ var labelStyle = {
27972
+ textOverflow: "ellipsis",
27973
+ overflowX: "hidden",
27974
+ width: "100%",
27975
+ whiteSpace: "nowrap"
27976
+ };
27977
+
27947
27978
  var _excluded$e = ["onChange"];
27948
- var answerTypeOptions = Object.keys(QuestionAnswerType).filter(function (key) {
27949
- return Number.isNaN(+key);
27950
- }).map(function (label, index) {
27951
- return {
27952
- label: t$1(label.toLowerCase()),
27953
- value: index
27954
- };
27955
- });
27956
27979
  var BpIcon$1 = styled("span")(function (_ref) {
27957
27980
  var theme = _ref.theme;
27958
27981
  return {
@@ -28023,13 +28046,13 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28023
28046
  }, React__default.createElement(FormLabel, {
28024
28047
  htmlFor: "textual_answer",
28025
28048
  className: styles$9["question-label"] + " form-label"
28026
- }, t$1("textual_answer")), React__default.createElement(Field, {
28049
+ }, t("textual_answer")), React__default.createElement(Field, {
28027
28050
  name: path + ".textualAnswer",
28028
28051
  render: function render(_ref3) {
28029
28052
  var field = _ref3.field;
28030
28053
  return React__default.createElement(TextField, Object.assign({}, field, {
28031
28054
  size: "small",
28032
- placeholder: t$1("textual_answer")
28055
+ placeholder: t("textual_answer")
28033
28056
  }));
28034
28057
  }
28035
28058
  }));
@@ -28055,7 +28078,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28055
28078
  return handleCheckMultiChoice(+e.target.value);
28056
28079
  }
28057
28080
  }),
28058
- label: t$1("number_question", {
28081
+ label: t("number_question", {
28059
28082
  number: i
28060
28083
  })
28061
28084
  });
@@ -28091,7 +28114,7 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28091
28114
  checkedIcon: React__default.createElement(BpCheckedIcon$1, null),
28092
28115
  icon: React__default.createElement(BpIcon$1, null)
28093
28116
  }),
28094
- label: t$1("number_question", {
28117
+ label: t("number_question", {
28095
28118
  number: i
28096
28119
  })
28097
28120
  });
@@ -28100,10 +28123,27 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28100
28123
  return null;
28101
28124
  }
28102
28125
  };
28103
- console.log({
28104
- isLoadingQuestionTypes: isLoadingQuestionTypes,
28105
- path: path
28126
+ var handleChangeQuestionType = function handleChangeQuestionType(val) {
28127
+ if (typeof (val === null || val === void 0 ? void 0 : val.value) === "string") {
28128
+ setFieldValue(path + ".questionTypeId", 0);
28129
+ setFieldValue(path + ".questionTypeName", val === null || val === void 0 ? void 0 : val.value);
28130
+ } else {
28131
+ setFieldValue(path + ".questionTypeId", (val === null || val === void 0 ? void 0 : val.value) || 0);
28132
+ }
28133
+ setFieldValue(path + ".questionType", val);
28134
+ };
28135
+ var _useTranslation = useTranslation(),
28136
+ t = _useTranslation.t;
28137
+ var answerTypeOptions = Object.keys(QuestionAnswerType).filter(function (key) {
28138
+ return Number.isNaN(+key);
28139
+ }).map(function (label, index) {
28140
+ return {
28141
+ label: t(label.toLowerCase()),
28142
+ value: index
28143
+ };
28106
28144
  });
28145
+ var theme = useTheme();
28146
+ var isTabletUp = useMediaQuery(theme.breakpoints.up('lg'));
28107
28147
  return React__default.createElement(Stack, {
28108
28148
  direction: "row",
28109
28149
  alignItems: "center",
@@ -28112,11 +28152,12 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28112
28152
  }, React__default.createElement(Stack, {
28113
28153
  direction: "row",
28114
28154
  alignItems: "center",
28155
+ minWidth: "50%",
28115
28156
  flexGrow: 1
28116
28157
  }, React__default.createElement(Box, null, React__default.createElement(Box, {
28117
28158
  className: styles$9["question-title"] + " me-2 text-nowrap",
28118
28159
  sx: questionTitleStyle
28119
- }, t$1("problem_number_question", {
28160
+ }, t("problem_number_question", {
28120
28161
  number: data.questionOrder + 1
28121
28162
  }))), React__default.createElement(Box, {
28122
28163
  flexGrow: 1
@@ -28126,12 +28167,13 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28126
28167
  }, React__default.createElement(FormControl, {
28127
28168
  sx: {
28128
28169
  flexGrow: 1,
28129
- width: "168px"
28170
+ width: isTabletUp ? "120px" : "100px"
28130
28171
  }
28131
28172
  }, React__default.createElement(FormLabel, {
28132
28173
  htmlFor: "score",
28133
- className: styles$9["question-label"] + " form-label"
28134
- }, t$1("score")), React__default.createElement(Field, {
28174
+ className: styles$9["question-label"] + " form-label",
28175
+ sx: labelStyle
28176
+ }, t("score")), React__default.createElement(Field, {
28135
28177
  name: path + ".score",
28136
28178
  render: function render(_ref4) {
28137
28179
  var field = _ref4.field;
@@ -28145,12 +28187,13 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28145
28187
  })), isMath && React__default.createElement(FormGroup, {
28146
28188
  sx: {
28147
28189
  flexGrow: 1,
28148
- width: "240px"
28190
+ width: isTabletUp ? "180px" : "120px"
28149
28191
  }
28150
28192
  }, React__default.createElement(FormLabel, {
28151
28193
  htmlFor: "type",
28152
- className: styles$9["question-label"] + " form-label"
28153
- }, t$1("type")), React__default.createElement(Field, {
28194
+ className: styles$9["question-label"] + " form-label",
28195
+ sx: labelStyle
28196
+ }, t("type")), React__default.createElement(Field, {
28154
28197
  name: path + ".questionTypeId",
28155
28198
  render: function render(_ref5) {
28156
28199
  var _ref5$field = _ref5.field,
@@ -28162,26 +28205,20 @@ var QuestionBlock = function QuestionBlock(_ref2) {
28162
28205
  isLoading: optionKey === path + ".questionTypeId" ? isLoadingQuestionTypes : false,
28163
28206
  onMenuOpen: handleOpenQuestionTypeMenu,
28164
28207
  onMenuClose: onCloseQuestionTypeMenu,
28165
- onChange: function onChange(val) {
28166
- if (typeof (val === null || val === void 0 ? void 0 : val.value) === "string") {
28167
- setFieldValue(path + ".questionTypeId", 0);
28168
- setFieldValue(path + ".questionTypeName", val === null || val === void 0 ? void 0 : val.value);
28169
- } else {
28170
- setFieldValue(path + ".questionTypeId", (val === null || val === void 0 ? void 0 : val.value) || 0);
28171
- }
28172
- setFieldValue(path + ".questionType", val);
28173
- }
28208
+ onChange: handleChangeQuestionType,
28209
+ isClearable: true
28174
28210
  }));
28175
28211
  }
28176
28212
  })), React__default.createElement(FormGroup, {
28177
28213
  sx: {
28178
28214
  flexGrow: 1,
28179
- width: "240px"
28215
+ width: isTabletUp ? "180px" : "100px"
28180
28216
  }
28181
28217
  }, React__default.createElement(FormLabel, {
28182
28218
  htmlFor: "question_answer_type",
28183
- className: styles$9["question-label"] + " form-label"
28184
- }, t$1("question_answer_type")), React__default.createElement(Field, {
28219
+ className: styles$9["question-label"] + " form-label",
28220
+ sx: labelStyle
28221
+ }, t("question_answer_type")), React__default.createElement(Field, {
28185
28222
  name: path + ".questionAnswerType",
28186
28223
  render: function render(_ref6) {
28187
28224
  var field = _ref6.field;
@@ -28209,6 +28246,7 @@ var QuestionBlock$1 = memo(QuestionBlock, isEqual$1);
28209
28246
 
28210
28247
  var _excluded$f = ["data", "path", "isMath", "open", "isLoadingCategories", "isLoadingQuestionTypes", "optionKey", "categories", "questionTypes", "onDelete", "onOpenSubCategoryMenu", "onOpenCategoryMenu", "onCloseCategoryMenu", "onCloseQuestionTypeMenu", "onOpenQuestionTypeMenu"];
28211
28248
  var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28249
+ var _data$articles$3, _data$articles$3$cate, _data$articles$4, _data$articles$4$cate;
28212
28250
  var data = _ref.data,
28213
28251
  path = _ref.path,
28214
28252
  isMath = _ref.isMath,
@@ -28229,6 +28267,10 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28229
28267
  var articles = data.articles,
28230
28268
  questions = data.questions;
28231
28269
  var blockErrors = _.get(errors, path);
28270
+ var handleOpenQuestionTypeMenu = useCallback(function (key) {
28271
+ var _data$articles$, _data$articles$$categ, _data$articles$2, _data$articles$2$cate;
28272
+ onOpenQuestionTypeMenu(key, (_data$articles$ = data.articles[0]) === null || _data$articles$ === void 0 ? void 0 : (_data$articles$$categ = _data$articles$.categories) === null || _data$articles$$categ === void 0 ? void 0 : _data$articles$$categ[0], (_data$articles$2 = data.articles[0]) === null || _data$articles$2 === void 0 ? void 0 : (_data$articles$2$cate = _data$articles$2.categories) === null || _data$articles$2$cate === void 0 ? void 0 : _data$articles$2$cate[1]);
28273
+ }, [(_data$articles$3 = data.articles[0]) === null || _data$articles$3 === void 0 ? void 0 : (_data$articles$3$cate = _data$articles$3.categories) === null || _data$articles$3$cate === void 0 ? void 0 : _data$articles$3$cate[0], (_data$articles$4 = data.articles[0]) === null || _data$articles$4 === void 0 ? void 0 : (_data$articles$4$cate = _data$articles$4.categories) === null || _data$articles$4$cate === void 0 ? void 0 : _data$articles$4$cate[1]]);
28232
28274
  return React__default.createElement(FieldArray, {
28233
28275
  name: path + ".articles",
28234
28276
  render: function render(arrayHelpers) {
@@ -28290,7 +28332,7 @@ var QuestionGroupBlockBody = function QuestionGroupBlockBody(_ref) {
28290
28332
  questionTypes: questionTypes,
28291
28333
  isLoadingQuestionTypes: isLoadingQuestionTypes,
28292
28334
  optionKey: optionKey,
28293
- onOpenQuestionTypeMenu: onOpenQuestionTypeMenu,
28335
+ onOpenQuestionTypeMenu: handleOpenQuestionTypeMenu,
28294
28336
  onCloseQuestionTypeMenu: onCloseQuestionTypeMenu
28295
28337
  }, formikProps));
28296
28338
  }
@@ -28412,6 +28454,14 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28412
28454
  setFieldValue(path + ".articles[0].categoryOptions", (_questionGroup$articl2 = questionGroup.articles[0]) === null || _questionGroup$articl2 === void 0 ? void 0 : _questionGroup$articl2.categoryOptions);
28413
28455
  }
28414
28456
  };
28457
+ var handleChangeCategory = function handleChangeCategory(val) {
28458
+ setFieldValue(path + ".articles[0].categoryOptions", [val]);
28459
+ setFieldValue(path + ".articles[0].categories", [val === null || val === void 0 ? void 0 : val.value]);
28460
+ };
28461
+ var handleChangeSubCategory = function handleChangeSubCategory(val) {
28462
+ setFieldValue(path + ".articles[0].categories[1]", val === null || val === void 0 ? void 0 : val.value);
28463
+ setFieldValue(path + ".articles[0].categoryOptions[1]", val);
28464
+ };
28415
28465
  var summary = open ? "" : [t("number_questions", {
28416
28466
  n: data.questionCount
28417
28467
  }), (_data$articles$2 = data.articles[0]) === null || _data$articles$2 === void 0 ? void 0 : (_data$articles$2$cate = _data$articles$2.categoryOptions) === null || _data$articles$2$cate === void 0 ? void 0 : (_data$articles$2$cate2 = _data$articles$2$cate[0]) === null || _data$articles$2$cate2 === void 0 ? void 0 : _data$articles$2$cate2.label, (_data$articles$3 = data.articles[0]) === null || _data$articles$3 === void 0 ? void 0 : (_data$articles$3$cate = _data$articles$3.categoryOptions) === null || _data$articles$3$cate === void 0 ? void 0 : (_data$articles$3$cate2 = _data$articles$3$cate[1]) === null || _data$articles$3$cate2 === void 0 ? void 0 : _data$articles$3$cate2.label, isMath ? data.questions.map(function (i) {
@@ -28524,10 +28574,7 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28524
28574
  onMenuOpen: handleOpenCategoryMenu,
28525
28575
  onMenuClose: onCloseCategoryMenu
28526
28576
  },
28527
- onChange: function onChange(val) {
28528
- setFieldValue(path + ".articles[0].categories[0]", val === null || val === void 0 ? void 0 : val.value);
28529
- setFieldValue(path + ".articles[0].categoryOptions[0]", val);
28530
- },
28577
+ onChange: handleChangeCategory,
28531
28578
  placeholder: t("select_category")
28532
28579
  });
28533
28580
  }
@@ -28562,14 +28609,12 @@ var QuestionGroupBlock = function QuestionGroupBlock(_ref) {
28562
28609
  optionValue: field.value,
28563
28610
  options: categories,
28564
28611
  rest: {
28612
+ isClearable: true,
28565
28613
  isLoading: optionKey === path + ".articles[0].categories[1]" ? isLoadingCategories : false,
28566
28614
  onMenuOpen: handleOpenSubCategoryMenu,
28567
28615
  onMenuClose: onCloseCategoryMenu
28568
28616
  },
28569
- onChange: function onChange(val) {
28570
- setFieldValue(path + ".articles[0].categories[1]", val === null || val === void 0 ? void 0 : val.value);
28571
- setFieldValue(path + ".articles[0].categoryOptions[1]", val);
28572
- },
28617
+ onChange: handleChangeSubCategory,
28573
28618
  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]),
28574
28619
  placeholder: t("select_category")
28575
28620
  });
@@ -28859,7 +28904,7 @@ var ChapterBlock = function ChapterBlock(_ref) {
28859
28904
  e.stopPropagation();
28860
28905
  onDelete("" + t("are_you_sure_you_want_to_delete_the_chapter", {
28861
28906
  chapter: title
28862
- }), title, path.replace(/\[(\d+)\]$/, ''), expandedIndex);
28907
+ }), title, path.replace(/\[(\d+)\]$/, ""), expandedIndex);
28863
28908
  };
28864
28909
  var pageNameError = _.get(errors, path + ".name");
28865
28910
  var pageFromError = _.get(errors, path + ".pageFrom");
@@ -29302,8 +29347,8 @@ var useTextbookOptions = function useTextbookOptions(subjectId, isMath, filter,
29302
29347
  var questionTypeFilters = getOptionFilter();
29303
29348
  return Promise.resolve(getQuestionTypesApi(isSuperAdmin, _extends({}, questionTypeFilters, {
29304
29349
  subjectId: subjectId,
29305
- parentCategorId: subCategoryId,
29306
- rootParentCategorId: categoryId,
29350
+ parentCategoryId: subCategoryId,
29351
+ rootParentCategoryId: categoryId,
29307
29352
  textSearch: (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : _inputRef$current7.value
29308
29353
  }))).then(function (res) {
29309
29354
  setQuestionTypes(res.data.items.map(function (i) {
@@ -30097,19 +30142,35 @@ var TextbookOwnersTab = function TextbookOwnersTab(_ref) {
30097
30142
  }));
30098
30143
  };
30099
30144
 
30100
- var _reduceToMathArticles = function reduceToMathArticles(textbook, isMath, isInit) {
30101
- if (isInit === void 0) {
30102
- isInit = true;
30103
- }
30104
- var values = isInit ? _.cloneDeep(textbook) : textbook;
30105
- if (isInit) values.type = isMath;
30145
+ var _reduceToMathArticles = function reduceToMathArticles(textbook, isMath) {
30146
+ var values = isMath !== undefined ? _.cloneDeep(textbook) : textbook;
30147
+ if (isMath !== undefined) values.type = isMath;
30106
30148
  for (var key in values) {
30107
30149
  if (values.hasOwnProperty(key)) {
30108
30150
  if (key === "articles") {
30109
30151
  var _values$key;
30110
30152
  values[key] = (_values$key = values[key]) !== null && _values$key !== void 0 && _values$key.length ? [values[key][0]] : [DEFAULT_ARTICLE];
30111
30153
  } else if (typeof values[key] === "object" && values[key] !== null) {
30112
- _reduceToMathArticles(values[key], isMath, false);
30154
+ _reduceToMathArticles(values[key]);
30155
+ }
30156
+ }
30157
+ }
30158
+ return values;
30159
+ };
30160
+ var _resetAllCrategoriesAndQuestionTypesBySubject = function resetAllCrategoriesAndQuestionTypesBySubject(textbook, subject) {
30161
+ var values = subject ? _.cloneDeep(textbook) : textbook;
30162
+ if (subject) {
30163
+ values.subjectId = subject === null || subject === void 0 ? void 0 : subject.value;
30164
+ values.subject = subject;
30165
+ }
30166
+ for (var key in values) {
30167
+ if (values.hasOwnProperty(key)) {
30168
+ if (key === "categories" || key === "categoryOptions") {
30169
+ values[key] = [];
30170
+ } else if (key === "questionType" || key === "questionTypeId") {
30171
+ values[key] = null;
30172
+ } else if (typeof values[key] === "object" && values[key] !== null) {
30173
+ _resetAllCrategoriesAndQuestionTypesBySubject(values[key]);
30113
30174
  }
30114
30175
  }
30115
30176
  }
@@ -30238,8 +30299,7 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30238
30299
  errors = formikProps.errors,
30239
30300
  dirty = formikProps.dirty,
30240
30301
  submitCount = formikProps.submitCount,
30241
- setValues = formikProps.setValues,
30242
- setFieldValue = formikProps.setFieldValue;
30302
+ setValues = formikProps.setValues;
30243
30303
  useEffect(function () {
30244
30304
  var handleBeforeUnload = function handleBeforeUnload(event) {
30245
30305
  var message = t$1("are_you_sure_you_want_to_quit_yours_changes_may_not_be_saved");
@@ -30257,8 +30317,8 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30257
30317
  setValues(newValues);
30258
30318
  };
30259
30319
  var handleChangeSubject = function handleChangeSubject(val) {
30260
- setFieldValue("subject", val);
30261
- setFieldValue("subjectId", val === null || val === void 0 ? void 0 : val.value);
30320
+ var newValues = _resetAllCrategoriesAndQuestionTypesBySubject(values, val);
30321
+ setValues(newValues);
30262
30322
  };
30263
30323
  var inforErrors = errors.coverImage || errors.grade || errors.isbn || errors.preparedType || errors.publicationDate || errors.publisher;
30264
30324
  var contentsErrors = errors.chapters;
@@ -30343,9 +30403,6 @@ var PreparedTextbookForm = function PreparedTextbookForm(_ref) {
30343
30403
  },
30344
30404
  variant: "contained",
30345
30405
  onClick: function onClick() {
30346
- console.log({
30347
- errors: errors
30348
- });
30349
30406
  if (!_.isEmpty(errors)) {
30350
30407
  toast.error(t$1("please_fill_in_the_blank_fields"));
30351
30408
  }