touchstudy-core 0.1.22 → 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.
- package/dist/components/Chats/ChatItem.d.ts +1 -0
- package/dist/components/Chats/apiClient/conversationService.d.ts +2 -0
- package/dist/components/Chats/components/ImageDetailDialog.d.ts +9 -0
- package/dist/components/Chats/hooks/useDialog.d.ts +1 -0
- package/dist/containers/Exams/hooks/useExamDetailView.d.ts +1 -0
- package/dist/containers/Login/configs/constants.d.ts +2 -1
- package/dist/index.js +296 -135
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +297 -136
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -1
package/dist/index.modern.js
CHANGED
@@ -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}}
|
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) || "
|
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) || "
|
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,6 +2843,7 @@ 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
2849
|
backgroundRepeat: "no-repeat",
|
@@ -2826,7 +2873,8 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2826
2873
|
showTimestamp = _ref.showTimestamp,
|
2827
2874
|
isStudent = _ref.isStudent,
|
2828
2875
|
showName = _ref.showName,
|
2829
|
-
contentType = _ref.contentType
|
2876
|
+
contentType = _ref.contentType,
|
2877
|
+
toggleImageDialog = _ref.toggleImageDialog;
|
2830
2878
|
var _useTranslation = useTranslation(),
|
2831
2879
|
t = _useTranslation.t;
|
2832
2880
|
return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
|
@@ -2868,6 +2916,7 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2868
2916
|
}, t("student")))), React.createElement(Box, {
|
2869
2917
|
padding: "4px 0px"
|
2870
2918
|
}), contentType ? React.createElement("img", {
|
2919
|
+
onClick: toggleImageDialog,
|
2871
2920
|
src: content,
|
2872
2921
|
style: {
|
2873
2922
|
backgroundRepeat: "no-repeat",
|
@@ -2887,6 +2936,115 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2887
2936
|
}, content))));
|
2888
2937
|
};
|
2889
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
|
+
|
2890
3048
|
var ChatItemType;
|
2891
3049
|
(function (ChatItemType) {
|
2892
3050
|
ChatItemType[ChatItemType["Default"] = 0] = "Default";
|
@@ -2895,7 +3053,20 @@ var ChatItemType;
|
|
2895
3053
|
})(ChatItemType || (ChatItemType = {}));
|
2896
3054
|
var ChatItem = function ChatItem(props) {
|
2897
3055
|
var isMe = props.isMe;
|
2898
|
-
|
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
|
+
}));
|
2899
3070
|
};
|
2900
3071
|
|
2901
3072
|
var MessageSortBy;
|
@@ -3161,57 +3332,6 @@ var iconChecked = function iconChecked(_ref) {
|
|
3161
3332
|
}));
|
3162
3333
|
};
|
3163
3334
|
|
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
3335
|
var ChatHeader = function ChatHeader(_ref) {
|
3216
3336
|
var fullName = _ref.fullName,
|
3217
3337
|
examTitle = _ref.examTitle,
|
@@ -3426,6 +3546,10 @@ var ChatContainer = function ChatContainer(_ref) {
|
|
3426
3546
|
if (scrollTop <= scrollOffset) {
|
3427
3547
|
return Promise.resolve(onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop()).then(function (isSuccessLoad) {
|
3428
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
|
+
});
|
3429
3553
|
listRef.current.scrollTop = listRef.current.scrollHeight - scrollHeight;
|
3430
3554
|
}
|
3431
3555
|
});
|
@@ -3443,24 +3567,20 @@ var ChatContainer = function ChatContainer(_ref) {
|
|
3443
3567
|
}
|
3444
3568
|
};
|
3445
3569
|
useEffect(function () {
|
3446
|
-
var _listRef$current, _chatListProps$messag, _listRef$
|
3570
|
+
var _listRef$current, _chatListProps$messag, _listRef$current2;
|
3447
3571
|
scrollRef.current && clearTimeout(scrollRef.current);
|
3448
3572
|
addEventTimeout.current && clearTimeout(addEventTimeout.current);
|
3449
3573
|
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener("scroll", handleScroll);
|
3450
3574
|
if (isScrollToEnd && !isLoading && (_chatListProps$messag = chatListProps.messages) !== null && _chatListProps$messag !== void 0 && _chatListProps$messag.length) {
|
3451
|
-
var _listItemRef$
|
3452
|
-
(_listItemRef$
|
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({
|
3453
3577
|
behavior: "smooth"
|
3454
3578
|
});
|
3455
3579
|
onEndScrollToEnd === null || onEndScrollToEnd === void 0 ? void 0 : onEndScrollToEnd();
|
3456
|
-
|
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);
|
3580
|
+
} else (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
|
3461
3581
|
return function () {
|
3462
|
-
var _listRef$
|
3463
|
-
(_listRef$
|
3582
|
+
var _listRef$current3;
|
3583
|
+
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.removeEventListener("scroll", handleScroll);
|
3464
3584
|
scrollRef.current && clearTimeout(scrollRef.current);
|
3465
3585
|
addEventTimeout.current && clearTimeout(addEventTimeout.current);
|
3466
3586
|
};
|
@@ -3510,14 +3630,16 @@ var useMessageList = function useMessageList() {
|
|
3510
3630
|
var _temp = _catch(function () {
|
3511
3631
|
var filter = _extends({}, messageFilter);
|
3512
3632
|
return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
|
3513
|
-
|
3514
|
-
|
3515
|
-
|
3516
|
-
|
3517
|
-
|
3518
|
-
|
3519
|
-
|
3520
|
-
|
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
|
+
});
|
3521
3643
|
});
|
3522
3644
|
});
|
3523
3645
|
});
|
@@ -3537,28 +3659,30 @@ var useMessageList = function useMessageList() {
|
|
3537
3659
|
return true;
|
3538
3660
|
};
|
3539
3661
|
var _exit = false;
|
3540
|
-
if (isLoading) return Promise.resolve();
|
3662
|
+
if (isLoading || messageFilter.currentPage === messageFilter.totalPages) return Promise.resolve();
|
3541
3663
|
var filter = _extends({}, messageFilter, {
|
3542
3664
|
currentPage: ((messageFilter === null || messageFilter === void 0 ? void 0 : messageFilter.currentPage) || 1) + 1
|
3543
3665
|
});
|
3544
|
-
setMessageFilter(filter);
|
3545
3666
|
setLoading(true);
|
3546
3667
|
var _temp3 = _catch(function () {
|
3547
3668
|
return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3555
|
-
setMessageFilter(function (prev) {
|
3556
|
-
return _extends({}, prev, {
|
3557
|
-
totalItems: res.data.totalItems,
|
3558
|
-
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);
|
3559
3676
|
});
|
3560
|
-
|
3561
|
-
|
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
|
+
});
|
3562
3686
|
});
|
3563
3687
|
}, function () {
|
3564
3688
|
toast.error("Fail to fetch data!");
|
@@ -3671,34 +3795,26 @@ var useChatContainer = function useChatContainer(props) {
|
|
3671
3795
|
}
|
3672
3796
|
};
|
3673
3797
|
var handleUploadImage = function handleUploadImage(file) {
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
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
|
-
}));
|
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
|
3695
3806
|
});
|
3696
|
-
toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
|
3697
3807
|
});
|
3698
|
-
}, function () {
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
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();
|
3702
3818
|
};
|
3703
3819
|
var handleChangeInput = function handleChangeInput(text) {
|
3704
3820
|
setMessage({
|
@@ -3712,6 +3828,14 @@ var useChatContainer = function useChatContainer(props) {
|
|
3712
3828
|
return [].concat(state, [data]);
|
3713
3829
|
});
|
3714
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
|
+
};
|
3715
3839
|
var handleCompletedConversation = function handleCompletedConversation(data) {
|
3716
3840
|
if (!data) return;
|
3717
3841
|
setSelectedConversation(JSON.parse(data));
|
@@ -3728,8 +3852,10 @@ var useChatContainer = function useChatContainer(props) {
|
|
3728
3852
|
setSelectedFile(null);
|
3729
3853
|
};
|
3730
3854
|
var cleanupPusher = function cleanupPusher() {
|
3731
|
-
var _pusher$current;
|
3855
|
+
var _pusher$current, _pusher$current2, _pusher$current3;
|
3732
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);
|
3733
3859
|
channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
|
3734
3860
|
};
|
3735
3861
|
useEffect(function () {
|
@@ -3746,10 +3872,11 @@ var useChatContainer = function useChatContainer(props) {
|
|
3746
3872
|
}, _headers[AcademyHeaders] = academyDomain, _headers)
|
3747
3873
|
}
|
3748
3874
|
});
|
3749
|
-
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();
|
3750
3876
|
channel.current = pusher.current.subscribe(channelName.current);
|
3751
3877
|
pusher.current.bind("new-message-event", handleNewMessageSent);
|
3752
3878
|
pusher.current.bind("completed-conversation-event", handleCompletedConversation);
|
3879
|
+
pusher.current.bind("new-conversation-event", handleNewConversation);
|
3753
3880
|
}
|
3754
3881
|
return cleanupPusher;
|
3755
3882
|
}, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, academyDomain]);
|
@@ -3867,7 +3994,7 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
|
|
3867
3994
|
}, _headers[AcademyHeaders] = academyDomain, _headers)
|
3868
3995
|
}
|
3869
3996
|
});
|
3870
|
-
channelName.current = "presence-conversation-channel-userId-" + userId;
|
3997
|
+
channelName.current = "presence-conversation-channel-userId-" + userId + "-" + academyDomain.trim().toUpperCase();
|
3871
3998
|
channel.current = pusher.current.subscribe(channelName.current);
|
3872
3999
|
channel.current.bind("message-conversation-event", handleNewMessageConversationCreated);
|
3873
4000
|
channel.current.bind("message-conversation-read-event", handleReadMessageConversation);
|
@@ -4134,12 +4261,16 @@ var ScoreSelector = function ScoreSelector(_ref) {
|
|
4134
4261
|
isDisabled = _ref.isDisabled;
|
4135
4262
|
var _useTranslation = useTranslation(),
|
4136
4263
|
t = _useTranslation.t;
|
4137
|
-
var scoreOptions =
|
4138
|
-
return {
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
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]);
|
4143
4274
|
return React.createElement(CustomSelect, {
|
4144
4275
|
inputId: id,
|
4145
4276
|
value: value,
|
@@ -4156,6 +4287,8 @@ var QuestionView = function QuestionView(_ref) {
|
|
4156
4287
|
isDisabled = _ref.isDisabled,
|
4157
4288
|
onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
|
4158
4289
|
onChangeScoreAnswer = _ref.onChangeScoreAnswer;
|
4290
|
+
var _useTranslation = useTranslation(),
|
4291
|
+
t = _useTranslation.t;
|
4159
4292
|
var handleChangeCorrectAnswer = function handleChangeCorrectAnswer(e) {
|
4160
4293
|
return onChangeCorrectAnswers(e.target.value, index);
|
4161
4294
|
};
|
@@ -4165,7 +4298,9 @@ var QuestionView = function QuestionView(_ref) {
|
|
4165
4298
|
className: "d-flex flex-grow-1"
|
4166
4299
|
}, React.createElement("div", {
|
4167
4300
|
className: styles$1["question-title"] + " me-2 text-nowrap"
|
4168
|
-
}, "
|
4301
|
+
}, t("problem_number_question", {
|
4302
|
+
number: question.questionOrder + 1
|
4303
|
+
})), React.createElement(FormControl, {
|
4169
4304
|
className: "flex-grow-1 w-100"
|
4170
4305
|
}, React.createElement(RadioGroup, {
|
4171
4306
|
value: question.correctAnswers[0],
|
@@ -4186,7 +4321,9 @@ var QuestionView = function QuestionView(_ref) {
|
|
4186
4321
|
control: React.createElement(Radio, {
|
4187
4322
|
size: "small"
|
4188
4323
|
}),
|
4189
|
-
label:
|
4324
|
+
label: t("number_question", {
|
4325
|
+
number: i
|
4326
|
+
})
|
4190
4327
|
});
|
4191
4328
|
})))), React.createElement("div", {
|
4192
4329
|
className: "d-flex align-items-center"
|
@@ -4568,6 +4705,26 @@ var useExamDetailView = function useExamDetailView(props) {
|
|
4568
4705
|
}))
|
4569
4706
|
}));
|
4570
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
|
+
};
|
4571
4728
|
var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
|
4572
4729
|
if (!exam) return;
|
4573
4730
|
if (newAnswerCount === answerCount) return;
|
@@ -4695,10 +4852,10 @@ var useExamDetailView = function useExamDetailView(props) {
|
|
4695
4852
|
return options;
|
4696
4853
|
}, [exam.duration]);
|
4697
4854
|
useEffect(function () {
|
4698
|
-
onChangeExam(_extends({}, exam, {
|
4855
|
+
if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
|
4699
4856
|
subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
|
4700
4857
|
}));
|
4701
|
-
}, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id]);
|
4858
|
+
}, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
|
4702
4859
|
return {
|
4703
4860
|
t: t,
|
4704
4861
|
durationOptions: durationOptions,
|
@@ -4710,7 +4867,8 @@ var useExamDetailView = function useExamDetailView(props) {
|
|
4710
4867
|
handleChangeCorrectAnswers: handleChangeCorrectAnswers,
|
4711
4868
|
handleChangeAnswerCount: handleChangeAnswerCount,
|
4712
4869
|
handleChangeQuestionCount: handleChangeQuestionCount,
|
4713
|
-
handleChangeCategory: handleChangeCategory
|
4870
|
+
handleChangeCategory: handleChangeCategory,
|
4871
|
+
handleDeleteArticle: handleDeleteArticle
|
4714
4872
|
};
|
4715
4873
|
};
|
4716
4874
|
|
@@ -4740,7 +4898,8 @@ var ExamDetailView = function ExamDetailView(_ref) {
|
|
4740
4898
|
handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
|
4741
4899
|
handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
|
4742
4900
|
handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
|
4743
|
-
handleChangeCategory = _useExamDetailView.handleChangeCategory
|
4901
|
+
handleChangeCategory = _useExamDetailView.handleChangeCategory,
|
4902
|
+
handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
|
4744
4903
|
return React.createElement(Grid, {
|
4745
4904
|
container: true,
|
4746
4905
|
spacing: 3,
|
@@ -4779,7 +4938,7 @@ var ExamDetailView = function ExamDetailView(_ref) {
|
|
4779
4938
|
}, React.createElement("label", {
|
4780
4939
|
className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
|
4781
4940
|
htmlFor: "duration"
|
4782
|
-
}, "
|
4941
|
+
}, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React.createElement(CustomSelect, {
|
4783
4942
|
inputId: "subject",
|
4784
4943
|
value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
|
4785
4944
|
options: subjectOptions,
|
@@ -4798,8 +4957,10 @@ var ExamDetailView = function ExamDetailView(_ref) {
|
|
4798
4957
|
onChangeAnswerCount: handleChangeAnswerCount,
|
4799
4958
|
onChangeCorrectAnswers: handleChangeCorrectAnswers,
|
4800
4959
|
onChangeScoreAnswer: handleChangeScoreAnswer,
|
4960
|
+
onDelete: handleDeleteArticle,
|
4801
4961
|
isDisabled: isDisabled,
|
4802
|
-
selectedSubject: selectedSubject
|
4962
|
+
selectedSubject: selectedSubject,
|
4963
|
+
isDeletable: examGroupByArticle.length > 1
|
4803
4964
|
})));
|
4804
4965
|
}), React.createElement(Grid, {
|
4805
4966
|
item: true,
|