touchstudy-core 0.1.98 → 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.
@@ -251,6 +251,14 @@ var getAccessToken = (function () {
251
251
  }
252
252
  });
253
253
 
254
+ var getLanguage = (function () {
255
+ try {
256
+ return localStorage.getItem(LANGUAGE);
257
+ } catch (err) {
258
+ return null;
259
+ }
260
+ });
261
+
254
262
  var api = axios.create({
255
263
  baseURL: BASE_URL,
256
264
  timeout: 0,
@@ -275,13 +283,15 @@ var apiUpload = axios.create({
275
283
  var paramDomain = searchParams.get('domain');
276
284
  var paramLang = searchParams.get('lang');
277
285
  var academyDomainStorage = getAcademyDomain();
286
+ var langStorage = getLanguage();
278
287
  var academyDomain = paramDomain || academyDomainStorage;
288
+ var language = paramLang || langStorage;
279
289
  if (token) {
280
290
  config.headers.Authorization = "Bearer " + token;
281
291
  localStorage.setItem("LAST_TIME_REQUEST", moment().utc().format("YYYY-MM-DD HH:mm:ss"));
282
292
  }
283
293
  if (academyDomain && !config.headers[AcademyHeaders]) config.headers[AcademyHeaders] = "" + academyDomain;
284
- if (paramLang) config.headers[LanguageHeaders] = "" + paramLang;
294
+ if (language) config.headers[LanguageHeaders] = "" + language;
285
295
  return config;
286
296
  }, function (error) {
287
297
  return Promise.reject(error);
@@ -1188,14 +1198,6 @@ var LANGUAGES = [{
1188
1198
  var DEFAULT_LANGUAGE = LANGUAGES[0];
1189
1199
  var LOGIN_URL = "/login";
1190
1200
 
1191
- var getLanguage = (function () {
1192
- try {
1193
- return localStorage.getItem(LANGUAGE);
1194
- } catch (err) {
1195
- return null;
1196
- }
1197
- });
1198
-
1199
1201
  var useLanguage = function useLanguage(history) {
1200
1202
  var dispatch = useDispatch();
1201
1203
  var _useTranslation = useTranslation(),
@@ -2960,6 +2962,12 @@ var notify_share_textbook = {
2960
2962
  update_success: "공유 교과서가 성공적으로 업데이트되었습니다!",
2961
2963
  update_fail: "업데이트 실패!"
2962
2964
  };
2965
+ var notify_share_exam = {
2966
+ share_success: "시험 공유 성공!",
2967
+ share_fail: "시험 또는 교사가 존재하지 않습니다!",
2968
+ update_success: "공유 시험을 성공적으로 업데이트했습니다!",
2969
+ update_fail: "업데이트 실패!"
2970
+ };
2963
2971
  var academyadminteacher = "아카데미 관리자/선생님";
2964
2972
  var total_student = "총 학생 수";
2965
2973
  var total_teacher = "총 교사 수";
@@ -2970,6 +2978,7 @@ var the_exam_code_you_are_looking_for_was_not_found = "찾고 있는 시험 코
2970
2978
  var view_user = "사용자 보기";
2971
2979
  var exam_code = "시험 코드";
2972
2980
  var version = "버전";
2981
+ var exam_sessions = "시험 세션";
2973
2982
  var lang_ko = {
2974
2983
  problem_solving: problem_solving,
2975
2984
  my_story: my_story,
@@ -3774,6 +3783,7 @@ var lang_ko = {
3774
3783
  authority: authority,
3775
3784
  share_textbook: share_textbook,
3776
3785
  notify_share_textbook: notify_share_textbook,
3786
+ notify_share_exam: notify_share_exam,
3777
3787
  academyadminteacher: academyadminteacher,
3778
3788
  total_student: total_student,
3779
3789
  total_teacher: total_teacher,
@@ -3783,7 +3793,8 @@ var lang_ko = {
3783
3793
  the_exam_code_you_are_looking_for_was_not_found: the_exam_code_you_are_looking_for_was_not_found,
3784
3794
  view_user: view_user,
3785
3795
  exam_code: exam_code,
3786
- version: version
3796
+ version: version,
3797
+ exam_sessions: exam_sessions
3787
3798
  };
3788
3799
 
3789
3800
  var problem_solving$1 = "Problem Solving";
@@ -4603,6 +4614,12 @@ var notify_share_textbook$1 = {
4603
4614
  update_success: "Update shared textbook successfully!",
4604
4615
  update_fail: "Update fail!"
4605
4616
  };
4617
+ var notify_share_exam$1 = {
4618
+ share_success: "Share exam successfully!",
4619
+ share_fail: "Exam or teacher not exists!",
4620
+ update_success: "Update shared exam successfully!",
4621
+ update_fail: "Update fail!"
4622
+ };
4606
4623
  var academyadminteacher$1 = "AcademyAdmin / Teacher";
4607
4624
  var total_student$1 = "Total Student";
4608
4625
  var total_teacher$1 = "Total Teacher";
@@ -4613,6 +4630,7 @@ var the_exam_code_you_are_looking_for_was_not_found$1 = "The exam code you are l
4613
4630
  var view_user$1 = "View User";
4614
4631
  var exam_code$1 = "exam code";
4615
4632
  var version$1 = "Version";
4633
+ var exam_sessions$1 = "Exam sessions";
4616
4634
  var lang_en = {
4617
4635
  problem_solving: problem_solving$1,
4618
4636
  my_story: my_story$1,
@@ -5419,6 +5437,7 @@ var lang_en = {
5419
5437
  authority: authority$1,
5420
5438
  share_textbook: share_textbook$1,
5421
5439
  notify_share_textbook: notify_share_textbook$1,
5440
+ notify_share_exam: notify_share_exam$1,
5422
5441
  academyadminteacher: academyadminteacher$1,
5423
5442
  total_student: total_student$1,
5424
5443
  total_teacher: total_teacher$1,
@@ -5428,7 +5447,8 @@ var lang_en = {
5428
5447
  the_exam_code_you_are_looking_for_was_not_found: the_exam_code_you_are_looking_for_was_not_found$1,
5429
5448
  view_user: view_user$1,
5430
5449
  exam_code: exam_code$1,
5431
- version: version$1
5450
+ version: version$1,
5451
+ exam_sessions: exam_sessions$1
5432
5452
  };
5433
5453
 
5434
5454
  i18n.use(initReactI18next).init({
@@ -8942,7 +8962,7 @@ var getCategoryListApi = function getCategoryListApi(data) {
8942
8962
  var PAGE_TITLE_DETAIL = "textbook_detail";
8943
8963
  var PAGE_TITLE_CREATE = "create_textbook";
8944
8964
  var useTextbookDetail = function useTextbookDetail(props) {
8945
- var _textbook$subject3;
8965
+ var _user$roles, _textbook$subject3, _textbook$createdBy2;
8946
8966
  var role = props.role,
8947
8967
  isReadonlyParam = props.isReadonlyParam,
8948
8968
  navigate = props.navigate,
@@ -8950,39 +8970,42 @@ var useTextbookDetail = function useTextbookDetail(props) {
8950
8970
  var _useTranslation = useTranslation(),
8951
8971
  t = _useTranslation.t;
8952
8972
  var dispatch = useDispatch();
8953
- var _useState = useState(false),
8954
- isReadonly = _useState[0],
8955
- setReadonly = _useState[1];
8956
- var _useState2 = useState(DEFAULT_TEXTBOOK),
8957
- textbook = _useState2[0],
8958
- setTextbook = _useState2[1];
8959
- var _useState3 = useState(false),
8960
- isNotFound = _useState3[0],
8961
- setNotFound = _useState3[1];
8973
+ var _useState = useState(DEFAULT_TEXTBOOK),
8974
+ textbook = _useState[0],
8975
+ setTextbook = _useState[1];
8976
+ var _useState2 = useState(false),
8977
+ isNotFound = _useState2[0],
8978
+ setNotFound = _useState2[1];
8979
+ var _useState3 = useState(),
8980
+ textbookId = _useState3[0],
8981
+ setTextbookId = _useState3[1];
8962
8982
  var _useState4 = useState(),
8963
- textbookId = _useState4[0],
8964
- setTextbookId = _useState4[1];
8965
- var _useState5 = useState(),
8966
- parentChapter = _useState5[0],
8967
- setParentChapter = _useState5[1];
8968
- var _useState6 = useState([]),
8969
- articlesSelected = _useState6[0],
8970
- setArticlesSelected = _useState6[1];
8983
+ parentChapter = _useState4[0],
8984
+ setParentChapter = _useState4[1];
8985
+ var _useState5 = useState([]),
8986
+ articlesSelected = _useState5[0],
8987
+ setArticlesSelected = _useState5[1];
8988
+ var _useState6 = useState(),
8989
+ selectedChapter = _useState6[0],
8990
+ setSelectedChapter = _useState6[1];
8971
8991
  var _useState7 = useState(),
8972
- selectedChapter = _useState7[0],
8973
- setSelectedChapter = _useState7[1];
8974
- var _useState8 = useState(),
8975
- selectedDeleteItem = _useState8[0],
8976
- setSelectedDeleteItem = _useState8[1];
8992
+ selectedDeleteItem = _useState7[0],
8993
+ setSelectedDeleteItem = _useState7[1];
8977
8994
  var updateChapterRef = useRef();
8978
8995
  var updateArticleRef = useRef();
8979
- var _useState9 = useState(false),
8980
- isEditedTitle = _useState9[0],
8981
- setEditedTitle = _useState9[1];
8982
- var _useState10 = useState([]),
8983
- categoryList = _useState10[0],
8984
- setCategoryList = _useState10[1];
8996
+ var _useState8 = useState(false),
8997
+ isEditedTitle = _useState8[0],
8998
+ setEditedTitle = _useState8[1];
8999
+ var _useState9 = useState([]),
9000
+ categoryList = _useState9[0],
9001
+ setCategoryList = _useState9[1];
8985
9002
  var textbookUrl = role === Role.Teacher ? TEXTBOOK_URL$1 : ADMIN_TEXTBOOK_URL;
9003
+ var isAdminSite = role === Role.Admin;
9004
+ var user = useSelector(function (state) {
9005
+ var _state$common;
9006
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
9007
+ });
9008
+ 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);
8986
9009
  var _useExam = useExam({
8987
9010
  navigate: navigate
8988
9011
  }),
@@ -9682,9 +9705,14 @@ var useTextbookDetail = function useTextbookDetail(props) {
9682
9705
  useEffect(function () {
9683
9706
  document.title = t("study_peak") + " | " + t(id ? PAGE_TITLE_DETAIL : PAGE_TITLE_CREATE);
9684
9707
  }, [id, t]);
9685
- useEffect(function () {
9686
- setReadonly(textbook.isCreatedByAdmin || !!isReadonlyParam);
9687
- }, [isReadonlyParam, textbook.isCreatedByAdmin]);
9708
+ var isReadonly = useMemo(function () {
9709
+ var _textbook$createdBy;
9710
+ if (!user.id) return true;
9711
+ if (!textbook.id) return false;
9712
+ if (isReadonlyParam) return true;
9713
+ 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;
9714
+ return true;
9715
+ }, [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
9716
  return {
9689
9717
  id: id,
9690
9718
  t: t,