touchstudy-core 0.1.99 → 0.1.100

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.
@@ -71,6 +71,7 @@ export declare type TextbookDetailResponse = {
71
71
  subject?: SubjectResponse;
72
72
  chapters: ChapterResponse[];
73
73
  isCreatedByAdmin?: boolean;
74
+ createdBy?: UserResponse;
74
75
  };
75
76
  export declare type UserResponse = {
76
77
  id: number;
package/dist/index.js CHANGED
@@ -2961,6 +2961,12 @@ var notify_share_textbook = {
2961
2961
  update_success: "공유 교과서가 성공적으로 업데이트되었습니다!",
2962
2962
  update_fail: "업데이트 실패!"
2963
2963
  };
2964
+ var notify_share_exam = {
2965
+ share_success: "시험 공유 성공!",
2966
+ share_fail: "시험 또는 교사가 존재하지 않습니다!",
2967
+ update_success: "공유 시험을 성공적으로 업데이트했습니다!",
2968
+ update_fail: "업데이트 실패!"
2969
+ };
2964
2970
  var academyadminteacher = "아카데미 관리자/선생님";
2965
2971
  var total_student = "총 학생 수";
2966
2972
  var total_teacher = "총 교사 수";
@@ -2971,6 +2977,7 @@ var the_exam_code_you_are_looking_for_was_not_found = "찾고 있는 시험 코
2971
2977
  var view_user = "사용자 보기";
2972
2978
  var exam_code = "시험 코드";
2973
2979
  var version = "버전";
2980
+ var exam_sessions = "시험 세션";
2974
2981
  var lang_ko = {
2975
2982
  problem_solving: problem_solving,
2976
2983
  my_story: my_story,
@@ -3775,6 +3782,7 @@ var lang_ko = {
3775
3782
  authority: authority,
3776
3783
  share_textbook: share_textbook,
3777
3784
  notify_share_textbook: notify_share_textbook,
3785
+ notify_share_exam: notify_share_exam,
3778
3786
  academyadminteacher: academyadminteacher,
3779
3787
  total_student: total_student,
3780
3788
  total_teacher: total_teacher,
@@ -3784,7 +3792,8 @@ var lang_ko = {
3784
3792
  the_exam_code_you_are_looking_for_was_not_found: the_exam_code_you_are_looking_for_was_not_found,
3785
3793
  view_user: view_user,
3786
3794
  exam_code: exam_code,
3787
- version: version
3795
+ version: version,
3796
+ exam_sessions: exam_sessions
3788
3797
  };
3789
3798
 
3790
3799
  var problem_solving$1 = "Problem Solving";
@@ -4604,6 +4613,12 @@ var notify_share_textbook$1 = {
4604
4613
  update_success: "Update shared textbook successfully!",
4605
4614
  update_fail: "Update fail!"
4606
4615
  };
4616
+ var notify_share_exam$1 = {
4617
+ share_success: "Share exam successfully!",
4618
+ share_fail: "Exam or teacher not exists!",
4619
+ update_success: "Update shared exam successfully!",
4620
+ update_fail: "Update fail!"
4621
+ };
4607
4622
  var academyadminteacher$1 = "AcademyAdmin / Teacher";
4608
4623
  var total_student$1 = "Total Student";
4609
4624
  var total_teacher$1 = "Total Teacher";
@@ -4614,6 +4629,7 @@ var the_exam_code_you_are_looking_for_was_not_found$1 = "The exam code you are l
4614
4629
  var view_user$1 = "View User";
4615
4630
  var exam_code$1 = "exam code";
4616
4631
  var version$1 = "Version";
4632
+ var exam_sessions$1 = "Exam sessions";
4617
4633
  var lang_en = {
4618
4634
  problem_solving: problem_solving$1,
4619
4635
  my_story: my_story$1,
@@ -5420,6 +5436,7 @@ var lang_en = {
5420
5436
  authority: authority$1,
5421
5437
  share_textbook: share_textbook$1,
5422
5438
  notify_share_textbook: notify_share_textbook$1,
5439
+ notify_share_exam: notify_share_exam$1,
5423
5440
  academyadminteacher: academyadminteacher$1,
5424
5441
  total_student: total_student$1,
5425
5442
  total_teacher: total_teacher$1,
@@ -5429,7 +5446,8 @@ var lang_en = {
5429
5446
  the_exam_code_you_are_looking_for_was_not_found: the_exam_code_you_are_looking_for_was_not_found$1,
5430
5447
  view_user: view_user$1,
5431
5448
  exam_code: exam_code$1,
5432
- version: version$1
5449
+ version: version$1,
5450
+ exam_sessions: exam_sessions$1
5433
5451
  };
5434
5452
 
5435
5453
  i18n__default.use(reactI18next.initReactI18next).init({
@@ -8942,7 +8960,7 @@ var getCategoryListApi = function getCategoryListApi(data) {
8942
8960
  var PAGE_TITLE_DETAIL = "textbook_detail";
8943
8961
  var PAGE_TITLE_CREATE = "create_textbook";
8944
8962
  var useTextbookDetail = function useTextbookDetail(props) {
8945
- var _textbook$subject3;
8963
+ var _user$roles, _textbook$subject3, _textbook$createdBy2;
8946
8964
  var role = props.role,
8947
8965
  isReadonlyParam = props.isReadonlyParam,
8948
8966
  navigate = props.navigate,
@@ -8950,39 +8968,42 @@ var useTextbookDetail = function useTextbookDetail(props) {
8950
8968
  var _useTranslation = reactI18next.useTranslation(),
8951
8969
  t = _useTranslation.t;
8952
8970
  var dispatch = reactRedux.useDispatch();
8953
- var _useState = React.useState(false),
8954
- isReadonly = _useState[0],
8955
- setReadonly = _useState[1];
8956
- var _useState2 = React.useState(DEFAULT_TEXTBOOK),
8957
- textbook = _useState2[0],
8958
- setTextbook = _useState2[1];
8959
- var _useState3 = React.useState(false),
8960
- isNotFound = _useState3[0],
8961
- setNotFound = _useState3[1];
8971
+ var _useState = React.useState(DEFAULT_TEXTBOOK),
8972
+ textbook = _useState[0],
8973
+ setTextbook = _useState[1];
8974
+ var _useState2 = React.useState(false),
8975
+ isNotFound = _useState2[0],
8976
+ setNotFound = _useState2[1];
8977
+ var _useState3 = React.useState(),
8978
+ textbookId = _useState3[0],
8979
+ setTextbookId = _useState3[1];
8962
8980
  var _useState4 = React.useState(),
8963
- textbookId = _useState4[0],
8964
- setTextbookId = _useState4[1];
8965
- var _useState5 = React.useState(),
8966
- parentChapter = _useState5[0],
8967
- setParentChapter = _useState5[1];
8968
- var _useState6 = React.useState([]),
8969
- articlesSelected = _useState6[0],
8970
- setArticlesSelected = _useState6[1];
8981
+ parentChapter = _useState4[0],
8982
+ setParentChapter = _useState4[1];
8983
+ var _useState5 = React.useState([]),
8984
+ articlesSelected = _useState5[0],
8985
+ setArticlesSelected = _useState5[1];
8986
+ var _useState6 = React.useState(),
8987
+ selectedChapter = _useState6[0],
8988
+ setSelectedChapter = _useState6[1];
8971
8989
  var _useState7 = React.useState(),
8972
- selectedChapter = _useState7[0],
8973
- setSelectedChapter = _useState7[1];
8974
- var _useState8 = React.useState(),
8975
- selectedDeleteItem = _useState8[0],
8976
- setSelectedDeleteItem = _useState8[1];
8990
+ selectedDeleteItem = _useState7[0],
8991
+ setSelectedDeleteItem = _useState7[1];
8977
8992
  var updateChapterRef = React.useRef();
8978
8993
  var updateArticleRef = React.useRef();
8979
- var _useState9 = React.useState(false),
8980
- isEditedTitle = _useState9[0],
8981
- setEditedTitle = _useState9[1];
8982
- var _useState10 = React.useState([]),
8983
- categoryList = _useState10[0],
8984
- setCategoryList = _useState10[1];
8994
+ var _useState8 = React.useState(false),
8995
+ isEditedTitle = _useState8[0],
8996
+ setEditedTitle = _useState8[1];
8997
+ var _useState9 = React.useState([]),
8998
+ categoryList = _useState9[0],
8999
+ setCategoryList = _useState9[1];
8985
9000
  var textbookUrl = role === exports.Role.Teacher ? TEXTBOOK_URL$1 : ADMIN_TEXTBOOK_URL;
9001
+ var isAdminSite = role === exports.Role.Admin;
9002
+ var user = reactRedux.useSelector(function (state) {
9003
+ var _state$common;
9004
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
9005
+ });
9006
+ var isAdmin = user === null || user === void 0 ? void 0 : (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Admin);
8986
9007
  var _useExam = useExam({
8987
9008
  navigate: navigate
8988
9009
  }),
@@ -9682,9 +9703,14 @@ var useTextbookDetail = function useTextbookDetail(props) {
9682
9703
  React.useEffect(function () {
9683
9704
  document.title = t("study_peak") + " | " + t(id ? PAGE_TITLE_DETAIL : PAGE_TITLE_CREATE);
9684
9705
  }, [id, t]);
9685
- React.useEffect(function () {
9686
- setReadonly(textbook.isCreatedByAdmin || !!isReadonlyParam);
9687
- }, [isReadonlyParam, textbook.isCreatedByAdmin]);
9706
+ var isReadonly = React.useMemo(function () {
9707
+ var _textbook$createdBy;
9708
+ if (!user.id) return true;
9709
+ if (!textbook.id) return false;
9710
+ if (isReadonlyParam) return true;
9711
+ if (isAdminSite && isAdmin || !textbook.isCreatedByAdmin && !isAdmin && !isAdminSite && (textbook === null || textbook === void 0 ? void 0 : (_textbook$createdBy = textbook.createdBy) === null || _textbook$createdBy === void 0 ? void 0 : _textbook$createdBy.id) === (user === null || user === void 0 ? void 0 : user.id)) return false;
9712
+ return true;
9713
+ }, [isReadonlyParam, textbook.isCreatedByAdmin, isAdminSite, isAdmin, textbook.id, textbook === null || textbook === void 0 ? void 0 : (_textbook$createdBy2 = textbook.createdBy) === null || _textbook$createdBy2 === void 0 ? void 0 : _textbook$createdBy2.id, user === null || user === void 0 ? void 0 : user.id]);
9688
9714
  return {
9689
9715
  id: id,
9690
9716
  t: t,