touchstudy-core 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -16,11 +16,18 @@ var gapiScript = require('gapi-script');
16
16
  var i18n = _interopDefault(require('i18next'));
17
17
  var reactI18next = require('react-i18next');
18
18
  var io5 = require('react-icons/io5');
19
- var Select = _interopDefault(require('react-select'));
19
+ require('moment/locale/ko.js');
20
+ require('moment/locale/en-au.js');
21
+ var Select = require('react-select');
22
+ var Select__default = _interopDefault(Select);
23
+ var fa = require('react-icons/fa');
20
24
  var reactRouterDom = require('react-router-dom');
21
25
  var io = require('react-icons/io');
22
- var reactToastify = require('react-toastify');
23
26
  var Pusher = _interopDefault(require('pusher-js'));
27
+ var reactToastify = require('react-toastify');
28
+ var CreatableSelect = _interopDefault(require('react-select/creatable'));
29
+ var pi = require('react-icons/pi');
30
+ var _ = _interopDefault(require('lodash'));
24
31
 
25
32
  var setLoading = toolkit.createAction("common/setLoading");
26
33
  var setAlert = toolkit.createAction("common/setAlert");
@@ -33,6 +40,7 @@ var isLocalHost = Boolean(window.location.hostname === "localhost" || window.loc
33
40
  var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
34
41
  var ACCESS_TOKEN = "ACCESS_TOKEN";
35
42
  var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
43
+ var DATE_TIME_MIN_VALUE = "0001-01-01T00:00:00";
36
44
  var BASE_URL = function () {
37
45
  return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
38
46
  }();
@@ -63,7 +71,7 @@ var encodeParams = function encodeParams(params) {
63
71
  };
64
72
 
65
73
  var utcToLocalTime = (function (time, FORMAT) {
66
- if (time === DATE_MIN_VALUE) return "";
74
+ if (time === DATE_MIN_VALUE || time === DATE_TIME_MIN_VALUE) return "";
67
75
  try {
68
76
  return moment.utc(time).local().format(FORMAT || "yyyy-MM-DD");
69
77
  } catch (_unused) {
@@ -150,6 +158,11 @@ var AuthenticationMessage;
150
158
  AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
151
159
  AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
152
160
  })(AuthenticationMessage || (AuthenticationMessage = {}));
161
+ (function (Role) {
162
+ Role["Student"] = "Student";
163
+ Role["Teacher"] = "Teacher";
164
+ Role["Admin"] = "Admin";
165
+ })(exports.Role || (exports.Role = {}));
153
166
 
154
167
  var useGoogleSignOut = function useGoogleSignOut(props) {
155
168
  var dispatch = reactRedux.useDispatch();
@@ -196,7 +209,8 @@ var schema = yup.object({
196
209
  var BlockLogin = function BlockLogin(_ref) {
197
210
  var defaultInfo = _ref.defaultInfo,
198
211
  onNavigate = _ref.onNavigate,
199
- isTeacher = _ref.isTeacher;
212
+ _ref$role = _ref.role,
213
+ role = _ref$role === void 0 ? exports.Role.Student : _ref$role;
200
214
  var dispatch = reactRedux.useDispatch();
201
215
  var _useGoogleSignOut = useGoogleSignOut({
202
216
  onNavigate: onNavigate
@@ -222,7 +236,6 @@ var BlockLogin = function BlockLogin(_ref) {
222
236
  token: accessToken,
223
237
  googleId: googleId
224
238
  };
225
- var role = isTeacher ? "Teacher" : "Student";
226
239
  dispatch(setLoading(true));
227
240
  var _temp = _catch(function () {
228
241
  return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
@@ -230,7 +243,7 @@ var BlockLogin = function BlockLogin(_ref) {
230
243
  var tokenJWT = res1.data.token;
231
244
  localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
232
245
  localStorage.setItem(ACCESS_TOKEN, tokenJWT);
233
- if (!isTeacher && isFirstLogin) {
246
+ if (role === exports.Role.Student && isFirstLogin) {
234
247
  onNavigate("/register/info");
235
248
  } else {
236
249
  onNavigate("/");
@@ -349,7 +362,7 @@ var useLogin = function useLogin(onNavigate) {
349
362
 
350
363
  var Login = function Login(_ref) {
351
364
  var onNavigate = _ref.onNavigate,
352
- isTeacher = _ref.isTeacher;
365
+ role = _ref.role;
353
366
  var _useLogin = useLogin(onNavigate),
354
367
  defaultInfo = _useLogin.defaultInfo;
355
368
  return React__default.createElement("div", {
@@ -364,7 +377,7 @@ var Login = function Login(_ref) {
364
377
  }, React__default.createElement(BlockLogin, {
365
378
  defaultInfo: defaultInfo,
366
379
  onNavigate: onNavigate,
367
- isTeacher: isTeacher
380
+ role: role
368
381
  }))));
369
382
  };
370
383
 
@@ -604,11 +617,11 @@ var NotFound = function NotFound() {
604
617
  document.title = TITLE;
605
618
  });
606
619
  return React__default.createElement("div", {
607
- className: "not-found"
620
+ className: "not-found d-flex justify-content-center"
608
621
  }, React__default.createElement("div", {
609
- className: "clearfix"
622
+ className: "clearfix pt-5"
610
623
  }, React__default.createElement("h1", {
611
- className: "float-left display-3 mr-4"
624
+ className: "float-left display-3 fw-bold mr-4 text-center"
612
625
  }, "404"), React__default.createElement("div", {
613
626
  className: "float-left"
614
627
  }, React__default.createElement("h4", {
@@ -663,16 +676,13 @@ var LayoutContext = function LayoutContext(_ref) {
663
676
  var _state$common;
664
677
  return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
665
678
  });
679
+ var roles = (user === null || user === void 0 ? void 0 : user.roles) || [];
666
680
  var resetAuth = function resetAuth() {
667
681
  handleSignOut();
668
682
  };
669
683
  var checkRoleUser = React.useCallback(function () {
670
- var _user$roles, _user$roles2;
671
684
  if (!user) return;
672
- var isAdmin = (_user$roles = user.roles) === null || _user$roles === void 0 ? void 0 : _user$roles.includes("Admin");
673
- if (isAdmin && role !== "Teacher") alert(user.email + " not allow to register " + role);
674
- if (isAdmin) return;
675
- if (!((_user$roles2 = user.roles) !== null && _user$roles2 !== void 0 && _user$roles2.includes(role))) {
685
+ if (!roles.includes(role)) {
676
686
  alert(user.email + " not allow to register " + role);
677
687
  resetAuth();
678
688
  }
@@ -725,19 +735,47 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
725
735
  _ref$title = _ref.title,
726
736
  title = _ref$title === void 0 ? "Confirmation" : _ref$title,
727
737
  toggle = _ref.toggle,
728
- onConfirm = _ref.onConfirm;
738
+ onConfirm = _ref.onConfirm,
739
+ confirmText = _ref.confirmText;
740
+ var _useState = React.useState(),
741
+ confirmTextValue = _useState[0],
742
+ setConfirmTextValue = _useState[1];
743
+ var handleConfirm = function handleConfirm() {
744
+ onConfirm();
745
+ };
746
+ var handleChangeConfirmText = function handleChangeConfirmText(e) {
747
+ setConfirmTextValue(e.target.value);
748
+ };
749
+ var handlePaste = function handlePaste(e) {
750
+ e.preventDefault();
751
+ };
752
+ React.useEffect(function () {
753
+ !open && setConfirmTextValue(undefined);
754
+ }, [open]);
755
+ var isValid = !!confirmText && !!confirmTextValue && confirmTextValue.trim() === confirmText.trim();
729
756
  return React__default.createElement(reactstrap.Modal, {
730
757
  isOpen: open,
731
758
  toggle: toggle,
732
- centered: true
759
+ centered: true,
760
+ zIndex: 1102
733
761
  }, React__default.createElement(reactstrap.ModalHeader, {
734
762
  toggle: toggle
735
- }, title), React__default.createElement(reactstrap.ModalBody, null, text), React__default.createElement(reactstrap.ModalFooter, null, React__default.createElement(reactstrap.Button, {
763
+ }, title), React__default.createElement(reactstrap.ModalBody, null, React__default.createElement("p", null, React__default.createElement("strong", null, text)), !!confirmText && React__default.createElement("div", null, React__default.createElement("p", null, "Enter \"", React__default.createElement("strong", null, confirmText), "\" to confirm delete"), React__default.createElement(reactstrap.Input, {
764
+ value: confirmTextValue,
765
+ onChange: handleChangeConfirmText,
766
+ placeholder: "Please enter...",
767
+ onPaste: handlePaste,
768
+ invalid: !isValid && confirmTextValue !== undefined,
769
+ valid: isValid
770
+ }))), React__default.createElement(reactstrap.ModalFooter, null, React__default.createElement(reactstrap.Button, {
736
771
  color: "secondary",
772
+ className: "px-3",
737
773
  onClick: toggle
738
774
  }, cancelText), React__default.createElement(reactstrap.Button, {
739
775
  color: isDelete ? "danger" : "primary",
740
- onClick: onConfirm
776
+ className: "px-3",
777
+ disabled: !!confirmText && (confirmTextValue === null || confirmTextValue === void 0 ? void 0 : confirmTextValue.trim()) !== confirmText.trim(),
778
+ onClick: handleConfirm
741
779
  }, okText)));
742
780
  };
743
781
 
@@ -755,7 +793,8 @@ var CommonDialog = function CommonDialog(_ref) {
755
793
  isOpen: open,
756
794
  toggle: onClose,
757
795
  centered: centered,
758
- size: size
796
+ size: size,
797
+ zIndex: 1102
759
798
  }, React__default.createElement(reactstrap.ModalHeader, {
760
799
  toggle: onClose
761
800
  }, title), children);
@@ -971,6 +1010,50 @@ var problem = "문제";
971
1010
  var problem_solving_time = "문제풀이 시간";
972
1011
  var minutes = "분";
973
1012
  var correct_rate = "정확한 비율";
1013
+ var title = "시험명";
1014
+ var duration = "시험 시간";
1015
+ var answer_count = "답변 수";
1016
+ var question_count = "문제 갯수";
1017
+ var category = "문항 카테고리";
1018
+ var save_and_exit = "저장 및 종료";
1019
+ var update_exam = "시험 업데이트";
1020
+ var create_exam = "새 시험 만들기";
1021
+ var enter_title = "시험 제목을 입력하세요";
1022
+ var select_placeholder = "선택하다...";
1023
+ var view_exam = "시험 보기";
1024
+ var back = "뒤쪽에";
1025
+ var date_format = "YYYY년 MM월 DD일";
1026
+ var date_time_format = "YYYY-MM-DD HH:mm";
1027
+ var date_time_format_12h = "YYYY-MM-DD HH:mm A";
1028
+ var full_date_time_format = "YYYY년 MMMM Do HH:mm:ss";
1029
+ var total_questions = "총 질문수";
1030
+ var code = "암호";
1031
+ var type = "유형";
1032
+ var description = "설명";
1033
+ var actions = "행위";
1034
+ var start_time = "시작 시간";
1035
+ var end_time = "종료 시간";
1036
+ var start_date = "시작일";
1037
+ var end_date = "종료일";
1038
+ var weekly_day = "주간";
1039
+ var weekly_days = "주간";
1040
+ var enter_class_name = "수업 이름을 입력하세요";
1041
+ var name = "이름";
1042
+ var total_teachers = "총 교사 수";
1043
+ var full_name = "이름";
1044
+ var email = "이메일";
1045
+ var payments = "지불";
1046
+ var view_payments = "결제 보기";
1047
+ var sunday = "일요일";
1048
+ var monday = "월요일";
1049
+ var tuesday = "화요일";
1050
+ var wednesday = "수요일";
1051
+ var thursday = "목요일";
1052
+ var friday = "금요일";
1053
+ var saturday = "토요일";
1054
+ var total_lessons = "총 수업";
1055
+ var weekly_days_required = "평일 필수";
1056
+ var main_teacher = "주 교사";
974
1057
  var lang_ko = {
975
1058
  problem_solving: problem_solving,
976
1059
  my_story: my_story,
@@ -1028,7 +1111,51 @@ var lang_ko = {
1028
1111
  problem: problem,
1029
1112
  problem_solving_time: problem_solving_time,
1030
1113
  minutes: minutes,
1031
- correct_rate: correct_rate
1114
+ correct_rate: correct_rate,
1115
+ title: title,
1116
+ duration: duration,
1117
+ answer_count: answer_count,
1118
+ question_count: question_count,
1119
+ category: category,
1120
+ save_and_exit: save_and_exit,
1121
+ update_exam: update_exam,
1122
+ create_exam: create_exam,
1123
+ enter_title: enter_title,
1124
+ select_placeholder: select_placeholder,
1125
+ view_exam: view_exam,
1126
+ back: back,
1127
+ date_format: date_format,
1128
+ date_time_format: date_time_format,
1129
+ date_time_format_12h: date_time_format_12h,
1130
+ full_date_time_format: full_date_time_format,
1131
+ total_questions: total_questions,
1132
+ code: code,
1133
+ type: type,
1134
+ description: description,
1135
+ actions: actions,
1136
+ start_time: start_time,
1137
+ end_time: end_time,
1138
+ start_date: start_date,
1139
+ end_date: end_date,
1140
+ weekly_day: weekly_day,
1141
+ weekly_days: weekly_days,
1142
+ enter_class_name: enter_class_name,
1143
+ name: name,
1144
+ total_teachers: total_teachers,
1145
+ full_name: full_name,
1146
+ email: email,
1147
+ payments: payments,
1148
+ view_payments: view_payments,
1149
+ sunday: sunday,
1150
+ monday: monday,
1151
+ tuesday: tuesday,
1152
+ wednesday: wednesday,
1153
+ thursday: thursday,
1154
+ friday: friday,
1155
+ saturday: saturday,
1156
+ total_lessons: total_lessons,
1157
+ weekly_days_required: weekly_days_required,
1158
+ main_teacher: main_teacher
1032
1159
  };
1033
1160
 
1034
1161
  var problem_solving$1 = "Problem Solving";
@@ -1088,6 +1215,86 @@ var problem$1 = "Problem ";
1088
1215
  var problem_solving_time$1 = "Problem solving time";
1089
1216
  var minutes$1 = "m";
1090
1217
  var correct_rate$1 = "Correct rate";
1218
+ var difficult_level = "Difficult level";
1219
+ var difficulty_explain = "(The Difficulty Level provides an indication of the difficulty level of each test question)";
1220
+ var explain_your_answer = "Explain your answer";
1221
+ var hint = "Hint";
1222
+ var save_and_add_next_question = "Save and add next question";
1223
+ var save_and_exit$1 = "Save and exit";
1224
+ var question_text = "Question text";
1225
+ var title$1 = "Title";
1226
+ var create_question = "Create question";
1227
+ var parent_question = "Parent question";
1228
+ var edit_question = "Edit question";
1229
+ var easy = "Easy";
1230
+ var intermediate = "Intermediate";
1231
+ var difficult = "Difficult";
1232
+ var article = "Article";
1233
+ var correct_answer = "Correct answer";
1234
+ var mark = "Mark";
1235
+ var answer = "Answer";
1236
+ var add_new_row = "Add new row";
1237
+ var question_text_required = "Question text is required";
1238
+ var create_question_success = "Question is created successfully";
1239
+ var update_question_success = "Question is updated successfully";
1240
+ var number_of_answers = "Number of answers";
1241
+ var correct_answers = "Correct answers";
1242
+ var category$1 = "Category";
1243
+ var score = "Score";
1244
+ var enter_title$1 = "Enter title";
1245
+ var enter_score = "Enter score";
1246
+ var exam_title_required = "Exam title is required";
1247
+ var question_category_required = "Question category is required";
1248
+ var start_time$1 = "Start time";
1249
+ var end_time$1 = "End time";
1250
+ var start_date$1 = "Start date";
1251
+ var end_date$1 = "End date";
1252
+ var weekly_day$1 = "Weekly day";
1253
+ var weekly_days$1 = "Weekly days";
1254
+ var enter_class_name$1 = "Enter class name";
1255
+ var class_required = "Class name is required";
1256
+ var total_teachers$1 = "Total teachers";
1257
+ var start_date_required = "Start date is required";
1258
+ var end_date_required = "End date is required";
1259
+ var full_name$1 = "Full name";
1260
+ var email$1 = "Email";
1261
+ var is_paid = "Is paid";
1262
+ var payment_time = "Payment time";
1263
+ var create_and_continue = "Create and continue";
1264
+ var payments$1 = "Payments";
1265
+ var duration$1 = "Duration";
1266
+ var answer_count$1 = "Answer count";
1267
+ var question_count$1 = "Question count";
1268
+ var multi_choice = "Is multiple";
1269
+ var select_placeholder$1 = "Select...";
1270
+ var view_exam$1 = "View exam";
1271
+ var update_exam$1 = "Update exam";
1272
+ var create_exam$1 = "Create exam";
1273
+ var back$1 = "Back";
1274
+ var date_format$1 = "MM-DD-YYYY";
1275
+ var date_time_format$1 = "MM-DD-YYYY HH:mm";
1276
+ var date_time_format_12h$1 = "MM-DD-YYYY HH:mm A";
1277
+ var full_date_time_format$1 = "MMM Do YYYY HH:mm:ss";
1278
+ var total_questions$1 = "Total questions";
1279
+ var code$1 = "Code";
1280
+ var type$1 = "Type";
1281
+ var description$1 = "Description";
1282
+ var actions$1 = "Actions";
1283
+ var name$1 = "Name";
1284
+ var sunday$1 = "Sunday";
1285
+ var monday$1 = "Monday";
1286
+ var tuesday$1 = "Tuesday";
1287
+ var wednesday$1 = "Wednesday";
1288
+ var thursday$1 = "Thursday";
1289
+ var friday$1 = "Friday";
1290
+ var saturday$1 = "Saturday";
1291
+ var total_lessons$1 = "Total lessons";
1292
+ var is_cancelled = "Is cancelled";
1293
+ var date = "Date";
1294
+ var weekly_days_required$1 = "Weekly days are required";
1295
+ var main_teacher$1 = "Main teacher";
1296
+ var main_teacher_required = "Main teacher is required";
1297
+ var teacher = "Teacher";
1091
1298
  var lang_en = {
1092
1299
  problem_solving: problem_solving$1,
1093
1300
  my_story: my_story$1,
@@ -1145,7 +1352,87 @@ var lang_en = {
1145
1352
  problem: problem$1,
1146
1353
  problem_solving_time: problem_solving_time$1,
1147
1354
  minutes: minutes$1,
1148
- correct_rate: correct_rate$1
1355
+ correct_rate: correct_rate$1,
1356
+ difficult_level: difficult_level,
1357
+ difficulty_explain: difficulty_explain,
1358
+ explain_your_answer: explain_your_answer,
1359
+ hint: hint,
1360
+ save_and_add_next_question: save_and_add_next_question,
1361
+ save_and_exit: save_and_exit$1,
1362
+ question_text: question_text,
1363
+ title: title$1,
1364
+ create_question: create_question,
1365
+ parent_question: parent_question,
1366
+ edit_question: edit_question,
1367
+ easy: easy,
1368
+ intermediate: intermediate,
1369
+ difficult: difficult,
1370
+ article: article,
1371
+ correct_answer: correct_answer,
1372
+ mark: mark,
1373
+ answer: answer,
1374
+ add_new_row: add_new_row,
1375
+ question_text_required: question_text_required,
1376
+ create_question_success: create_question_success,
1377
+ update_question_success: update_question_success,
1378
+ number_of_answers: number_of_answers,
1379
+ correct_answers: correct_answers,
1380
+ category: category$1,
1381
+ score: score,
1382
+ enter_title: enter_title$1,
1383
+ enter_score: enter_score,
1384
+ exam_title_required: exam_title_required,
1385
+ question_category_required: question_category_required,
1386
+ start_time: start_time$1,
1387
+ end_time: end_time$1,
1388
+ start_date: start_date$1,
1389
+ end_date: end_date$1,
1390
+ weekly_day: weekly_day$1,
1391
+ weekly_days: weekly_days$1,
1392
+ enter_class_name: enter_class_name$1,
1393
+ class_required: class_required,
1394
+ total_teachers: total_teachers$1,
1395
+ start_date_required: start_date_required,
1396
+ end_date_required: end_date_required,
1397
+ full_name: full_name$1,
1398
+ email: email$1,
1399
+ is_paid: is_paid,
1400
+ payment_time: payment_time,
1401
+ create_and_continue: create_and_continue,
1402
+ payments: payments$1,
1403
+ duration: duration$1,
1404
+ answer_count: answer_count$1,
1405
+ question_count: question_count$1,
1406
+ multi_choice: multi_choice,
1407
+ select_placeholder: select_placeholder$1,
1408
+ view_exam: view_exam$1,
1409
+ update_exam: update_exam$1,
1410
+ create_exam: create_exam$1,
1411
+ back: back$1,
1412
+ date_format: date_format$1,
1413
+ date_time_format: date_time_format$1,
1414
+ date_time_format_12h: date_time_format_12h$1,
1415
+ full_date_time_format: full_date_time_format$1,
1416
+ total_questions: total_questions$1,
1417
+ code: code$1,
1418
+ type: type$1,
1419
+ description: description$1,
1420
+ actions: actions$1,
1421
+ name: name$1,
1422
+ sunday: sunday$1,
1423
+ monday: monday$1,
1424
+ tuesday: tuesday$1,
1425
+ wednesday: wednesday$1,
1426
+ thursday: thursday$1,
1427
+ friday: friday$1,
1428
+ saturday: saturday$1,
1429
+ total_lessons: total_lessons$1,
1430
+ is_cancelled: is_cancelled,
1431
+ date: date,
1432
+ weekly_days_required: weekly_days_required$1,
1433
+ main_teacher: main_teacher$1,
1434
+ main_teacher_required: main_teacher_required,
1435
+ teacher: teacher
1149
1436
  };
1150
1437
 
1151
1438
  i18n.use(reactI18next.initReactI18next).init({
@@ -1164,28 +1451,27 @@ i18n.use(reactI18next.initReactI18next).init({
1164
1451
  }
1165
1452
  });
1166
1453
 
1167
- var DEFAULT_LANGUAGE_CODE = "ko";
1454
+ var DEFAULT_LANGUAGE_INDEX = 0;
1168
1455
  var LANGUAGES = [{
1169
1456
  code: "ko",
1170
1457
  fullName: "Korean",
1171
1458
  shortName: "Korean",
1172
1459
  nativeName: "Korean",
1173
1460
  name: "Korean",
1174
- image: "/images/korea.png"
1461
+ image: "/images/korea.png",
1462
+ momentLangCode: "ko"
1175
1463
  }, {
1176
1464
  code: "en",
1177
1465
  fullName: "English",
1178
1466
  shortName: "English",
1179
1467
  nativeName: "English",
1180
1468
  name: "English",
1181
- image: "/images/usa.png"
1469
+ image: "/images/usa.png",
1470
+ momentLangCode: "en-au"
1182
1471
  }];
1183
- var SUPPORTED_LANGUAGES_CODE = LANGUAGES.map(function (i) {
1184
- return i.code;
1185
- });
1186
1472
 
1187
- var TheLanguageDropdown = function TheLanguageDropdown() {
1188
- var defaultLanguage = !!localStorage.getItem("language") ? localStorage.getItem("language") : navigator.language || DEFAULT_LANGUAGE_CODE;
1473
+ var useLanguage = function useLanguage() {
1474
+ var defaultLanguage = !!localStorage.getItem("language") ? localStorage.getItem("language") : navigator.language || LANGUAGES[DEFAULT_LANGUAGE_INDEX].code;
1189
1475
  var dispatch = reactRedux.useDispatch();
1190
1476
  var _useTranslation = reactI18next.useTranslation(),
1191
1477
  i18n = _useTranslation.i18n;
@@ -1201,25 +1487,42 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
1201
1487
  });
1202
1488
  };
1203
1489
  var changeLanguageApp = function changeLanguageApp(lang) {
1204
- if (!SUPPORTED_LANGUAGES_CODE.includes(lang)) lang = DEFAULT_LANGUAGE_CODE;
1205
- i18n.changeLanguage(lang);
1206
- localStorage.setItem("language", lang);
1207
- setItemLanguage(lang);
1208
- dispatch(setLanguage(lang));
1490
+ var language = LANGUAGES.find(function (i) {
1491
+ return i.code === lang;
1492
+ });
1493
+ if (!language) language = LANGUAGES[DEFAULT_LANGUAGE_INDEX];
1494
+ i18n.changeLanguage(language.code);
1495
+ moment.locale(language.momentLangCode);
1496
+ localStorage.setItem("language", language.code);
1497
+ setItemLanguage(language.code);
1498
+ dispatch(setLanguage(language.code));
1209
1499
  };
1500
+ React.useEffect(function () {
1501
+ changeLanguageApp(language);
1502
+ }, [language]);
1210
1503
  var currentLanguage = React.useMemo(function () {
1211
1504
  var currentLang = LANGUAGES.find(function (i) {
1212
1505
  return i.code === language;
1213
1506
  });
1214
1507
  if (!currentLang) return null;
1215
- return React__default.createElement(React__default.Fragment, null, React__default.createElement("img", {
1216
- className: "mr-2 " + styles['dropdown-menu-flag'],
1217
- src: currentLang.image
1218
- }), " ", currentLang.shortName);
1219
- }, [language]);
1220
- React.useEffect(function () {
1221
- changeLanguageApp(language);
1508
+ return currentLang;
1222
1509
  }, [language]);
1510
+ return {
1511
+ language: language,
1512
+ dropdownOpen: dropdownOpen,
1513
+ currentLanguage: currentLanguage,
1514
+ toggle: toggle,
1515
+ setItemLanguage: setItemLanguage
1516
+ };
1517
+ };
1518
+
1519
+ var TheLanguageDropdown = function TheLanguageDropdown() {
1520
+ var _useLanguage = useLanguage(),
1521
+ currentLanguage = _useLanguage.currentLanguage,
1522
+ language = _useLanguage.language,
1523
+ dropdownOpen = _useLanguage.dropdownOpen,
1524
+ toggle = _useLanguage.toggle,
1525
+ setItemLanguage = _useLanguage.setItemLanguage;
1223
1526
  return React__default.createElement(reactstrap.Dropdown, {
1224
1527
  isOpen: dropdownOpen,
1225
1528
  toggle: toggle,
@@ -1233,7 +1536,10 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
1233
1536
  display: 'flex',
1234
1537
  alignItems: 'center'
1235
1538
  }
1236
- }, currentLanguage, React__default.createElement(io5.IoChevronDown, {
1539
+ }, !!currentLanguage && React__default.createElement("img", {
1540
+ className: "mr-2 " + styles['dropdown-menu-flag'],
1541
+ src: currentLanguage.image
1542
+ }), !!currentLanguage && currentLanguage.shortName, React__default.createElement(io5.IoChevronDown, {
1237
1543
  className: "ml-2",
1238
1544
  style: {
1239
1545
  fontSize: '15px',
@@ -1317,14 +1623,54 @@ function _objectWithoutPropertiesLoose(source, excluded) {
1317
1623
  return target;
1318
1624
  }
1319
1625
 
1320
- var _excluded = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
1626
+ var _excluded = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
1627
+ var DropdownIndicator = function DropdownIndicator(props) {
1628
+ return React__default.createElement(Select.components.DropdownIndicator, Object.assign({}, props), React__default.createElement(fa.FaCaretDown, {
1629
+ color: "#5458D5"
1630
+ }));
1631
+ };
1632
+ var CustomOption = function CustomOption(props) {
1633
+ return React__default.createElement(Select.components.Option, Object.assign({}, props), React__default.createElement("div", {
1634
+ style: {
1635
+ fontSize: "14px",
1636
+ fontWeight: 500
1637
+ }
1638
+ }, props.data.label));
1639
+ };
1640
+ var customStyles = {
1641
+ control: function control(baseStyles, state) {
1642
+ return _extends({}, baseStyles, {
1643
+ fontSize: "14px",
1644
+ fontWeight: 700,
1645
+ color: "#5458D5",
1646
+ borderColor: state.isFocused ? '#5458D5' : '#C3C5FE'
1647
+ });
1648
+ },
1649
+ input: function input(baseStyles, _) {
1650
+ return _extends({}, baseStyles, {
1651
+ fontSize: "14px",
1652
+ fontWeight: 700,
1653
+ color: "#5458D5"
1654
+ });
1655
+ },
1656
+ singleValue: function singleValue(baseStyles) {
1657
+ return _extends({}, baseStyles, {
1658
+ fontSize: "14px",
1659
+ fontWeight: 700,
1660
+ color: "#5458D5"
1661
+ });
1662
+ }
1663
+ };
1321
1664
  var CustomSelect = function CustomSelect(_ref) {
1322
- var options = _ref.options,
1665
+ var isDefault = _ref.isDefault,
1666
+ options = _ref.options,
1323
1667
  isDisabled = _ref.isDisabled,
1324
1668
  scrollBottom = _ref.scrollBottom,
1325
1669
  value = _ref.value,
1326
1670
  isMulti = _ref.isMulti,
1327
1671
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1672
+ var _useTranslation = reactI18next.useTranslation(),
1673
+ t = _useTranslation.t;
1328
1674
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
1329
1675
  return value.includes(i.value);
1330
1676
  }) : isMulti ? options.filter(function (i) {
@@ -1332,12 +1678,22 @@ var CustomSelect = function CustomSelect(_ref) {
1332
1678
  }) : options.find(function (i) {
1333
1679
  return i.value == value;
1334
1680
  });
1335
- return React__default.createElement(Select, Object.assign({
1681
+ return React__default.createElement(Select__default, Object.assign({
1336
1682
  isDisabled: isDisabled,
1337
1683
  options: options,
1338
- value: initialValues,
1684
+ value: !isDefault ? initialValues != null ? initialValues : null : undefined,
1685
+ defaultValue: isDefault ? initialValues : undefined,
1339
1686
  menuPlacement: scrollBottom ? "top" : "auto",
1340
- isMulti: isMulti
1687
+ isMulti: isMulti,
1688
+ components: {
1689
+ IndicatorSeparator: function IndicatorSeparator() {
1690
+ return null;
1691
+ },
1692
+ DropdownIndicator: DropdownIndicator,
1693
+ Option: CustomOption
1694
+ },
1695
+ styles: customStyles,
1696
+ placeholder: t("select_placeholder")
1341
1697
  }, rest));
1342
1698
  };
1343
1699
 
@@ -1409,6 +1765,8 @@ var ChatRightItem = function ChatRightItem(_ref) {
1409
1765
  var _useState2 = React.useState(false),
1410
1766
  isShowInfo = _useState2[0],
1411
1767
  setShowInfo = _useState2[1];
1768
+ var _useTranslation = reactI18next.useTranslation(),
1769
+ t = _useTranslation.t;
1412
1770
  var handleShowInfo = function handleShowInfo() {
1413
1771
  setShowInfo(!isShowInfo);
1414
1772
  !isFirst && !isSystemLog && setShowTime(!isShowInfo);
@@ -1441,12 +1799,12 @@ var ChatRightItem = function ChatRightItem(_ref) {
1441
1799
  }
1442
1800
  }, "Add message to exam")), isSystemLog || !!isFirst ? React__default.createElement("p", {
1443
1801
  className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1444
- }, utcToLocalTime(createdAt, "HH:mm DD MMM YYYY")) : React__default.createElement(reactstrap.Collapse, {
1802
+ }, utcToLocalTime(createdAt, t("date_time_format"))) : React__default.createElement(reactstrap.Collapse, {
1445
1803
  className: "w-100",
1446
1804
  isOpen: isShowTime
1447
1805
  }, React__default.createElement("p", {
1448
1806
  className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1449
- }, utcToLocalTime(createdAt, "HH:mm DD MMM YYYY"))), isSystemLog ? React__default.createElement("div", {
1807
+ }, utcToLocalTime(createdAt, t("date_time_format")))), isSystemLog ? React__default.createElement("div", {
1450
1808
  className: "text-center w-100"
1451
1809
  }, React__default.createElement(reactRouterDom.Link, {
1452
1810
  to: "" + (actionLink || "/"),
@@ -1503,6 +1861,8 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
1503
1861
  var _useState2 = React.useState(false),
1504
1862
  isShowInfo = _useState2[0],
1505
1863
  setShowInfo = _useState2[1];
1864
+ var _useTranslation = reactI18next.useTranslation(),
1865
+ t = _useTranslation.t;
1506
1866
  var handleShowInfo = function handleShowInfo() {
1507
1867
  if (!id) return;
1508
1868
  setShowInfo(!isShowInfo);
@@ -1531,12 +1891,12 @@ var ChatLeftItem = function ChatLeftItem(_ref) {
1531
1891
  }
1532
1892
  }, "Add message to exam")), isSystemLog || !!isFirst ? React__default.createElement("p", {
1533
1893
  className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1534
- }, utcToLocalTime(createdAt, "HH:mm DD MMM YYYY")) : React__default.createElement(reactstrap.Collapse, {
1894
+ }, utcToLocalTime(createdAt, t("date_time_format"))) : React__default.createElement(reactstrap.Collapse, {
1535
1895
  className: "w-100",
1536
1896
  isOpen: isShowTime
1537
1897
  }, React__default.createElement("p", {
1538
1898
  className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1539
- }, utcToLocalTime(createdAt, "HH:mm DD MMM YYYY"))), isSystemLog ? React__default.createElement("div", {
1899
+ }, utcToLocalTime(createdAt, t("date_time_format")))), isSystemLog ? React__default.createElement("div", {
1540
1900
  className: "text-center w-100"
1541
1901
  }, React__default.createElement(reactRouterDom.Link, {
1542
1902
  to: "" + (actionLink || "/"),
@@ -1688,9 +2048,16 @@ var ChatHeader = function ChatHeader(_ref) {
1688
2048
  var name = _ref.name,
1689
2049
  avatar = _ref.avatar,
1690
2050
  options = _ref.options,
2051
+ selectedOption = _ref.selectedOption,
1691
2052
  onChangeOption = _ref.onChangeOption;
1692
2053
  var wrapperRef = React.useRef(null);
1693
2054
  var actionRef = React.useRef(null);
2055
+ var language = reactRedux.useSelector(function (state) {
2056
+ var _state$common;
2057
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.language;
2058
+ });
2059
+ var _useTranslation = reactI18next.useTranslation(),
2060
+ t = _useTranslation.t;
1694
2061
  var handleChangeOption = function handleChangeOption(val) {
1695
2062
  onChangeOption === null || onChangeOption === void 0 ? void 0 : onChangeOption(val);
1696
2063
  };
@@ -1707,10 +2074,10 @@ var ChatHeader = function ChatHeader(_ref) {
1707
2074
  return options === null || options === void 0 ? void 0 : options.map(function (i) {
1708
2075
  return {
1709
2076
  value: i.id,
1710
- label: i.title + " (" + utcToLocalTime(i.startTime) + ")"
2077
+ label: i.title + " (" + utcToLocalTime(i.startTime, t("date_time_format")) + ")"
1711
2078
  };
1712
2079
  });
1713
- }, [JSON.stringify(options)]);
2080
+ }, [JSON.stringify(options), language]);
1714
2081
  return React__default.createElement("div", {
1715
2082
  className: "d-flex bg-light rounded-3 p-3"
1716
2083
  }, React__default.createElement("div", null, React__default.createElement("img", {
@@ -1726,6 +2093,7 @@ var ChatHeader = function ChatHeader(_ref) {
1726
2093
  }, selectOptions !== undefined && React__default.createElement("div", {
1727
2094
  className: styles$1["header__select"] + " mx-3"
1728
2095
  }, React__default.createElement(CustomSelect, {
2096
+ value: selectedOption,
1729
2097
  options: selectOptions,
1730
2098
  onChange: handleChangeOption,
1731
2099
  isClearable: true
@@ -1843,7 +2211,7 @@ var ChatContainer = function ChatContainer(_ref) {
1843
2211
  onAddExamMessage: handleAddExamMessage
1844
2212
  }))), React__default.createElement("div", null, React__default.createElement(InputChat, Object.assign({}, inputProps, {
1845
2213
  inputRef: inputRef
1846
- }))), React__default.createElement(reactToastify.ToastContainer, null));
2214
+ }))));
1847
2215
  };
1848
2216
 
1849
2217
  var CONVERSATION_URL = BASE_URL + "/api/conversation";
@@ -1960,13 +2328,14 @@ var useMessageList = function useMessageList(userId, getListExamOptions) {
1960
2328
  examId: !examId ? messageFilter.examId : examId
1961
2329
  });
1962
2330
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
2331
+ var _res$data$items2;
1963
2332
  function _temp(_getListExamOptions) {
1964
2333
  _getListExamOptions;
1965
2334
  }
1966
- setMessages(function (state) {
2335
+ if (messageFilter.beforeDate) setMessages(function (state) {
1967
2336
  var _res$data$items;
1968
2337
  return [].concat(((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse()) || [], state);
1969
- });
2338
+ });else setMessages((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse());
1970
2339
  return getListExamOptions ? Promise.resolve(!!getListExamOptions && getListExamOptions(userId)).then(_temp) : _temp(!!getListExamOptions && getListExamOptions(userId));
1971
2340
  });
1972
2341
  }, function (error) {
@@ -2398,6 +2767,7 @@ var useChatContainer = function useChatContainer(props) {
2398
2767
  name: userName,
2399
2768
  avatar: userAvatar,
2400
2769
  options: exams,
2770
+ selectedOption: messageFilter.examId,
2401
2771
  onChangeOption: handleFilterExam
2402
2772
  },
2403
2773
  chatListProps: {
@@ -2563,9 +2933,12 @@ var useConversationList = function useConversationList() {
2563
2933
  return i.id === lastMessage.conversationId;
2564
2934
  });
2565
2935
  if (updateIndex < 0) return state;
2566
- return [].concat(state.slice(0, updateIndex), [_extends({}, state[updateIndex], {
2936
+ console.log({
2567
2937
  lastMessage: lastMessage
2568
- })], state.slice(updateIndex + 1));
2938
+ });
2939
+ return [_extends({}, state[updateIndex], {
2940
+ lastMessage: lastMessage
2941
+ })].concat(state.slice(0, updateIndex), state.slice(updateIndex + 1));
2569
2942
  });
2570
2943
  };
2571
2944
  var handleCreateConversationSuccess = function handleCreateConversationSuccess(id) {
@@ -2654,8 +3027,538 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
2654
3027
  return {};
2655
3028
  };
2656
3029
 
3030
+ var _excluded$1 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3031
+ var CustomCreatable = function CustomCreatable(_ref) {
3032
+ var options = _ref.options,
3033
+ isDisabled = _ref.isDisabled,
3034
+ scrollBottom = _ref.scrollBottom,
3035
+ value = _ref.value,
3036
+ isMulti = _ref.isMulti,
3037
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
3038
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
3039
+ return value.includes(i.value);
3040
+ }) : isMulti ? options.filter(function (i) {
3041
+ return i.value == value;
3042
+ }) : options.find(function (i) {
3043
+ return i.value == value;
3044
+ });
3045
+ return React__default.createElement(CreatableSelect, Object.assign({
3046
+ isClearable: true,
3047
+ isDisabled: isDisabled,
3048
+ options: options,
3049
+ value: initialValues,
3050
+ menuPlacement: scrollBottom ? "top" : "auto",
3051
+ isMulti: isMulti
3052
+ }, rest));
3053
+ };
3054
+
3055
+ var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3056
+ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3057
+ var isDefault = _ref.isDefault,
3058
+ options = _ref.options,
3059
+ isDisabled = _ref.isDisabled,
3060
+ scrollBottom = _ref.scrollBottom,
3061
+ value = _ref.value,
3062
+ isMulti = _ref.isMulti,
3063
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3064
+ var initialValues = Array.isArray(value) ? options.filter(function (i) {
3065
+ return value.includes(i.value);
3066
+ }) : isMulti ? options.filter(function (i) {
3067
+ return i.value == value;
3068
+ }) : options.find(function (i) {
3069
+ return i.value == value;
3070
+ });
3071
+ return React__default.createElement(Select__default, Object.assign({
3072
+ isDisabled: isDisabled,
3073
+ options: options,
3074
+ value: !isDefault ? initialValues : undefined,
3075
+ defaultValue: isDefault ? initialValues : undefined,
3076
+ menuPlacement: scrollBottom ? "top" : "auto",
3077
+ isMulti: isMulti
3078
+ }, rest));
3079
+ };
3080
+
3081
+ var styles$2 = {"question":"_2uc_W","question-article":"_2p7kY","question-title":"_2tHmc","question--active":"_3IHYm","question-label":"_26ATj","question-input":"_3R8PR","question-btn":"_1VZac"};
3082
+
3083
+ var DURATION_OPTIONS = Array.from({
3084
+ length: 120
3085
+ }, function (_, i) {
3086
+ return i + 1;
3087
+ });
3088
+ var SCORE_OPTIONS = Array.from({
3089
+ length: 10
3090
+ }, function (_, i) {
3091
+ return i + 1;
3092
+ });
3093
+ var QUESTION_OPTIONS = Array.from({
3094
+ length: 40
3095
+ }, function (_, i) {
3096
+ return i + 1;
3097
+ });
3098
+ var ANSWER_OPTIONS = Array.from({
3099
+ length: 9
3100
+ }, function (_, i) {
3101
+ return i + 2;
3102
+ });
3103
+ var DEFAULT_SCORE = 2;
3104
+ var DEFAULT_ANSWER_COUNT = 5;
3105
+
3106
+ var QuestionView = function QuestionView(_ref) {
3107
+ var index = _ref.index,
3108
+ question = _ref.question,
3109
+ answerCount = _ref.answerCount,
3110
+ isDisabled = _ref.isDisabled,
3111
+ onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
3112
+ onChangeScoreAnswer = _ref.onChangeScoreAnswer;
3113
+ var scoreOptions = SCORE_OPTIONS.map(function (i) {
3114
+ return {
3115
+ label: DEFAULT_SCORE === i ? i + "\uC810 (\uAE30\uBCF8\uAC12)" : i + "\uC810",
3116
+ value: i
3117
+ };
3118
+ });
3119
+ return React__default.createElement("div", {
3120
+ className: "d-flex justify-content-between"
3121
+ }, React__default.createElement("div", {
3122
+ className: "d-flex flex-grow-1"
3123
+ }, React__default.createElement("div", {
3124
+ className: styles$2["question-title"] + " me-2"
3125
+ }, "\uBB38\uC81C ", question.questionOrder + 1, "\uBC88"), React__default.createElement("div", {
3126
+ className: "d-flex flex-grow-1"
3127
+ }, Array.from({
3128
+ length: answerCount
3129
+ }, function (_, i) {
3130
+ return i + 1;
3131
+ }).map(function (i) {
3132
+ return React__default.createElement(reactstrap.FormGroup, {
3133
+ className: "d-flex flex-column px-4"
3134
+ }, React__default.createElement(reactstrap.Label, {
3135
+ htmlFor: "answer-" + i,
3136
+ className: "" + styles$2["question-label"]
3137
+ }, i, "\uBC88"), React__default.createElement(reactstrap.Input, {
3138
+ id: "answer-" + i,
3139
+ type: "radio",
3140
+ checked: question.correctAnswers.includes(i),
3141
+ onClick: function onClick() {
3142
+ return onChangeCorrectAnswers(i, index);
3143
+ },
3144
+ disabled: isDisabled
3145
+ }));
3146
+ }))), React__default.createElement("div", {
3147
+ className: "d-flex align-items-center"
3148
+ }, React__default.createElement(reactstrap.FormGroup, {
3149
+ className: "mx-3",
3150
+ style: {
3151
+ width: "140px"
3152
+ }
3153
+ }, React__default.createElement(CustomSelect, {
3154
+ value: question.score,
3155
+ options: scoreOptions,
3156
+ onChange: function onChange(value) {
3157
+ return onChangeScoreAnswer(value.value, index);
3158
+ },
3159
+ isDisabled: isDisabled
3160
+ }))));
3161
+ };
3162
+
3163
+ var ArticleGroupView = function ArticleGroupView(_ref) {
3164
+ var categoryOptions = _ref.categoryOptions,
3165
+ article = _ref.article,
3166
+ questions = _ref.questions,
3167
+ answerCount = _ref.answerCount,
3168
+ questionCount = _ref.questionCount,
3169
+ categoryId = _ref.categoryId,
3170
+ isActive = _ref.isActive,
3171
+ isDisabled = _ref.isDisabled,
3172
+ onChangeQuestionCount = _ref.onChangeQuestionCount,
3173
+ onChangeCategory = _ref.onChangeCategory,
3174
+ onChangeAnswerCount = _ref.onChangeAnswerCount,
3175
+ onChangeCorrectAnswers = _ref.onChangeCorrectAnswers,
3176
+ onChangeScoreAnswer = _ref.onChangeScoreAnswer;
3177
+ var _useTranslation = reactI18next.useTranslation(),
3178
+ t = _useTranslation.t;
3179
+ var handleChangeQuestionCount = function handleChangeQuestionCount(value) {
3180
+ onChangeQuestionCount(article, value === null || value === void 0 ? void 0 : value.value, answerCount);
3181
+ };
3182
+ var handleChangeCategory = function handleChangeCategory(value) {
3183
+ onChangeCategory(article, value === null || value === void 0 ? void 0 : value.value);
3184
+ };
3185
+ var handleChangeAnswerCount = function handleChangeAnswerCount(value) {
3186
+ onChangeAnswerCount(article, value === null || value === void 0 ? void 0 : value.value, answerCount);
3187
+ };
3188
+ var handleChangeCorrectAnswers = function handleChangeCorrectAnswers(value, index) {
3189
+ onChangeCorrectAnswers(article, index, value);
3190
+ };
3191
+ var handleChangeScoreAnswer = function handleChangeScoreAnswer(value, index) {
3192
+ onChangeScoreAnswer(article, index, value);
3193
+ };
3194
+ var questionOptions = QUESTION_OPTIONS.map(function (i) {
3195
+ return {
3196
+ label: i + "\uAC1C",
3197
+ value: i
3198
+ };
3199
+ });
3200
+ var answerOptions = ANSWER_OPTIONS.map(function (i) {
3201
+ return {
3202
+ label: i + "\uBC88",
3203
+ value: i
3204
+ };
3205
+ });
3206
+ return React__default.createElement("div", {
3207
+ className: "d-flex " + styles$2["question"] + " " + (isActive ? styles$2["question--active"] : "")
3208
+ }, React__default.createElement("div", {
3209
+ className: "py-1"
3210
+ }, React__default.createElement(pi.PiDotsNineLight, {
3211
+ size: 18
3212
+ })), React__default.createElement("div", {
3213
+ className: "px-4"
3214
+ }, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
3215
+ xs: 12
3216
+ }, React__default.createElement("p", {
3217
+ className: "mb-0 " + styles$2["question-article"]
3218
+ }, "\uBB38\uD56D"), React__default.createElement("p", {
3219
+ className: "text-center " + styles$2["question-article"]
3220
+ }, article)))), React__default.createElement("div", {
3221
+ className: "flex-grow-1"
3222
+ }, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
3223
+ xs: 3
3224
+ }, React__default.createElement(reactstrap.FormGroup, null, React__default.createElement(reactstrap.Label, {
3225
+ htmlFor: "question_count",
3226
+ className: "" + styles$2["question-label"]
3227
+ }, t("question_count")), React__default.createElement(CustomSelect, {
3228
+ inputId: "question_count",
3229
+ value: questionCount,
3230
+ options: questionOptions,
3231
+ onChange: handleChangeQuestionCount,
3232
+ isDisabled: isDisabled
3233
+ }))), React__default.createElement(reactstrap.Col, {
3234
+ xs: 3
3235
+ }, React__default.createElement(reactstrap.FormGroup, null, React__default.createElement(reactstrap.Label, {
3236
+ htmlFor: "category",
3237
+ className: "" + styles$2["question-label"]
3238
+ }, t("category")), React__default.createElement(CustomSelect, {
3239
+ inputId: "category",
3240
+ value: categoryId,
3241
+ options: categoryOptions,
3242
+ onChange: handleChangeCategory,
3243
+ isDisabled: isDisabled
3244
+ }))), React__default.createElement(reactstrap.Col, {
3245
+ xs: 3
3246
+ }, React__default.createElement(reactstrap.FormGroup, null, React__default.createElement(reactstrap.Label, {
3247
+ htmlFor: "answer_count",
3248
+ className: "" + styles$2["question-label"]
3249
+ }, t("answer_count")), React__default.createElement(CustomSelect, {
3250
+ inputId: "answer_count",
3251
+ value: answerCount,
3252
+ options: answerOptions,
3253
+ onChange: handleChangeAnswerCount,
3254
+ isDisabled: isDisabled
3255
+ }))), React__default.createElement(reactstrap.Col, {
3256
+ xs: 3
3257
+ })), React__default.createElement("div", null, questions.map(function (q, index) {
3258
+ return React__default.createElement(QuestionView, {
3259
+ key: index,
3260
+ question: q,
3261
+ answerCount: answerCount,
3262
+ index: index,
3263
+ onChangeCorrectAnswers: handleChangeCorrectAnswers,
3264
+ onChangeScoreAnswer: handleChangeScoreAnswer,
3265
+ isDisabled: isDisabled
3266
+ });
3267
+ }))));
3268
+ };
3269
+
3270
+ var useExamDetailView = function useExamDetailView(props) {
3271
+ var exam = props.exam,
3272
+ onChangeExam = props.onChangeExam;
3273
+ var _useTranslation = reactI18next.useTranslation(),
3274
+ t = _useTranslation.t;
3275
+ var handleChangeQuestionCount = function handleChangeQuestionCount(article, questionCount, answerCount) {
3276
+ if (!exam) return;
3277
+ var examQuestions = exam.questions;
3278
+ var questions = examQuestions.filter(function (i) {
3279
+ return i.article === +article;
3280
+ });
3281
+ var prevQuestions = examQuestions.filter(function (i) {
3282
+ return i.article < +article;
3283
+ });
3284
+ var nextQuestions = examQuestions.filter(function (i) {
3285
+ return i.article > +article;
3286
+ });
3287
+ var lastOrder = questions[questions.length - 1].questionOrder;
3288
+ if (questions.length === questionCount) return;
3289
+ if (questions.length < questionCount) {
3290
+ var additionalQuestions = Array.from({
3291
+ length: questionCount - questions.length
3292
+ }).map(function (_, index) {
3293
+ var _questions$;
3294
+ return {
3295
+ article: +article,
3296
+ correctAnswers: [1],
3297
+ numberOfAnswers: answerCount,
3298
+ categoryId: (_questions$ = questions[0]) === null || _questions$ === void 0 ? void 0 : _questions$.categoryId,
3299
+ score: DEFAULT_SCORE,
3300
+ questionOrder: lastOrder + index + 1
3301
+ };
3302
+ });
3303
+ var newQuestions = [].concat(prevQuestions, questions, additionalQuestions, nextQuestions.map(function (i) {
3304
+ return _extends({}, i, {
3305
+ questionOrder: i.questionOrder + questionCount - questions.length
3306
+ });
3307
+ }));
3308
+ onChangeExam(_extends({}, exam, {
3309
+ questions: [].concat(newQuestions)
3310
+ }));
3311
+ } else {
3312
+ var remainQuestions = questions.slice(0, questionCount);
3313
+ var _newQuestions = [].concat(prevQuestions, remainQuestions, nextQuestions.map(function (i) {
3314
+ return _extends({}, i, {
3315
+ questionOrder: i.questionOrder - questions.length + questionCount
3316
+ });
3317
+ }));
3318
+ onChangeExam(_extends({}, exam, {
3319
+ questions: [].concat(_newQuestions)
3320
+ }));
3321
+ }
3322
+ };
3323
+ var handleChangeCategory = function handleChangeCategory(article, categoryId) {
3324
+ if (!exam) return;
3325
+ var examQuestions = exam.questions;
3326
+ var questions = examQuestions.filter(function (i) {
3327
+ return i.article === +article;
3328
+ });
3329
+ var otherQuestions = examQuestions.filter(function (i) {
3330
+ return i.article !== +article;
3331
+ });
3332
+ onChangeExam(_extends({}, exam, {
3333
+ questions: [].concat(otherQuestions, questions.map(function (q) {
3334
+ return _extends({}, q, {
3335
+ categoryId: categoryId
3336
+ });
3337
+ }))
3338
+ }));
3339
+ };
3340
+ var handleChangeAnswerCount = function handleChangeAnswerCount(article, newAnswerCount, answerCount) {
3341
+ if (!exam) return;
3342
+ if (newAnswerCount === answerCount) return;
3343
+ var examQuestions = exam.questions;
3344
+ var questions = examQuestions.filter(function (i) {
3345
+ return i.article === +article;
3346
+ });
3347
+ var otherQuestions = examQuestions.filter(function (i) {
3348
+ return i.article !== +article;
3349
+ });
3350
+ if (answerCount < newAnswerCount) {
3351
+ onChangeExam(_extends({}, exam, {
3352
+ questions: [].concat(otherQuestions, questions.map(function (q) {
3353
+ return _extends({}, q, {
3354
+ numberOfAnswers: newAnswerCount
3355
+ });
3356
+ }))
3357
+ }));
3358
+ } else {
3359
+ onChangeExam(_extends({}, exam, {
3360
+ questions: [].concat(otherQuestions, questions.map(function (q) {
3361
+ return _extends({}, q, {
3362
+ numberOfAnswers: newAnswerCount,
3363
+ correctAnswers: q.correctAnswers.filter(function (i) {
3364
+ return i <= newAnswerCount;
3365
+ })
3366
+ });
3367
+ }))
3368
+ }));
3369
+ }
3370
+ };
3371
+ var handleChangeCorrectAnswers = function handleChangeCorrectAnswers(article, index, answer) {
3372
+ if (!exam) return;
3373
+ var examQuestions = exam.questions;
3374
+ var questions = examQuestions.filter(function (i) {
3375
+ return i.article === +article;
3376
+ });
3377
+ var otherQuestions = examQuestions.filter(function (i) {
3378
+ return i.article !== +article;
3379
+ });
3380
+ var selectedQuestion = questions[index];
3381
+ onChangeExam(_extends({}, exam, {
3382
+ questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
3383
+ correctAnswers: [answer]
3384
+ })], questions.slice(index + 1))
3385
+ }));
3386
+ };
3387
+ var handleChangeScoreAnswer = function handleChangeScoreAnswer(article, index, score) {
3388
+ if (!exam) return;
3389
+ var examQuestions = exam.questions;
3390
+ var questions = examQuestions.filter(function (i) {
3391
+ return i.article === +article;
3392
+ });
3393
+ var otherQuestions = examQuestions.filter(function (i) {
3394
+ return i.article !== +article;
3395
+ });
3396
+ var selectedQuestion = questions[index];
3397
+ if (score === selectedQuestion.score) return;
3398
+ onChangeExam(_extends({}, exam, {
3399
+ questions: [].concat(otherQuestions, questions.slice(0, index), [_extends({}, selectedQuestion, {
3400
+ score: score
3401
+ })], questions.slice(index + 1))
3402
+ }));
3403
+ };
3404
+ var handleChangeDuration = function handleChangeDuration(value) {
3405
+ if (!exam) return;
3406
+ onChangeExam(_extends({}, exam, {
3407
+ duration: value === null || value === void 0 ? void 0 : value.value
3408
+ }));
3409
+ };
3410
+ var handleChangeTitle = function handleChangeTitle(e) {
3411
+ if (!exam) return;
3412
+ onChangeExam(_extends({}, exam, {
3413
+ title: e.target.value
3414
+ }));
3415
+ };
3416
+ var handleAddArticle = function handleAddArticle() {
3417
+ var _$maxBy, _$maxBy2;
3418
+ if (!exam) return;
3419
+ var maxArticle = ((_$maxBy = _.maxBy(exam.questions, "article")) === null || _$maxBy === void 0 ? void 0 : _$maxBy.article) || 0;
3420
+ var maxOrder = ((_$maxBy2 = _.maxBy(exam.questions, "questionOrder")) === null || _$maxBy2 === void 0 ? void 0 : _$maxBy2.questionOrder) || 0;
3421
+ onChangeExam(_extends({}, exam, {
3422
+ questions: [].concat(exam.questions, [{
3423
+ article: maxArticle + 1,
3424
+ correctAnswers: [1],
3425
+ numberOfAnswers: DEFAULT_ANSWER_COUNT,
3426
+ score: DEFAULT_SCORE,
3427
+ questionOrder: maxOrder + 1
3428
+ }])
3429
+ }));
3430
+ };
3431
+ var examGroupByArticle = React.useMemo(function () {
3432
+ if (!exam) return [];
3433
+ var articles = [];
3434
+ var groupedArticle = _.groupBy(exam.questions, "article");
3435
+ for (var key in groupedArticle) {
3436
+ if (Object.prototype.hasOwnProperty.call(groupedArticle, key)) {
3437
+ var _questions$find, _$maxBy3;
3438
+ var questions = groupedArticle[key];
3439
+ articles.push({
3440
+ article: +key,
3441
+ categoryId: (_questions$find = questions.find(function (i) {
3442
+ return !!i.categoryId;
3443
+ })) === null || _questions$find === void 0 ? void 0 : _questions$find.categoryId,
3444
+ answerCount: ((_$maxBy3 = _.maxBy(questions, "numberOfAnswers")) === null || _$maxBy3 === void 0 ? void 0 : _$maxBy3.numberOfAnswers) || DEFAULT_ANSWER_COUNT,
3445
+ questionCount: questions.length,
3446
+ questions: questions
3447
+ });
3448
+ }
3449
+ }
3450
+ return _.sortBy(articles, "article");
3451
+ }, [JSON.stringify(exam)]);
3452
+ var durationOptions = React.useMemo(function () {
3453
+ var options = DURATION_OPTIONS.map(function (i) {
3454
+ return {
3455
+ label: i + "\uBD84",
3456
+ value: i
3457
+ };
3458
+ });
3459
+ if (!!exam.duration && exam.duration > DURATION_OPTIONS[DURATION_OPTIONS.length - 1]) return [].concat(options, [{
3460
+ label: exam.duration + "\uBD84",
3461
+ value: exam.duration
3462
+ }]);
3463
+ return options;
3464
+ }, [exam.duration]);
3465
+ return {
3466
+ t: t,
3467
+ durationOptions: durationOptions,
3468
+ examGroupByArticle: examGroupByArticle,
3469
+ handleAddArticle: handleAddArticle,
3470
+ handleChangeScoreAnswer: handleChangeScoreAnswer,
3471
+ handleChangeTitle: handleChangeTitle,
3472
+ handleChangeDuration: handleChangeDuration,
3473
+ handleChangeCorrectAnswers: handleChangeCorrectAnswers,
3474
+ handleChangeAnswerCount: handleChangeAnswerCount,
3475
+ handleChangeQuestionCount: handleChangeQuestionCount,
3476
+ handleChangeCategory: handleChangeCategory
3477
+ };
3478
+ };
3479
+
3480
+ var ExamDetailView = function ExamDetailView(_ref) {
3481
+ var _ref$className = _ref.className,
3482
+ className = _ref$className === void 0 ? "" : _ref$className,
3483
+ categoryOptions = _ref.categoryOptions,
3484
+ exam = _ref.exam,
3485
+ _ref$isUsingMui = _ref.isUsingMui,
3486
+ isUsingMui = _ref$isUsingMui === void 0 ? true : _ref$isUsingMui,
3487
+ isDisabled = _ref.isDisabled,
3488
+ onChangeExam = _ref.onChangeExam;
3489
+ var _useExamDetailView = useExamDetailView({
3490
+ exam: exam,
3491
+ onChangeExam: onChangeExam
3492
+ }),
3493
+ t = _useExamDetailView.t,
3494
+ durationOptions = _useExamDetailView.durationOptions,
3495
+ examGroupByArticle = _useExamDetailView.examGroupByArticle,
3496
+ handleAddArticle = _useExamDetailView.handleAddArticle,
3497
+ handleChangeScoreAnswer = _useExamDetailView.handleChangeScoreAnswer,
3498
+ handleChangeTitle = _useExamDetailView.handleChangeTitle,
3499
+ handleChangeDuration = _useExamDetailView.handleChangeDuration,
3500
+ handleChangeCorrectAnswers = _useExamDetailView.handleChangeCorrectAnswers,
3501
+ handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
3502
+ handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
3503
+ handleChangeCategory = _useExamDetailView.handleChangeCategory;
3504
+ return React__default.createElement(reactstrap.Row, {
3505
+ className: "" + className
3506
+ }, React__default.createElement(reactstrap.Col, {
3507
+ xs: 5
3508
+ }, React__default.createElement(reactstrap.FormGroup, null, React__default.createElement(reactstrap.Label, {
3509
+ className: "" + styles$2["question-label"],
3510
+ htmlFor: "title"
3511
+ }, t("title")), React__default.createElement(reactstrap.Input, {
3512
+ disabled: isDisabled,
3513
+ className: "w-100 rounded-2 " + styles$2["question-input"],
3514
+ value: exam.title,
3515
+ id: "title",
3516
+ placeholder: t("enter_title"),
3517
+ onChange: handleChangeTitle
3518
+ }))), React__default.createElement(reactstrap.Col, {
3519
+ xs: 3
3520
+ }, React__default.createElement(reactstrap.FormGroup, null, React__default.createElement(reactstrap.Label, {
3521
+ className: "" + styles$2["question-label"],
3522
+ htmlFor: "duration"
3523
+ }, t("duration")), React__default.createElement(CustomSelect, {
3524
+ inputId: "duration",
3525
+ value: exam.duration,
3526
+ options: durationOptions,
3527
+ onChange: handleChangeDuration,
3528
+ isDisabled: isDisabled
3529
+ }))), React__default.createElement(reactstrap.Col, {
3530
+ xs: 4
3531
+ }), examGroupByArticle.map(function (i, index) {
3532
+ return React__default.createElement(reactstrap.Col, {
3533
+ xs: 12,
3534
+ key: i.article,
3535
+ className: (index === 0 && !isUsingMui ? "mt-3" : "") + " " + (!isUsingMui ? "mb-4" : "")
3536
+ }, React__default.createElement(ArticleGroupView, Object.assign({}, i, {
3537
+ categoryOptions: categoryOptions,
3538
+ isActive: index === examGroupByArticle.length - 1,
3539
+ onChangeQuestionCount: handleChangeQuestionCount,
3540
+ onChangeCategory: handleChangeCategory,
3541
+ onChangeAnswerCount: handleChangeAnswerCount,
3542
+ onChangeCorrectAnswers: handleChangeCorrectAnswers,
3543
+ onChangeScoreAnswer: handleChangeScoreAnswer,
3544
+ isDisabled: isDisabled
3545
+ })));
3546
+ }), React__default.createElement(reactstrap.Col, {
3547
+ xs: 12
3548
+ }, React__default.createElement(reactstrap.Button, {
3549
+ disabled: isDisabled,
3550
+ className: "w-100 d-flex justify-content-center align-items-center " + styles$2["question-btn"],
3551
+ color: "primary",
3552
+ outline: true,
3553
+ onClick: handleAddArticle
3554
+ }, React__default.createElement(fa.FaPlusCircle, {
3555
+ className: "me-2"
3556
+ }), "\uBB38\uD56D \uCD94\uAC00\uD558\uAE30")));
3557
+ };
3558
+
2657
3559
  var historyCore = history.createBrowserHistory();
2658
3560
 
3561
+ exports.moment = moment;
2659
3562
  Object.defineProperty(exports, 'I18nextProvider', {
2660
3563
  enumerable: true,
2661
3564
  get: function () {
@@ -2668,17 +3571,34 @@ Object.defineProperty(exports, 'useTranslation', {
2668
3571
  return reactI18next.useTranslation;
2669
3572
  }
2670
3573
  });
3574
+ Object.defineProperty(exports, 'ToastContainer', {
3575
+ enumerable: true,
3576
+ get: function () {
3577
+ return reactToastify.ToastContainer;
3578
+ }
3579
+ });
3580
+ Object.defineProperty(exports, 'toast', {
3581
+ enumerable: true,
3582
+ get: function () {
3583
+ return reactToastify.toast;
3584
+ }
3585
+ });
2671
3586
  exports.ACCESS_TOKEN = ACCESS_TOKEN;
2672
3587
  exports.BASE_URL = BASE_URL;
2673
3588
  exports.ChatContainer = ChatContainer;
2674
3589
  exports.CommonAlert = CommonAlert;
2675
3590
  exports.CommonDialog = CommonDialog;
2676
3591
  exports.ConfirmDialog = ConfirmDialog;
3592
+ exports.CustomAsyncSelect = CustomAsyncSelect;
3593
+ exports.CustomCreatable = CustomCreatable;
2677
3594
  exports.CustomPagination = CustomPagination;
2678
3595
  exports.CustomSelect = CustomSelect;
2679
3596
  exports.DATE_MIN_VALUE = DATE_MIN_VALUE;
3597
+ exports.DATE_TIME_MIN_VALUE = DATE_TIME_MIN_VALUE;
2680
3598
  exports.EXAM_CHANNEL = EXAM_CHANNEL;
2681
3599
  exports.EXAM_STUDENT_CHANNEL = EXAM_STUDENT_CHANNEL;
3600
+ exports.ExamDetailView = ExamDetailView;
3601
+ exports.LANGUAGES = LANGUAGES;
2682
3602
  exports.LayoutContext = LayoutContext;
2683
3603
  exports.Loading = Loading;
2684
3604
  exports.Login = Login;
@@ -2702,6 +3622,7 @@ exports.toISOString = toISOString;
2702
3622
  exports.useChatContainer = useChatContainer;
2703
3623
  exports.useConversationList = useConversationList;
2704
3624
  exports.useGoogleSignOut = useGoogleSignOut;
3625
+ exports.useLanguage = useLanguage;
2705
3626
  exports.usePusherConversation = usePusherConversation;
2706
3627
  exports.utcToLocalTime = utcToLocalTime;
2707
3628
  //# sourceMappingURL=index.js.map