touchstudy-core 0.1.22 → 0.1.24

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.
package/dist/index.js CHANGED
@@ -140,6 +140,7 @@ var AuthenticationMessage;
140
140
  Role["Student"] = "Student";
141
141
  Role["Teacher"] = "Teacher";
142
142
  Role["Admin"] = "Admin";
143
+ Role["AcademyAdmin"] = "AcademyAdmin";
143
144
  })(exports.Role || (exports.Role = {}));
144
145
 
145
146
  // A type of promise-like that resolves synchronously and supports only one observer
@@ -1458,6 +1459,16 @@ var update_textbook_title = "교과서 제목 업데이트";
1458
1459
  var invalid_weekly_day_time = "주간 요일 시간이 잘못되었습니다";
1459
1460
  var no_image = "이미지 없음";
1460
1461
  var school_name = "학교 이름";
1462
+ var phone_number = "전화번호";
1463
+ var major = "주요한";
1464
+ var roles = "역할";
1465
+ var searching_for = "검색 중...";
1466
+ var parent_name = "부모님 성함";
1467
+ var users = "사용자";
1468
+ var new_user = "새로운 사용자";
1469
+ var academy_admin = "아카데미 관리자";
1470
+ var switch_academy_admin = "스위치 아카데미 관리자";
1471
+ var there_are_no_lessons_this_week = "이번주는 수업이 없습니다";
1461
1472
  var lang_ko = {
1462
1473
  problem_solving: problem_solving,
1463
1474
  my_story: my_story,
@@ -1701,7 +1712,17 @@ var lang_ko = {
1701
1712
  update_textbook_title: update_textbook_title,
1702
1713
  invalid_weekly_day_time: invalid_weekly_day_time,
1703
1714
  no_image: no_image,
1704
- school_name: school_name
1715
+ school_name: school_name,
1716
+ phone_number: phone_number,
1717
+ major: major,
1718
+ roles: roles,
1719
+ searching_for: searching_for,
1720
+ parent_name: parent_name,
1721
+ users: users,
1722
+ new_user: new_user,
1723
+ academy_admin: academy_admin,
1724
+ switch_academy_admin: switch_academy_admin,
1725
+ there_are_no_lessons_this_week: there_are_no_lessons_this_week
1705
1726
  };
1706
1727
 
1707
1728
  var problem_solving$1 = "Problem Solving";
@@ -1971,7 +1992,7 @@ var add_new_chapter_to_textbook$1 = "Add new chapter to the textbook";
1971
1992
  var add_new_subchapter_to_parent_chapter$1 = "Add new subchapter to the parent chapter ({{ chapterName }})";
1972
1993
  var add$1 = "Add";
1973
1994
  var add_new_article_to_chapter$1 = "Add new article to the chapter ({{ chapterName }})";
1974
- var score_format$1 = "{{score}}points";
1995
+ var score_format$1 = "{{score}}pts";
1975
1996
  var round$1 = "{{number}} round";
1976
1997
  var number_grade$1 = "Grade {{number}}";
1977
1998
  var print$1 = "Print";
@@ -1983,6 +2004,16 @@ var update_textbook_title$1 = "Update textbook title";
1983
2004
  var invalid_weekly_day_time$1 = "Invalid weekly day time";
1984
2005
  var no_image$1 = "No image";
1985
2006
  var school_name$1 = "School name";
2007
+ var phone_number$1 = "Phone Number";
2008
+ var major$1 = "Major";
2009
+ var roles$1 = "Roles";
2010
+ var searching_for$1 = "Searching for...";
2011
+ var parent_name$1 = "Parent name";
2012
+ var users$1 = "Users";
2013
+ var new_user$1 = "New user";
2014
+ var academy_admin$1 = "Academy Admin";
2015
+ var switch_academy_admin$1 = "Switch Academy Admin";
2016
+ var there_are_no_lessons_this_week$1 = "There are no lessons this week";
1986
2017
  var lang_en = {
1987
2018
  problem_solving: problem_solving$1,
1988
2019
  my_story: my_story$1,
@@ -2260,7 +2291,17 @@ var lang_en = {
2260
2291
  update_textbook_title: update_textbook_title$1,
2261
2292
  invalid_weekly_day_time: invalid_weekly_day_time$1,
2262
2293
  no_image: no_image$1,
2263
- school_name: school_name$1
2294
+ school_name: school_name$1,
2295
+ phone_number: phone_number$1,
2296
+ major: major$1,
2297
+ roles: roles$1,
2298
+ searching_for: searching_for$1,
2299
+ parent_name: parent_name$1,
2300
+ users: users$1,
2301
+ new_user: new_user$1,
2302
+ academy_admin: academy_admin$1,
2303
+ switch_academy_admin: switch_academy_admin$1,
2304
+ there_are_no_lessons_this_week: there_are_no_lessons_this_week$1
2264
2305
  };
2265
2306
 
2266
2307
  i18n.use(reactI18next.initReactI18next).init({
@@ -2445,6 +2486,8 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
2445
2486
  var _state$common2;
2446
2487
  return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
2447
2488
  });
2489
+ var _useTranslation = reactI18next.useTranslation(),
2490
+ t = _useTranslation.t;
2448
2491
  var getAcademies = function getAcademies(isLoading) {
2449
2492
  if (isLoading === void 0) {
2450
2493
  isLoading = true;
@@ -2505,7 +2548,7 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
2505
2548
  });
2506
2549
  }, function (error) {
2507
2550
  var _error$response2, _error$response2$data;
2508
- reactToastify.toast.error((error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.title) || "Switch academy failed");
2551
+ reactToastify.toast.error((error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.title) || t("switch_academy_admin"));
2509
2552
  });
2510
2553
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
2511
2554
  } catch (e) {
@@ -2549,6 +2592,8 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2549
2592
  });
2550
2593
  var isAdmin = role === exports.Role.Admin;
2551
2594
  var isSuperAdmin = user && !user.academyDomain && ((_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Admin));
2595
+ var _useTranslation = reactI18next.useTranslation(),
2596
+ t = _useTranslation.t;
2552
2597
  var _useState = React.useState(null),
2553
2598
  open = _useState[0],
2554
2599
  setOpen = _useState[1];
@@ -2585,7 +2630,7 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2585
2630
  color: "#5458D5",
2586
2631
  minWidth: 150
2587
2632
  }
2588
- }, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || "Switch Academy Admin"), React__default.createElement("div", {
2633
+ }, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || t("switch_academy_admin")), React__default.createElement("div", {
2589
2634
  className: "" + stylesGlobal["switch-icon"]
2590
2635
  }, React__default.createElement(go.GoArrowSwitch, {
2591
2636
  size: 14
@@ -2768,7 +2813,8 @@ var ChatRightItem = function ChatRightItem(_ref) {
2768
2813
  showTimestamp = _ref.showTimestamp,
2769
2814
  isStudent = _ref.isStudent,
2770
2815
  showName = _ref.showName,
2771
- contentType = _ref.contentType;
2816
+ contentType = _ref.contentType,
2817
+ toggleImageDialog = _ref.toggleImageDialog;
2772
2818
  var _useTranslation = reactI18next.useTranslation(),
2773
2819
  t = _useTranslation.t;
2774
2820
  return React__default.createElement("div", null, showTimestamp && React__default.createElement(material.Typography, {
@@ -2796,14 +2842,12 @@ var ChatRightItem = function ChatRightItem(_ref) {
2796
2842
  lineHeight: "16.71px",
2797
2843
  color: "#5458D5"
2798
2844
  }, sender === null || sender === void 0 ? void 0 : sender.fullName)), contentType ? React__default.createElement("img", {
2845
+ onClick: toggleImageDialog,
2799
2846
  src: content,
2800
2847
  style: {
2801
- backgroundRepeat: "no-repeat",
2802
- width: "200px",
2803
2848
  height: "200px",
2804
2849
  position: "relative",
2805
- backgroundSize: "cover",
2806
- objectFit: "cover"
2850
+ objectFit: "contain"
2807
2851
  }
2808
2852
  }) : React__default.createElement("div", {
2809
2853
  className: styles["wrap-content"] + " " + styles["content-chat-receiver"],
@@ -2825,7 +2869,8 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2825
2869
  showTimestamp = _ref.showTimestamp,
2826
2870
  isStudent = _ref.isStudent,
2827
2871
  showName = _ref.showName,
2828
- contentType = _ref.contentType;
2872
+ contentType = _ref.contentType,
2873
+ toggleImageDialog = _ref.toggleImageDialog;
2829
2874
  var _useTranslation = reactI18next.useTranslation(),
2830
2875
  t = _useTranslation.t;
2831
2876
  return React__default.createElement("div", null, showTimestamp && React__default.createElement(material.Typography, {
@@ -2867,14 +2912,12 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2867
2912
  }, t("student")))), React__default.createElement(material.Box, {
2868
2913
  padding: "4px 0px"
2869
2914
  }), contentType ? React__default.createElement("img", {
2915
+ onClick: toggleImageDialog,
2870
2916
  src: content,
2871
2917
  style: {
2872
- backgroundRepeat: "no-repeat",
2873
- width: "200px",
2874
2918
  height: "200px",
2875
2919
  position: "relative",
2876
- backgroundSize: "cover",
2877
- objectFit: "cover"
2920
+ objectFit: "contain"
2878
2921
  }
2879
2922
  }) : React__default.createElement("div", {
2880
2923
  className: styles["wrap-content"] + " " + styles["content-chat-sender"]
@@ -2886,6 +2929,115 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2886
2929
  }, content))));
2887
2930
  };
2888
2931
 
2932
+ var ImageDetailDialog = function ImageDetailDialog(_ref) {
2933
+ var open = _ref.open,
2934
+ toggleDialog = _ref.toggleDialog,
2935
+ content = _ref.content,
2936
+ downloadFile = _ref.downloadFile;
2937
+ var _useTranslation = reactI18next.useTranslation(),
2938
+ t = _useTranslation.t;
2939
+ return React__default.createElement(CommonDialog, {
2940
+ open: open,
2941
+ onClose: toggleDialog,
2942
+ size: "sm",
2943
+ title: t("image")
2944
+ }, React__default.createElement(material.DialogContent, {
2945
+ sx: {
2946
+ overflowY: "unset"
2947
+ }
2948
+ }, React__default.createElement(material.Stack, null, React__default.createElement(material.Stack, {
2949
+ display: "flex",
2950
+ justifyContent: "center",
2951
+ alignItems: "center"
2952
+ }, React__default.createElement("img", {
2953
+ src: content,
2954
+ style: {
2955
+ width: "500px",
2956
+ position: "relative",
2957
+ objectFit: "contain",
2958
+ objectPosition: "center"
2959
+ }
2960
+ })), React__default.createElement(material.Button, {
2961
+ sx: {
2962
+ margin: "10px 0"
2963
+ },
2964
+ variant: "outlined",
2965
+ fullWidth: true,
2966
+ onClick: function onClick() {
2967
+ return downloadFile(content);
2968
+ }
2969
+ }, t("download")))));
2970
+ };
2971
+
2972
+ var CONVERSATION_URL = BASE_URL + "/api/conversation";
2973
+ var apiAddMessage = function apiAddMessage(conversationId, message) {
2974
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
2975
+ };
2976
+ var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
2977
+ return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
2978
+ params: filter
2979
+ });
2980
+ };
2981
+ var updateLastTimeReadConversation = function updateLastTimeReadConversation(conversationId) {
2982
+ return api.put(CONVERSATION_URL + "/" + conversationId);
2983
+ };
2984
+ var completeConversation = function completeConversation(conversationId) {
2985
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
2986
+ };
2987
+ var apiUploadImageFile = function apiUploadImageFile(file) {
2988
+ return apiUpload.post(BASE_URL + "/api/file/images", file);
2989
+ };
2990
+
2991
+ var FileSaver_min = createCommonjsModule(function (module, exports) {
2992
+ (function(a,b){b();})(commonjsGlobal,function(){function b(a,b){return "undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c);},d.onerror=function(){console.error("could not download file");},d.send();}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send();}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"));}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b);}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof commonjsGlobal&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href);},4E4),setTimeout(function(){e(j);},0));}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else {var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i);});}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null;},k.readAsDataURL(b);}else {var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m);},4E4);}});f.saveAs=g.saveAs=g,(module.exports=g);});
2993
+
2994
+
2995
+ });
2996
+
2997
+ var useDialog = function useDialog() {
2998
+ var _useState = React.useState(false),
2999
+ openConfirmDialog = _useState[0],
3000
+ setOpenConfirmDialog = _useState[1];
3001
+ var toggleConfirmDialog = function toggleConfirmDialog() {
3002
+ setOpenConfirmDialog(function (state) {
3003
+ return !state;
3004
+ });
3005
+ };
3006
+ var handleConfirm = function handleConfirm(conversationId) {
3007
+ try {
3008
+ var _temp2 = function _temp2() {
3009
+ setLoading(false);
3010
+ };
3011
+ setLoading(true);
3012
+ var _temp = _catch(function () {
3013
+ return Promise.resolve(completeConversation(conversationId)).then(function () {
3014
+ toggleConfirmDialog();
3015
+ reactToastify.toast.success("Complete conversation success");
3016
+ });
3017
+ }, function () {
3018
+ reactToastify.toast.error("Failed to complete conversation");
3019
+ });
3020
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3021
+ } catch (e) {
3022
+ return Promise.reject(e);
3023
+ }
3024
+ };
3025
+ var downloadFile = function downloadFile(content) {
3026
+ try {
3027
+ FileSaver_min.saveAs(content, "image.png");
3028
+ return Promise.resolve();
3029
+ } catch (e) {
3030
+ return Promise.reject(e);
3031
+ }
3032
+ };
3033
+ return {
3034
+ openConfirmDialog: openConfirmDialog,
3035
+ toggleConfirmDialog: toggleConfirmDialog,
3036
+ handleConfirm: handleConfirm,
3037
+ downloadFile: downloadFile
3038
+ };
3039
+ };
3040
+
2889
3041
  (function (ChatItemType) {
2890
3042
  ChatItemType[ChatItemType["Default"] = 0] = "Default";
2891
3043
  ChatItemType[ChatItemType["Exam"] = 1] = "Exam";
@@ -2893,7 +3045,20 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2893
3045
  })(exports.ChatItemType || (exports.ChatItemType = {}));
2894
3046
  var ChatItem = function ChatItem(props) {
2895
3047
  var isMe = props.isMe;
2896
- return React__default.createElement(React.Fragment, null, isMe ? React__default.createElement(ChatRightItem, Object.assign({}, props)) : React__default.createElement(ChatLeftItem, Object.assign({}, props)));
3048
+ var _useDialog = useDialog(),
3049
+ openConfirmDialog = _useDialog.openConfirmDialog,
3050
+ toggleConfirmDialog = _useDialog.toggleConfirmDialog,
3051
+ downloadFile = _useDialog.downloadFile;
3052
+ return React__default.createElement(React.Fragment, null, isMe ? React__default.createElement(ChatRightItem, Object.assign({}, props, {
3053
+ toggleImageDialog: toggleConfirmDialog
3054
+ })) : React__default.createElement(ChatLeftItem, Object.assign({}, props, {
3055
+ toggleImageDialog: toggleConfirmDialog
3056
+ })), React__default.createElement(ImageDetailDialog, {
3057
+ open: openConfirmDialog,
3058
+ toggleDialog: toggleConfirmDialog,
3059
+ content: props.content || "",
3060
+ downloadFile: downloadFile
3061
+ }));
2897
3062
  };
2898
3063
 
2899
3064
  var MessageSortBy;
@@ -3079,10 +3244,9 @@ var InputChat = function InputChat(_ref) {
3079
3244
  }, React__default.createElement("img", {
3080
3245
  src: selectedFile === null || selectedFile === void 0 ? void 0 : selectedFile.content,
3081
3246
  style: {
3082
- backgroundRepeat: "no-repeat",
3083
- width: "100px",
3084
3247
  height: "100px",
3085
- backgroundSize: "cover"
3248
+ objectFit: "contain",
3249
+ objectPosition: "center"
3086
3250
  }
3087
3251
  }), React__default.createElement("div", {
3088
3252
  style: {
@@ -3159,57 +3323,6 @@ var iconChecked = function iconChecked(_ref) {
3159
3323
  }));
3160
3324
  };
3161
3325
 
3162
- var CONVERSATION_URL = BASE_URL + "/api/conversation";
3163
- var apiAddMessage = function apiAddMessage(conversationId, message) {
3164
- return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
3165
- };
3166
- var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
3167
- return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
3168
- params: filter
3169
- });
3170
- };
3171
- var completeConversation = function completeConversation(conversationId) {
3172
- return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
3173
- };
3174
- var apiUploadImageFile = function apiUploadImageFile(file) {
3175
- return apiUpload.post(BASE_URL + "/api/file/images", file);
3176
- };
3177
-
3178
- var useDialog = function useDialog() {
3179
- var _useState = React.useState(false),
3180
- openConfirmDialog = _useState[0],
3181
- setOpenConfirmDialog = _useState[1];
3182
- var toggleConfirmDialog = function toggleConfirmDialog() {
3183
- setOpenConfirmDialog(function (state) {
3184
- return !state;
3185
- });
3186
- };
3187
- var handleConfirm = function handleConfirm(conversationId) {
3188
- try {
3189
- var _temp2 = function _temp2() {
3190
- setLoading(false);
3191
- };
3192
- setLoading(true);
3193
- var _temp = _catch(function () {
3194
- return Promise.resolve(completeConversation(conversationId)).then(function () {
3195
- toggleConfirmDialog();
3196
- reactToastify.toast.success("Complete conversation success");
3197
- });
3198
- }, function () {
3199
- reactToastify.toast.error("Failed to complete conversation");
3200
- });
3201
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3202
- } catch (e) {
3203
- return Promise.reject(e);
3204
- }
3205
- };
3206
- return {
3207
- openConfirmDialog: openConfirmDialog,
3208
- toggleConfirmDialog: toggleConfirmDialog,
3209
- handleConfirm: handleConfirm
3210
- };
3211
- };
3212
-
3213
3326
  var ChatHeader = function ChatHeader(_ref) {
3214
3327
  var fullName = _ref.fullName,
3215
3328
  examTitle = _ref.examTitle,
@@ -3424,6 +3537,10 @@ var ChatContainer = function ChatContainer(_ref) {
3424
3537
  if (scrollTop <= scrollOffset) {
3425
3538
  return Promise.resolve(onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop()).then(function (isSuccessLoad) {
3426
3539
  if (isSuccessLoad) {
3540
+ var _listItemRef$current, _listItemRef$current$;
3541
+ (_listItemRef$current = listItemRef.current) === null || _listItemRef$current === void 0 ? void 0 : (_listItemRef$current$ = _listItemRef$current.lastElementChild) === null || _listItemRef$current$ === void 0 ? void 0 : _listItemRef$current$.scrollIntoView({
3542
+ behavior: "smooth"
3543
+ });
3427
3544
  listRef.current.scrollTop = listRef.current.scrollHeight - scrollHeight;
3428
3545
  }
3429
3546
  });
@@ -3441,24 +3558,20 @@ var ChatContainer = function ChatContainer(_ref) {
3441
3558
  }
3442
3559
  };
3443
3560
  React.useEffect(function () {
3444
- var _listRef$current, _chatListProps$messag, _listRef$current3;
3561
+ var _listRef$current, _chatListProps$messag, _listRef$current2;
3445
3562
  scrollRef.current && clearTimeout(scrollRef.current);
3446
3563
  addEventTimeout.current && clearTimeout(addEventTimeout.current);
3447
3564
  (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener("scroll", handleScroll);
3448
3565
  if (isScrollToEnd && !isLoading && (_chatListProps$messag = chatListProps.messages) !== null && _chatListProps$messag !== void 0 && _chatListProps$messag.length) {
3449
- var _listItemRef$current, _listItemRef$current$;
3450
- (_listItemRef$current = listItemRef.current) === null || _listItemRef$current === void 0 ? void 0 : (_listItemRef$current$ = _listItemRef$current.lastElementChild) === null || _listItemRef$current$ === void 0 ? void 0 : _listItemRef$current$.scrollIntoView({
3566
+ var _listItemRef$current2, _listItemRef$current3;
3567
+ (_listItemRef$current2 = listItemRef.current) === null || _listItemRef$current2 === void 0 ? void 0 : (_listItemRef$current3 = _listItemRef$current2.lastElementChild) === null || _listItemRef$current3 === void 0 ? void 0 : _listItemRef$current3.scrollIntoView({
3451
3568
  behavior: "smooth"
3452
3569
  });
3453
3570
  onEndScrollToEnd === null || onEndScrollToEnd === void 0 ? void 0 : onEndScrollToEnd();
3454
- addEventTimeout.current = setTimeout(function () {
3455
- var _listRef$current2;
3456
- (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
3457
- }, 800);
3458
- } else (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.addEventListener("scroll", handleScroll);
3571
+ } else (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
3459
3572
  return function () {
3460
- var _listRef$current4;
3461
- (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : _listRef$current4.removeEventListener("scroll", handleScroll);
3573
+ var _listRef$current3;
3574
+ (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.removeEventListener("scroll", handleScroll);
3462
3575
  scrollRef.current && clearTimeout(scrollRef.current);
3463
3576
  addEventTimeout.current && clearTimeout(addEventTimeout.current);
3464
3577
  };
@@ -3508,14 +3621,16 @@ var useMessageList = function useMessageList() {
3508
3621
  var _temp = _catch(function () {
3509
3622
  var filter = _extends({}, messageFilter);
3510
3623
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3511
- setMessages(function (prev) {
3512
- var _res$data$items;
3513
- return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3514
- });
3515
- setMessageFilter(function (prev) {
3516
- return _extends({}, prev, {
3517
- totalItems: res.data.totalItems,
3518
- totalPages: res.data.totalPages
3624
+ return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
3625
+ setMessages(function (prev) {
3626
+ var _res$data$items;
3627
+ return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3628
+ });
3629
+ setMessageFilter(function (prev) {
3630
+ return _extends({}, prev, {
3631
+ totalItems: res.data.totalItems,
3632
+ totalPages: res.data.totalPages
3633
+ });
3519
3634
  });
3520
3635
  });
3521
3636
  });
@@ -3535,28 +3650,30 @@ var useMessageList = function useMessageList() {
3535
3650
  return true;
3536
3651
  };
3537
3652
  var _exit = false;
3538
- if (isLoading) return Promise.resolve();
3653
+ if (isLoading || messageFilter.currentPage === messageFilter.totalPages) return Promise.resolve();
3539
3654
  var filter = _extends({}, messageFilter, {
3540
3655
  currentPage: ((messageFilter === null || messageFilter === void 0 ? void 0 : messageFilter.currentPage) || 1) + 1
3541
3656
  });
3542
- setMessageFilter(filter);
3543
3657
  setLoading(true);
3544
3658
  var _temp3 = _catch(function () {
3545
3659
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3546
- setMessages(function (prev) {
3547
- var _res$data$items2;
3548
- var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3549
- var dataFilter = new Set(data);
3550
- return Array.from(dataFilter);
3551
- });
3552
- if (res.data.items) {
3553
- setMessageFilter(function (prev) {
3554
- return _extends({}, prev, {
3555
- totalItems: res.data.totalItems,
3556
- totalPages: res.data.totalPages
3660
+ return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
3661
+ if (res.data.items.length) {
3662
+ setMessages(function (prev) {
3663
+ var _res$data$items2;
3664
+ var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3665
+ var dataFilter = new Set(data);
3666
+ return Array.from(dataFilter);
3557
3667
  });
3558
- });
3559
- }
3668
+ setMessageFilter(function (prev) {
3669
+ return _extends({}, prev, {
3670
+ totalItems: res.data.totalItems,
3671
+ totalPages: res.data.totalPages,
3672
+ currentPage: res.data.page
3673
+ });
3674
+ });
3675
+ }
3676
+ });
3560
3677
  });
3561
3678
  }, function () {
3562
3679
  reactToastify.toast.error("Fail to fetch data!");
@@ -3669,34 +3786,26 @@ var useChatContainer = function useChatContainer(props) {
3669
3786
  }
3670
3787
  };
3671
3788
  var handleUploadImage = function handleUploadImage(file) {
3672
- try {
3673
- console.log({
3674
- file: file
3675
- });
3676
- if (!file) return Promise.resolve();
3677
- return Promise.resolve(_finally(function () {
3678
- return _catch(function () {
3679
- var formData = new FormData();
3680
- formData.append("upload", file);
3681
- return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
3682
- var _res$data;
3683
- setSelectedFile({
3684
- content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3685
- });
3686
- });
3687
- }, function (error) {
3688
- var _error$response2;
3689
- setMessages(function (state) {
3690
- return [].concat(state.filter(function (i) {
3691
- return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3692
- }));
3789
+ return file ? Promise.resolve(_finally(function () {
3790
+ return _catch(function () {
3791
+ var formData = new FormData();
3792
+ formData.append("upload", file);
3793
+ return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
3794
+ var _res$data;
3795
+ setSelectedFile({
3796
+ content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3693
3797
  });
3694
- reactToastify.toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3695
3798
  });
3696
- }, function () {}));
3697
- } catch (e) {
3698
- return Promise.reject(e);
3699
- }
3799
+ }, function (error) {
3800
+ var _error$response2;
3801
+ setMessages(function (state) {
3802
+ return [].concat(state.filter(function (i) {
3803
+ return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3804
+ }));
3805
+ });
3806
+ reactToastify.toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3807
+ });
3808
+ }, function () {})) : Promise.resolve();
3700
3809
  };
3701
3810
  var handleChangeInput = function handleChangeInput(text) {
3702
3811
  setMessage({
@@ -3710,6 +3819,14 @@ var useChatContainer = function useChatContainer(props) {
3710
3819
  return [].concat(state, [data]);
3711
3820
  });
3712
3821
  };
3822
+ var handleNewConversation = function handleNewConversation(data) {
3823
+ if (!data) return;
3824
+ var item = JSON.parse(data);
3825
+ setScrollToEnd(true);
3826
+ setMessages(function (state) {
3827
+ return [].concat(state, [item]);
3828
+ });
3829
+ };
3713
3830
  var handleCompletedConversation = function handleCompletedConversation(data) {
3714
3831
  if (!data) return;
3715
3832
  setSelectedConversation(JSON.parse(data));
@@ -3726,8 +3843,10 @@ var useChatContainer = function useChatContainer(props) {
3726
3843
  setSelectedFile(null);
3727
3844
  };
3728
3845
  var cleanupPusher = function cleanupPusher() {
3729
- var _pusher$current;
3846
+ var _pusher$current, _pusher$current2, _pusher$current3;
3730
3847
  (_pusher$current = pusher.current) === null || _pusher$current === void 0 ? void 0 : _pusher$current.unbind("new-message-event", handleNewMessageSent);
3848
+ (_pusher$current2 = pusher.current) === null || _pusher$current2 === void 0 ? void 0 : _pusher$current2.unbind("completed-conversation-event", handleCompletedConversation);
3849
+ (_pusher$current3 = pusher.current) === null || _pusher$current3 === void 0 ? void 0 : _pusher$current3.unbind("new-conversation-event", handleNewConversation);
3731
3850
  channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
3732
3851
  };
3733
3852
  React.useEffect(function () {
@@ -3744,10 +3863,11 @@ var useChatContainer = function useChatContainer(props) {
3744
3863
  }, _headers[AcademyHeaders] = academyDomain, _headers)
3745
3864
  }
3746
3865
  });
3747
- channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id);
3866
+ channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id) + "-" + academyDomain.trim().toUpperCase();
3748
3867
  channel.current = pusher.current.subscribe(channelName.current);
3749
3868
  pusher.current.bind("new-message-event", handleNewMessageSent);
3750
3869
  pusher.current.bind("completed-conversation-event", handleCompletedConversation);
3870
+ pusher.current.bind("new-conversation-event", handleNewConversation);
3751
3871
  }
3752
3872
  return cleanupPusher;
3753
3873
  }, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, academyDomain]);
@@ -3865,7 +3985,7 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
3865
3985
  }, _headers[AcademyHeaders] = academyDomain, _headers)
3866
3986
  }
3867
3987
  });
3868
- channelName.current = "presence-conversation-channel-userId-" + userId;
3988
+ channelName.current = "presence-conversation-channel-userId-" + userId + "-" + academyDomain.trim().toUpperCase();
3869
3989
  channel.current = pusher.current.subscribe(channelName.current);
3870
3990
  channel.current.bind("message-conversation-event", handleNewMessageConversationCreated);
3871
3991
  channel.current.bind("message-conversation-read-event", handleReadMessageConversation);
@@ -4132,12 +4252,16 @@ var ScoreSelector = function ScoreSelector(_ref) {
4132
4252
  isDisabled = _ref.isDisabled;
4133
4253
  var _useTranslation = reactI18next.useTranslation(),
4134
4254
  t = _useTranslation.t;
4135
- var scoreOptions = SCORE_OPTIONS.map(function (i) {
4136
- return {
4137
- label: "" + t(i + "\uC810") + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
4138
- value: i
4139
- };
4140
- });
4255
+ var scoreOptions = React.useMemo(function () {
4256
+ return SCORE_OPTIONS.map(function (i) {
4257
+ return {
4258
+ label: "" + t("score_format", {
4259
+ score: i
4260
+ }) + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
4261
+ value: i
4262
+ };
4263
+ });
4264
+ }, [t]);
4141
4265
  return React__default.createElement(CustomSelect, {
4142
4266
  inputId: id,
4143
4267
  value: value,
@@ -4154,6 +4278,8 @@ var QuestionView = function QuestionView(_ref) {
4154
4278
  isDisabled = _ref.isDisabled,
4155
4279
  onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
4156
4280
  onChangeScoreAnswer = _ref.onChangeScoreAnswer;
4281
+ var _useTranslation = reactI18next.useTranslation(),
4282
+ t = _useTranslation.t;
4157
4283
  var handleChangeCorrectAnswer = function handleChangeCorrectAnswer(e) {
4158
4284
  return onChangeCorrectAnswers(e.target.value, index);
4159
4285
  };
@@ -4163,7 +4289,9 @@ var QuestionView = function QuestionView(_ref) {
4163
4289
  className: "d-flex flex-grow-1"
4164
4290
  }, React__default.createElement("div", {
4165
4291
  className: styles$1["question-title"] + " me-2 text-nowrap"
4166
- }, "\uBB38\uC81C ", question.questionOrder + 1, "\uBC88"), React__default.createElement(material.FormControl, {
4292
+ }, t("problem_number_question", {
4293
+ number: question.questionOrder + 1
4294
+ })), React__default.createElement(material.FormControl, {
4167
4295
  className: "flex-grow-1 w-100"
4168
4296
  }, React__default.createElement(material.RadioGroup, {
4169
4297
  value: question.correctAnswers[0],
@@ -4184,7 +4312,9 @@ var QuestionView = function QuestionView(_ref) {
4184
4312
  control: React__default.createElement(material.Radio, {
4185
4313
  size: "small"
4186
4314
  }),
4187
- label: i + "\uBC88"
4315
+ label: t("number_question", {
4316
+ number: i
4317
+ })
4188
4318
  });
4189
4319
  })))), React__default.createElement("div", {
4190
4320
  className: "d-flex align-items-center"
@@ -4566,6 +4696,26 @@ var useExamDetailView = function useExamDetailView(props) {
4566
4696
  }))
4567
4697
  }));
4568
4698
  };
4699
+ var handleDeleteArticle = function handleDeleteArticle(article) {
4700
+ if (!exam) return;
4701
+ var removedQuestions = exam.questions.filter(function (i) {
4702
+ return i.article === +article;
4703
+ }).map(function (i) {
4704
+ return i.questionOrder;
4705
+ });
4706
+ var max = Math.max.apply(Math, removedQuestions);
4707
+ var examQuestions = exam.questions.filter(function (i) {
4708
+ return i.article !== +article;
4709
+ }).map(function (i) {
4710
+ return _extends({}, i, {
4711
+ article: i.article > article ? i.article - 1 : i.article,
4712
+ questionOrder: i.questionOrder > max ? i.questionOrder - removedQuestions.length : i.questionOrder
4713
+ });
4714
+ });
4715
+ onChangeExam(_extends({}, exam, {
4716
+ questions: [].concat(examQuestions)
4717
+ }));
4718
+ };
4569
4719
  var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
4570
4720
  if (!exam) return;
4571
4721
  if (newAnswerCount === answerCount) return;
@@ -4693,10 +4843,10 @@ var useExamDetailView = function useExamDetailView(props) {
4693
4843
  return options;
4694
4844
  }, [exam.duration]);
4695
4845
  React.useEffect(function () {
4696
- onChangeExam(_extends({}, exam, {
4846
+ if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
4697
4847
  subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
4698
4848
  }));
4699
- }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id]);
4849
+ }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
4700
4850
  return {
4701
4851
  t: t,
4702
4852
  durationOptions: durationOptions,
@@ -4708,7 +4858,8 @@ var useExamDetailView = function useExamDetailView(props) {
4708
4858
  handleChangeCorrectAnswers: handleChangeCorrectAnswers,
4709
4859
  handleChangeAnswerCount: handleChangeAnswerCount,
4710
4860
  handleChangeQuestionCount: handleChangeQuestionCount,
4711
- handleChangeCategory: handleChangeCategory
4861
+ handleChangeCategory: handleChangeCategory,
4862
+ handleDeleteArticle: handleDeleteArticle
4712
4863
  };
4713
4864
  };
4714
4865
 
@@ -4738,7 +4889,8 @@ var ExamDetailView = function ExamDetailView(_ref) {
4738
4889
  handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
4739
4890
  handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
4740
4891
  handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
4741
- handleChangeCategory = _useExamDetailView.handleChangeCategory;
4892
+ handleChangeCategory = _useExamDetailView.handleChangeCategory,
4893
+ handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
4742
4894
  return React__default.createElement(material.Grid, {
4743
4895
  container: true,
4744
4896
  spacing: 3,
@@ -4777,7 +4929,7 @@ var ExamDetailView = function ExamDetailView(_ref) {
4777
4929
  }, React__default.createElement("label", {
4778
4930
  className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
4779
4931
  htmlFor: "duration"
4780
- }, " ", t("subject")), React__default.createElement(CustomSelect, {
4932
+ }, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React__default.createElement(CustomSelect, {
4781
4933
  inputId: "subject",
4782
4934
  value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
4783
4935
  options: subjectOptions,
@@ -4796,8 +4948,10 @@ var ExamDetailView = function ExamDetailView(_ref) {
4796
4948
  onChangeAnswerCount: handleChangeAnswerCount,
4797
4949
  onChangeCorrectAnswers: handleChangeCorrectAnswers,
4798
4950
  onChangeScoreAnswer: handleChangeScoreAnswer,
4951
+ onDelete: handleDeleteArticle,
4799
4952
  isDisabled: isDisabled,
4800
- selectedSubject: selectedSubject
4953
+ selectedSubject: selectedSubject,
4954
+ isDeletable: examGroupByArticle.length > 1
4801
4955
  })));
4802
4956
  }), React__default.createElement(material.Grid, {
4803
4957
  item: true,