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.js
CHANGED
@@ -140,6 +140,7 @@ var AuthenticationMessage;
|
|
140
140
|
Role["Student"] = "Student";
|
141
141
|
Role["Teacher"] = "Teacher";
|
142
142
|
Role["Admin"] = "Admin";
|
143
|
+
Role["AcademyAdmin"] = "AcademyAdmin";
|
143
144
|
})(exports.Role || (exports.Role = {}));
|
144
145
|
|
145
146
|
// A type of promise-like that resolves synchronously and supports only one observer
|
@@ -1458,6 +1459,16 @@ var update_textbook_title = "교과서 제목 업데이트";
|
|
1458
1459
|
var invalid_weekly_day_time = "주간 요일 시간이 잘못되었습니다";
|
1459
1460
|
var no_image = "이미지 없음";
|
1460
1461
|
var school_name = "학교 이름";
|
1462
|
+
var phone_number = "전화번호";
|
1463
|
+
var major = "주요한";
|
1464
|
+
var roles = "역할";
|
1465
|
+
var searching_for = "검색 중...";
|
1466
|
+
var parent_name = "부모님 성함";
|
1467
|
+
var users = "사용자";
|
1468
|
+
var new_user = "새로운 사용자";
|
1469
|
+
var academy_admin = "아카데미 관리자";
|
1470
|
+
var switch_academy_admin = "스위치 아카데미 관리자";
|
1471
|
+
var there_are_no_lessons_this_week = "이번주는 수업이 없습니다";
|
1461
1472
|
var lang_ko = {
|
1462
1473
|
problem_solving: problem_solving,
|
1463
1474
|
my_story: my_story,
|
@@ -1701,7 +1712,17 @@ var lang_ko = {
|
|
1701
1712
|
update_textbook_title: update_textbook_title,
|
1702
1713
|
invalid_weekly_day_time: invalid_weekly_day_time,
|
1703
1714
|
no_image: no_image,
|
1704
|
-
school_name: school_name
|
1715
|
+
school_name: school_name,
|
1716
|
+
phone_number: phone_number,
|
1717
|
+
major: major,
|
1718
|
+
roles: roles,
|
1719
|
+
searching_for: searching_for,
|
1720
|
+
parent_name: parent_name,
|
1721
|
+
users: users,
|
1722
|
+
new_user: new_user,
|
1723
|
+
academy_admin: academy_admin,
|
1724
|
+
switch_academy_admin: switch_academy_admin,
|
1725
|
+
there_are_no_lessons_this_week: there_are_no_lessons_this_week
|
1705
1726
|
};
|
1706
1727
|
|
1707
1728
|
var problem_solving$1 = "Problem Solving";
|
@@ -1971,7 +1992,7 @@ var add_new_chapter_to_textbook$1 = "Add new chapter to the textbook";
|
|
1971
1992
|
var add_new_subchapter_to_parent_chapter$1 = "Add new subchapter to the parent chapter ({{ chapterName }})";
|
1972
1993
|
var add$1 = "Add";
|
1973
1994
|
var add_new_article_to_chapter$1 = "Add new article to the chapter ({{ chapterName }})";
|
1974
|
-
var score_format$1 = "{{score}}
|
1995
|
+
var score_format$1 = "{{score}}pts";
|
1975
1996
|
var round$1 = "{{number}} round";
|
1976
1997
|
var number_grade$1 = "Grade {{number}}";
|
1977
1998
|
var print$1 = "Print";
|
@@ -1983,6 +2004,16 @@ var update_textbook_title$1 = "Update textbook title";
|
|
1983
2004
|
var invalid_weekly_day_time$1 = "Invalid weekly day time";
|
1984
2005
|
var no_image$1 = "No image";
|
1985
2006
|
var school_name$1 = "School name";
|
2007
|
+
var phone_number$1 = "Phone Number";
|
2008
|
+
var major$1 = "Major";
|
2009
|
+
var roles$1 = "Roles";
|
2010
|
+
var searching_for$1 = "Searching for...";
|
2011
|
+
var parent_name$1 = "Parent name";
|
2012
|
+
var users$1 = "Users";
|
2013
|
+
var new_user$1 = "New user";
|
2014
|
+
var academy_admin$1 = "Academy Admin";
|
2015
|
+
var switch_academy_admin$1 = "Switch Academy Admin";
|
2016
|
+
var there_are_no_lessons_this_week$1 = "There are no lessons this week";
|
1986
2017
|
var lang_en = {
|
1987
2018
|
problem_solving: problem_solving$1,
|
1988
2019
|
my_story: my_story$1,
|
@@ -2260,7 +2291,17 @@ var lang_en = {
|
|
2260
2291
|
update_textbook_title: update_textbook_title$1,
|
2261
2292
|
invalid_weekly_day_time: invalid_weekly_day_time$1,
|
2262
2293
|
no_image: no_image$1,
|
2263
|
-
school_name: school_name$1
|
2294
|
+
school_name: school_name$1,
|
2295
|
+
phone_number: phone_number$1,
|
2296
|
+
major: major$1,
|
2297
|
+
roles: roles$1,
|
2298
|
+
searching_for: searching_for$1,
|
2299
|
+
parent_name: parent_name$1,
|
2300
|
+
users: users$1,
|
2301
|
+
new_user: new_user$1,
|
2302
|
+
academy_admin: academy_admin$1,
|
2303
|
+
switch_academy_admin: switch_academy_admin$1,
|
2304
|
+
there_are_no_lessons_this_week: there_are_no_lessons_this_week$1
|
2264
2305
|
};
|
2265
2306
|
|
2266
2307
|
i18n.use(reactI18next.initReactI18next).init({
|
@@ -2445,6 +2486,8 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
|
|
2445
2486
|
var _state$common2;
|
2446
2487
|
return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
|
2447
2488
|
});
|
2489
|
+
var _useTranslation = reactI18next.useTranslation(),
|
2490
|
+
t = _useTranslation.t;
|
2448
2491
|
var getAcademies = function getAcademies(isLoading) {
|
2449
2492
|
if (isLoading === void 0) {
|
2450
2493
|
isLoading = true;
|
@@ -2505,7 +2548,7 @@ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl,
|
|
2505
2548
|
});
|
2506
2549
|
}, function (error) {
|
2507
2550
|
var _error$response2, _error$response2$data;
|
2508
|
-
reactToastify.toast.error((error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.title) || "
|
2551
|
+
reactToastify.toast.error((error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.title) || t("switch_academy_admin"));
|
2509
2552
|
});
|
2510
2553
|
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
|
2511
2554
|
} catch (e) {
|
@@ -2549,6 +2592,8 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
|
|
2549
2592
|
});
|
2550
2593
|
var isAdmin = role === exports.Role.Admin;
|
2551
2594
|
var isSuperAdmin = user && !user.academyDomain && ((_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes(exports.Role.Admin));
|
2595
|
+
var _useTranslation = reactI18next.useTranslation(),
|
2596
|
+
t = _useTranslation.t;
|
2552
2597
|
var _useState = React.useState(null),
|
2553
2598
|
open = _useState[0],
|
2554
2599
|
setOpen = _useState[1];
|
@@ -2585,7 +2630,7 @@ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
|
|
2585
2630
|
color: "#5458D5",
|
2586
2631
|
minWidth: 150
|
2587
2632
|
}
|
2588
|
-
}, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || "
|
2633
|
+
}, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || t("switch_academy_admin")), React__default.createElement("div", {
|
2589
2634
|
className: "" + stylesGlobal["switch-icon"]
|
2590
2635
|
}, React__default.createElement(go.GoArrowSwitch, {
|
2591
2636
|
size: 14
|
@@ -2768,7 +2813,8 @@ var ChatRightItem = function ChatRightItem(_ref) {
|
|
2768
2813
|
showTimestamp = _ref.showTimestamp,
|
2769
2814
|
isStudent = _ref.isStudent,
|
2770
2815
|
showName = _ref.showName,
|
2771
|
-
contentType = _ref.contentType
|
2816
|
+
contentType = _ref.contentType,
|
2817
|
+
toggleImageDialog = _ref.toggleImageDialog;
|
2772
2818
|
var _useTranslation = reactI18next.useTranslation(),
|
2773
2819
|
t = _useTranslation.t;
|
2774
2820
|
return React__default.createElement("div", null, showTimestamp && React__default.createElement(material.Typography, {
|
@@ -2796,6 +2842,7 @@ var ChatRightItem = function ChatRightItem(_ref) {
|
|
2796
2842
|
lineHeight: "16.71px",
|
2797
2843
|
color: "#5458D5"
|
2798
2844
|
}, sender === null || sender === void 0 ? void 0 : sender.fullName)), contentType ? React__default.createElement("img", {
|
2845
|
+
onClick: toggleImageDialog,
|
2799
2846
|
src: content,
|
2800
2847
|
style: {
|
2801
2848
|
backgroundRepeat: "no-repeat",
|
@@ -2825,7 +2872,8 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2825
2872
|
showTimestamp = _ref.showTimestamp,
|
2826
2873
|
isStudent = _ref.isStudent,
|
2827
2874
|
showName = _ref.showName,
|
2828
|
-
contentType = _ref.contentType
|
2875
|
+
contentType = _ref.contentType,
|
2876
|
+
toggleImageDialog = _ref.toggleImageDialog;
|
2829
2877
|
var _useTranslation = reactI18next.useTranslation(),
|
2830
2878
|
t = _useTranslation.t;
|
2831
2879
|
return React__default.createElement("div", null, showTimestamp && React__default.createElement(material.Typography, {
|
@@ -2867,6 +2915,7 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2867
2915
|
}, t("student")))), React__default.createElement(material.Box, {
|
2868
2916
|
padding: "4px 0px"
|
2869
2917
|
}), contentType ? React__default.createElement("img", {
|
2918
|
+
onClick: toggleImageDialog,
|
2870
2919
|
src: content,
|
2871
2920
|
style: {
|
2872
2921
|
backgroundRepeat: "no-repeat",
|
@@ -2886,6 +2935,115 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2886
2935
|
}, content))));
|
2887
2936
|
};
|
2888
2937
|
|
2938
|
+
var ImageDetailDialog = function ImageDetailDialog(_ref) {
|
2939
|
+
var open = _ref.open,
|
2940
|
+
toggleDialog = _ref.toggleDialog,
|
2941
|
+
content = _ref.content,
|
2942
|
+
downloadFile = _ref.downloadFile;
|
2943
|
+
var _useTranslation = reactI18next.useTranslation(),
|
2944
|
+
t = _useTranslation.t;
|
2945
|
+
return React__default.createElement(CommonDialog, {
|
2946
|
+
open: open,
|
2947
|
+
onClose: toggleDialog,
|
2948
|
+
size: "sm",
|
2949
|
+
title: t("image")
|
2950
|
+
}, React__default.createElement(material.DialogContent, {
|
2951
|
+
sx: {
|
2952
|
+
overflowY: "unset"
|
2953
|
+
}
|
2954
|
+
}, React__default.createElement(material.Stack, null, React__default.createElement(material.Stack, {
|
2955
|
+
display: "flex",
|
2956
|
+
justifyContent: "center",
|
2957
|
+
alignItems: "center"
|
2958
|
+
}, React__default.createElement("img", {
|
2959
|
+
src: content,
|
2960
|
+
style: {
|
2961
|
+
width: "500px",
|
2962
|
+
height: "500px",
|
2963
|
+
position: "relative",
|
2964
|
+
objectFit: "cover"
|
2965
|
+
}
|
2966
|
+
})), React__default.createElement(material.Button, {
|
2967
|
+
sx: {
|
2968
|
+
margin: "10px 0"
|
2969
|
+
},
|
2970
|
+
variant: "outlined",
|
2971
|
+
fullWidth: true,
|
2972
|
+
onClick: function onClick() {
|
2973
|
+
return downloadFile(content);
|
2974
|
+
}
|
2975
|
+
}, t("download")))));
|
2976
|
+
};
|
2977
|
+
|
2978
|
+
var CONVERSATION_URL = BASE_URL + "/api/conversation";
|
2979
|
+
var apiAddMessage = function apiAddMessage(conversationId, message) {
|
2980
|
+
return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
|
2981
|
+
};
|
2982
|
+
var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
|
2983
|
+
return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
|
2984
|
+
params: filter
|
2985
|
+
});
|
2986
|
+
};
|
2987
|
+
var updateLastTimeReadConversation = function updateLastTimeReadConversation(conversationId) {
|
2988
|
+
return api.put(CONVERSATION_URL + "/" + conversationId);
|
2989
|
+
};
|
2990
|
+
var completeConversation = function completeConversation(conversationId) {
|
2991
|
+
return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
|
2992
|
+
};
|
2993
|
+
var apiUploadImageFile = function apiUploadImageFile(file) {
|
2994
|
+
return apiUpload.post(BASE_URL + "/api/file/images", file);
|
2995
|
+
};
|
2996
|
+
|
2997
|
+
var FileSaver_min = createCommonjsModule(function (module, exports) {
|
2998
|
+
(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);});
|
2999
|
+
|
3000
|
+
|
3001
|
+
});
|
3002
|
+
|
3003
|
+
var useDialog = function useDialog() {
|
3004
|
+
var _useState = React.useState(false),
|
3005
|
+
openConfirmDialog = _useState[0],
|
3006
|
+
setOpenConfirmDialog = _useState[1];
|
3007
|
+
var toggleConfirmDialog = function toggleConfirmDialog() {
|
3008
|
+
setOpenConfirmDialog(function (state) {
|
3009
|
+
return !state;
|
3010
|
+
});
|
3011
|
+
};
|
3012
|
+
var handleConfirm = function handleConfirm(conversationId) {
|
3013
|
+
try {
|
3014
|
+
var _temp2 = function _temp2() {
|
3015
|
+
setLoading(false);
|
3016
|
+
};
|
3017
|
+
setLoading(true);
|
3018
|
+
var _temp = _catch(function () {
|
3019
|
+
return Promise.resolve(completeConversation(conversationId)).then(function () {
|
3020
|
+
toggleConfirmDialog();
|
3021
|
+
reactToastify.toast.success("Complete conversation success");
|
3022
|
+
});
|
3023
|
+
}, function () {
|
3024
|
+
reactToastify.toast.error("Failed to complete conversation");
|
3025
|
+
});
|
3026
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
3027
|
+
} catch (e) {
|
3028
|
+
return Promise.reject(e);
|
3029
|
+
}
|
3030
|
+
};
|
3031
|
+
var downloadFile = function downloadFile(content) {
|
3032
|
+
try {
|
3033
|
+
FileSaver_min.saveAs(content, "image.png");
|
3034
|
+
return Promise.resolve();
|
3035
|
+
} catch (e) {
|
3036
|
+
return Promise.reject(e);
|
3037
|
+
}
|
3038
|
+
};
|
3039
|
+
return {
|
3040
|
+
openConfirmDialog: openConfirmDialog,
|
3041
|
+
toggleConfirmDialog: toggleConfirmDialog,
|
3042
|
+
handleConfirm: handleConfirm,
|
3043
|
+
downloadFile: downloadFile
|
3044
|
+
};
|
3045
|
+
};
|
3046
|
+
|
2889
3047
|
(function (ChatItemType) {
|
2890
3048
|
ChatItemType[ChatItemType["Default"] = 0] = "Default";
|
2891
3049
|
ChatItemType[ChatItemType["Exam"] = 1] = "Exam";
|
@@ -2893,7 +3051,20 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
|
|
2893
3051
|
})(exports.ChatItemType || (exports.ChatItemType = {}));
|
2894
3052
|
var ChatItem = function ChatItem(props) {
|
2895
3053
|
var isMe = props.isMe;
|
2896
|
-
|
3054
|
+
var _useDialog = useDialog(),
|
3055
|
+
openConfirmDialog = _useDialog.openConfirmDialog,
|
3056
|
+
toggleConfirmDialog = _useDialog.toggleConfirmDialog,
|
3057
|
+
downloadFile = _useDialog.downloadFile;
|
3058
|
+
return React__default.createElement(React.Fragment, null, isMe ? React__default.createElement(ChatRightItem, Object.assign({}, props, {
|
3059
|
+
toggleImageDialog: toggleConfirmDialog
|
3060
|
+
})) : React__default.createElement(ChatLeftItem, Object.assign({}, props, {
|
3061
|
+
toggleImageDialog: toggleConfirmDialog
|
3062
|
+
})), React__default.createElement(ImageDetailDialog, {
|
3063
|
+
open: openConfirmDialog,
|
3064
|
+
toggleDialog: toggleConfirmDialog,
|
3065
|
+
content: props.content || "",
|
3066
|
+
downloadFile: downloadFile
|
3067
|
+
}));
|
2897
3068
|
};
|
2898
3069
|
|
2899
3070
|
var MessageSortBy;
|
@@ -3159,57 +3330,6 @@ var iconChecked = function iconChecked(_ref) {
|
|
3159
3330
|
}));
|
3160
3331
|
};
|
3161
3332
|
|
3162
|
-
var CONVERSATION_URL = BASE_URL + "/api/conversation";
|
3163
|
-
var apiAddMessage = function apiAddMessage(conversationId, message) {
|
3164
|
-
return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
|
3165
|
-
};
|
3166
|
-
var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
|
3167
|
-
return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
|
3168
|
-
params: filter
|
3169
|
-
});
|
3170
|
-
};
|
3171
|
-
var completeConversation = function completeConversation(conversationId) {
|
3172
|
-
return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
|
3173
|
-
};
|
3174
|
-
var apiUploadImageFile = function apiUploadImageFile(file) {
|
3175
|
-
return apiUpload.post(BASE_URL + "/api/file/images", file);
|
3176
|
-
};
|
3177
|
-
|
3178
|
-
var useDialog = function useDialog() {
|
3179
|
-
var _useState = React.useState(false),
|
3180
|
-
openConfirmDialog = _useState[0],
|
3181
|
-
setOpenConfirmDialog = _useState[1];
|
3182
|
-
var toggleConfirmDialog = function toggleConfirmDialog() {
|
3183
|
-
setOpenConfirmDialog(function (state) {
|
3184
|
-
return !state;
|
3185
|
-
});
|
3186
|
-
};
|
3187
|
-
var handleConfirm = function handleConfirm(conversationId) {
|
3188
|
-
try {
|
3189
|
-
var _temp2 = function _temp2() {
|
3190
|
-
setLoading(false);
|
3191
|
-
};
|
3192
|
-
setLoading(true);
|
3193
|
-
var _temp = _catch(function () {
|
3194
|
-
return Promise.resolve(completeConversation(conversationId)).then(function () {
|
3195
|
-
toggleConfirmDialog();
|
3196
|
-
reactToastify.toast.success("Complete conversation success");
|
3197
|
-
});
|
3198
|
-
}, function () {
|
3199
|
-
reactToastify.toast.error("Failed to complete conversation");
|
3200
|
-
});
|
3201
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
3202
|
-
} catch (e) {
|
3203
|
-
return Promise.reject(e);
|
3204
|
-
}
|
3205
|
-
};
|
3206
|
-
return {
|
3207
|
-
openConfirmDialog: openConfirmDialog,
|
3208
|
-
toggleConfirmDialog: toggleConfirmDialog,
|
3209
|
-
handleConfirm: handleConfirm
|
3210
|
-
};
|
3211
|
-
};
|
3212
|
-
|
3213
3333
|
var ChatHeader = function ChatHeader(_ref) {
|
3214
3334
|
var fullName = _ref.fullName,
|
3215
3335
|
examTitle = _ref.examTitle,
|
@@ -3424,6 +3544,10 @@ var ChatContainer = function ChatContainer(_ref) {
|
|
3424
3544
|
if (scrollTop <= scrollOffset) {
|
3425
3545
|
return Promise.resolve(onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop()).then(function (isSuccessLoad) {
|
3426
3546
|
if (isSuccessLoad) {
|
3547
|
+
var _listItemRef$current, _listItemRef$current$;
|
3548
|
+
(_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({
|
3549
|
+
behavior: "smooth"
|
3550
|
+
});
|
3427
3551
|
listRef.current.scrollTop = listRef.current.scrollHeight - scrollHeight;
|
3428
3552
|
}
|
3429
3553
|
});
|
@@ -3441,24 +3565,20 @@ var ChatContainer = function ChatContainer(_ref) {
|
|
3441
3565
|
}
|
3442
3566
|
};
|
3443
3567
|
React.useEffect(function () {
|
3444
|
-
var _listRef$current, _chatListProps$messag, _listRef$
|
3568
|
+
var _listRef$current, _chatListProps$messag, _listRef$current2;
|
3445
3569
|
scrollRef.current && clearTimeout(scrollRef.current);
|
3446
3570
|
addEventTimeout.current && clearTimeout(addEventTimeout.current);
|
3447
3571
|
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener("scroll", handleScroll);
|
3448
3572
|
if (isScrollToEnd && !isLoading && (_chatListProps$messag = chatListProps.messages) !== null && _chatListProps$messag !== void 0 && _chatListProps$messag.length) {
|
3449
|
-
var _listItemRef$
|
3450
|
-
(_listItemRef$
|
3573
|
+
var _listItemRef$current2, _listItemRef$current3;
|
3574
|
+
(_listItemRef$current2 = listItemRef.current) === null || _listItemRef$current2 === void 0 ? void 0 : (_listItemRef$current3 = _listItemRef$current2.lastElementChild) === null || _listItemRef$current3 === void 0 ? void 0 : _listItemRef$current3.scrollIntoView({
|
3451
3575
|
behavior: "smooth"
|
3452
3576
|
});
|
3453
3577
|
onEndScrollToEnd === null || onEndScrollToEnd === void 0 ? void 0 : onEndScrollToEnd();
|
3454
|
-
|
3455
|
-
var _listRef$current2;
|
3456
|
-
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
|
3457
|
-
}, 800);
|
3458
|
-
} else (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.addEventListener("scroll", handleScroll);
|
3578
|
+
} else (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
|
3459
3579
|
return function () {
|
3460
|
-
var _listRef$
|
3461
|
-
(_listRef$
|
3580
|
+
var _listRef$current3;
|
3581
|
+
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.removeEventListener("scroll", handleScroll);
|
3462
3582
|
scrollRef.current && clearTimeout(scrollRef.current);
|
3463
3583
|
addEventTimeout.current && clearTimeout(addEventTimeout.current);
|
3464
3584
|
};
|
@@ -3508,14 +3628,16 @@ var useMessageList = function useMessageList() {
|
|
3508
3628
|
var _temp = _catch(function () {
|
3509
3629
|
var filter = _extends({}, messageFilter);
|
3510
3630
|
return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
|
3511
|
-
|
3512
|
-
|
3513
|
-
|
3514
|
-
|
3515
|
-
|
3516
|
-
|
3517
|
-
|
3518
|
-
|
3631
|
+
return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
|
3632
|
+
setMessages(function (prev) {
|
3633
|
+
var _res$data$items;
|
3634
|
+
return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
|
3635
|
+
});
|
3636
|
+
setMessageFilter(function (prev) {
|
3637
|
+
return _extends({}, prev, {
|
3638
|
+
totalItems: res.data.totalItems,
|
3639
|
+
totalPages: res.data.totalPages
|
3640
|
+
});
|
3519
3641
|
});
|
3520
3642
|
});
|
3521
3643
|
});
|
@@ -3535,28 +3657,30 @@ var useMessageList = function useMessageList() {
|
|
3535
3657
|
return true;
|
3536
3658
|
};
|
3537
3659
|
var _exit = false;
|
3538
|
-
if (isLoading) return Promise.resolve();
|
3660
|
+
if (isLoading || messageFilter.currentPage === messageFilter.totalPages) return Promise.resolve();
|
3539
3661
|
var filter = _extends({}, messageFilter, {
|
3540
3662
|
currentPage: ((messageFilter === null || messageFilter === void 0 ? void 0 : messageFilter.currentPage) || 1) + 1
|
3541
3663
|
});
|
3542
|
-
setMessageFilter(filter);
|
3543
3664
|
setLoading(true);
|
3544
3665
|
var _temp3 = _catch(function () {
|
3545
3666
|
return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
|
3546
|
-
|
3547
|
-
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
setMessageFilter(function (prev) {
|
3554
|
-
return _extends({}, prev, {
|
3555
|
-
totalItems: res.data.totalItems,
|
3556
|
-
totalPages: res.data.totalPages
|
3667
|
+
return Promise.resolve(updateLastTimeReadConversation(conversationId)).then(function () {
|
3668
|
+
if (res.data.items.length) {
|
3669
|
+
setMessages(function (prev) {
|
3670
|
+
var _res$data$items2;
|
3671
|
+
var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
|
3672
|
+
var dataFilter = new Set(data);
|
3673
|
+
return Array.from(dataFilter);
|
3557
3674
|
});
|
3558
|
-
|
3559
|
-
|
3675
|
+
setMessageFilter(function (prev) {
|
3676
|
+
return _extends({}, prev, {
|
3677
|
+
totalItems: res.data.totalItems,
|
3678
|
+
totalPages: res.data.totalPages,
|
3679
|
+
currentPage: res.data.page
|
3680
|
+
});
|
3681
|
+
});
|
3682
|
+
}
|
3683
|
+
});
|
3560
3684
|
});
|
3561
3685
|
}, function () {
|
3562
3686
|
reactToastify.toast.error("Fail to fetch data!");
|
@@ -3669,34 +3793,26 @@ var useChatContainer = function useChatContainer(props) {
|
|
3669
3793
|
}
|
3670
3794
|
};
|
3671
3795
|
var handleUploadImage = function handleUploadImage(file) {
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
formData.append("upload", file);
|
3681
|
-
return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
|
3682
|
-
var _res$data;
|
3683
|
-
setSelectedFile({
|
3684
|
-
content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
|
3685
|
-
});
|
3686
|
-
});
|
3687
|
-
}, function (error) {
|
3688
|
-
var _error$response2;
|
3689
|
-
setMessages(function (state) {
|
3690
|
-
return [].concat(state.filter(function (i) {
|
3691
|
-
return (i === null || i === void 0 ? void 0 : i.id) !== 0;
|
3692
|
-
}));
|
3796
|
+
return file ? Promise.resolve(_finally(function () {
|
3797
|
+
return _catch(function () {
|
3798
|
+
var formData = new FormData();
|
3799
|
+
formData.append("upload", file);
|
3800
|
+
return Promise.resolve(apiUploadImageFile(formData)).then(function (res) {
|
3801
|
+
var _res$data;
|
3802
|
+
setSelectedFile({
|
3803
|
+
content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
|
3693
3804
|
});
|
3694
|
-
reactToastify.toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
|
3695
3805
|
});
|
3696
|
-
}, function () {
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3806
|
+
}, function (error) {
|
3807
|
+
var _error$response2;
|
3808
|
+
setMessages(function (state) {
|
3809
|
+
return [].concat(state.filter(function (i) {
|
3810
|
+
return (i === null || i === void 0 ? void 0 : i.id) !== 0;
|
3811
|
+
}));
|
3812
|
+
});
|
3813
|
+
reactToastify.toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
|
3814
|
+
});
|
3815
|
+
}, function () {})) : Promise.resolve();
|
3700
3816
|
};
|
3701
3817
|
var handleChangeInput = function handleChangeInput(text) {
|
3702
3818
|
setMessage({
|
@@ -3710,6 +3826,14 @@ var useChatContainer = function useChatContainer(props) {
|
|
3710
3826
|
return [].concat(state, [data]);
|
3711
3827
|
});
|
3712
3828
|
};
|
3829
|
+
var handleNewConversation = function handleNewConversation(data) {
|
3830
|
+
if (!data) return;
|
3831
|
+
var item = JSON.parse(data);
|
3832
|
+
setScrollToEnd(true);
|
3833
|
+
setMessages(function (state) {
|
3834
|
+
return [].concat(state, [item]);
|
3835
|
+
});
|
3836
|
+
};
|
3713
3837
|
var handleCompletedConversation = function handleCompletedConversation(data) {
|
3714
3838
|
if (!data) return;
|
3715
3839
|
setSelectedConversation(JSON.parse(data));
|
@@ -3726,8 +3850,10 @@ var useChatContainer = function useChatContainer(props) {
|
|
3726
3850
|
setSelectedFile(null);
|
3727
3851
|
};
|
3728
3852
|
var cleanupPusher = function cleanupPusher() {
|
3729
|
-
var _pusher$current;
|
3853
|
+
var _pusher$current, _pusher$current2, _pusher$current3;
|
3730
3854
|
(_pusher$current = pusher.current) === null || _pusher$current === void 0 ? void 0 : _pusher$current.unbind("new-message-event", handleNewMessageSent);
|
3855
|
+
(_pusher$current2 = pusher.current) === null || _pusher$current2 === void 0 ? void 0 : _pusher$current2.unbind("completed-conversation-event", handleCompletedConversation);
|
3856
|
+
(_pusher$current3 = pusher.current) === null || _pusher$current3 === void 0 ? void 0 : _pusher$current3.unbind("new-conversation-event", handleNewConversation);
|
3731
3857
|
channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
|
3732
3858
|
};
|
3733
3859
|
React.useEffect(function () {
|
@@ -3744,10 +3870,11 @@ var useChatContainer = function useChatContainer(props) {
|
|
3744
3870
|
}, _headers[AcademyHeaders] = academyDomain, _headers)
|
3745
3871
|
}
|
3746
3872
|
});
|
3747
|
-
channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id);
|
3873
|
+
channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id) + "-" + academyDomain.trim().toUpperCase();
|
3748
3874
|
channel.current = pusher.current.subscribe(channelName.current);
|
3749
3875
|
pusher.current.bind("new-message-event", handleNewMessageSent);
|
3750
3876
|
pusher.current.bind("completed-conversation-event", handleCompletedConversation);
|
3877
|
+
pusher.current.bind("new-conversation-event", handleNewConversation);
|
3751
3878
|
}
|
3752
3879
|
return cleanupPusher;
|
3753
3880
|
}, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, academyDomain]);
|
@@ -3865,7 +3992,7 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
|
|
3865
3992
|
}, _headers[AcademyHeaders] = academyDomain, _headers)
|
3866
3993
|
}
|
3867
3994
|
});
|
3868
|
-
channelName.current = "presence-conversation-channel-userId-" + userId;
|
3995
|
+
channelName.current = "presence-conversation-channel-userId-" + userId + "-" + academyDomain.trim().toUpperCase();
|
3869
3996
|
channel.current = pusher.current.subscribe(channelName.current);
|
3870
3997
|
channel.current.bind("message-conversation-event", handleNewMessageConversationCreated);
|
3871
3998
|
channel.current.bind("message-conversation-read-event", handleReadMessageConversation);
|
@@ -4132,12 +4259,16 @@ var ScoreSelector = function ScoreSelector(_ref) {
|
|
4132
4259
|
isDisabled = _ref.isDisabled;
|
4133
4260
|
var _useTranslation = reactI18next.useTranslation(),
|
4134
4261
|
t = _useTranslation.t;
|
4135
|
-
var scoreOptions =
|
4136
|
-
return {
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4262
|
+
var scoreOptions = React.useMemo(function () {
|
4263
|
+
return SCORE_OPTIONS.map(function (i) {
|
4264
|
+
return {
|
4265
|
+
label: "" + t("score_format", {
|
4266
|
+
score: i
|
4267
|
+
}) + (DEFAULT_SCORE === i ? " (" + t("default").toLocaleLowerCase() + ")" : ""),
|
4268
|
+
value: i
|
4269
|
+
};
|
4270
|
+
});
|
4271
|
+
}, [t]);
|
4141
4272
|
return React__default.createElement(CustomSelect, {
|
4142
4273
|
inputId: id,
|
4143
4274
|
value: value,
|
@@ -4154,6 +4285,8 @@ var QuestionView = function QuestionView(_ref) {
|
|
4154
4285
|
isDisabled = _ref.isDisabled,
|
4155
4286
|
onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
|
4156
4287
|
onChangeScoreAnswer = _ref.onChangeScoreAnswer;
|
4288
|
+
var _useTranslation = reactI18next.useTranslation(),
|
4289
|
+
t = _useTranslation.t;
|
4157
4290
|
var handleChangeCorrectAnswer = function handleChangeCorrectAnswer(e) {
|
4158
4291
|
return onChangeCorrectAnswers(e.target.value, index);
|
4159
4292
|
};
|
@@ -4163,7 +4296,9 @@ var QuestionView = function QuestionView(_ref) {
|
|
4163
4296
|
className: "d-flex flex-grow-1"
|
4164
4297
|
}, React__default.createElement("div", {
|
4165
4298
|
className: styles$1["question-title"] + " me-2 text-nowrap"
|
4166
|
-
}, "
|
4299
|
+
}, t("problem_number_question", {
|
4300
|
+
number: question.questionOrder + 1
|
4301
|
+
})), React__default.createElement(material.FormControl, {
|
4167
4302
|
className: "flex-grow-1 w-100"
|
4168
4303
|
}, React__default.createElement(material.RadioGroup, {
|
4169
4304
|
value: question.correctAnswers[0],
|
@@ -4184,7 +4319,9 @@ var QuestionView = function QuestionView(_ref) {
|
|
4184
4319
|
control: React__default.createElement(material.Radio, {
|
4185
4320
|
size: "small"
|
4186
4321
|
}),
|
4187
|
-
label:
|
4322
|
+
label: t("number_question", {
|
4323
|
+
number: i
|
4324
|
+
})
|
4188
4325
|
});
|
4189
4326
|
})))), React__default.createElement("div", {
|
4190
4327
|
className: "d-flex align-items-center"
|
@@ -4566,6 +4703,26 @@ var useExamDetailView = function useExamDetailView(props) {
|
|
4566
4703
|
}))
|
4567
4704
|
}));
|
4568
4705
|
};
|
4706
|
+
var handleDeleteArticle = function handleDeleteArticle(article) {
|
4707
|
+
if (!exam) return;
|
4708
|
+
var removedQuestions = exam.questions.filter(function (i) {
|
4709
|
+
return i.article === +article;
|
4710
|
+
}).map(function (i) {
|
4711
|
+
return i.questionOrder;
|
4712
|
+
});
|
4713
|
+
var max = Math.max.apply(Math, removedQuestions);
|
4714
|
+
var examQuestions = exam.questions.filter(function (i) {
|
4715
|
+
return i.article !== +article;
|
4716
|
+
}).map(function (i) {
|
4717
|
+
return _extends({}, i, {
|
4718
|
+
article: i.article > article ? i.article - 1 : i.article,
|
4719
|
+
questionOrder: i.questionOrder > max ? i.questionOrder - removedQuestions.length : i.questionOrder
|
4720
|
+
});
|
4721
|
+
});
|
4722
|
+
onChangeExam(_extends({}, exam, {
|
4723
|
+
questions: [].concat(examQuestions)
|
4724
|
+
}));
|
4725
|
+
};
|
4569
4726
|
var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
|
4570
4727
|
if (!exam) return;
|
4571
4728
|
if (newAnswerCount === answerCount) return;
|
@@ -4693,10 +4850,10 @@ var useExamDetailView = function useExamDetailView(props) {
|
|
4693
4850
|
return options;
|
4694
4851
|
}, [exam.duration]);
|
4695
4852
|
React.useEffect(function () {
|
4696
|
-
onChangeExam(_extends({}, exam, {
|
4853
|
+
if ((selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) !== exam.subjectId) onChangeExam(_extends({}, exam, {
|
4697
4854
|
subjectId: (selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id) || 0
|
4698
4855
|
}));
|
4699
|
-
}, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id]);
|
4856
|
+
}, [selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id, exam.subjectId]);
|
4700
4857
|
return {
|
4701
4858
|
t: t,
|
4702
4859
|
durationOptions: durationOptions,
|
@@ -4708,7 +4865,8 @@ var useExamDetailView = function useExamDetailView(props) {
|
|
4708
4865
|
handleChangeCorrectAnswers: handleChangeCorrectAnswers,
|
4709
4866
|
handleChangeAnswerCount: handleChangeAnswerCount,
|
4710
4867
|
handleChangeQuestionCount: handleChangeQuestionCount,
|
4711
|
-
handleChangeCategory: handleChangeCategory
|
4868
|
+
handleChangeCategory: handleChangeCategory,
|
4869
|
+
handleDeleteArticle: handleDeleteArticle
|
4712
4870
|
};
|
4713
4871
|
};
|
4714
4872
|
|
@@ -4738,7 +4896,8 @@ var ExamDetailView = function ExamDetailView(_ref) {
|
|
4738
4896
|
handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
|
4739
4897
|
handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
|
4740
4898
|
handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
|
4741
|
-
handleChangeCategory = _useExamDetailView.handleChangeCategory
|
4899
|
+
handleChangeCategory = _useExamDetailView.handleChangeCategory,
|
4900
|
+
handleDeleteArticle = _useExamDetailView.handleDeleteArticle;
|
4742
4901
|
return React__default.createElement(material.Grid, {
|
4743
4902
|
container: true,
|
4744
4903
|
spacing: 3,
|
@@ -4777,7 +4936,7 @@ var ExamDetailView = function ExamDetailView(_ref) {
|
|
4777
4936
|
}, React__default.createElement("label", {
|
4778
4937
|
className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
|
4779
4938
|
htmlFor: "duration"
|
4780
|
-
}, "
|
4939
|
+
}, t("subject"), " ", selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.name), React__default.createElement(CustomSelect, {
|
4781
4940
|
inputId: "subject",
|
4782
4941
|
value: selectedSubject === null || selectedSubject === void 0 ? void 0 : selectedSubject.id,
|
4783
4942
|
options: subjectOptions,
|
@@ -4796,8 +4955,10 @@ var ExamDetailView = function ExamDetailView(_ref) {
|
|
4796
4955
|
onChangeAnswerCount: handleChangeAnswerCount,
|
4797
4956
|
onChangeCorrectAnswers: handleChangeCorrectAnswers,
|
4798
4957
|
onChangeScoreAnswer: handleChangeScoreAnswer,
|
4958
|
+
onDelete: handleDeleteArticle,
|
4799
4959
|
isDisabled: isDisabled,
|
4800
|
-
selectedSubject: selectedSubject
|
4960
|
+
selectedSubject: selectedSubject,
|
4961
|
+
isDeletable: examGroupByArticle.length > 1
|
4801
4962
|
})));
|
4802
4963
|
}), React__default.createElement(material.Grid, {
|
4803
4964
|
item: true,
|