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.
@@ -9,7 +9,7 @@ import { useDispatch, useSelector } from 'react-redux';
9
9
  import axios from 'axios';
10
10
  import { useTranslation, initReactI18next } from 'react-i18next';
11
11
  export { I18nextProvider, useTranslation } from 'react-i18next';
12
- import { Grid, Dialog, DialogTitle, IconButton, DialogContent, TextField, DialogActions, Button, Box, Typography, Pagination, CircularProgress, FormControl, RadioGroup, FormControlLabel, Radio, FormGroup, FormLabel, Table } from '@mui/material';
12
+ import { Grid, Dialog, DialogTitle, IconButton, DialogContent, TextField, DialogActions, Button, Box, Typography, Pagination, Stack, CircularProgress, FormControl, RadioGroup, FormControlLabel, Radio, FormGroup, FormLabel, Table } from '@mui/material';
13
13
  import { gapi } from 'gapi-script';
14
14
  import { IoClose, IoCloseOutline } from 'react-icons/io5';
15
15
  import i18n from 'i18next';
@@ -139,6 +139,7 @@ var Role;
139
139
  Role["Student"] = "Student";
140
140
  Role["Teacher"] = "Teacher";
141
141
  Role["Admin"] = "Admin";
142
+ Role["AcademyAdmin"] = "AcademyAdmin";
142
143
  })(Role || (Role = {}));
143
144
 
144
145
  // A type of promise-like that resolves synchronously and supports only one observer
@@ -1459,6 +1460,16 @@ var update_textbook_title = "교과서 제목 업데이트";
1459
1460
  var invalid_weekly_day_time = "주간 요일 시간이 잘못되었습니다";
1460
1461
  var no_image = "이미지 없음";
1461
1462
  var school_name = "학교 이름";
1463
+ var phone_number = "전화번호";
1464
+ var major = "주요한";
1465
+ var roles = "역할";
1466
+ var searching_for = "검색 중...";
1467
+ var parent_name = "부모님 성함";
1468
+ var users = "사용자";
1469
+ var new_user = "새로운 사용자";
1470
+ var academy_admin = "아카데미 관리자";
1471
+ var switch_academy_admin = "스위치 아카데미 관리자";
1472
+ var there_are_no_lessons_this_week = "이번주는 수업이 없습니다";
1462
1473
  var lang_ko = {
1463
1474
  problem_solving: problem_solving,
1464
1475
  my_story: my_story,
@@ -1702,7 +1713,17 @@ var lang_ko = {
1702
1713
  update_textbook_title: update_textbook_title,
1703
1714
  invalid_weekly_day_time: invalid_weekly_day_time,
1704
1715
  no_image: no_image,
1705
- school_name: school_name
1716
+ school_name: school_name,
1717
+ phone_number: phone_number,
1718
+ major: major,
1719
+ roles: roles,
1720
+ searching_for: searching_for,
1721
+ parent_name: parent_name,
1722
+ users: users,
1723
+ new_user: new_user,
1724
+ academy_admin: academy_admin,
1725
+ switch_academy_admin: switch_academy_admin,
1726
+ there_are_no_lessons_this_week: there_are_no_lessons_this_week
1706
1727
  };
1707
1728
 
1708
1729
  var problem_solving$1 = "Problem Solving";
@@ -1972,7 +1993,7 @@ var add_new_chapter_to_textbook$1 = "Add new chapter to the textbook";
1972
1993
  var add_new_subchapter_to_parent_chapter$1 = "Add new subchapter to the parent chapter ({{ chapterName }})";
1973
1994
  var add$1 = "Add";
1974
1995
  var add_new_article_to_chapter$1 = "Add new article to the chapter ({{ chapterName }})";
1975
- var score_format$1 = "{{score}}points";
1996
+ var score_format$1 = "{{score}}pts";
1976
1997
  var round$1 = "{{number}} round";
1977
1998
  var number_grade$1 = "Grade {{number}}";
1978
1999
  var print$1 = "Print";
@@ -1984,6 +2005,16 @@ var update_textbook_title$1 = "Update textbook title";
1984
2005
  var invalid_weekly_day_time$1 = "Invalid weekly day time";
1985
2006
  var no_image$1 = "No image";
1986
2007
  var school_name$1 = "School name";
2008
+ var phone_number$1 = "Phone Number";
2009
+ var major$1 = "Major";
2010
+ var roles$1 = "Roles";
2011
+ var searching_for$1 = "Searching for...";
2012
+ var parent_name$1 = "Parent name";
2013
+ var users$1 = "Users";
2014
+ var new_user$1 = "New user";
2015
+ var academy_admin$1 = "Academy Admin";
2016
+ var switch_academy_admin$1 = "Switch Academy Admin";
2017
+ var there_are_no_lessons_this_week$1 = "There are no lessons this week";
1987
2018
  var lang_en = {
1988
2019
  problem_solving: problem_solving$1,
1989
2020
  my_story: my_story$1,
@@ -2261,7 +2292,17 @@ var lang_en = {
2261
2292
  update_textbook_title: update_textbook_title$1,
2262
2293
  invalid_weekly_day_time: invalid_weekly_day_time$1,
2263
2294
  no_image: no_image$1,
2264
- school_name: school_name$1
2295
+ school_name: school_name$1,
2296
+ phone_number: phone_number$1,
2297
+ major: major$1,
2298
+ roles: roles$1,
2299
+ searching_for: searching_for$1,
2300
+ parent_name: parent_name$1,
2301
+ users: users$1,
2302
+ new_user: new_user$1,
2303
+ academy_admin: academy_admin$1,
2304
+ switch_academy_admin: switch_academy_admin$1,
2305
+ there_are_no_lessons_this_week: there_are_no_lessons_this_week$1
2265
2306
  };
2266
2307
 
2267
2308
  i18n.use(initReactI18next).init({
@@ -2446,6 +2487,8 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
2446
2487
  var _state$common2;
2447
2488
  return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
2448
2489
  });
2490
+ var _useTranslation = useTranslation(),
2491
+ t = _useTranslation.t;
2449
2492
  var getAcademies = function getAcademies(isLoading) {
2450
2493
  if (isLoading === void 0) {
2451
2494
  isLoading = true;
@@ -2506,7 +2549,7 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
2506
2549
  });
2507
2550
  }, function (error) {
2508
2551
  var _error$response2, _error$response2$data;
2509
- 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");
2552
+ 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"));
2510
2553
  });
2511
2554
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
2512
2555
  } catch (e) {
@@ -2550,6 +2593,8 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2550
2593
  });
2551
2594
  var isAdmin = role === Role.Admin;
2552
2595
  var isSuperAdmin = user && !user.academyDomain && ((_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(Role.Admin));
2596
+ var _useTranslation = useTranslation(),
2597
+ t = _useTranslation.t;
2553
2598
  var _useState = useState(null),
2554
2599
  open = _useState[0],
2555
2600
  setOpen = _useState[1];
@@ -2586,7 +2631,7 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2586
2631
  color: "#5458D5",
2587
2632
  minWidth: 150
2588
2633
  }
2589
- }, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || "Switch Academy Admin"), React.createElement("div", {
2634
+ }, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || t("switch_academy_admin")), React.createElement("div", {
2590
2635
  className: "" + stylesGlobal["switch-icon"]
2591
2636
  }, React.createElement(GoArrowSwitch, {
2592
2637
  size: 14
@@ -2769,7 +2814,8 @@ var ChatRightItem = function ChatRightItem(_ref) {
2769
2814
  showTimestamp = _ref.showTimestamp,
2770
2815
  isStudent = _ref.isStudent,
2771
2816
  showName = _ref.showName,
2772
- contentType = _ref.contentType;
2817
+ contentType = _ref.contentType,
2818
+ toggleImageDialog = _ref.toggleImageDialog;
2773
2819
  var _useTranslation = useTranslation(),
2774
2820
  t = _useTranslation.t;
2775
2821
  return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
@@ -2797,14 +2843,12 @@ var ChatRightItem = function ChatRightItem(_ref) {
2797
2843
  lineHeight: "16.71px",
2798
2844
  color: "#5458D5"
2799
2845
  }, sender === null || sender === void 0 ? void 0 : sender.fullName)), contentType ? React.createElement("img", {
2846
+ onClick: toggleImageDialog,
2800
2847
  src: content,
2801
2848
  style: {
2802
- backgroundRepeat: "no-repeat",
2803
- width: "200px",
2804
2849
  height: "200px",
2805
2850
  position: "relative",
2806
- backgroundSize: "cover",
2807
- objectFit: "cover"
2851
+ objectFit: "contain"
2808
2852
  }
2809
2853
  }) : React.createElement("div", {
2810
2854
  className: styles["wrap-content"] + " " + styles["content-chat-receiver"],
@@ -2826,7 +2870,8 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2826
2870
  showTimestamp = _ref.showTimestamp,
2827
2871
  isStudent = _ref.isStudent,
2828
2872
  showName = _ref.showName,
2829
- contentType = _ref.contentType;
2873
+ contentType = _ref.contentType,
2874
+ toggleImageDialog = _ref.toggleImageDialog;
2830
2875
  var _useTranslation = useTranslation(),
2831
2876
  t = _useTranslation.t;
2832
2877
  return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
@@ -2868,14 +2913,12 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2868
2913
  }, t("student")))), React.createElement(Box, {
2869
2914
  padding: "4px 0px"
2870
2915
  }), contentType ? React.createElement("img", {
2916
+ onClick: toggleImageDialog,
2871
2917
  src: content,
2872
2918
  style: {
2873
- backgroundRepeat: "no-repeat",
2874
- width: "200px",
2875
2919
  height: "200px",
2876
2920
  position: "relative",
2877
- backgroundSize: "cover",
2878
- objectFit: "cover"
2921
+ objectFit: "contain"
2879
2922
  }
2880
2923
  }) : React.createElement("div", {
2881
2924
  className: styles["wrap-content"] + " " + styles["content-chat-sender"]
@@ -2887,6 +2930,115 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2887
2930
  }, content))));
2888
2931
  };
2889
2932
 
2933
+ var ImageDetailDialog = function ImageDetailDialog(_ref) {
2934
+ var open = _ref.open,
2935
+ toggleDialog = _ref.toggleDialog,
2936
+ content = _ref.content,
2937
+ downloadFile = _ref.downloadFile;
2938
+ var _useTranslation = useTranslation(),
2939
+ t = _useTranslation.t;
2940
+ return React.createElement(CommonDialog, {
2941
+ open: open,
2942
+ onClose: toggleDialog,
2943
+ size: "sm",
2944
+ title: t("image")
2945
+ }, React.createElement(DialogContent, {
2946
+ sx: {
2947
+ overflowY: "unset"
2948
+ }
2949
+ }, React.createElement(Stack, null, React.createElement(Stack, {
2950
+ display: "flex",
2951
+ justifyContent: "center",
2952
+ alignItems: "center"
2953
+ }, React.createElement("img", {
2954
+ src: content,
2955
+ style: {
2956
+ width: "500px",
2957
+ position: "relative",
2958
+ objectFit: "contain",
2959
+ objectPosition: "center"
2960
+ }
2961
+ })), React.createElement(Button, {
2962
+ sx: {
2963
+ margin: "10px 0"
2964
+ },
2965
+ variant: "outlined",
2966
+ fullWidth: true,
2967
+ onClick: function onClick() {
2968
+ return downloadFile(content);
2969
+ }
2970
+ }, t("download")))));
2971
+ };
2972
+
2973
+ var CONVERSATION_URL = BASE_URL + "/api/conversation";
2974
+ var apiAddMessage = function apiAddMessage(conversationId, message) {
2975
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
2976
+ };
2977
+ var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
2978
+ return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
2979
+ params: filter
2980
+ });
2981
+ };
2982
+ var updateLastTimeReadConversation = function updateLastTimeReadConversation(conversationId) {
2983
+ return api.put(CONVERSATION_URL + "/" + conversationId);
2984
+ };
2985
+ var completeConversation = function completeConversation(conversationId) {
2986
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
2987
+ };
2988
+ var apiUploadImageFile = function apiUploadImageFile(file) {
2989
+ return apiUpload.post(BASE_URL + "/api/file/images", file);
2990
+ };
2991
+
2992
+ var FileSaver_min = createCommonjsModule(function (module, exports) {
2993
+ (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);});
2994
+
2995
+ //# sourceMappingURL=FileSaver.min.js.map
2996
+ });
2997
+
2998
+ var useDialog = function useDialog() {
2999
+ var _useState = useState(false),
3000
+ openConfirmDialog = _useState[0],
3001
+ setOpenConfirmDialog = _useState[1];
3002
+ var toggleConfirmDialog = function toggleConfirmDialog() {
3003
+ setOpenConfirmDialog(function (state) {
3004
+ return !state;
3005
+ });
3006
+ };
3007
+ var handleConfirm = function handleConfirm(conversationId) {
3008
+ try {
3009
+ var _temp2 = function _temp2() {
3010
+ setLoading(false);
3011
+ };
3012
+ setLoading(true);
3013
+ var _temp = _catch(function () {
3014
+ return Promise.resolve(completeConversation(conversationId)).then(function () {
3015
+ toggleConfirmDialog();
3016
+ toast.success("Complete conversation success");
3017
+ });
3018
+ }, function () {
3019
+ toast.error("Failed to complete conversation");
3020
+ });
3021
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3022
+ } catch (e) {
3023
+ return Promise.reject(e);
3024
+ }
3025
+ };
3026
+ var downloadFile = function downloadFile(content) {
3027
+ try {
3028
+ FileSaver_min.saveAs(content, "image.png");
3029
+ return Promise.resolve();
3030
+ } catch (e) {
3031
+ return Promise.reject(e);
3032
+ }
3033
+ };
3034
+ return {
3035
+ openConfirmDialog: openConfirmDialog,
3036
+ toggleConfirmDialog: toggleConfirmDialog,
3037
+ handleConfirm: handleConfirm,
3038
+ downloadFile: downloadFile
3039
+ };
3040
+ };
3041
+
2890
3042
  var ChatItemType;
2891
3043
  (function (ChatItemType) {
2892
3044
  ChatItemType[ChatItemType["Default"] = 0] = "Default";
@@ -2895,7 +3047,20 @@ var ChatItemType;
2895
3047
  })(ChatItemType || (ChatItemType = {}));
2896
3048
  var ChatItem = function ChatItem(props) {
2897
3049
  var isMe = props.isMe;
2898
- return React.createElement(Fragment$1, null, isMe ? React.createElement(ChatRightItem, Object.assign({}, props)) : React.createElement(ChatLeftItem, Object.assign({}, props)));
3050
+ var _useDialog = useDialog(),
3051
+ openConfirmDialog = _useDialog.openConfirmDialog,
3052
+ toggleConfirmDialog = _useDialog.toggleConfirmDialog,
3053
+ downloadFile = _useDialog.downloadFile;
3054
+ return React.createElement(Fragment$1, null, isMe ? React.createElement(ChatRightItem, Object.assign({}, props, {
3055
+ toggleImageDialog: toggleConfirmDialog
3056
+ })) : React.createElement(ChatLeftItem, Object.assign({}, props, {
3057
+ toggleImageDialog: toggleConfirmDialog
3058
+ })), React.createElement(ImageDetailDialog, {
3059
+ open: openConfirmDialog,
3060
+ toggleDialog: toggleConfirmDialog,
3061
+ content: props.content || "",
3062
+ downloadFile: downloadFile
3063
+ }));
2899
3064
  };
2900
3065
 
2901
3066
  var MessageSortBy;
@@ -3081,10 +3246,9 @@ var InputChat = function InputChat(_ref) {
3081
3246
  }, React.createElement("img", {
3082
3247
  src: selectedFile === null || selectedFile === void 0 ? void 0 : selectedFile.content,
3083
3248
  style: {
3084
- backgroundRepeat: "no-repeat",
3085
- width: "100px",
3086
3249
  height: "100px",
3087
- backgroundSize: "cover"
3250
+ objectFit: "contain",
3251
+ objectPosition: "center"
3088
3252
  }
3089
3253
  }), React.createElement("div", {
3090
3254
  style: {
@@ -3161,57 +3325,6 @@ var iconChecked = function iconChecked(_ref) {
3161
3325
  }));
3162
3326
  };
3163
3327
 
3164
- var CONVERSATION_URL = BASE_URL + "/api/conversation";
3165
- var apiAddMessage = function apiAddMessage(conversationId, message) {
3166
- return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
3167
- };
3168
- var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
3169
- return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
3170
- params: filter
3171
- });
3172
- };
3173
- var completeConversation = function completeConversation(conversationId) {
3174
- return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
3175
- };
3176
- var apiUploadImageFile = function apiUploadImageFile(file) {
3177
- return apiUpload.post(BASE_URL + "/api/file/images", file);
3178
- };
3179
-
3180
- var useDialog = function useDialog() {
3181
- var _useState = useState(false),
3182
- openConfirmDialog = _useState[0],
3183
- setOpenConfirmDialog = _useState[1];
3184
- var toggleConfirmDialog = function toggleConfirmDialog() {
3185
- setOpenConfirmDialog(function (state) {
3186
- return !state;
3187
- });
3188
- };
3189
- var handleConfirm = function handleConfirm(conversationId) {
3190
- try {
3191
- var _temp2 = function _temp2() {
3192
- setLoading(false);
3193
- };
3194
- setLoading(true);
3195
- var _temp = _catch(function () {
3196
- return Promise.resolve(completeConversation(conversationId)).then(function () {
3197
- toggleConfirmDialog();
3198
- toast.success("Complete conversation success");
3199
- });
3200
- }, function () {
3201
- toast.error("Failed to complete conversation");
3202
- });
3203
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3204
- } catch (e) {
3205
- return Promise.reject(e);
3206
- }
3207
- };
3208
- return {
3209
- openConfirmDialog: openConfirmDialog,
3210
- toggleConfirmDialog: toggleConfirmDialog,
3211
- handleConfirm: handleConfirm
3212
- };
3213
- };
3214
-
3215
3328
  var ChatHeader = function ChatHeader(_ref) {
3216
3329
  var fullName = _ref.fullName,
3217
3330
  examTitle = _ref.examTitle,
@@ -3426,6 +3539,10 @@ var ChatContainer = function ChatContainer(_ref) {
3426
3539
  if (scrollTop <= scrollOffset) {
3427
3540
  return Promise.resolve(onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop()).then(function (isSuccessLoad) {
3428
3541
  if (isSuccessLoad) {
3542
+ var _listItemRef$current, _listItemRef$current$;
3543
+ (_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({
3544
+ behavior: "smooth"
3545
+ });
3429
3546
  listRef.current.scrollTop = listRef.current.scrollHeight - scrollHeight;
3430
3547
  }
3431
3548
  });
@@ -3443,24 +3560,20 @@ var ChatContainer = function ChatContainer(_ref) {
3443
3560
  }
3444
3561
  };
3445
3562
  useEffect(function () {
3446
- var _listRef$current, _chatListProps$messag, _listRef$current3;
3563
+ var _listRef$current, _chatListProps$messag, _listRef$current2;
3447
3564
  scrollRef.current && clearTimeout(scrollRef.current);
3448
3565
  addEventTimeout.current && clearTimeout(addEventTimeout.current);
3449
3566
  (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener("scroll", handleScroll);
3450
3567
  if (isScrollToEnd && !isLoading && (_chatListProps$messag = chatListProps.messages) !== null && _chatListProps$messag !== void 0 && _chatListProps$messag.length) {
3451
- var _listItemRef$current, _listItemRef$current$;
3452
- (_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({
3568
+ var _listItemRef$current2, _listItemRef$current3;
3569
+ (_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({
3453
3570
  behavior: "smooth"
3454
3571
  });
3455
3572
  onEndScrollToEnd === null || onEndScrollToEnd === void 0 ? void 0 : onEndScrollToEnd();
3456
- addEventTimeout.current = setTimeout(function () {
3457
- var _listRef$current2;
3458
- (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
3459
- }, 800);
3460
- } else (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.addEventListener("scroll", handleScroll);
3573
+ } else (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
3461
3574
  return function () {
3462
- var _listRef$current4;
3463
- (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : _listRef$current4.removeEventListener("scroll", handleScroll);
3575
+ var _listRef$current3;
3576
+ (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.removeEventListener("scroll", handleScroll);
3464
3577
  scrollRef.current && clearTimeout(scrollRef.current);
3465
3578
  addEventTimeout.current && clearTimeout(addEventTimeout.current);
3466
3579
  };
@@ -3510,14 +3623,16 @@ var useMessageList = function useMessageList() {
3510
3623
  var _temp = _catch(function () {
3511
3624
  var filter = _extends({}, messageFilter);
3512
3625
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3513
- setMessages(function (prev) {
3514
- var _res$data$items;
3515
- return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3516
- });
3517
- setMessageFilter(function (prev) {
3518
- return _extends({}, prev, {
3519
- totalItems: res.data.totalItems,
3520
- totalPages: res.data.totalPages
3626
+ return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
3627
+ setMessages(function (prev) {
3628
+ var _res$data$items;
3629
+ return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3630
+ });
3631
+ setMessageFilter(function (prev) {
3632
+ return _extends({}, prev, {
3633
+ totalItems: res.data.totalItems,
3634
+ totalPages: res.data.totalPages
3635
+ });
3521
3636
  });
3522
3637
  });
3523
3638
  });
@@ -3537,28 +3652,30 @@ var useMessageList = function useMessageList() {
3537
3652
  return true;
3538
3653
  };
3539
3654
  var _exit = false;
3540
- if (isLoading) return Promise.resolve();
3655
+ if (isLoading || messageFilter.currentPage === messageFilter.totalPages) return Promise.resolve();
3541
3656
  var filter = _extends({}, messageFilter, {
3542
3657
  currentPage: ((messageFilter === null || messageFilter === void 0 ? void 0 : messageFilter.currentPage) || 1) + 1
3543
3658
  });
3544
- setMessageFilter(filter);
3545
3659
  setLoading(true);
3546
3660
  var _temp3 = _catch(function () {
3547
3661
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3548
- setMessages(function (prev) {
3549
- var _res$data$items2;
3550
- var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3551
- var dataFilter = new Set(data);
3552
- return Array.from(dataFilter);
3553
- });
3554
- if (res.data.items) {
3555
- setMessageFilter(function (prev) {
3556
- return _extends({}, prev, {
3557
- totalItems: res.data.totalItems,
3558
- totalPages: res.data.totalPages
3662
+ return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
3663
+ if (res.data.items.length) {
3664
+ setMessages(function (prev) {
3665
+ var _res$data$items2;
3666
+ var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3667
+ var dataFilter = new Set(data);
3668
+ return Array.from(dataFilter);
3559
3669
  });
3560
- });
3561
- }
3670
+ setMessageFilter(function (prev) {
3671
+ return _extends({}, prev, {
3672
+ totalItems: res.data.totalItems,
3673
+ totalPages: res.data.totalPages,
3674
+ currentPage: res.data.page
3675
+ });
3676
+ });
3677
+ }
3678
+ });
3562
3679
  });
3563
3680
  }, function () {
3564
3681
  toast.error("Fail to fetch data!");
@@ -3671,34 +3788,26 @@ var useChatContainer = function useChatContainer(props) {
3671
3788
  }
3672
3789
  };
3673
3790
  var handleUploadImage = function handleUploadImage(file) {
3674
- try {
3675
- console.log({
3676
- file: file
3677
- });
3678
- if (!file) return Promise.resolve();
3679
- return Promise.resolve(_finally(function () {
3680
- return _catch(function () {
3681
- var formData = new FormData();
3682
- formData.append("upload", file);
3683
- return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
3684
- var _res$data;
3685
- setSelectedFile({
3686
- content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3687
- });
3688
- });
3689
- }, function (error) {
3690
- var _error$response2;
3691
- setMessages(function (state) {
3692
- return [].concat(state.filter(function (i) {
3693
- return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3694
- }));
3791
+ return file ? Promise.resolve(_finally(function () {
3792
+ return _catch(function () {
3793
+ var formData = new FormData();
3794
+ formData.append("upload", file);
3795
+ return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
3796
+ var _res$data;
3797
+ setSelectedFile({
3798
+ content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3695
3799
  });
3696
- toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3697
3800
  });
3698
- }, function () {}));
3699
- } catch (e) {
3700
- return Promise.reject(e);
3701
- }
3801
+ }, function (error) {
3802
+ var _error$response2;
3803
+ setMessages(function (state) {
3804
+ return [].concat(state.filter(function (i) {
3805
+ return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3806
+ }));
3807
+ });
3808
+ toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3809
+ });
3810
+ }, function () {})) : Promise.resolve();
3702
3811
  };
3703
3812
  var handleChangeInput = function handleChangeInput(text) {
3704
3813
  setMessage({
@@ -3712,6 +3821,14 @@ var useChatContainer = function useChatContainer(props) {
3712
3821
  return [].concat(state, [data]);
3713
3822
  });
3714
3823
  };
3824
+ var handleNewConversation = function handleNewConversation(data) {
3825
+ if (!data) return;
3826
+ var item = JSON.parse(data);
3827
+ setScrollToEnd(true);
3828
+ setMessages(function (state) {
3829
+ return [].concat(state, [item]);
3830
+ });
3831
+ };
3715
3832
  var handleCompletedConversation = function handleCompletedConversation(data) {
3716
3833
  if (!data) return;
3717
3834
  setSelectedConversation(JSON.parse(data));
@@ -3728,8 +3845,10 @@ var useChatContainer = function useChatContainer(props) {
3728
3845
  setSelectedFile(null);
3729
3846
  };
3730
3847
  var cleanupPusher = function cleanupPusher() {
3731
- var _pusher$current;
3848
+ var _pusher$current, _pusher$current2, _pusher$current3;
3732
3849
  (_pusher$current = pusher.current) === null || _pusher$current === void 0 ? void 0 : _pusher$current.unbind("new-message-event", handleNewMessageSent);
3850
+ (_pusher$current2 = pusher.current) === null || _pusher$current2 === void 0 ? void 0 : _pusher$current2.unbind("completed-conversation-event", handleCompletedConversation);
3851
+ (_pusher$current3 = pusher.current) === null || _pusher$current3 === void 0 ? void 0 : _pusher$current3.unbind("new-conversation-event", handleNewConversation);
3733
3852
  channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
3734
3853
  };
3735
3854
  useEffect(function () {
@@ -3746,10 +3865,11 @@ var useChatContainer = function useChatContainer(props) {
3746
3865
  }, _headers[AcademyHeaders] = academyDomain, _headers)
3747
3866
  }
3748
3867
  });
3749
- channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id);
3868
+ channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id) + "-" + academyDomain.trim().toUpperCase();
3750
3869
  channel.current = pusher.current.subscribe(channelName.current);
3751
3870
  pusher.current.bind("new-message-event", handleNewMessageSent);
3752
3871
  pusher.current.bind("completed-conversation-event", handleCompletedConversation);
3872
+ pusher.current.bind("new-conversation-event", handleNewConversation);
3753
3873
  }
3754
3874
  return cleanupPusher;
3755
3875
  }, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, academyDomain]);
@@ -3867,7 +3987,7 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
3867
3987
  }, _headers[AcademyHeaders] = academyDomain, _headers)
3868
3988
  }
3869
3989
  });
3870
- channelName.current = "presence-conversation-channel-userId-" + userId;
3990
+ channelName.current = "presence-conversation-channel-userId-" + userId + "-" + academyDomain.trim().toUpperCase();
3871
3991
  channel.current = pusher.current.subscribe(channelName.current);
3872
3992
  channel.current.bind("message-conversation-event", handleNewMessageConversationCreated);
3873
3993
  channel.current.bind("message-conversation-read-event", handleReadMessageConversation);
@@ -4134,12 +4254,16 @@ var ScoreSelector = function ScoreSelector(_ref) {
4134
4254
  isDisabled = _ref.isDisabled;
4135
4255
  var _useTranslation = useTranslation(),
4136
4256
  t = _useTranslation.t;
4137
- var scoreOptions = SCORE_OPTIONS.map(function (i) {
4138
- return {
4139
- label: "" + t(i + "\uC810") + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
4140
- value: i
4141
- };
4142
- });
4257
+ var scoreOptions = useMemo(function () {
4258
+ return SCORE_OPTIONS.map(function (i) {
4259
+ return {
4260
+ label: "" + t("score_format", {
4261
+ score: i
4262
+ }) + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
4263
+ value: i
4264
+ };
4265
+ });
4266
+ }, [t]);
4143
4267
  return React.createElement(CustomSelect, {
4144
4268
  inputId: id,
4145
4269
  value: value,
@@ -4156,6 +4280,8 @@ var QuestionView = function QuestionView(_ref) {
4156
4280
  isDisabled = _ref.isDisabled,
4157
4281
  onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
4158
4282
  onChangeScoreAnswer = _ref.onChangeScoreAnswer;
4283
+ var _useTranslation = useTranslation(),
4284
+ t = _useTranslation.t;
4159
4285
  var handleChangeCorrectAnswer = function handleChangeCorrectAnswer(e) {
4160
4286
  return onChangeCorrectAnswers(e.target.value, index);
4161
4287
  };
@@ -4165,7 +4291,9 @@ var QuestionView = function QuestionView(_ref) {
4165
4291
  className: "d-flex flex-grow-1"
4166
4292
  }, React.createElement("div", {
4167
4293
  className: styles$1["question-title"] + " me-2 text-nowrap"
4168
- }, "\uBB38\uC81C ", question.questionOrder + 1, "\uBC88"), React.createElement(FormControl, {
4294
+ }, t("problem_number_question", {
4295
+ number: question.questionOrder + 1
4296
+ })), React.createElement(FormControl, {
4169
4297
  className: "flex-grow-1 w-100"
4170
4298
  }, React.createElement(RadioGroup, {
4171
4299
  value: question.correctAnswers[0],
@@ -4186,7 +4314,9 @@ var QuestionView = function QuestionView(_ref) {
4186
4314
  control: React.createElement(Radio, {
4187
4315
  size: "small"
4188
4316
  }),
4189
- label: i + "\uBC88"
4317
+ label: t("number_question", {
4318
+ number: i
4319
+ })
4190
4320
  });
4191
4321
  })))), React.createElement("div", {
4192
4322
  className: "d-flex align-items-center"
@@ -4568,6 +4698,26 @@ var useExamDetailView = function useExamDetailView(props) {
4568
4698
  }))
4569
4699
  }));
4570
4700
  };
4701
+ var handleDeleteArticle = function handleDeleteArticle(article) {
4702
+ if (!exam) return;
4703
+ var removedQuestions = exam.questions.filter(function (i) {
4704
+ return i.article === +article;
4705
+ }).map(function (i) {
4706
+ return i.questionOrder;
4707
+ });
4708
+ var max = Math.max.apply(Math, removedQuestions);
4709
+ var examQuestions = exam.questions.filter(function (i) {
4710
+ return i.article !== +article;
4711
+ }).map(function (i) {
4712
+ return _extends({}, i, {
4713
+ article: i.article > article ? i.article - 1 : i.article,
4714
+ questionOrder: i.questionOrder > max ? i.questionOrder - removedQuestions.length : i.questionOrder
4715
+ });
4716
+ });
4717
+ onChangeExam(_extends({}, exam, {
4718
+ questions: [].concat(examQuestions)
4719
+ }));
4720
+ };
4571
4721
  var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
4572
4722
  if (!exam) return;
4573
4723
  if (newAnswerCount === answerCount) return;
@@ -4695,10 +4845,10 @@ var useExamDetailView = function useExamDetailView(props) {
4695
4845
  return options;
4696
4846
  }, [exam.duration]);
4697
4847
  useEffect(function () {
4698
- onChangeExam(_extends({}, exam, {
4848
+ if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
4699
4849
  subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
4700
4850
  }));
4701
- }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id]);
4851
+ }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
4702
4852
  return {
4703
4853
  t: t,
4704
4854
  durationOptions: durationOptions,
@@ -4710,7 +4860,8 @@ var useExamDetailView = function useExamDetailView(props) {
4710
4860
  handleChangeCorrectAnswers: handleChangeCorrectAnswers,
4711
4861
  handleChangeAnswerCount: handleChangeAnswerCount,
4712
4862
  handleChangeQuestionCount: handleChangeQuestionCount,
4713
- handleChangeCategory: handleChangeCategory
4863
+ handleChangeCategory: handleChangeCategory,
4864
+ handleDeleteArticle: handleDeleteArticle
4714
4865
  };
4715
4866
  };
4716
4867
 
@@ -4740,7 +4891,8 @@ var ExamDetailView = function ExamDetailView(_ref) {
4740
4891
  handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
4741
4892
  handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
4742
4893
  handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
4743
- handleChangeCategory = _useExamDetailView.handleChangeCategory;
4894
+ handleChangeCategory = _useExamDetailView.handleChangeCategory,
4895
+ handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
4744
4896
  return React.createElement(Grid, {
4745
4897
  container: true,
4746
4898
  spacing: 3,
@@ -4779,7 +4931,7 @@ var ExamDetailView = function ExamDetailView(_ref) {
4779
4931
  }, React.createElement("label", {
4780
4932
  className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
4781
4933
  htmlFor: "duration"
4782
- }, " ", t("subject")), React.createElement(CustomSelect, {
4934
+ }, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React.createElement(CustomSelect, {
4783
4935
  inputId: "subject",
4784
4936
  value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
4785
4937
  options: subjectOptions,
@@ -4798,8 +4950,10 @@ var ExamDetailView = function ExamDetailView(_ref) {
4798
4950
  onChangeAnswerCount: handleChangeAnswerCount,
4799
4951
  onChangeCorrectAnswers: handleChangeCorrectAnswers,
4800
4952
  onChangeScoreAnswer: handleChangeScoreAnswer,
4953
+ onDelete: handleDeleteArticle,
4801
4954
  isDisabled: isDisabled,
4802
- selectedSubject: selectedSubject
4955
+ selectedSubject: selectedSubject,
4956
+ isDeletable: examGroupByArticle.length > 1
4803
4957
  })));
4804
4958
  }), React.createElement(Grid, {
4805
4959
  item: true,