touchstudy-core 0.1.21 → 0.1.23

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
@@ -1042,6 +1043,7 @@ var CommonDialog = function CommonDialog(_ref) {
1042
1043
  _ref$isShowHeader = _ref.isShowHeader,
1043
1044
  isShowHeader = _ref$isShowHeader === void 0 ? true : _ref$isShowHeader,
1044
1045
  titleClassName = _ref.titleClassName,
1046
+ minWidth = _ref.minWidth,
1045
1047
  onClose = _ref.onClose;
1046
1048
  return React.createElement(Dialog, {
1047
1049
  open: open,
@@ -1054,7 +1056,8 @@ var CommonDialog = function CommonDialog(_ref) {
1054
1056
  },
1055
1057
  PaperProps: {
1056
1058
  sx: {
1057
- overflowY: "unset"
1059
+ overflowY: "unset",
1060
+ minWidth: minWidth
1058
1061
  }
1059
1062
  }
1060
1063
  }, isShowHeader ? React.createElement(Fragment$1, null, React.createElement(DialogTitle, {
@@ -1456,6 +1459,17 @@ var parent_phone_number = "학부모 전화번호";
1456
1459
  var update_textbook_title = "교과서 제목 업데이트";
1457
1460
  var invalid_weekly_day_time = "주간 요일 시간이 잘못되었습니다";
1458
1461
  var no_image = "이미지 없음";
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 = "이번주는 수업이 없습니다";
1459
1473
  var lang_ko = {
1460
1474
  problem_solving: problem_solving,
1461
1475
  my_story: my_story,
@@ -1698,7 +1712,18 @@ var lang_ko = {
1698
1712
  parent_phone_number: parent_phone_number,
1699
1713
  update_textbook_title: update_textbook_title,
1700
1714
  invalid_weekly_day_time: invalid_weekly_day_time,
1701
- no_image: no_image
1715
+ no_image: no_image,
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
1702
1727
  };
1703
1728
 
1704
1729
  var problem_solving$1 = "Problem Solving";
@@ -1968,7 +1993,7 @@ var add_new_chapter_to_textbook$1 = "Add new chapter to the textbook";
1968
1993
  var add_new_subchapter_to_parent_chapter$1 = "Add new subchapter to the parent chapter ({{ chapterName }})";
1969
1994
  var add$1 = "Add";
1970
1995
  var add_new_article_to_chapter$1 = "Add new article to the chapter ({{ chapterName }})";
1971
- var score_format$1 = "{{score}}points";
1996
+ var score_format$1 = "{{score}}pts";
1972
1997
  var round$1 = "{{number}} round";
1973
1998
  var number_grade$1 = "Grade {{number}}";
1974
1999
  var print$1 = "Print";
@@ -1979,6 +2004,17 @@ var parent_phone_number$1 = "Parent Phone Number";
1979
2004
  var update_textbook_title$1 = "Update textbook title";
1980
2005
  var invalid_weekly_day_time$1 = "Invalid weekly day time";
1981
2006
  var no_image$1 = "No image";
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";
1982
2018
  var lang_en = {
1983
2019
  problem_solving: problem_solving$1,
1984
2020
  my_story: my_story$1,
@@ -2255,7 +2291,18 @@ var lang_en = {
2255
2291
  parent_phone_number: parent_phone_number$1,
2256
2292
  update_textbook_title: update_textbook_title$1,
2257
2293
  invalid_weekly_day_time: invalid_weekly_day_time$1,
2258
- no_image: no_image$1
2294
+ no_image: no_image$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
2259
2306
  };
2260
2307
 
2261
2308
  i18n.use(initReactI18next).init({
@@ -2440,6 +2487,8 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
2440
2487
  var _state$common2;
2441
2488
  return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
2442
2489
  });
2490
+ var _useTranslation = useTranslation(),
2491
+ t = _useTranslation.t;
2443
2492
  var getAcademies = function getAcademies(isLoading) {
2444
2493
  if (isLoading === void 0) {
2445
2494
  isLoading = true;
@@ -2500,7 +2549,7 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
2500
2549
  });
2501
2550
  }, function (error) {
2502
2551
  var _error$response2, _error$response2$data;
2503
- 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"));
2504
2553
  });
2505
2554
  return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
2506
2555
  } catch (e) {
@@ -2544,6 +2593,8 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2544
2593
  });
2545
2594
  var isAdmin = role === Role.Admin;
2546
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;
2547
2598
  var _useState = useState(null),
2548
2599
  open = _useState[0],
2549
2600
  setOpen = _useState[1];
@@ -2580,7 +2631,7 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2580
2631
  color: "#5458D5",
2581
2632
  minWidth: 150
2582
2633
  }
2583
- }, (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", {
2584
2635
  className: "" + stylesGlobal["switch-icon"]
2585
2636
  }, React.createElement(GoArrowSwitch, {
2586
2637
  size: 14
@@ -2763,7 +2814,8 @@ var ChatRightItem = function ChatRightItem(_ref) {
2763
2814
  showTimestamp = _ref.showTimestamp,
2764
2815
  isStudent = _ref.isStudent,
2765
2816
  showName = _ref.showName,
2766
- contentType = _ref.contentType;
2817
+ contentType = _ref.contentType,
2818
+ toggleImageDialog = _ref.toggleImageDialog;
2767
2819
  var _useTranslation = useTranslation(),
2768
2820
  t = _useTranslation.t;
2769
2821
  return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
@@ -2791,6 +2843,7 @@ var ChatRightItem = function ChatRightItem(_ref) {
2791
2843
  lineHeight: "16.71px",
2792
2844
  color: "#5458D5"
2793
2845
  }, sender === null || sender === void 0 ? void 0 : sender.fullName)), contentType ? React.createElement("img", {
2846
+ onClick: toggleImageDialog,
2794
2847
  src: content,
2795
2848
  style: {
2796
2849
  backgroundRepeat: "no-repeat",
@@ -2820,7 +2873,8 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2820
2873
  showTimestamp = _ref.showTimestamp,
2821
2874
  isStudent = _ref.isStudent,
2822
2875
  showName = _ref.showName,
2823
- contentType = _ref.contentType;
2876
+ contentType = _ref.contentType,
2877
+ toggleImageDialog = _ref.toggleImageDialog;
2824
2878
  var _useTranslation = useTranslation(),
2825
2879
  t = _useTranslation.t;
2826
2880
  return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
@@ -2862,6 +2916,7 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2862
2916
  }, t("student")))), React.createElement(Box, {
2863
2917
  padding: "4px 0px"
2864
2918
  }), contentType ? React.createElement("img", {
2919
+ onClick: toggleImageDialog,
2865
2920
  src: content,
2866
2921
  style: {
2867
2922
  backgroundRepeat: "no-repeat",
@@ -2881,6 +2936,115 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
2881
2936
  }, content))));
2882
2937
  };
2883
2938
 
2939
+ var ImageDetailDialog = function ImageDetailDialog(_ref) {
2940
+ var open = _ref.open,
2941
+ toggleDialog = _ref.toggleDialog,
2942
+ content = _ref.content,
2943
+ downloadFile = _ref.downloadFile;
2944
+ var _useTranslation = useTranslation(),
2945
+ t = _useTranslation.t;
2946
+ return React.createElement(CommonDialog, {
2947
+ open: open,
2948
+ onClose: toggleDialog,
2949
+ size: "sm",
2950
+ title: t("image")
2951
+ }, React.createElement(DialogContent, {
2952
+ sx: {
2953
+ overflowY: "unset"
2954
+ }
2955
+ }, React.createElement(Stack, null, React.createElement(Stack, {
2956
+ display: "flex",
2957
+ justifyContent: "center",
2958
+ alignItems: "center"
2959
+ }, React.createElement("img", {
2960
+ src: content,
2961
+ style: {
2962
+ width: "500px",
2963
+ height: "500px",
2964
+ position: "relative",
2965
+ objectFit: "cover"
2966
+ }
2967
+ })), React.createElement(Button, {
2968
+ sx: {
2969
+ margin: "10px 0"
2970
+ },
2971
+ variant: "outlined",
2972
+ fullWidth: true,
2973
+ onClick: function onClick() {
2974
+ return downloadFile(content);
2975
+ }
2976
+ }, t("download")))));
2977
+ };
2978
+
2979
+ var CONVERSATION_URL = BASE_URL + "/api/conversation";
2980
+ var apiAddMessage = function apiAddMessage(conversationId, message) {
2981
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
2982
+ };
2983
+ var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
2984
+ return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
2985
+ params: filter
2986
+ });
2987
+ };
2988
+ var updateLastTimeReadConversation = function updateLastTimeReadConversation(conversationId) {
2989
+ return api.put(CONVERSATION_URL + "/" + conversationId);
2990
+ };
2991
+ var completeConversation = function completeConversation(conversationId) {
2992
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
2993
+ };
2994
+ var apiUploadImageFile = function apiUploadImageFile(file) {
2995
+ return apiUpload.post(BASE_URL + "/api/file/images", file);
2996
+ };
2997
+
2998
+ var FileSaver_min = createCommonjsModule(function (module, exports) {
2999
+ (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);});
3000
+
3001
+ //# sourceMappingURL=FileSaver.min.js.map
3002
+ });
3003
+
3004
+ var useDialog = function useDialog() {
3005
+ var _useState = useState(false),
3006
+ openConfirmDialog = _useState[0],
3007
+ setOpenConfirmDialog = _useState[1];
3008
+ var toggleConfirmDialog = function toggleConfirmDialog() {
3009
+ setOpenConfirmDialog(function (state) {
3010
+ return !state;
3011
+ });
3012
+ };
3013
+ var handleConfirm = function handleConfirm(conversationId) {
3014
+ try {
3015
+ var _temp2 = function _temp2() {
3016
+ setLoading(false);
3017
+ };
3018
+ setLoading(true);
3019
+ var _temp = _catch(function () {
3020
+ return Promise.resolve(completeConversation(conversationId)).then(function () {
3021
+ toggleConfirmDialog();
3022
+ toast.success("Complete conversation success");
3023
+ });
3024
+ }, function () {
3025
+ toast.error("Failed to complete conversation");
3026
+ });
3027
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3028
+ } catch (e) {
3029
+ return Promise.reject(e);
3030
+ }
3031
+ };
3032
+ var downloadFile = function downloadFile(content) {
3033
+ try {
3034
+ FileSaver_min.saveAs(content, "image.png");
3035
+ return Promise.resolve();
3036
+ } catch (e) {
3037
+ return Promise.reject(e);
3038
+ }
3039
+ };
3040
+ return {
3041
+ openConfirmDialog: openConfirmDialog,
3042
+ toggleConfirmDialog: toggleConfirmDialog,
3043
+ handleConfirm: handleConfirm,
3044
+ downloadFile: downloadFile
3045
+ };
3046
+ };
3047
+
2884
3048
  var ChatItemType;
2885
3049
  (function (ChatItemType) {
2886
3050
  ChatItemType[ChatItemType["Default"] = 0] = "Default";
@@ -2889,7 +3053,20 @@ var ChatItemType;
2889
3053
  })(ChatItemType || (ChatItemType = {}));
2890
3054
  var ChatItem = function ChatItem(props) {
2891
3055
  var isMe = props.isMe;
2892
- return React.createElement(Fragment$1, null, isMe ? React.createElement(ChatRightItem, Object.assign({}, props)) : React.createElement(ChatLeftItem, Object.assign({}, props)));
3056
+ var _useDialog = useDialog(),
3057
+ openConfirmDialog = _useDialog.openConfirmDialog,
3058
+ toggleConfirmDialog = _useDialog.toggleConfirmDialog,
3059
+ downloadFile = _useDialog.downloadFile;
3060
+ return React.createElement(Fragment$1, null, isMe ? React.createElement(ChatRightItem, Object.assign({}, props, {
3061
+ toggleImageDialog: toggleConfirmDialog
3062
+ })) : React.createElement(ChatLeftItem, Object.assign({}, props, {
3063
+ toggleImageDialog: toggleConfirmDialog
3064
+ })), React.createElement(ImageDetailDialog, {
3065
+ open: openConfirmDialog,
3066
+ toggleDialog: toggleConfirmDialog,
3067
+ content: props.content || "",
3068
+ downloadFile: downloadFile
3069
+ }));
2893
3070
  };
2894
3071
 
2895
3072
  var MessageSortBy;
@@ -3155,57 +3332,6 @@ var iconChecked = function iconChecked(_ref) {
3155
3332
  }));
3156
3333
  };
3157
3334
 
3158
- var CONVERSATION_URL = BASE_URL + "/api/conversation";
3159
- var apiAddMessage = function apiAddMessage(conversationId, message) {
3160
- return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
3161
- };
3162
- var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
3163
- return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
3164
- params: filter
3165
- });
3166
- };
3167
- var completeConversation = function completeConversation(conversationId) {
3168
- return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
3169
- };
3170
- var apiUploadImageFile = function apiUploadImageFile(file) {
3171
- return apiUpload.post(BASE_URL + "/api/file/images", file);
3172
- };
3173
-
3174
- var useDialog = function useDialog() {
3175
- var _useState = useState(false),
3176
- openConfirmDialog = _useState[0],
3177
- setOpenConfirmDialog = _useState[1];
3178
- var toggleConfirmDialog = function toggleConfirmDialog() {
3179
- setOpenConfirmDialog(function (state) {
3180
- return !state;
3181
- });
3182
- };
3183
- var handleConfirm = function handleConfirm(conversationId) {
3184
- try {
3185
- var _temp2 = function _temp2() {
3186
- setLoading(false);
3187
- };
3188
- setLoading(true);
3189
- var _temp = _catch(function () {
3190
- return Promise.resolve(completeConversation(conversationId)).then(function () {
3191
- toggleConfirmDialog();
3192
- toast.success("Complete conversation success");
3193
- });
3194
- }, function () {
3195
- toast.error("Failed to complete conversation");
3196
- });
3197
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3198
- } catch (e) {
3199
- return Promise.reject(e);
3200
- }
3201
- };
3202
- return {
3203
- openConfirmDialog: openConfirmDialog,
3204
- toggleConfirmDialog: toggleConfirmDialog,
3205
- handleConfirm: handleConfirm
3206
- };
3207
- };
3208
-
3209
3335
  var ChatHeader = function ChatHeader(_ref) {
3210
3336
  var fullName = _ref.fullName,
3211
3337
  examTitle = _ref.examTitle,
@@ -3420,6 +3546,10 @@ var ChatContainer = function ChatContainer(_ref) {
3420
3546
  if (scrollTop <= scrollOffset) {
3421
3547
  return Promise.resolve(onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop()).then(function (isSuccessLoad) {
3422
3548
  if (isSuccessLoad) {
3549
+ var _listItemRef$current, _listItemRef$current$;
3550
+ (_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({
3551
+ behavior: "smooth"
3552
+ });
3423
3553
  listRef.current.scrollTop = listRef.current.scrollHeight - scrollHeight;
3424
3554
  }
3425
3555
  });
@@ -3437,24 +3567,20 @@ var ChatContainer = function ChatContainer(_ref) {
3437
3567
  }
3438
3568
  };
3439
3569
  useEffect(function () {
3440
- var _listRef$current, _chatListProps$messag, _listRef$current3;
3570
+ var _listRef$current, _chatListProps$messag, _listRef$current2;
3441
3571
  scrollRef.current && clearTimeout(scrollRef.current);
3442
3572
  addEventTimeout.current && clearTimeout(addEventTimeout.current);
3443
3573
  (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener("scroll", handleScroll);
3444
3574
  if (isScrollToEnd && !isLoading && (_chatListProps$messag = chatListProps.messages) !== null && _chatListProps$messag !== void 0 && _chatListProps$messag.length) {
3445
- var _listItemRef$current, _listItemRef$current$;
3446
- (_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({
3575
+ var _listItemRef$current2, _listItemRef$current3;
3576
+ (_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({
3447
3577
  behavior: "smooth"
3448
3578
  });
3449
3579
  onEndScrollToEnd === null || onEndScrollToEnd === void 0 ? void 0 : onEndScrollToEnd();
3450
- addEventTimeout.current = setTimeout(function () {
3451
- var _listRef$current2;
3452
- (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
3453
- }, 800);
3454
- } else (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.addEventListener("scroll", handleScroll);
3580
+ } else (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
3455
3581
  return function () {
3456
- var _listRef$current4;
3457
- (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : _listRef$current4.removeEventListener("scroll", handleScroll);
3582
+ var _listRef$current3;
3583
+ (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.removeEventListener("scroll", handleScroll);
3458
3584
  scrollRef.current && clearTimeout(scrollRef.current);
3459
3585
  addEventTimeout.current && clearTimeout(addEventTimeout.current);
3460
3586
  };
@@ -3504,14 +3630,16 @@ var useMessageList = function useMessageList() {
3504
3630
  var _temp = _catch(function () {
3505
3631
  var filter = _extends({}, messageFilter);
3506
3632
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3507
- setMessages(function (prev) {
3508
- var _res$data$items;
3509
- return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3510
- });
3511
- setMessageFilter(function (prev) {
3512
- return _extends({}, prev, {
3513
- totalItems: res.data.totalItems,
3514
- totalPages: res.data.totalPages
3633
+ return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
3634
+ setMessages(function (prev) {
3635
+ var _res$data$items;
3636
+ return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3637
+ });
3638
+ setMessageFilter(function (prev) {
3639
+ return _extends({}, prev, {
3640
+ totalItems: res.data.totalItems,
3641
+ totalPages: res.data.totalPages
3642
+ });
3515
3643
  });
3516
3644
  });
3517
3645
  });
@@ -3531,28 +3659,30 @@ var useMessageList = function useMessageList() {
3531
3659
  return true;
3532
3660
  };
3533
3661
  var _exit = false;
3534
- if (isLoading) return Promise.resolve();
3662
+ if (isLoading || messageFilter.currentPage === messageFilter.totalPages) return Promise.resolve();
3535
3663
  var filter = _extends({}, messageFilter, {
3536
3664
  currentPage: ((messageFilter === null || messageFilter === void 0 ? void 0 : messageFilter.currentPage) || 1) + 1
3537
3665
  });
3538
- setMessageFilter(filter);
3539
3666
  setLoading(true);
3540
3667
  var _temp3 = _catch(function () {
3541
3668
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3542
- setMessages(function (prev) {
3543
- var _res$data$items2;
3544
- var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3545
- var dataFilter = new Set(data);
3546
- return Array.from(dataFilter);
3547
- });
3548
- if (res.data.items) {
3549
- setMessageFilter(function (prev) {
3550
- return _extends({}, prev, {
3551
- totalItems: res.data.totalItems,
3552
- totalPages: res.data.totalPages
3669
+ return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
3670
+ if (res.data.items.length) {
3671
+ setMessages(function (prev) {
3672
+ var _res$data$items2;
3673
+ var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3674
+ var dataFilter = new Set(data);
3675
+ return Array.from(dataFilter);
3553
3676
  });
3554
- });
3555
- }
3677
+ setMessageFilter(function (prev) {
3678
+ return _extends({}, prev, {
3679
+ totalItems: res.data.totalItems,
3680
+ totalPages: res.data.totalPages,
3681
+ currentPage: res.data.page
3682
+ });
3683
+ });
3684
+ }
3685
+ });
3556
3686
  });
3557
3687
  }, function () {
3558
3688
  toast.error("Fail to fetch data!");
@@ -3665,34 +3795,26 @@ var useChatContainer = function useChatContainer(props) {
3665
3795
  }
3666
3796
  };
3667
3797
  var handleUploadImage = function handleUploadImage(file) {
3668
- try {
3669
- console.log({
3670
- file: file
3671
- });
3672
- if (!file) return Promise.resolve();
3673
- return Promise.resolve(_finally(function () {
3674
- return _catch(function () {
3675
- var formData = new FormData();
3676
- formData.append("upload", file);
3677
- return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
3678
- var _res$data;
3679
- setSelectedFile({
3680
- content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3681
- });
3682
- });
3683
- }, function (error) {
3684
- var _error$response2;
3685
- setMessages(function (state) {
3686
- return [].concat(state.filter(function (i) {
3687
- return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3688
- }));
3798
+ return file ? Promise.resolve(_finally(function () {
3799
+ return _catch(function () {
3800
+ var formData = new FormData();
3801
+ formData.append("upload", file);
3802
+ return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
3803
+ var _res$data;
3804
+ setSelectedFile({
3805
+ content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3689
3806
  });
3690
- toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3691
3807
  });
3692
- }, function () {}));
3693
- } catch (e) {
3694
- return Promise.reject(e);
3695
- }
3808
+ }, function (error) {
3809
+ var _error$response2;
3810
+ setMessages(function (state) {
3811
+ return [].concat(state.filter(function (i) {
3812
+ return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3813
+ }));
3814
+ });
3815
+ toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3816
+ });
3817
+ }, function () {})) : Promise.resolve();
3696
3818
  };
3697
3819
  var handleChangeInput = function handleChangeInput(text) {
3698
3820
  setMessage({
@@ -3706,6 +3828,14 @@ var useChatContainer = function useChatContainer(props) {
3706
3828
  return [].concat(state, [data]);
3707
3829
  });
3708
3830
  };
3831
+ var handleNewConversation = function handleNewConversation(data) {
3832
+ if (!data) return;
3833
+ var item = JSON.parse(data);
3834
+ setScrollToEnd(true);
3835
+ setMessages(function (state) {
3836
+ return [].concat(state, [item]);
3837
+ });
3838
+ };
3709
3839
  var handleCompletedConversation = function handleCompletedConversation(data) {
3710
3840
  if (!data) return;
3711
3841
  setSelectedConversation(JSON.parse(data));
@@ -3722,8 +3852,10 @@ var useChatContainer = function useChatContainer(props) {
3722
3852
  setSelectedFile(null);
3723
3853
  };
3724
3854
  var cleanupPusher = function cleanupPusher() {
3725
- var _pusher$current;
3855
+ var _pusher$current, _pusher$current2, _pusher$current3;
3726
3856
  (_pusher$current = pusher.current) === null || _pusher$current === void 0 ? void 0 : _pusher$current.unbind("new-message-event", handleNewMessageSent);
3857
+ (_pusher$current2 = pusher.current) === null || _pusher$current2 === void 0 ? void 0 : _pusher$current2.unbind("completed-conversation-event", handleCompletedConversation);
3858
+ (_pusher$current3 = pusher.current) === null || _pusher$current3 === void 0 ? void 0 : _pusher$current3.unbind("new-conversation-event", handleNewConversation);
3727
3859
  channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
3728
3860
  };
3729
3861
  useEffect(function () {
@@ -3740,10 +3872,11 @@ var useChatContainer = function useChatContainer(props) {
3740
3872
  }, _headers[AcademyHeaders] = academyDomain, _headers)
3741
3873
  }
3742
3874
  });
3743
- channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id);
3875
+ channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id) + "-" + academyDomain.trim().toUpperCase();
3744
3876
  channel.current = pusher.current.subscribe(channelName.current);
3745
3877
  pusher.current.bind("new-message-event", handleNewMessageSent);
3746
3878
  pusher.current.bind("completed-conversation-event", handleCompletedConversation);
3879
+ pusher.current.bind("new-conversation-event", handleNewConversation);
3747
3880
  }
3748
3881
  return cleanupPusher;
3749
3882
  }, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, academyDomain]);
@@ -3861,7 +3994,7 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
3861
3994
  }, _headers[AcademyHeaders] = academyDomain, _headers)
3862
3995
  }
3863
3996
  });
3864
- channelName.current = "presence-conversation-channel-userId-" + userId;
3997
+ channelName.current = "presence-conversation-channel-userId-" + userId + "-" + academyDomain.trim().toUpperCase();
3865
3998
  channel.current = pusher.current.subscribe(channelName.current);
3866
3999
  channel.current.bind("message-conversation-event", handleNewMessageConversationCreated);
3867
4000
  channel.current.bind("message-conversation-read-event", handleReadMessageConversation);
@@ -4128,12 +4261,16 @@ var ScoreSelector = function ScoreSelector(_ref) {
4128
4261
  isDisabled = _ref.isDisabled;
4129
4262
  var _useTranslation = useTranslation(),
4130
4263
  t = _useTranslation.t;
4131
- var scoreOptions = SCORE_OPTIONS.map(function (i) {
4132
- return {
4133
- label: "" + t(i + "\uC810") + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
4134
- value: i
4135
- };
4136
- });
4264
+ var scoreOptions = useMemo(function () {
4265
+ return SCORE_OPTIONS.map(function (i) {
4266
+ return {
4267
+ label: "" + t("score_format", {
4268
+ score: i
4269
+ }) + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
4270
+ value: i
4271
+ };
4272
+ });
4273
+ }, [t]);
4137
4274
  return React.createElement(CustomSelect, {
4138
4275
  inputId: id,
4139
4276
  value: value,
@@ -4150,6 +4287,8 @@ var QuestionView = function QuestionView(_ref) {
4150
4287
  isDisabled = _ref.isDisabled,
4151
4288
  onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
4152
4289
  onChangeScoreAnswer = _ref.onChangeScoreAnswer;
4290
+ var _useTranslation = useTranslation(),
4291
+ t = _useTranslation.t;
4153
4292
  var handleChangeCorrectAnswer = function handleChangeCorrectAnswer(e) {
4154
4293
  return onChangeCorrectAnswers(e.target.value, index);
4155
4294
  };
@@ -4159,7 +4298,9 @@ var QuestionView = function QuestionView(_ref) {
4159
4298
  className: "d-flex flex-grow-1"
4160
4299
  }, React.createElement("div", {
4161
4300
  className: styles$1["question-title"] + " me-2 text-nowrap"
4162
- }, "\uBB38\uC81C ", question.questionOrder + 1, "\uBC88"), React.createElement(FormControl, {
4301
+ }, t("problem_number_question", {
4302
+ number: question.questionOrder + 1
4303
+ })), React.createElement(FormControl, {
4163
4304
  className: "flex-grow-1 w-100"
4164
4305
  }, React.createElement(RadioGroup, {
4165
4306
  value: question.correctAnswers[0],
@@ -4180,7 +4321,9 @@ var QuestionView = function QuestionView(_ref) {
4180
4321
  control: React.createElement(Radio, {
4181
4322
  size: "small"
4182
4323
  }),
4183
- label: i + "\uBC88"
4324
+ label: t("number_question", {
4325
+ number: i
4326
+ })
4184
4327
  });
4185
4328
  })))), React.createElement("div", {
4186
4329
  className: "d-flex align-items-center"
@@ -4562,6 +4705,26 @@ var useExamDetailView = function useExamDetailView(props) {
4562
4705
  }))
4563
4706
  }));
4564
4707
  };
4708
+ var handleDeleteArticle = function handleDeleteArticle(article) {
4709
+ if (!exam) return;
4710
+ var removedQuestions = exam.questions.filter(function (i) {
4711
+ return i.article === +article;
4712
+ }).map(function (i) {
4713
+ return i.questionOrder;
4714
+ });
4715
+ var max = Math.max.apply(Math, removedQuestions);
4716
+ var examQuestions = exam.questions.filter(function (i) {
4717
+ return i.article !== +article;
4718
+ }).map(function (i) {
4719
+ return _extends({}, i, {
4720
+ article: i.article > article ? i.article - 1 : i.article,
4721
+ questionOrder: i.questionOrder > max ? i.questionOrder - removedQuestions.length : i.questionOrder
4722
+ });
4723
+ });
4724
+ onChangeExam(_extends({}, exam, {
4725
+ questions: [].concat(examQuestions)
4726
+ }));
4727
+ };
4565
4728
  var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
4566
4729
  if (!exam) return;
4567
4730
  if (newAnswerCount === answerCount) return;
@@ -4689,10 +4852,10 @@ var useExamDetailView = function useExamDetailView(props) {
4689
4852
  return options;
4690
4853
  }, [exam.duration]);
4691
4854
  useEffect(function () {
4692
- onChangeExam(_extends({}, exam, {
4855
+ if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
4693
4856
  subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
4694
4857
  }));
4695
- }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id]);
4858
+ }, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
4696
4859
  return {
4697
4860
  t: t,
4698
4861
  durationOptions: durationOptions,
@@ -4704,7 +4867,8 @@ var useExamDetailView = function useExamDetailView(props) {
4704
4867
  handleChangeCorrectAnswers: handleChangeCorrectAnswers,
4705
4868
  handleChangeAnswerCount: handleChangeAnswerCount,
4706
4869
  handleChangeQuestionCount: handleChangeQuestionCount,
4707
- handleChangeCategory: handleChangeCategory
4870
+ handleChangeCategory: handleChangeCategory,
4871
+ handleDeleteArticle: handleDeleteArticle
4708
4872
  };
4709
4873
  };
4710
4874
 
@@ -4734,7 +4898,8 @@ var ExamDetailView = function ExamDetailView(_ref) {
4734
4898
  handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
4735
4899
  handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
4736
4900
  handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
4737
- handleChangeCategory = _useExamDetailView.handleChangeCategory;
4901
+ handleChangeCategory = _useExamDetailView.handleChangeCategory,
4902
+ handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
4738
4903
  return React.createElement(Grid, {
4739
4904
  container: true,
4740
4905
  spacing: 3,
@@ -4773,7 +4938,7 @@ var ExamDetailView = function ExamDetailView(_ref) {
4773
4938
  }, React.createElement("label", {
4774
4939
  className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
4775
4940
  htmlFor: "duration"
4776
- }, " ", t("subject")), React.createElement(CustomSelect, {
4941
+ }, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React.createElement(CustomSelect, {
4777
4942
  inputId: "subject",
4778
4943
  value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
4779
4944
  options: subjectOptions,
@@ -4792,8 +4957,10 @@ var ExamDetailView = function ExamDetailView(_ref) {
4792
4957
  onChangeAnswerCount: handleChangeAnswerCount,
4793
4958
  onChangeCorrectAnswers: handleChangeCorrectAnswers,
4794
4959
  onChangeScoreAnswer: handleChangeScoreAnswer,
4960
+ onDelete: handleDeleteArticle,
4795
4961
  isDisabled: isDisabled,
4796
- selectedSubject: selectedSubject
4962
+ selectedSubject: selectedSubject,
4963
+ isDeletable: examGroupByArticle.length > 1
4797
4964
  })));
4798
4965
  }), React.createElement(Grid, {
4799
4966
  item: true,
@@ -7301,7 +7468,12 @@ function CreateNewQuestionDialog(_ref) {
7301
7468
  t = _useTranslation.t;
7302
7469
  return React.createElement(Dialog, {
7303
7470
  onClose: toggleCreateQuestion,
7304
- open: openCreateQuestionDialog
7471
+ open: openCreateQuestionDialog,
7472
+ PaperProps: {
7473
+ sx: {
7474
+ minWidth: "363px"
7475
+ }
7476
+ }
7305
7477
  }, React.createElement(DialogTitle$1, {
7306
7478
  id: "customized-dialog-title"
7307
7479
  }, React.createElement(Typography$1, {
@@ -8009,7 +8181,12 @@ function CreateNewQuestionDialog$1(_ref) {
8009
8181
  examSessionId = _ref.examSessionId;
8010
8182
  return React.createElement(Dialog, {
8011
8183
  onClose: toggleCreateQuestion,
8012
- open: openCreateQuestionDialog
8184
+ open: openCreateQuestionDialog,
8185
+ PaperProps: {
8186
+ sx: {
8187
+ minWidth: "363px"
8188
+ }
8189
+ }
8013
8190
  }, React.createElement(DialogTitle$1, {
8014
8191
  id: "customized-dialog-title"
8015
8192
  }, React.createElement(Typography$1, {