touchstudy-core 0.1.13 → 0.1.15

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.
Files changed (42) hide show
  1. package/dist/assets/iconChatBubble.d.ts +3 -0
  2. package/dist/assets/iconChecked.d.ts +3 -0
  3. package/dist/assets/iconPersonActive.d.ts +3 -0
  4. package/dist/assets/iconPersonNoActive.d.ts +3 -0
  5. package/dist/assets/iconSendMessenger.d.ts +4 -0
  6. package/dist/components/Chats/ChatContainer.d.ts +0 -1
  7. package/dist/components/Chats/ChatHeader.d.ts +9 -6
  8. package/dist/components/Chats/ChatItem.d.ts +6 -21
  9. package/dist/components/Chats/ChatList.d.ts +1 -2
  10. package/dist/components/Chats/ChatRightItem.d.ts +1 -5
  11. package/dist/components/Chats/InputChat.d.ts +6 -3
  12. package/dist/components/Chats/apiClient/conversationService.d.ts +2 -0
  13. package/dist/components/Chats/configs/constants.d.ts +5 -0
  14. package/dist/components/Chats/configs/types.d.ts +79 -15
  15. package/dist/components/Chats/hooks/useChatContainer.d.ts +20 -25
  16. package/dist/components/Chats/hooks/useDialog.d.ts +6 -0
  17. package/dist/components/Chats/hooks/useMessageList.d.ts +3 -5
  18. package/dist/containers/Login/apiClient/index.d.ts +0 -1
  19. package/dist/containers/Login/views/Login.d.ts +3 -0
  20. package/dist/containers/Login/views/block/BlockLogin.d.ts +3 -0
  21. package/dist/index.css +349 -0
  22. package/dist/index.d.ts +12 -8
  23. package/dist/index.js +1652 -1225
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.modern.js +1631 -1214
  26. package/dist/index.modern.js.map +1 -1
  27. package/dist/layouts/TheAcademyDropdown.d.ts +10 -0
  28. package/dist/redux/commons/action.d.ts +1 -0
  29. package/dist/services/academyService.d.ts +3 -0
  30. package/dist/services/accountService.d.ts +5 -0
  31. package/dist/utils/constants.d.ts +11 -7
  32. package/dist/utils/hooks/index.d.ts +3 -0
  33. package/dist/utils/hooks/useAutoAcademyDomain.d.ts +2 -0
  34. package/dist/utils/{useGoogleSignOut.d.ts → hooks/useGoogleSignOut.d.ts} +1 -1
  35. package/dist/utils/{useLanguage.d.ts → hooks/useLanguage.d.ts} +1 -1
  36. package/dist/utils/hooks/useLogin.d.ts +7 -0
  37. package/dist/utils/hooks/useSwitchAcademy.d.ts +10 -0
  38. package/dist/utils/types/academy.d.ts +6 -0
  39. package/dist/utils/types/login.d.ts +33 -0
  40. package/package.json +2 -1
  41. package/dist/components/Chats/hooks/useConversationList.d.ts +0 -20
  42. package/dist/components/Chats/hooks/useExamList.d.ts +0 -6
@@ -3,26 +3,26 @@ import { createAction, createReducer, configureStore } from '@reduxjs/toolkit';
3
3
  import moment from 'moment';
4
4
  export { default as moment } from 'moment';
5
5
  import React, { useState, useCallback, useEffect, Fragment, useRef, useMemo } from 'react';
6
- import { Row, Col, Form, Modal, ModalHeader, ModalBody, Input, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Collapse, InputGroup, Spinner, FormGroup, Label } from 'reactstrap';
6
+ import { Row, Col, Form, Modal, ModalHeader, ModalBody, Input, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, FormGroup, Label } from 'reactstrap';
7
7
  import { Formik } from 'formik';
8
8
  import { object, string, boolean } from 'yup';
9
9
  import GoogleLogin, { useGoogleLogout } from '@leecheuk/react-google-login';
10
- import axios from 'axios';
11
10
  import { useDispatch, useSelector } from 'react-redux';
11
+ import axios from 'axios';
12
+ import { useTranslation, initReactI18next } from 'react-i18next';
13
+ export { I18nextProvider, useTranslation } from 'react-i18next';
12
14
  import { gapi } from 'gapi-script';
13
15
  import i18n from 'i18next';
14
- import { initReactI18next, useTranslation } from 'react-i18next';
15
- export { I18nextProvider, useTranslation } from 'react-i18next';
16
- import { IoChevronDown } from 'react-icons/io5';
16
+ import { IoChevronDown, IoCloseOutline } from 'react-icons/io5';
17
17
  import 'moment/locale/ko.js';
18
18
  import 'moment/locale/en-au.js';
19
- import Select, { components } from 'react-select';
20
- import { FaCaretDown, FaPlusCircle } from 'react-icons/fa';
21
- import { Link } from 'react-router-dom';
22
- import { IoIosCloseCircle, IoMdSend } from 'react-icons/io';
23
- import Pusher from 'pusher-js';
19
+ import { GoArrowSwitch } from 'react-icons/go';
24
20
  import { toast } from 'react-toastify';
25
21
  export { ToastContainer, toast } from 'react-toastify';
22
+ import Select, { components } from 'react-select';
23
+ import { FaCaretDown, FaImage, FaPlusCircle } from 'react-icons/fa';
24
+ import { Typography, Grid, Box, Button as Button$1, CircularProgress } from '@mui/material';
25
+ import Pusher from 'pusher-js';
26
26
  import CreatableSelect from 'react-select/creatable';
27
27
  import { PiDotsNineLight } from 'react-icons/pi';
28
28
  import _ from 'lodash';
@@ -32,20 +32,23 @@ var setAlert = createAction("common/setAlert");
32
32
  var setUser = createAction("common/setUser");
33
33
  var setLanguage = createAction("common/setLanguage");
34
34
  var reset = createAction("common/reset");
35
-
36
- var isLocalHost = Boolean(window.location.hostname === "localhost" || window.location.hostname === "[::1]" || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));
37
-
38
- var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
35
+ var setReFetchUserAcademies = createAction("common/setReFetchUserAcademies");
36
+
37
+ var GOOGLE_RECAPTCHA_KEY = process.env.REACT_APP_GOOGLE_RECAPTCHA_KEY || "";
38
+ var GOOGLE_CLIENT_ID = process.env.REACT_APP_GOOGLE_CLIENT_ID || "";
39
+ var GOOGLE_RECAPTCHA_ID = process.env.REACT_APP_GOOGLE_RECAPTCHA_ID || "";
40
+ var GOOGLE_RECAPTCHA_SECRET = process.env.REACT_APP_GOOGLE_RECAPTCHA_SECRET || "";
41
+ var BASE_URL = process.env.REACT_APP_BASE_URL || "";
42
+ var SUPER_ADMIN_BASE_URL = process.env.REACT_APP_SUPER_ADMIN_BASE_URL || "";
43
+ var PUSHER_CONFIG = {
44
+ cluster: process.env.REACT_APP_PUSHER_CONFIG_CLUSTER || "",
45
+ key: process.env.REACT_APP_PUSHER_CONFIG_KEY || ""
46
+ };
39
47
  var ACCESS_TOKEN = "ACCESS_TOKEN";
48
+ var ACADEMY_DOMAIN = "ACADEMY_DOMAIN";
49
+ var AcademyHeaders = "Academy-Headers";
40
50
  var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
41
51
  var DATE_TIME_MIN_VALUE = "0001-01-01T00:00:00";
42
- var BASE_URL = function () {
43
- return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
44
- }();
45
- var PUSHER_CONFIG = {
46
- cluster: "ap1",
47
- key: "9018c77328885a14150b"
48
- };
49
52
  var EXAM_CHANNEL = "presence-exam-channel";
50
53
  var EXAM_STUDENT_CHANNEL = "EXAM-CHANNEL-{examCode}-STUDENT-{studentId}";
51
54
  var getAccessToken = function getAccessToken() {
@@ -55,6 +58,13 @@ var getAccessToken = function getAccessToken() {
55
58
  return null;
56
59
  }
57
60
  };
61
+ var getAcademyDomain = function getAcademyDomain() {
62
+ try {
63
+ return localStorage.getItem(ACADEMY_DOMAIN);
64
+ } catch (err) {
65
+ return null;
66
+ }
67
+ };
58
68
  var encodeParams = function encodeParams(params) {
59
69
  return Object.keys(params).filter(function (key) {
60
70
  return params[key] || params[key] === 0 || params[key] === false;
@@ -77,6 +87,47 @@ var utcToLocalTime = (function (time, FORMAT) {
77
87
  }
78
88
  });
79
89
 
90
+ function _extends() {
91
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
92
+ for (var i = 1; i < arguments.length; i++) {
93
+ var source = arguments[i];
94
+ for (var key in source) {
95
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
96
+ target[key] = source[key];
97
+ }
98
+ }
99
+ }
100
+ return target;
101
+ };
102
+ return _extends.apply(this, arguments);
103
+ }
104
+ function _objectWithoutPropertiesLoose(source, excluded) {
105
+ if (source == null) return {};
106
+ var target = {};
107
+ var sourceKeys = Object.keys(source);
108
+ var key, i;
109
+ for (i = 0; i < sourceKeys.length; i++) {
110
+ key = sourceKeys[i];
111
+ if (excluded.indexOf(key) >= 0) continue;
112
+ target[key] = source[key];
113
+ }
114
+ return target;
115
+ }
116
+
117
+ var stylesGlobal = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","dropdown-academy":"_3CMVp","image-academy":"_2ibYC","academy-btn":"_1JMRU","switch-icon":"_N4FNf","dropdown-content-academy":"_31Dr0","dropdown-academy-item":"_3bjcz","noGutters":"_31ZQk","custom-col-2":"_3yXyK","custom-col-3":"_1RsJQ","custom-col-5":"_L42CP","custom-col-10":"_2u6eL","custom-row":"_8x7OP","custom-col":"_1JmTh","custom-col-4":"_3HO1e","custom-col-8":"_Oy31M","custom-col-12":"_3aUKo","custom-container":"_39LRs","form-label":"__Ut-u","form-control":"_2k4dX","btn-outline-primary":"_2PWdX"};
118
+
119
+ var AuthenticationMessage;
120
+ (function (AuthenticationMessage) {
121
+ AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
122
+ AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
123
+ })(AuthenticationMessage || (AuthenticationMessage = {}));
124
+ var Role;
125
+ (function (Role) {
126
+ Role["Student"] = "Student";
127
+ Role["Teacher"] = "Teacher";
128
+ Role["Admin"] = "Admin";
129
+ })(Role || (Role = {}));
130
+
80
131
  // A type of promise-like that resolves synchronously and supports only one observer
81
132
 
82
133
  const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
@@ -96,7 +147,18 @@ function _catch(body, recover) {
96
147
  return result;
97
148
  }
98
149
 
99
- var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi"};
150
+ // Asynchronously await a promise and invoke a finally continuation that always overrides the result
151
+ function _finally(body, finalizer) {
152
+ try {
153
+ var result = body();
154
+ } catch (e) {
155
+ return finalizer();
156
+ }
157
+ if (result && result.then) {
158
+ return result.then(finalizer, finalizer);
159
+ }
160
+ return finalizer();
161
+ }
100
162
 
101
163
  var api = axios.create({
102
164
  baseURL: BASE_URL,
@@ -118,10 +180,17 @@ var apiUpload = axios.create({
118
180
  [api, apiUpload].forEach(function (i) {
119
181
  return i.interceptors.request.use(function (config) {
120
182
  var token = getAccessToken();
183
+ var searchParams = new URLSearchParams(window.location.search);
184
+ var paramDomain = searchParams.get('domain');
185
+ var academyDomainStorage = getAcademyDomain();
186
+ var academyDomain = paramDomain || academyDomainStorage;
121
187
  if (token) {
122
188
  config.headers.Authorization = "Bearer " + token;
123
189
  localStorage.setItem("LAST_TIME_REQUETST", moment().utc().format("YYYY-MM-DD HH:mm:ss"));
124
190
  }
191
+ if (academyDomain && !config.headers[AcademyHeaders]) {
192
+ config.headers[AcademyHeaders] = "" + academyDomain;
193
+ }
125
194
  return config;
126
195
  }, function (error) {
127
196
  return Promise.reject(error);
@@ -135,33 +204,34 @@ var apiUpload = axios.create({
135
204
  console.log({
136
205
  error: error
137
206
  });
138
- if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
139
- window.location.href = "/login";
140
- }
141
- if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) == 403) {
207
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401 || ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) == 403) {
142
208
  localStorage.removeItem(ACCESS_TOKEN);
143
- localStorage.removeItem("USER_EMAIL");
144
209
  window.location.href = "/login";
145
210
  }
146
211
  return Promise.reject(error);
147
212
  });
148
213
  });
149
214
 
150
- var apiLoginGoogle = function apiLoginGoogle(body, role) {
151
- return api.post(BASE_URL + "/api/auth/" + role + "/login", body);
215
+ var AUTH_URL = BASE_URL + "/api/auth";
216
+ var AUTH_SUPER_ADMIN_URL = SUPER_ADMIN_BASE_URL + "/api/auth";
217
+ var getInfo = function getInfo() {
218
+ return api.get(AUTH_URL + "/info");
219
+ };
220
+ var getSuperAdminInfoFromWeb = function getSuperAdminInfoFromWeb() {
221
+ return api.get(AUTH_SUPER_ADMIN_URL + "/info");
222
+ };
223
+ var apiLoginGoogle = function apiLoginGoogle(body) {
224
+ return api.post(AUTH_URL + "/login", body);
225
+ };
226
+ var apiLoginGoogleSuperAdmin = function apiLoginGoogleSuperAdmin(body) {
227
+ return api.post(AUTH_SUPER_ADMIN_URL + "/login", body);
228
+ };
229
+ var apiLoginWithAccessToken = function apiLoginWithAccessToken(body, domain) {
230
+ var _headers;
231
+ return api.post(AUTH_URL + "/login/access-token", body, {
232
+ headers: (_headers = {}, _headers[AcademyHeaders] = domain, _headers)
233
+ });
152
234
  };
153
-
154
- var AuthenticationMessage;
155
- (function (AuthenticationMessage) {
156
- AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
157
- AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
158
- })(AuthenticationMessage || (AuthenticationMessage = {}));
159
- var Role;
160
- (function (Role) {
161
- Role["Student"] = "Student";
162
- Role["Teacher"] = "Teacher";
163
- Role["Admin"] = "Admin";
164
- })(Role || (Role = {}));
165
235
 
166
236
  var useGoogleSignOut = function useGoogleSignOut(props) {
167
237
  var dispatch = useDispatch();
@@ -180,9 +250,15 @@ var useGoogleSignOut = function useGoogleSignOut(props) {
180
250
  }),
181
251
  signOut = _useGoogleLogout.signOut,
182
252
  loaded = _useGoogleLogout.loaded;
183
- var handleSignOut = function handleSignOut() {
253
+ var handleSignOut = function handleSignOut(isRemoveDomainStorage) {
254
+ if (isRemoveDomainStorage === void 0) {
255
+ isRemoveDomainStorage = false;
256
+ }
184
257
  localStorage.removeItem("USER_INFORMATION");
185
258
  localStorage.removeItem(ACCESS_TOKEN);
259
+ if (isRemoveDomainStorage) {
260
+ localStorage.removeItem(ACADEMY_DOMAIN);
261
+ }
186
262
  try {
187
263
  signOut();
188
264
  } catch (error) {
@@ -199,7 +275,120 @@ var useGoogleSignOut = function useGoogleSignOut(props) {
199
275
  };
200
276
  };
201
277
 
202
- var ERROR_MESSAGE = "Login fail!";
278
+ var ERROR_MESSAGE = "request_login_fail";
279
+ var useLogin = function useLogin(onNavigate, homeAcademyUrl, homeUrl, registerUrl) {
280
+ var dispatch = useDispatch();
281
+ var _useTranslation = useTranslation(),
282
+ t = _useTranslation.t;
283
+ var _useGoogleSignOut = useGoogleSignOut({
284
+ onNavigate: onNavigate
285
+ }),
286
+ handleSignOut = _useGoogleSignOut.handleSignOut;
287
+ var searchParams = new URLSearchParams(window.location.search);
288
+ var paramDomain = searchParams.get('domain');
289
+ var handleLoginGoogle = function handleLoginGoogle(data, isLogout) {
290
+ if (isLogout === void 0) {
291
+ isLogout = true;
292
+ }
293
+ try {
294
+ var academyDomain = paramDomain || getAcademyDomain();
295
+ var isStudent = data.role === Role.Student;
296
+ return Promise.resolve(handleLogin(function () {
297
+ return new Promise(function (resolve, reject) {
298
+ try {
299
+ var _temp = _catch(function () {
300
+ return Promise.resolve(academyDomain ? apiLoginGoogle(data) : apiLoginGoogleSuperAdmin(data)).then(function (loginResponse) {
301
+ var result = loginResponse.data;
302
+ resolve(result);
303
+ });
304
+ }, function (error) {
305
+ !!academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
306
+ reject(error);
307
+ });
308
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
309
+ } catch (e) {
310
+ return Promise.reject(e);
311
+ }
312
+ });
313
+ }, isStudent, isLogout)).then(function () {});
314
+ } catch (e) {
315
+ return Promise.reject(e);
316
+ }
317
+ };
318
+ var handleLoginAccessToken = function handleLoginAccessToken(data, isLogout, domain) {
319
+ if (isLogout === void 0) {
320
+ isLogout = true;
321
+ }
322
+ try {
323
+ var isStudent = data.role === Role.Student;
324
+ return Promise.resolve(handleLogin(function () {
325
+ return new Promise(function (resolve, reject) {
326
+ try {
327
+ var _temp2 = _catch(function () {
328
+ return Promise.resolve(apiLoginWithAccessToken(data, domain)).then(function (loginResponse) {
329
+ var result = loginResponse.data;
330
+ resolve(result);
331
+ });
332
+ }, function (error) {
333
+ reject(error);
334
+ });
335
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
336
+ } catch (e) {
337
+ return Promise.reject(e);
338
+ }
339
+ });
340
+ }, isStudent, isLogout)).then(function () {});
341
+ } catch (e) {
342
+ return Promise.reject(e);
343
+ }
344
+ };
345
+ var handleLogin = function handleLogin(apiLogin, isStudent, isLogout) {
346
+ if (isLogout === void 0) {
347
+ isLogout = true;
348
+ }
349
+ try {
350
+ var _temp4 = function _temp4() {
351
+ dispatch(setLoading(false));
352
+ };
353
+ dispatch(setLoading(true));
354
+ var _temp3 = _catch(function () {
355
+ return Promise.resolve(apiLogin()).then(function (loginResponse) {
356
+ var isFirstLogin = loginResponse.isFirstLogin,
357
+ token = loginResponse.token,
358
+ user = loginResponse.user;
359
+ var isAcademy = !!(user !== null && user !== void 0 && user.academyDomain);
360
+ var needToRegister = isStudent && isFirstLogin && isAcademy;
361
+ var redirectUrl = needToRegister ? registerUrl : isAcademy ? homeAcademyUrl : homeUrl;
362
+ redirectLoginUser(user, token, redirectUrl);
363
+ });
364
+ }, function (error) {
365
+ var _error$response, _error$response$data, _error$response2, _error$response2$data, _error$response3;
366
+ var message = undefined;
367
+ message = t((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || (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) || (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE);
368
+ message && alert(message);
369
+ isLogout && handleSignOut();
370
+ });
371
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
372
+ } catch (e) {
373
+ return Promise.reject(e);
374
+ }
375
+ };
376
+ var redirectLoginUser = function redirectLoginUser(data, token, redirectUrl) {
377
+ localStorage.setItem(ACCESS_TOKEN, token);
378
+ !data.academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
379
+ !!data.academyDomain && localStorage.setItem(ACADEMY_DOMAIN, data.academyDomain);
380
+ dispatch(setUser(_extends({}, data)));
381
+ if (redirectUrl) {
382
+ onNavigate(redirectUrl);
383
+ }
384
+ };
385
+ return {
386
+ handleLoginGoogle: handleLoginGoogle,
387
+ handleLoginAccessToken: handleLoginAccessToken,
388
+ redirectLoginUser: redirectLoginUser
389
+ };
390
+ };
391
+
203
392
  var schema = object({
204
393
  email: string().email("Email is invalid").required("Email is required"),
205
394
  password: string().required("Password is required"),
@@ -209,65 +398,32 @@ var BlockLogin = function BlockLogin(_ref) {
209
398
  var defaultInfo = _ref.defaultInfo,
210
399
  onNavigate = _ref.onNavigate,
211
400
  _ref$role = _ref.role,
212
- role = _ref$role === void 0 ? Role.Student : _ref$role;
213
- var dispatch = useDispatch();
214
- var _useGoogleSignOut = useGoogleSignOut({
215
- onNavigate: onNavigate
216
- }),
217
- handleSignOut = _useGoogleSignOut.handleSignOut;
401
+ role = _ref$role === void 0 ? Role.Student : _ref$role,
402
+ homeAcademyUrl = _ref.homeAcademyUrl,
403
+ homeUrl = _ref.homeUrl,
404
+ registerUrl = _ref.registerUrl;
405
+ var _useLogin = useLogin(onNavigate, homeAcademyUrl, homeUrl, registerUrl),
406
+ handleLoginGoogle = _useLogin.handleLoginGoogle;
218
407
  var onSuccessGoogle = function onSuccessGoogle(res) {
219
408
  try {
220
- var _temp3 = function () {
221
- if (!!(res !== null && res !== void 0 && res.accessToken)) {
222
- var _temp2 = function _temp2() {
223
- dispatch(setLoading(false));
224
- };
225
- var _res$profileObj = res.profileObj,
226
- email = _res$profileObj.email,
227
- imageUrl = _res$profileObj.imageUrl,
228
- name = _res$profileObj.name;
229
- var accessToken = res.tokenObj.id_token;
230
- var googleId = res.googleId;
231
- var infoLogin = {
232
- imageUrl: imageUrl,
233
- fullName: name,
234
- email: email,
235
- token: accessToken,
236
- googleId: googleId
237
- };
238
- dispatch(setLoading(true));
239
- var _temp = _catch(function () {
240
- return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
241
- var isFirstLogin = res1.data.isFirstLogin;
242
- var tokenJWT = res1.data.token;
243
- localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
244
- localStorage.setItem(ACCESS_TOKEN, tokenJWT);
245
- if (role === Role.Student && isFirstLogin) {
246
- onNavigate("/register/info");
247
- } else {
248
- onNavigate("/");
249
- }
250
- });
251
- }, function (error) {
252
- var _error$response, _error$response$data;
253
- var message = undefined;
254
- var type = error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.type;
255
- if (type === AuthenticationMessage.NotAllowedToRegister) {
256
- alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
257
- } else if (type) {
258
- var _error$response2, _error$response2$data;
259
- message = (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.message) || ERROR_MESSAGE;
260
- } else {
261
- var _error$response3;
262
- message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
263
- }
264
- message && alert(message);
265
- handleSignOut();
266
- });
267
- return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
268
- }
269
- }();
270
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
409
+ if (!!(res !== null && res !== void 0 && res.accessToken)) {
410
+ var _res$profileObj = res.profileObj,
411
+ email = _res$profileObj.email,
412
+ imageUrl = _res$profileObj.imageUrl,
413
+ name = _res$profileObj.name;
414
+ var accessToken = res.tokenObj.id_token;
415
+ var googleId = res.googleId;
416
+ var infoLogin = {
417
+ imageUrl: imageUrl,
418
+ fullName: name,
419
+ email: email,
420
+ token: accessToken,
421
+ googleId: googleId,
422
+ role: role
423
+ };
424
+ handleLoginGoogle(infoLogin);
425
+ }
426
+ return Promise.resolve();
271
427
  } catch (e) {
272
428
  return Promise.reject(e);
273
429
  }
@@ -283,17 +439,17 @@ var BlockLogin = function BlockLogin(_ref) {
283
439
  }, function (formikProps) {
284
440
  var handleSubmit = formikProps.handleSubmit;
285
441
  return React.createElement(Row, {
286
- className: "" + styles["box-login"]
442
+ className: "" + stylesGlobal["box-login"]
287
443
  }, React.createElement(Col, {
288
444
  className: "p-0 d-flex justify-content-center"
289
445
  }, React.createElement(Form, {
290
- className: "" + styles["block-login"],
446
+ className: "" + stylesGlobal["block-login"],
291
447
  onSubmit: handleSubmit
292
448
  }, React.createElement("div", {
293
- className: "" + styles["block-form"]
449
+ className: "" + stylesGlobal["block-form"]
294
450
  }, React.createElement("img", {
295
451
  src: "/images/logo.jpeg",
296
- className: "" + styles["img-login-rectangle"]
452
+ className: "" + stylesGlobal["img-login-rectangle"]
297
453
  }), React.createElement(Col, {
298
454
  className: "p-0 mt-1 mb-4"
299
455
  }, React.createElement(GoogleLogin, {
@@ -302,7 +458,7 @@ var BlockLogin = function BlockLogin(_ref) {
302
458
  onSuccess: onSuccessGoogle,
303
459
  onFailure: onFailureGoogle,
304
460
  cookiePolicy: "single_host_origin",
305
- className: "" + styles["btn-login-google"],
461
+ className: "" + stylesGlobal["btn-login-google"],
306
462
  isSignedIn: true
307
463
  }))))));
308
464
  });
@@ -322,7 +478,7 @@ var defaultInfo = {
322
478
  captcha: "",
323
479
  rememberMe: false
324
480
  };
325
- var useLogin = function useLogin(onNavigate) {
481
+ var useLogin$1 = function useLogin(onNavigate) {
326
482
  var _useState = useState(false),
327
483
  openLogin = _useState[0],
328
484
  setOpenLogin = _useState[1];
@@ -359,13 +515,14 @@ var useLogin = function useLogin(onNavigate) {
359
515
  };
360
516
  };
361
517
 
518
+ var _excluded = ["onNavigate"];
362
519
  var Login = function Login(_ref) {
363
520
  var onNavigate = _ref.onNavigate,
364
- role = _ref.role;
365
- var _useLogin = useLogin(onNavigate),
521
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
522
+ var _useLogin = useLogin$1(onNavigate),
366
523
  defaultInfo = _useLogin.defaultInfo;
367
524
  return React.createElement("div", {
368
- className: styles["login"] + " container-fluid font-family-lato"
525
+ className: stylesGlobal["login"] + " container-fluid font-family-lato"
369
526
  }, React.createElement(Row, {
370
527
  className: "h-100"
371
528
  }, React.createElement(Col, {
@@ -373,11 +530,10 @@ var Login = function Login(_ref) {
373
530
  md: 12,
374
531
  xs: 12,
375
532
  className: "d-flex justify-content-center h-100 align-items-center"
376
- }, React.createElement(BlockLogin, {
533
+ }, React.createElement(BlockLogin, Object.assign({
377
534
  defaultInfo: defaultInfo,
378
- onNavigate: onNavigate,
379
- role: role
380
- }))));
535
+ onNavigate: onNavigate
536
+ }, rest)))));
381
537
  };
382
538
 
383
539
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -582,7 +738,8 @@ var initialState = {
582
738
  type: "",
583
739
  message: ""
584
740
  },
585
- user: null
741
+ user: null,
742
+ isReFetchUserAcademies: false
586
743
  };
587
744
  var commonReducer = createReducer(initialState, function (builder) {
588
745
  builder.addCase(setLoading, function (state, action) {
@@ -595,6 +752,8 @@ var commonReducer = createReducer(initialState, function (builder) {
595
752
  state.language = action.payload;
596
753
  }).addCase(reset, function (_state, _action) {
597
754
  return initialState;
755
+ }).addCase(setReFetchUserAcademies, function (state, action) {
756
+ state.isReFetchUserAcademies = action.payload;
598
757
  });
599
758
  });
600
759
 
@@ -658,11 +817,6 @@ var Loading = function Loading() {
658
817
  }))) : null;
659
818
  };
660
819
 
661
- var AUTH_URL = BASE_URL + "/api/auth";
662
- var getInfo = function getInfo() {
663
- return api.get(AUTH_URL + "/info");
664
- };
665
-
666
820
  var LayoutContext = function LayoutContext(_ref) {
667
821
  var children = _ref.children,
668
822
  role = _ref.role,
@@ -671,6 +825,8 @@ var LayoutContext = function LayoutContext(_ref) {
671
825
  onNavigate: onNavigate
672
826
  }),
673
827
  handleSignOut = _useGoogleSignOut.handleSignOut;
828
+ var _useTranslation = useTranslation(),
829
+ t = _useTranslation.t;
674
830
  var dispatch = useDispatch();
675
831
  var user = useSelector(function (state) {
676
832
  var _state$common;
@@ -682,7 +838,7 @@ var LayoutContext = function LayoutContext(_ref) {
682
838
  };
683
839
  var checkRoleUser = useCallback(function () {
684
840
  if (!user) return;
685
- if (!roles.includes(role)) {
841
+ if (!roles.includes(role) && !!user.academyDomain) {
686
842
  alert(user.email + " not allow to register " + role);
687
843
  resetAuth();
688
844
  }
@@ -699,7 +855,7 @@ var LayoutContext = function LayoutContext(_ref) {
699
855
  }
700
856
  dispatch(setLoading(true));
701
857
  var _temp = _catch(function () {
702
- return Promise.resolve(getInfo()).then(function (info) {
858
+ return Promise.resolve(getAcademyDomain() ? getInfo() : getSuperAdminInfoFromWeb()).then(function (info) {
703
859
  if (!info) {
704
860
  resetAuth();
705
861
  }
@@ -709,7 +865,7 @@ var LayoutContext = function LayoutContext(_ref) {
709
865
  console.log({
710
866
  err: err
711
867
  });
712
- role === "Student" ? alert("학생, 다시 로그인해주세요.") : alert("선생님, 다시 로그인해주세요.");
868
+ alert(t(role === Role.Student ? "student_login_again" : role === Role.Admin ? "admin_login_again" : "teacher_login_again"));
713
869
  resetAuth();
714
870
  });
715
871
  return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
@@ -728,12 +884,12 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
728
884
  var open = _ref.open,
729
885
  text = _ref.text,
730
886
  _ref$cancelText = _ref.cancelText,
731
- cancelText = _ref$cancelText === void 0 ? "No" : _ref$cancelText,
887
+ cancelText = _ref$cancelText === void 0 ? "아니요" : _ref$cancelText,
732
888
  _ref$okText = _ref.okText,
733
- okText = _ref$okText === void 0 ? "Yes" : _ref$okText,
889
+ okText = _ref$okText === void 0 ? "" : _ref$okText,
734
890
  isDelete = _ref.isDelete,
735
891
  _ref$title = _ref.title,
736
- title = _ref$title === void 0 ? "Confirmation" : _ref$title,
892
+ title = _ref$title === void 0 ? "확인" : _ref$title,
737
893
  toggle = _ref.toggle,
738
894
  onConfirm = _ref.onConfirm,
739
895
  confirmText = _ref.confirmText;
@@ -998,6 +1154,7 @@ var number_question = "{{number}}번";
998
1154
  var answer_rate = "정답률";
999
1155
  var seconds = "초";
1000
1156
  var search_placeholder = "시험 이름으로 검색하기";
1157
+ var search_by_student = "학생명으로 검색하기";
1001
1158
  var study_touch = "영어연구소";
1002
1159
  var exam_information = "시험정보";
1003
1160
  var issue_number = "문제번호";
@@ -1055,6 +1212,65 @@ var saturday = "토요일";
1055
1212
  var total_lessons = "총 수업";
1056
1213
  var weekly_days_required = "평일 필수";
1057
1214
  var main_teacher = "주 교사";
1215
+ var the_first = "첫번째";
1216
+ var the_second = "두번째";
1217
+ var the_third = "세번째";
1218
+ var the_fourth = "네번째";
1219
+ var the_fifth = "다섯번째";
1220
+ var the_sixth = "여섯번째";
1221
+ var the_seventh = "일곱번째";
1222
+ var the_eighth = "여덟번째";
1223
+ var the_ninth = "아홉번째";
1224
+ var the_tenth = "열번째";
1225
+ var full_name_required = "성명은 필수 항목입니다";
1226
+ var email_required = "이메일은 필수입니다";
1227
+ var enter_full_name = "이름을 입력하세요";
1228
+ var enter_email = "이메일을 입력하세요";
1229
+ var admin = "관리자";
1230
+ var active = "활동적인";
1231
+ var create_new_user = "새 사용자 만들기";
1232
+ var update_user = "사용자 업데이트";
1233
+ var save = "구하다";
1234
+ var create_academy = "아카데미 만들기";
1235
+ var update_academy = "아카데미 업데이트";
1236
+ var connection_string = "연결 문자열";
1237
+ var image = "영상";
1238
+ var enter_academy_name = "학원명을 입력하세요";
1239
+ var enter_connection_string = "연결 문자열을 입력하세요";
1240
+ var academy_name_required = "아카데미 이름이 필요합니다";
1241
+ var connection_string_required = "연결 문자열 이름이 필요합니다";
1242
+ var not_allow_register_account_contact_admin = "가입 권한이 없는 계정입니다. 관리자에게 문의하세요.";
1243
+ var request_login_fail = "로그인 실패 요청!";
1244
+ var student_login_again = "학생, 다시 로그인해주세요.";
1245
+ var teacher_login_again = "선생님, 다시 로그인해주세요.";
1246
+ var admin_login_again = "선생님, 다시 로그인해주세요.";
1247
+ var domain_required = "도메인 이름이 필요합니다";
1248
+ var domain_name = "도메인 이름";
1249
+ var enter_academy_domain = "아카데미 도메인을 입력하세요";
1250
+ var created_by = "창조자";
1251
+ var modification_code = "시험 코드 수정은 불가능합니다.";
1252
+ var total_student_joined = "학생이 합류했습니다";
1253
+ var copy_to_clipboard = "클립 보드에 복사";
1254
+ var code_exam = "시험 코드";
1255
+ var button = {
1256
+ close: "닫기",
1257
+ send: "보내기"
1258
+ };
1259
+ var question_and_answer = "질문 및 답변";
1260
+ var problem_number_question = "문제 {{number}}번";
1261
+ var teacher_in_charge = "담당 교사";
1262
+ var counselor = "상담교사";
1263
+ var new_question = "새로운 질문";
1264
+ var hour = "시간";
1265
+ var minute = "분";
1266
+ var second = "두번째";
1267
+ var question_order = "{{number}} 번";
1268
+ var send_message = "메시지 보내기";
1269
+ var class_inquiry = "수업 문의";
1270
+ var no_academies_available = "이용 가능한 아카데미가 없습니다";
1271
+ var not_allow_register = "역할 등록을 허용하지 않음";
1272
+ var credentials_invalid = "자격 증명이 잘못되었습니다.";
1273
+ var role_is_invalid = "역할이 잘못되었습니다";
1058
1274
  var lang_ko = {
1059
1275
  problem_solving: problem_solving,
1060
1276
  my_story: my_story,
@@ -1100,6 +1316,7 @@ var lang_ko = {
1100
1316
  answer_rate: answer_rate,
1101
1317
  seconds: seconds,
1102
1318
  search_placeholder: search_placeholder,
1319
+ search_by_student: search_by_student,
1103
1320
  study_touch: study_touch,
1104
1321
  exam_information: exam_information,
1105
1322
  issue_number: issue_number,
@@ -1156,7 +1373,64 @@ var lang_ko = {
1156
1373
  saturday: saturday,
1157
1374
  total_lessons: total_lessons,
1158
1375
  weekly_days_required: weekly_days_required,
1159
- main_teacher: main_teacher
1376
+ main_teacher: main_teacher,
1377
+ the_first: the_first,
1378
+ the_second: the_second,
1379
+ the_third: the_third,
1380
+ the_fourth: the_fourth,
1381
+ the_fifth: the_fifth,
1382
+ the_sixth: the_sixth,
1383
+ the_seventh: the_seventh,
1384
+ the_eighth: the_eighth,
1385
+ the_ninth: the_ninth,
1386
+ the_tenth: the_tenth,
1387
+ full_name_required: full_name_required,
1388
+ email_required: email_required,
1389
+ enter_full_name: enter_full_name,
1390
+ enter_email: enter_email,
1391
+ admin: admin,
1392
+ active: active,
1393
+ create_new_user: create_new_user,
1394
+ update_user: update_user,
1395
+ save: save,
1396
+ create_academy: create_academy,
1397
+ update_academy: update_academy,
1398
+ connection_string: connection_string,
1399
+ image: image,
1400
+ enter_academy_name: enter_academy_name,
1401
+ enter_connection_string: enter_connection_string,
1402
+ academy_name_required: academy_name_required,
1403
+ connection_string_required: connection_string_required,
1404
+ not_allow_register_account_contact_admin: not_allow_register_account_contact_admin,
1405
+ request_login_fail: request_login_fail,
1406
+ student_login_again: student_login_again,
1407
+ teacher_login_again: teacher_login_again,
1408
+ admin_login_again: admin_login_again,
1409
+ domain_required: domain_required,
1410
+ domain_name: domain_name,
1411
+ enter_academy_domain: enter_academy_domain,
1412
+ created_by: created_by,
1413
+ modification_code: modification_code,
1414
+ total_student_joined: total_student_joined,
1415
+ copy_to_clipboard: copy_to_clipboard,
1416
+ code_exam: code_exam,
1417
+ button: button,
1418
+ question_and_answer: question_and_answer,
1419
+ problem_number_question: problem_number_question,
1420
+ teacher_in_charge: teacher_in_charge,
1421
+ counselor: counselor,
1422
+ new_question: new_question,
1423
+ hour: hour,
1424
+ minute: minute,
1425
+ second: second,
1426
+ question_order: question_order,
1427
+ send_message: send_message,
1428
+ class_inquiry: class_inquiry,
1429
+ no_academies_available: no_academies_available,
1430
+ not_allow_register: not_allow_register,
1431
+ credentials_invalid: credentials_invalid,
1432
+ role_is_invalid: role_is_invalid,
1433
+ "q&a": "질의응답"
1160
1434
  };
1161
1435
 
1162
1436
  var problem_solving$1 = "Problem Solving";
@@ -1203,6 +1477,7 @@ var number_question$1 = "No.{{number}}";
1203
1477
  var answer_rate$1 = "Answer rate";
1204
1478
  var seconds$1 = "s";
1205
1479
  var search_placeholder$1 = "Search by exam name";
1480
+ var search_by_student$1 = "Search by student name";
1206
1481
  var study_touch$1 = "Study touch";
1207
1482
  var exam_information$1 = "Exam information";
1208
1483
  var issue_number$1 = "Issue number";
@@ -1296,6 +1571,65 @@ var weekly_days_required$1 = "Weekly days are required";
1296
1571
  var main_teacher$1 = "Main teacher";
1297
1572
  var main_teacher_required = "Main teacher is required";
1298
1573
  var teacher = "Teacher";
1574
+ var the_first$1 = "The first";
1575
+ var the_second$1 = "The second";
1576
+ var the_third$1 = "The third";
1577
+ var the_fourth$1 = "The fourth";
1578
+ var the_fifth$1 = "The fifth";
1579
+ var the_sixth$1 = "The sixth";
1580
+ var the_seventh$1 = "The seventh";
1581
+ var the_eighth$1 = "The eighth";
1582
+ var the_ninth$1 = "The ninth";
1583
+ var the_tenth$1 = "The tenth";
1584
+ var full_name_required$1 = "Full name is required";
1585
+ var email_required$1 = "Email is required";
1586
+ var enter_full_name$1 = "Enter full name";
1587
+ var enter_email$1 = "Enter email";
1588
+ var admin$1 = "Admin";
1589
+ var active$1 = "Active";
1590
+ var create_new_user$1 = "Create new user";
1591
+ var update_user$1 = "Update user";
1592
+ var save$1 = "Save";
1593
+ var create_academy$1 = "Create academy";
1594
+ var update_academy$1 = "Update academy";
1595
+ var connection_string$1 = "Connection string";
1596
+ var image$1 = "Image";
1597
+ var enter_academy_name$1 = "Enter academy name";
1598
+ var enter_connection_string$1 = "Enter connection string";
1599
+ var academy_name_required$1 = "Academy name required";
1600
+ var connection_string_required$1 = "Connection string name required";
1601
+ var not_allow_register_account_contact_admin$1 = "This account does not have permission to sign up. Please contact your administrator.";
1602
+ var request_login_fail$1 = "Request login failure!";
1603
+ var student_login_again$1 = "Student, please log in again.";
1604
+ var teacher_login_again$1 = "Teacher, please log in again.";
1605
+ var admin_login_again$1 = "Admin, please log in again.";
1606
+ var domain_required$1 = "Domain name required";
1607
+ var domain_name$1 = "Domain name";
1608
+ var enter_academy_domain$1 = "Enter academy domain";
1609
+ var created_by$1 = "Created by";
1610
+ var modification_code$1 = "Modification of test code is not possible";
1611
+ var total_student_joined$1 = "Students have joined";
1612
+ var code_exam$1 = "Exam code";
1613
+ var copy_to_clipboard$1 = "Copy to clipboard";
1614
+ var button$1 = {
1615
+ close: "Close",
1616
+ send: "Send"
1617
+ };
1618
+ var question_and_answer$1 = "Question And Answer";
1619
+ var problem_number_question$1 = "Problem No.{{number}}";
1620
+ var teacher_in_charge$1 = "Teacher In Charge";
1621
+ var counselor$1 = "Counselor";
1622
+ var new_question$1 = "New Question";
1623
+ var hour$1 = "hour";
1624
+ var minute$1 = "minutes";
1625
+ var second$1 = "second";
1626
+ var question_order$1 = "Number {{number}}";
1627
+ var send_message$1 = "Send Message";
1628
+ var class_inquiry$1 = "Class inquiry";
1629
+ var no_academies_available$1 = "No academies available";
1630
+ var not_allow_register$1 = "Not allow to register role";
1631
+ var credentials_invalid$1 = "Credentials is invalid";
1632
+ var role_is_invalid$1 = "Role is invalid";
1299
1633
  var lang_en = {
1300
1634
  problem_solving: problem_solving$1,
1301
1635
  my_story: my_story$1,
@@ -1341,6 +1675,7 @@ var lang_en = {
1341
1675
  answer_rate: answer_rate$1,
1342
1676
  seconds: seconds$1,
1343
1677
  search_placeholder: search_placeholder$1,
1678
+ search_by_student: search_by_student$1,
1344
1679
  study_touch: study_touch$1,
1345
1680
  exam_information: exam_information$1,
1346
1681
  issue_number: issue_number$1,
@@ -1433,7 +1768,64 @@ var lang_en = {
1433
1768
  weekly_days_required: weekly_days_required$1,
1434
1769
  main_teacher: main_teacher$1,
1435
1770
  main_teacher_required: main_teacher_required,
1436
- teacher: teacher
1771
+ teacher: teacher,
1772
+ the_first: the_first$1,
1773
+ the_second: the_second$1,
1774
+ the_third: the_third$1,
1775
+ the_fourth: the_fourth$1,
1776
+ the_fifth: the_fifth$1,
1777
+ the_sixth: the_sixth$1,
1778
+ the_seventh: the_seventh$1,
1779
+ the_eighth: the_eighth$1,
1780
+ the_ninth: the_ninth$1,
1781
+ the_tenth: the_tenth$1,
1782
+ full_name_required: full_name_required$1,
1783
+ email_required: email_required$1,
1784
+ enter_full_name: enter_full_name$1,
1785
+ enter_email: enter_email$1,
1786
+ admin: admin$1,
1787
+ active: active$1,
1788
+ create_new_user: create_new_user$1,
1789
+ update_user: update_user$1,
1790
+ save: save$1,
1791
+ create_academy: create_academy$1,
1792
+ update_academy: update_academy$1,
1793
+ connection_string: connection_string$1,
1794
+ image: image$1,
1795
+ enter_academy_name: enter_academy_name$1,
1796
+ enter_connection_string: enter_connection_string$1,
1797
+ academy_name_required: academy_name_required$1,
1798
+ connection_string_required: connection_string_required$1,
1799
+ not_allow_register_account_contact_admin: not_allow_register_account_contact_admin$1,
1800
+ request_login_fail: request_login_fail$1,
1801
+ student_login_again: student_login_again$1,
1802
+ teacher_login_again: teacher_login_again$1,
1803
+ admin_login_again: admin_login_again$1,
1804
+ domain_required: domain_required$1,
1805
+ domain_name: domain_name$1,
1806
+ enter_academy_domain: enter_academy_domain$1,
1807
+ created_by: created_by$1,
1808
+ modification_code: modification_code$1,
1809
+ total_student_joined: total_student_joined$1,
1810
+ code_exam: code_exam$1,
1811
+ copy_to_clipboard: copy_to_clipboard$1,
1812
+ button: button$1,
1813
+ question_and_answer: question_and_answer$1,
1814
+ problem_number_question: problem_number_question$1,
1815
+ teacher_in_charge: teacher_in_charge$1,
1816
+ counselor: counselor$1,
1817
+ new_question: new_question$1,
1818
+ hour: hour$1,
1819
+ minute: minute$1,
1820
+ second: second$1,
1821
+ question_order: question_order$1,
1822
+ send_message: send_message$1,
1823
+ class_inquiry: class_inquiry$1,
1824
+ no_academies_available: no_academies_available$1,
1825
+ not_allow_register: not_allow_register$1,
1826
+ credentials_invalid: credentials_invalid$1,
1827
+ role_is_invalid: role_is_invalid$1,
1828
+ "q&a": "Q&A"
1437
1829
  };
1438
1830
 
1439
1831
  i18n.use(initReactI18next).init({
@@ -1527,9 +1919,9 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
1527
1919
  return React.createElement(Dropdown, {
1528
1920
  isOpen: dropdownOpen,
1529
1921
  toggle: toggle,
1530
- className: "" + styles["dropdown-menu"]
1922
+ className: "" + stylesGlobal["dropdown-menu"]
1531
1923
  }, React.createElement(DropdownToggle, {
1532
- className: styles["header-avatar"] + " d-flex align-items-center"
1924
+ className: stylesGlobal["header-avatar"] + " d-flex align-items-center"
1533
1925
  }, React.createElement("span", {
1534
1926
  style: {
1535
1927
  color: "#000",
@@ -1538,7 +1930,7 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
1538
1930
  alignItems: 'center'
1539
1931
  }
1540
1932
  }, !!currentLanguage && React.createElement("img", {
1541
- className: "mr-2 " + styles['dropdown-menu-flag'],
1933
+ className: "mr-2 " + stylesGlobal['dropdown-menu-flag'],
1542
1934
  src: currentLanguage.image
1543
1935
  }), !!currentLanguage && currentLanguage.shortName, React.createElement(IoChevronDown, {
1544
1936
  className: "ml-2",
@@ -1548,16 +1940,16 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
1548
1940
  marginTop: "2px"
1549
1941
  }
1550
1942
  }))), React.createElement(DropdownMenu, {
1551
- className: styles["dropdown-content-language"]
1943
+ className: stylesGlobal["dropdown-content-language"]
1552
1944
  }, LANGUAGES.map(function (lang, index) {
1553
1945
  return React.createElement(DropdownItem, {
1554
1946
  key: lang.code,
1555
- className: styles["dropdown-change"] + " px-0 py-0 " + (index === LANGUAGES.length - 1 ? "pb-2" : "pt-2"),
1947
+ className: stylesGlobal["dropdown-change"] + " px-0 py-0 " + (index === LANGUAGES.length - 1 ? "pb-2" : "pt-2"),
1556
1948
  onClick: function onClick() {
1557
1949
  return setItemLanguage(lang.code);
1558
1950
  }
1559
1951
  }, React.createElement("div", {
1560
- className: styles["dropdown-item-language"] + " " + styles["item-logout"] + " " + (language == lang.code ? styles['dropdown-item-language-active'] : "") + " d-flex align-items-center w-100"
1952
+ className: stylesGlobal["dropdown-item-language"] + " " + stylesGlobal["item-logout"] + " " + (language == lang.code ? stylesGlobal['dropdown-item-language-active'] : "") + " d-flex align-items-center w-100"
1561
1953
  }, React.createElement("span", {
1562
1954
  className: "mr-2 d-flex hover-opacity"
1563
1955
  }, React.createElement("img", {
@@ -1570,6 +1962,196 @@ var TheLanguageDropdown = function TheLanguageDropdown() {
1570
1962
  })));
1571
1963
  };
1572
1964
 
1965
+ var ACADEMY_URL = BASE_URL + "/api/academy";
1966
+ var SUPER_ADMIN_ACADEMY_URL = SUPER_ADMIN_BASE_URL + "/api/academies";
1967
+ var getAcademyList = function getAcademyList(role) {
1968
+ return api.get(SUPER_ADMIN_ACADEMY_URL + "/active", {
1969
+ params: {
1970
+ role: role
1971
+ }
1972
+ });
1973
+ };
1974
+ var getUserAcademies = function getUserAcademies(role) {
1975
+ return api.get("" + ACADEMY_URL, {
1976
+ params: {
1977
+ role: role
1978
+ }
1979
+ });
1980
+ };
1981
+ var switchAcademy = function switchAcademy(academyId) {
1982
+ return api.post(ACADEMY_URL + "/switch-academy?academyId=" + academyId);
1983
+ };
1984
+
1985
+ var useSwitchAcademy = function useSwitchAcademy(role, navigate, homeAcademyUrl, homeUrl) {
1986
+ if (role === void 0) {
1987
+ role = Role.Student;
1988
+ }
1989
+ var dispatch = useDispatch();
1990
+ var _useLogin = useLogin(navigate, homeAcademyUrl, homeUrl),
1991
+ handleLoginAccessToken = _useLogin.handleLoginAccessToken;
1992
+ var _useState = useState(false),
1993
+ dropdownOpen = _useState[0],
1994
+ setDropdownOpen = _useState[1];
1995
+ var toggleDropdown = function toggleDropdown() {
1996
+ return setDropdownOpen(function (prevState) {
1997
+ return !prevState;
1998
+ });
1999
+ };
2000
+ var _useState2 = useState([]),
2001
+ academyList = _useState2[0],
2002
+ setAcademyList = _useState2[1];
2003
+ var user = useSelector(function (state) {
2004
+ var _state$common;
2005
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
2006
+ });
2007
+ var isReFetchUserAcademies = useSelector(function (state) {
2008
+ var _state$common2;
2009
+ return state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : _state$common2.isReFetchUserAcademies;
2010
+ });
2011
+ var getAcademies = function getAcademies(isLoading) {
2012
+ if (isLoading === void 0) {
2013
+ isLoading = true;
2014
+ }
2015
+ try {
2016
+ var _temp3 = function _temp3() {
2017
+ isLoading && dispatch(setLoading(false));
2018
+ };
2019
+ if (!user) return Promise.resolve();
2020
+ var isSuperAdminUser = user && !user.academyDomain;
2021
+ var isSuperAdminRole = user.roles.includes(Role.Admin);
2022
+ isLoading && dispatch(setLoading(true));
2023
+ var _temp2 = _catch(function () {
2024
+ return Promise.resolve(isSuperAdminUser ? getAcademyList(role) : getUserAcademies(role)).then(function (res) {
2025
+ var items = res.data.items || [];
2026
+ if (isReFetchUserAcademies) dispatch(setReFetchUserAcademies(false));
2027
+ setAcademyList(items);
2028
+ var _temp = function () {
2029
+ if (!isSuperAdminRole && isSuperAdminUser && role == Role.Admin && items.length > 0) {
2030
+ return Promise.resolve(handleSwitchAcademy(items[0], false)).then(function () {});
2031
+ }
2032
+ }();
2033
+ if (_temp && _temp.then) return _temp.then(function () {});
2034
+ });
2035
+ }, function (error) {
2036
+ var _error$response, _error$response$data;
2037
+ toast.error((error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.tile) || "Get user academies failed");
2038
+ });
2039
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
2040
+ } catch (e) {
2041
+ return Promise.reject(e);
2042
+ }
2043
+ };
2044
+ var handleSwitchAcademy = function handleSwitchAcademy(selectedAcademy, isLoading) {
2045
+ if (isLoading === void 0) {
2046
+ isLoading = true;
2047
+ }
2048
+ try {
2049
+ var _temp5 = function _temp5() {
2050
+ isLoading && dispatch(setLoading(false));
2051
+ };
2052
+ isLoading && dispatch(setLoading(true));
2053
+ var academyId = selectedAcademy ? selectedAcademy.id : 0;
2054
+ var academyDomain = selectedAcademy ? selectedAcademy.domain : undefined;
2055
+ var _temp4 = _catch(function () {
2056
+ return Promise.resolve(switchAcademy(academyId)).then(function (res) {
2057
+ var data = res.data;
2058
+ var requestBody = {
2059
+ accessToken: data.accessToken,
2060
+ email: user.email,
2061
+ academyId: academyId,
2062
+ role: role
2063
+ };
2064
+ academyDomain && localStorage.setItem(ACADEMY_DOMAIN, academyDomain);
2065
+ !academyDomain && localStorage.removeItem(ACADEMY_DOMAIN);
2066
+ return Promise.resolve(handleLoginAccessToken(requestBody, false, user.academyDomain ? academyDomain : undefined)).then(function () {});
2067
+ });
2068
+ }, function (error) {
2069
+ var _error$response2, _error$response2$data;
2070
+ toast.error((error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.title) || "Switch academy failed");
2071
+ });
2072
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4));
2073
+ } catch (e) {
2074
+ return Promise.reject(e);
2075
+ }
2076
+ };
2077
+ useEffect(function () {
2078
+ getAcademies();
2079
+ }, [user === null || user === void 0 ? void 0 : user.academyDomain, user === null || user === void 0 ? void 0 : user.email]);
2080
+ useEffect(function () {
2081
+ isReFetchUserAcademies && getAcademies(false);
2082
+ }, [isReFetchUserAcademies]);
2083
+ var selectedAcademy = useMemo(function () {
2084
+ return academyList.find(function (i) {
2085
+ var _user$academyDomain;
2086
+ return i.domain.trim().toLowerCase() === (user === null || user === void 0 ? void 0 : (_user$academyDomain = user.academyDomain) === null || _user$academyDomain === void 0 ? void 0 : _user$academyDomain.trim().toLowerCase());
2087
+ });
2088
+ }, [user === null || user === void 0 ? void 0 : user.academyDomain, JSON.stringify(academyList)]);
2089
+ return {
2090
+ selectedAcademy: selectedAcademy,
2091
+ dropdownOpen: dropdownOpen,
2092
+ academyList: academyList,
2093
+ toggleDropdown: toggleDropdown,
2094
+ handleSwitchAcademy: handleSwitchAcademy
2095
+ };
2096
+ };
2097
+
2098
+ var TheAcademyDropdown = function TheAcademyDropdown(_ref) {
2099
+ var _selectedAcademy$name, _selectedAcademy$name2;
2100
+ var homeAcademyUrl = _ref.homeAcademyUrl,
2101
+ homeUrl = _ref.homeUrl,
2102
+ navigate = _ref.navigate,
2103
+ role = _ref.role;
2104
+ var _useSwitchAcademy = useSwitchAcademy(role, navigate, homeAcademyUrl, homeUrl),
2105
+ dropdownOpen = _useSwitchAcademy.dropdownOpen,
2106
+ academyList = _useSwitchAcademy.academyList,
2107
+ toggleDropdown = _useSwitchAcademy.toggleDropdown,
2108
+ handleSwitchAcademy = _useSwitchAcademy.handleSwitchAcademy,
2109
+ selectedAcademy = _useSwitchAcademy.selectedAcademy;
2110
+ var firstLetter = selectedAcademy === null || selectedAcademy === void 0 ? void 0 : (_selectedAcademy$name = selectedAcademy.name) === null || _selectedAcademy$name === void 0 ? void 0 : (_selectedAcademy$name2 = _selectedAcademy$name.charAt(0)) === null || _selectedAcademy$name2 === void 0 ? void 0 : _selectedAcademy$name2.toUpperCase();
2111
+ return React.createElement(Dropdown, {
2112
+ isOpen: dropdownOpen,
2113
+ toggle: toggleDropdown,
2114
+ className: stylesGlobal["dropdown-menu"] + " " + stylesGlobal["dropdown-academy"]
2115
+ }, React.createElement(DropdownToggle, {
2116
+ className: stylesGlobal["header-avatar"] + " d-flex align-items-center"
2117
+ }, React.createElement("div", {
2118
+ className: "" + stylesGlobal["image-academy"]
2119
+ }, selectedAcademy !== null && selectedAcademy !== void 0 && selectedAcademy.image ? React.createElement("img", {
2120
+ src: selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.image,
2121
+ alt: selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name
2122
+ }) : React.createElement("span", null, firstLetter)), React.createElement("p", {
2123
+ className: "text-start mb-0",
2124
+ style: {
2125
+ fontSize: 14,
2126
+ fontWeight: 600,
2127
+ color: "#5458D5",
2128
+ minWidth: 150
2129
+ }
2130
+ }, (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.name) || "No selected academy"), React.createElement("div", {
2131
+ className: "" + stylesGlobal["switch-icon"]
2132
+ }, React.createElement(GoArrowSwitch, {
2133
+ size: 14
2134
+ }))), React.createElement(DropdownMenu, {
2135
+ className: stylesGlobal["dropdown-content-academy"]
2136
+ }, academyList.map(function (academy) {
2137
+ return React.createElement(DropdownItem, {
2138
+ key: academy.id,
2139
+ className: stylesGlobal["dropdown-academy-item"] + " px-0 py-0",
2140
+ onClick: function onClick() {
2141
+ return handleSwitchAcademy(academy);
2142
+ }
2143
+ }, React.createElement("div", {
2144
+ className: stylesGlobal["dropdown-item-language"] + " " + stylesGlobal["item-logout"] + " " + (academy.id == (selectedAcademy === null || selectedAcademy === void 0 ? void 0 : selectedAcademy.id) ? stylesGlobal["dropdown-item-language-active"] : "") + " d-flex align-items-center w-100"
2145
+ }, React.createElement("span", {
2146
+ className: "mr-2 d-flex hover-opacity " + stylesGlobal["image-academy"]
2147
+ }, academy.image ? React.createElement("img", {
2148
+ src: academy.image
2149
+ }) : React.createElement("span", null, academy.name.charAt(0).toUpperCase())), academy.name));
2150
+ }), !academyList.length && React.createElement("p", {
2151
+ className: "px-2 text-center"
2152
+ }, "No academies available")));
2153
+ };
2154
+
1573
2155
  var minutesToTimeSpan = (function (time) {
1574
2156
  var h = Math.floor(time / 60);
1575
2157
  var m = time % 60;
@@ -1597,34 +2179,7 @@ var canAccess = function canAccess(userRoles, componentRoles) {
1597
2179
  return true;
1598
2180
  };
1599
2181
 
1600
- function _extends() {
1601
- _extends = Object.assign ? Object.assign.bind() : function (target) {
1602
- for (var i = 1; i < arguments.length; i++) {
1603
- var source = arguments[i];
1604
- for (var key in source) {
1605
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1606
- target[key] = source[key];
1607
- }
1608
- }
1609
- }
1610
- return target;
1611
- };
1612
- return _extends.apply(this, arguments);
1613
- }
1614
- function _objectWithoutPropertiesLoose(source, excluded) {
1615
- if (source == null) return {};
1616
- var target = {};
1617
- var sourceKeys = Object.keys(source);
1618
- var key, i;
1619
- for (i = 0; i < sourceKeys.length; i++) {
1620
- key = sourceKeys[i];
1621
- if (excluded.indexOf(key) >= 0) continue;
1622
- target[key] = source[key];
1623
- }
1624
- return target;
1625
- }
1626
-
1627
- var _excluded = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
2182
+ var _excluded$1 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
1628
2183
  var DropdownIndicator = function DropdownIndicator(props) {
1629
2184
  return React.createElement(components.DropdownIndicator, Object.assign({}, props), React.createElement(FaCaretDown, {
1630
2185
  color: "#5458D5"
@@ -1669,7 +2224,7 @@ var CustomSelect = function CustomSelect(_ref) {
1669
2224
  scrollBottom = _ref.scrollBottom,
1670
2225
  value = _ref.value,
1671
2226
  isMulti = _ref.isMulti,
1672
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
2227
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
1673
2228
  var _useTranslation = useTranslation(),
1674
2229
  t = _useTranslation.t;
1675
2230
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
@@ -1698,7 +2253,162 @@ var CustomSelect = function CustomSelect(_ref) {
1698
2253
  }, rest));
1699
2254
  };
1700
2255
 
1701
- var styles$1 = {"header__avatar":"_2oGcJ","header__select":"_2y2XV","body":"_ntGyI","list":"_m7Fwt","list__item__header":"_3BM8N","list__item__avatar":"_1ReOK","list__item__avatar-container":"_2qbld","list__item__message":"_3s01i","list__item__message--reply-from":"_2Qxi3","list__item__message--reply-from-right":"_34Vx4","list__item__message--reply":"_3uheq","list__item__message--reply-right":"_2iBr7","reply-text":"_3ZPjO"};
2256
+ var styles = {"header__avatar":"_2oGcJ","header__select":"_2y2XV","body":"_ntGyI","list":"_m7Fwt","list__item__header":"_3BM8N","list__item__avatar":"_1ReOK","list__item__avatar-container":"_2qbld","list__item__message":"_3s01i","list__item__message--reply-from":"_2Qxi3","list__item__message--reply-from-right":"_34Vx4","list__item__message--reply":"_3uheq","list__item__message--reply-right":"_2iBr7","reply-text":"_3ZPjO","container-custom":"_38A9k","student-row-col-1":"_Jt5t0","student-row-col-1-active":"_14DKj","row-col-2":"_qHGiR","inputBox":"_2iY67","inputBoxTable":"_3pCw0","background-chat":"_zILbw","wrap-content":"_38gsM","name-sender":"_Lfzyw","content-chat-sender":"_1X73E","content-chat-receiver":"_32V7T","custom-scroll":"_2Uul2","btn-send":"_395lb","btn-chat":"_gDYwm","input-chat":"_22TX5","btn-cancel":"_1u-eg","btn-register":"_22r6_","form-label-dialog":"_jADIA","form-select-width":"_WncPd","padding-content":"_3hz3H"};
2257
+
2258
+ var iconPersonNoActive = function iconPersonNoActive(_ref) {
2259
+ var _ref$width = _ref.width,
2260
+ width = _ref$width === void 0 ? "16" : _ref$width,
2261
+ _ref$height = _ref.height,
2262
+ height = _ref$height === void 0 ? "16" : _ref$height,
2263
+ color = _ref.color;
2264
+ return React.createElement("svg", {
2265
+ width: width,
2266
+ height: height,
2267
+ viewBox: "0 0 16 16",
2268
+ fill: color,
2269
+ xmlns: "http://www.w3.org/2000/svg"
2270
+ }, React.createElement("path", {
2271
+ d: "M10.395 2.01813C9.78691 1.36156 8.93753 1 8.00003 1C7.05753 1 6.20534 1.35937 5.60003 2.01187C4.98815 2.67156 4.69003 3.56813 4.76003 4.53625C4.89878 6.44625 6.35222 8 8.00003 8C9.64784 8 11.0988 6.44656 11.2397 4.53687C11.3107 3.5775 11.0107 2.68281 10.395 2.01813Z",
2272
+ fill: "#5458D5"
2273
+ }), React.createElement("path", {
2274
+ d: "M13.5001 15H2.50006C2.35608 15.0019 2.21349 14.9716 2.08267 14.9115C1.95185 14.8513 1.83609 14.7627 1.74381 14.6522C1.54068 14.4094 1.45881 14.0778 1.51943 13.7425C1.78318 12.2794 2.60631 11.0503 3.90006 10.1875C5.04943 9.42156 6.50537 9 8.00006 9C9.49474 9 10.9507 9.42188 12.1001 10.1875C13.3938 11.05 14.2169 12.2791 14.4807 13.7422C14.5413 14.0775 14.4594 14.4091 14.2563 14.6519C14.1641 14.7625 14.0483 14.8511 13.9175 14.9113C13.7867 14.9715 13.6441 15.0018 13.5001 15Z",
2275
+ fill: "#5458D5"
2276
+ }));
2277
+ };
2278
+
2279
+ var ChatRightItem = function ChatRightItem(_ref) {
2280
+ var content = _ref.content,
2281
+ createdAt = _ref.createdAt,
2282
+ sender = _ref.sender,
2283
+ showTimestamp = _ref.showTimestamp,
2284
+ isStudent = _ref.isStudent,
2285
+ showName = _ref.showName,
2286
+ contentType = _ref.contentType;
2287
+ var _useTranslation = useTranslation(),
2288
+ t = _useTranslation.t;
2289
+ return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
2290
+ fontWeight: 500,
2291
+ fontSize: "12px",
2292
+ lineHeight: "14.32px",
2293
+ color: "#97A1AF",
2294
+ textAlign: "center"
2295
+ }, utcToLocalTime(createdAt, t("date_time_format"))), React.createElement(Grid, {
2296
+ item: true,
2297
+ xs: 12,
2298
+ display: "flex",
2299
+ justifyContent: "flex-end",
2300
+ padding: "4px 0"
2301
+ }, React.createElement(Box, null, showName && isStudent && React.createElement(Box, {
2302
+ gap: "8px",
2303
+ className: " " + styles["name-sender"],
2304
+ display: "flex",
2305
+ alignItems: "center",
2306
+ flexDirection: "row"
2307
+ }, React.createElement(iconPersonNoActive, null), React.createElement(Typography, {
2308
+ fontWeight: 700,
2309
+ fontSize: 14,
2310
+ padding: "4px",
2311
+ lineHeight: "16.71px",
2312
+ color: "#5458D5"
2313
+ }, sender === null || sender === void 0 ? void 0 : sender.fullName)), contentType ? React.createElement("img", {
2314
+ src: content,
2315
+ style: {
2316
+ backgroundRepeat: "no-repeat",
2317
+ width: "200px",
2318
+ height: "200px",
2319
+ position: "relative",
2320
+ backgroundSize: "cover"
2321
+ }
2322
+ }) : React.createElement("div", {
2323
+ className: styles["wrap-content"] + " " + styles["content-chat-receiver"],
2324
+ style: {
2325
+ "float": "inline-end"
2326
+ }
2327
+ }, React.createElement(Typography, {
2328
+ fontWeight: 500,
2329
+ fontSize: "14px",
2330
+ lineHeight: "16.71px",
2331
+ color: "#fffff"
2332
+ }, content)))));
2333
+ };
2334
+
2335
+ var ChatLeftItem = function ChatLeftItem(_ref) {
2336
+ var content = _ref.content,
2337
+ sender = _ref.sender,
2338
+ createdAt = _ref.createdAt,
2339
+ showTimestamp = _ref.showTimestamp,
2340
+ isStudent = _ref.isStudent,
2341
+ showName = _ref.showName,
2342
+ contentType = _ref.contentType;
2343
+ var _useTranslation = useTranslation(),
2344
+ t = _useTranslation.t;
2345
+ return React.createElement("div", null, showTimestamp && React.createElement(Typography, {
2346
+ fontWeight: 500,
2347
+ fontSize: "12px",
2348
+ lineHeight: "14.32px",
2349
+ color: "#97A1AF",
2350
+ textAlign: "center"
2351
+ }, utcToLocalTime(createdAt, t("date_time_format"))), React.createElement(Grid, {
2352
+ item: true,
2353
+ xs: 12,
2354
+ padding: "4px 0"
2355
+ }, showName && React.createElement(Box, {
2356
+ gap: "4px",
2357
+ display: "flex",
2358
+ padding: "4px",
2359
+ flexDirection: "row",
2360
+ className: "" + styles["name-sender"]
2361
+ }, isStudent ? React.createElement(Fragment, null, React.createElement(Typography, {
2362
+ fontWeight: 500,
2363
+ fontSize: 14,
2364
+ lineHeight: "16.71px",
2365
+ color: "#97A1AF"
2366
+ }, t("counselor")), React.createElement(Typography, {
2367
+ fontWeight: 700,
2368
+ fontSize: 14,
2369
+ lineHeight: "16.71px",
2370
+ color: "#97A1AF"
2371
+ }, sender === null || sender === void 0 ? void 0 : sender.fullName)) : React.createElement(Fragment, null, React.createElement(Typography, {
2372
+ fontWeight: 700,
2373
+ fontSize: 14,
2374
+ lineHeight: "16.71px",
2375
+ color: "#5458D5"
2376
+ }, sender === null || sender === void 0 ? void 0 : sender.fullName), React.createElement(Typography, {
2377
+ fontWeight: 500,
2378
+ fontSize: 14,
2379
+ lineHeight: "16.71px",
2380
+ color: "#5458D5"
2381
+ }, t("student")))), React.createElement(Box, {
2382
+ padding: "4px 0px"
2383
+ }), contentType ? React.createElement("img", {
2384
+ src: content,
2385
+ style: {
2386
+ backgroundRepeat: "no-repeat",
2387
+ width: "200px",
2388
+ height: "200px",
2389
+ position: "relative",
2390
+ backgroundSize: "cover"
2391
+ }
2392
+ }) : React.createElement("div", {
2393
+ className: styles["wrap-content"] + " " + styles["content-chat-sender"]
2394
+ }, React.createElement(Typography, {
2395
+ fontWeight: 500,
2396
+ fontSize: "14px",
2397
+ lineHeight: "16.71px",
2398
+ color: "#414E62"
2399
+ }, content))));
2400
+ };
2401
+
2402
+ var ChatItemType;
2403
+ (function (ChatItemType) {
2404
+ ChatItemType[ChatItemType["Default"] = 0] = "Default";
2405
+ ChatItemType[ChatItemType["Exam"] = 1] = "Exam";
2406
+ ChatItemType[ChatItemType["Class"] = 2] = "Class";
2407
+ })(ChatItemType || (ChatItemType = {}));
2408
+ var ChatItem = function ChatItem(props) {
2409
+ var isMe = props.isMe;
2410
+ return React.createElement(Fragment, null, isMe ? React.createElement(ChatRightItem, Object.assign({}, props)) : React.createElement(ChatLeftItem, Object.assign({}, props)));
2411
+ };
1702
2412
 
1703
2413
  var MessageSortBy;
1704
2414
  (function (MessageSortBy) {
@@ -1712,7 +2422,7 @@ var OrderBy;
1712
2422
  var StudentSortBy;
1713
2423
  (function (StudentSortBy) {
1714
2424
  StudentSortBy["CreatedAt"] = "CreatedAt";
1715
- StudentSortBy["DisplayName"] = "DisplayName";
2425
+ StudentSortBy["FullName"] = "FullName";
1716
2426
  })(StudentSortBy || (StudentSortBy = {}));
1717
2427
  var StudentOrderBy;
1718
2428
  (function (StudentOrderBy) {
@@ -1737,371 +2447,460 @@ var MessageStatus;
1737
2447
  MessageStatus["SentError"] = "Sent fail, Retry";
1738
2448
  })(MessageStatus || (MessageStatus = {}));
1739
2449
 
1740
- var ChatRightItem = function ChatRightItem(_ref) {
1741
- var id = _ref.id,
1742
- content = _ref.content,
1743
- createdAt = _ref.createdAt,
1744
- isRead = _ref.isRead,
1745
- examCode = _ref.examCode,
1746
- isSystemLog = _ref.isSystemLog,
1747
- parentId = _ref.parentId,
1748
- _ref$showExamHeader = _ref.showExamHeader,
1749
- showExamHeader = _ref$showExamHeader === void 0 ? false : _ref$showExamHeader,
1750
- _ref$isFirst = _ref.isFirst,
1751
- isFirst = _ref$isFirst === void 0 ? true : _ref$isFirst,
1752
- isLast = _ref.isLast,
1753
- actionLink = _ref.actionLink,
1754
- examId = _ref.examId,
1755
- examTitle = _ref.examTitle,
1756
- parentContent = _ref.parentContent,
1757
- status = _ref.status,
1758
- selectedReplyMessageId = _ref.selectedReplyMessageId,
1759
- selectedReplyItemRef = _ref.selectedReplyItemRef,
1760
- onAddExamMessage = _ref.onAddExamMessage,
1761
- onReTrySendMessage = _ref.onReTrySendMessage,
1762
- onGotoParentMessage = _ref.onGotoParentMessage;
1763
- var _useState = useState(false),
1764
- isShowTime = _useState[0],
1765
- setShowTime = _useState[1];
1766
- var _useState2 = useState(false),
1767
- isShowInfo = _useState2[0],
1768
- setShowInfo = _useState2[1];
1769
- var _useTranslation = useTranslation(),
1770
- t = _useTranslation.t;
1771
- var handleShowInfo = function handleShowInfo() {
1772
- setShowInfo(!isShowInfo);
1773
- !isFirst && !isSystemLog && setShowTime(!isShowInfo);
1774
- };
1775
- var handleReTrySendMessage = function handleReTrySendMessage() {
1776
- if (status !== MessageStatus.SentError || !content) return;
1777
- onReTrySendMessage === null || onReTrySendMessage === void 0 ? void 0 : onReTrySendMessage({
1778
- content: content,
1779
- examId: examId,
1780
- examTitle: examTitle,
1781
- parentContent: parentContent,
1782
- parentId: parentId
1783
- });
1784
- };
1785
- useEffect(function () {
1786
- setShowTime(isSystemLog || !!isFirst);
1787
- }, [isFirst, isSystemLog]);
1788
- return React.createElement("li", {
1789
- ref: selectedReplyMessageId === id ? selectedReplyItemRef : undefined,
1790
- className: "px-3 " + (!isLast ? "pb-1" : "pb-3") + " " + (!!examCode ? "border border-top-0 border-info" : "") + " " + (!!examCode && isLast ? "border-bottom-1 mb-3" : "border-bottom-0")
1791
- }, showExamHeader && isFirst && React.createElement("div", {
1792
- className: "d-flex bg-info justify-content-between px-3 mb-3 py-1 " + styles$1["list__item__header"]
1793
- }, React.createElement(Link, {
1794
- to: "" + (actionLink || "/"),
1795
- className: "text-black"
1796
- }, examTitle), !!examId && !!examTitle && !!examCode && React.createElement("span", {
1797
- className: "pointer text-black",
1798
- onClick: function onClick() {
1799
- return onAddExamMessage === null || onAddExamMessage === void 0 ? void 0 : onAddExamMessage(examId, examTitle, examCode);
1800
- }
1801
- }, "Add message to exam")), isSystemLog || !!isFirst ? React.createElement("p", {
1802
- className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1803
- }, utcToLocalTime(createdAt, t("date_time_format"))) : React.createElement(Collapse, {
1804
- className: "w-100",
1805
- isOpen: isShowTime
1806
- }, React.createElement("p", {
1807
- className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1808
- }, utcToLocalTime(createdAt, t("date_time_format")))), isSystemLog ? React.createElement("div", {
1809
- className: "text-center w-100"
1810
- }, React.createElement(Link, {
1811
- to: "" + (actionLink || "/"),
1812
- title: "See the results",
1813
- className: "text-primary"
1814
- }, content)) : React.createElement("div", {
1815
- className: "d-flex align-items-start w-100 flex-row-reverse"
1816
- }, React.createElement("div", {
1817
- className: "d-flex flex-column align-items-end"
1818
- }, parentId && React.createElement("p", {
1819
- className: "px-3 bg-light opacity-50 pointer " + styles$1["list__item__message"] + " " + styles$1["list__item__message--reply-from-right"] + " mb-0 fw-medium " + styles$1["reply-text"],
1820
- onClick: function onClick() {
1821
- return onGotoParentMessage === null || onGotoParentMessage === void 0 ? void 0 : onGotoParentMessage(parentId);
1822
- }
1823
- }, React.createElement("b", null, "Reply To:"), " ", parentContent), React.createElement("p", {
1824
- className: "mb-0 py-2 px-3 fw-medium pointer " + styles$1["list__item__message"] + " " + (parentId ? styles$1["list__item__message--reply-right"] : "") + " text-end bg-primary text-white",
1825
- onClick: handleShowInfo
1826
- }, content), status !== MessageStatus.Default && React.createElement("p", {
1827
- onClick: handleReTrySendMessage,
1828
- className: "fs-6 mb-0 " + (status === MessageStatus.SentError ? "text-danger text-decoration-underline pointer" : "")
1829
- }, status), !isSystemLog && status === MessageStatus.Default && React.createElement(Collapse, {
1830
- isOpen: isShowInfo
1831
- }, React.createElement("p", {
1832
- className: "mb-0 py-1 px-3 fs-6 text-muted text-end"
1833
- }, isRead ? "seen" : "sent")))));
2450
+ var types = {
2451
+ __proto__: null,
2452
+ get MessageSortBy () { return MessageSortBy; },
2453
+ get OrderBy () { return OrderBy; },
2454
+ get StudentSortBy () { return StudentSortBy; },
2455
+ get StudentOrderBy () { return StudentOrderBy; },
2456
+ get MessageAction () { return MessageAction; },
2457
+ get MessageSourceType () { return MessageSourceType; },
2458
+ get MessageStatus () { return MessageStatus; }
1834
2459
  };
1835
2460
 
1836
- var ChatLeftItem = function ChatLeftItem(_ref) {
1837
- var id = _ref.id,
1838
- avatar = _ref.avatar,
1839
- content = _ref.content,
1840
- createdAt = _ref.createdAt,
1841
- examCode = _ref.examCode,
1842
- isSystemLog = _ref.isSystemLog,
1843
- parentId = _ref.parentId,
1844
- _ref$showExamHeader = _ref.showExamHeader,
1845
- showExamHeader = _ref$showExamHeader === void 0 ? false : _ref$showExamHeader,
1846
- _ref$isFirst = _ref.isFirst,
1847
- isFirst = _ref$isFirst === void 0 ? true : _ref$isFirst,
1848
- isLast = _ref.isLast,
1849
- actionLink = _ref.actionLink,
1850
- examId = _ref.examId,
1851
- examTitle = _ref.examTitle,
1852
- parentContent = _ref.parentContent,
1853
- onAddExamMessage = _ref.onAddExamMessage,
1854
- onReply = _ref.onReply,
1855
- selectedReplyMessageId = _ref.selectedReplyMessageId,
1856
- onToggleReply = _ref.onToggleReply,
1857
- selectedReplyItemRef = _ref.selectedReplyItemRef,
1858
- onGotoParentMessage = _ref.onGotoParentMessage;
1859
- var _useState = useState(false),
1860
- isShowTime = _useState[0],
1861
- setShowTime = _useState[1];
1862
- var _useState2 = useState(false),
1863
- isShowInfo = _useState2[0],
1864
- setShowInfo = _useState2[1];
1865
- var _useTranslation = useTranslation(),
1866
- t = _useTranslation.t;
1867
- var handleShowInfo = function handleShowInfo() {
1868
- if (!id) return;
1869
- setShowInfo(!isShowInfo);
1870
- onToggleReply === null || onToggleReply === void 0 ? void 0 : onToggleReply(id);
1871
- !isFirst && !isSystemLog && setShowTime(!isShowInfo);
1872
- };
1873
- var handleReply = function handleReply() {
1874
- if (!id) return;
1875
- onReply === null || onReply === void 0 ? void 0 : onReply(id, content || "", examId);
1876
- };
1877
- useEffect(function () {
1878
- setShowTime(isSystemLog || !!isFirst);
1879
- }, [isFirst, isSystemLog]);
1880
- return React.createElement("li", {
1881
- ref: selectedReplyMessageId === id ? selectedReplyItemRef : undefined,
1882
- className: "px-3 " + (!isLast ? "pb-1" : "pb-3") + " " + (!!examCode ? "border border-top-0 border-info" : "") + " " + (!!examCode && isLast ? "border-bottom-1 mb-3" : "border-bottom-0")
1883
- }, showExamHeader && isFirst && React.createElement("div", {
1884
- className: "d-flex bg-info justify-content-between px-3 mb-3 py-1 " + styles$1["list__item__header"]
1885
- }, React.createElement(Link, {
1886
- to: "" + (actionLink || "/"),
1887
- className: "text-black"
1888
- }, examTitle), !!examId && !!examTitle && !!examCode && React.createElement("span", {
1889
- className: "pointer text-black",
1890
- onClick: function onClick() {
1891
- return onAddExamMessage === null || onAddExamMessage === void 0 ? void 0 : onAddExamMessage(examId, examTitle, examCode);
1892
- }
1893
- }, "Add message to exam")), isSystemLog || !!isFirst ? React.createElement("p", {
1894
- className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1895
- }, utcToLocalTime(createdAt, t("date_time_format"))) : React.createElement(Collapse, {
1896
- className: "w-100",
1897
- isOpen: isShowTime
1898
- }, React.createElement("p", {
1899
- className: "mb-0 py-1 px-3 fs-6 text-muted text-center"
1900
- }, utcToLocalTime(createdAt, t("date_time_format")))), isSystemLog ? React.createElement("div", {
1901
- className: "text-center w-100"
1902
- }, React.createElement(Link, {
1903
- to: "" + (actionLink || "/"),
1904
- title: "See the results",
1905
- className: "text-primary"
1906
- }, content)) : React.createElement("div", {
1907
- className: "d-flex align-items-start w-100"
1908
- }, React.createElement("div", {
1909
- className: "rounded-circle " + styles$1["list__item__avatar-container"] + " bg-light me-2 mt-1 " + (isFirst ? "" : "opacity-0")
1910
- }, isFirst && React.createElement("img", {
1911
- className: styles$1["list__item__avatar"] + " bg-light rounded-circle",
1912
- src: avatar
1913
- })), React.createElement("div", {
1914
- className: "d-flex flex-column"
1915
- }, parentId && React.createElement("p", {
1916
- className: "opacity-50 mb-0 px-3 fw-medium pointer " + styles$1["list__item__message"] + " " + styles$1["list__item__message--reply-from"] + " " + styles$1["reply-text"] + " text-start bg-light",
1917
- onClick: function onClick() {
1918
- return onGotoParentMessage === null || onGotoParentMessage === void 0 ? void 0 : onGotoParentMessage(parentId);
1919
- }
1920
- }, React.createElement("b", null, "Reply To:"), " ", parentContent), React.createElement("p", {
1921
- className: "mb-0 py-2 px-3 fw-medium pointer " + styles$1["list__item__message"] + " " + (parentId ? styles$1["list__item__message--reply"] : "") + " text-start bg-light",
1922
- onClick: handleShowInfo
1923
- }, content), !isSystemLog && React.createElement(Collapse, {
1924
- className: "w-100",
1925
- isOpen: selectedReplyMessageId === id
1926
- }, React.createElement("p", {
1927
- onClick: handleReply,
1928
- className: "mb-0 py-1 px-3 fs-6 text-primary text-left pointer"
1929
- }, "Reply")))));
1930
- };
1931
-
1932
- var ChatItemType;
1933
- (function (ChatItemType) {
1934
- ChatItemType[ChatItemType["Default"] = 0] = "Default";
1935
- ChatItemType[ChatItemType["Exam"] = 1] = "Exam";
1936
- ChatItemType[ChatItemType["Class"] = 2] = "Class";
1937
- })(ChatItemType || (ChatItemType = {}));
1938
- var ChatItem = function ChatItem(props) {
1939
- var isMe = props.isMe,
1940
- onReTrySendMessage = props.onReTrySendMessage;
1941
- return React.createElement(Fragment, null, isMe ? React.createElement(ChatRightItem, Object.assign({}, props, {
1942
- onReTrySendMessage: onReTrySendMessage
1943
- })) : React.createElement(ChatLeftItem, Object.assign({}, props)));
2461
+ var ExamStatus;
2462
+ (function (ExamStatus) {
2463
+ ExamStatus["Default"] = "Default";
2464
+ ExamStatus["Pending"] = "Pending";
2465
+ ExamStatus["Inprogress"] = "Inprogress";
2466
+ ExamStatus["Completed"] = "Completed";
2467
+ })(ExamStatus || (ExamStatus = {}));
2468
+ var Roles;
2469
+ (function (Roles) {
2470
+ Roles["Student"] = "Student";
2471
+ Roles["Teacher"] = "Teacher";
2472
+ Roles["Admin"] = "Admin";
2473
+ })(Roles || (Roles = {}));
2474
+ var MESSAGE_DEFAULT_FILTER = {
2475
+ currentPage: 1,
2476
+ pageSize: 15,
2477
+ textSearch: "",
2478
+ sortColumnDirection: OrderBy.DESC,
2479
+ sortColumnName: MessageSortBy.CreatedAt
1944
2480
  };
1945
2481
 
1946
2482
  var ChatList = function ChatList(_ref) {
1947
2483
  var _ref$messages = _ref.messages,
1948
2484
  messages = _ref$messages === void 0 ? [] : _ref$messages,
1949
- onAddExamMessage = _ref.onAddExamMessage,
1950
- onReply = _ref.onReply,
2485
+ roles = _ref.roles,
1951
2486
  onReTrySendMessage = _ref.onReTrySendMessage,
1952
2487
  listItemRef = _ref.listItemRef;
1953
- var _useState = useState(),
1954
- selectedReplyMessageId = _useState[0],
1955
- setSelectedReplyMessageId = _useState[1];
1956
- var selectedReplyItemRef = useRef(null);
1957
- var handleToggleReply = function handleToggleReply(id) {
1958
- setSelectedReplyMessageId(id === selectedReplyMessageId ? undefined : id);
1959
- };
1960
- var handleSelectParentMessage = function handleSelectParentMessage(id) {
1961
- if (id === selectedReplyMessageId) selectedReplyItemRef.current && selectedReplyItemRef.current.scrollIntoView({
1962
- behavior: "smooth"
1963
- });else setSelectedReplyMessageId(id);
1964
- };
1965
- useEffect(function () {
1966
- selectedReplyMessageId && selectedReplyItemRef.current && selectedReplyItemRef.current.scrollIntoView({
1967
- behavior: "smooth"
2488
+ var filterMessage = useMemo(function () {
2489
+ var prevTime = 0;
2490
+ var prevSender;
2491
+ return messages.map(function (message) {
2492
+ var _message$sender, _message$sender2;
2493
+ var currentTime = new Date(message.createdAt).getTime();
2494
+ var showTimestamp = !prevTime || currentTime - prevTime > 20 * 60 * 1000;
2495
+ var showName = ((_message$sender = message.sender) === null || _message$sender === void 0 ? void 0 : _message$sender.fullName) !== prevSender;
2496
+ prevSender = (_message$sender2 = message.sender) === null || _message$sender2 === void 0 ? void 0 : _message$sender2.fullName;
2497
+ prevTime = currentTime;
2498
+ return _extends({}, message, {
2499
+ showTimestamp: showTimestamp,
2500
+ showName: showName
2501
+ });
1968
2502
  });
1969
- }, [selectedReplyMessageId, selectedReplyItemRef.current]);
2503
+ }, [JSON.stringify(messages)]);
2504
+ var isStudent = roles === null || roles === void 0 ? void 0 : roles.includes(Roles.Student);
1970
2505
  return React.createElement("ul", {
1971
2506
  ref: listItemRef,
1972
- className: styles$1["list"] + " h-100 d-flex flex-column py-3 px-0 mb-0"
1973
- }, React.createElement("li", {
1974
- className: "flex-grow-1",
1975
- key: "start-of-list"
1976
- }), !(messages !== null && messages !== void 0 && messages.length) && React.createElement("li", {
2507
+ className: styles["list"] + " " + styles["padding-content"] + " d-flex h-100 flex-column mb-0 " + (!(filterMessage !== null && filterMessage !== void 0 && filterMessage.length) ? 'justify-content-center' : '')
2508
+ }, !(filterMessage !== null && filterMessage !== void 0 && filterMessage.length) && React.createElement("li", {
1977
2509
  className: "text-muted text-center fst-italic fs-6"
1978
- }, "No message"), !!(messages !== null && messages !== void 0 && messages.length) && messages.map(function (message) {
2510
+ }, "No message"), !!(filterMessage !== null && filterMessage !== void 0 && filterMessage.length) && filterMessage.map(function (message) {
1979
2511
  return React.createElement(ChatItem, Object.assign({
1980
2512
  key: message.id
1981
2513
  }, message, {
1982
- onAddExamMessage: onAddExamMessage,
1983
- onReply: onReply,
1984
- selectedReplyMessageId: selectedReplyMessageId,
1985
- onToggleReply: handleToggleReply,
1986
- selectedReplyItemRef: selectedReplyItemRef,
1987
- onReTrySendMessage: onReTrySendMessage,
1988
- onGotoParentMessage: handleSelectParentMessage
2514
+ isStudent: isStudent,
2515
+ onReTrySendMessage: onReTrySendMessage
1989
2516
  }));
1990
2517
  }));
1991
2518
  };
1992
2519
 
2520
+ var iconSendMessage = function iconSendMessage(_ref) {
2521
+ var _ref$width = _ref.width,
2522
+ width = _ref$width === void 0 ? "16" : _ref$width,
2523
+ _ref$height = _ref.height,
2524
+ height = _ref$height === void 0 ? "16" : _ref$height,
2525
+ color = _ref.color;
2526
+ return React.createElement("svg", {
2527
+ width: width,
2528
+ height: height,
2529
+ viewBox: "0 0 16 16",
2530
+ fill: color,
2531
+ xmlns: "http://www.w3.org/2000/svg"
2532
+ }, React.createElement("path", {
2533
+ d: "M14.8934 7.09539L14.8884 7.0932L1.54219 1.55758C1.42993 1.51059 1.30778 1.49217 1.18666 1.50395C1.06554 1.51573 0.949225 1.55734 0.848125 1.62508C0.741311 1.69507 0.653573 1.79052 0.592805 1.90283C0.532037 2.01515 0.500145 2.14081 0.5 2.26852V5.80883C0.50006 5.98341 0.561019 6.15249 0.67237 6.28695C0.783722 6.42141 0.938491 6.5128 1.11 6.54539L8.38906 7.89133C8.41767 7.89675 8.44348 7.91199 8.46205 7.93441C8.48062 7.95683 8.49078 7.98503 8.49078 8.01414C8.49078 8.04325 8.48062 8.07145 8.46205 8.09387C8.44348 8.1163 8.41767 8.13153 8.38906 8.13695L1.11031 9.48289C0.938851 9.5154 0.784092 9.60667 0.67269 9.74101C0.561288 9.87534 0.500219 10.0443 0.5 10.2188V13.7598C0.499917 13.8817 0.530111 14.0018 0.587871 14.1092C0.645632 14.2166 0.729152 14.3079 0.830938 14.3751C0.953375 14.4564 1.09706 14.4999 1.24406 14.5001C1.34626 14.5 1.4474 14.4795 1.54156 14.4398L14.8875 8.9357L14.8934 8.93289C15.0731 8.85569 15.2262 8.72751 15.3337 8.56421C15.4413 8.40092 15.4986 8.20968 15.4986 8.01414C15.4986 7.81861 15.4413 7.62736 15.3337 7.46407C15.2262 7.30077 15.0731 7.1726 14.8934 7.09539Z",
2534
+ fill: "white"
2535
+ }));
2536
+ };
2537
+
1993
2538
  var InputChat = function InputChat(_ref) {
1994
2539
  var text = _ref.text,
1995
- parentText = _ref.parentText,
1996
- examTitle = _ref.examTitle,
1997
2540
  inputRef = _ref.inputRef,
1998
2541
  onChangeInput = _ref.onChangeInput,
1999
2542
  onSubmit = _ref.onSubmit,
2000
- onClearReply = _ref.onClearReply;
2543
+ isCompleted = _ref.isCompleted,
2544
+ handleUploadImage = _ref.handleUploadImage,
2545
+ selectedFile = _ref.selectedFile,
2546
+ handleDeleteSelectedImage = _ref.handleDeleteSelectedImage;
2547
+ var _useTranslation = useTranslation(),
2548
+ t = _useTranslation.t;
2549
+ var fileInputRef = useRef(null);
2001
2550
  var handleSubmit = function handleSubmit() {
2002
- if (!text.trim().length) return;
2003
2551
  onSubmit();
2004
2552
  };
2005
2553
  var handleInputChange = function handleInputChange(event) {
2006
2554
  onChangeInput(event.target.value);
2007
2555
  };
2008
2556
  var handleKeyPressEnter = function handleKeyPressEnter(e) {
2009
- if (e.code === "Enter") handleSubmit();
2557
+ if (e.key === "Enter") {
2558
+ handleSubmit();
2559
+ return;
2560
+ }
2010
2561
  };
2011
- var handleClearReply = function handleClearReply() {
2012
- onClearReply === null || onClearReply === void 0 ? void 0 : onClearReply();
2562
+ var handleSelectedFile = function handleSelectedFile(e) {
2563
+ var files = e.target.files;
2564
+ handleUploadImage(files[0]);
2565
+ if (fileInputRef.current) {
2566
+ fileInputRef.current.value = "";
2567
+ }
2013
2568
  };
2014
- return React.createElement("div", {
2015
- className: "bg-light rounded-3 p-2"
2016
- }, React.createElement(Collapse, {
2017
- isOpen: !!parentText || !!examTitle && !parentText
2018
- }, !!parentText ? React.createElement("div", {
2019
- className: "d-flex justify-content-between align-items-center"
2020
- }, React.createElement("p", {
2021
- className: "mb-3 " + styles$1["reply-text"]
2022
- }, React.createElement("b", null, "Reply to:"), " " + parentText), !!onClearReply && React.createElement("span", {
2023
- className: "pointer ms-3 mb-3 d-flex justify-content-center align-items-center",
2024
- onClick: handleClearReply
2025
- }, React.createElement(IoIosCloseCircle, null))) : React.createElement("div", {
2026
- className: "d-flex justify-content-between align-items-center"
2027
- }, React.createElement("p", {
2028
- className: "mb-3 " + styles$1["reply-text"]
2029
- }, React.createElement("b", null, "Reply to", examTitle ? " exam" : "", ": "), " " + examTitle), !!onClearReply && React.createElement("span", {
2030
- className: "pointer ms-3 mb-3 d-flex justify-content-center align-items-center",
2031
- onClick: handleClearReply
2032
- }, React.createElement(IoIosCloseCircle, null)))), React.createElement(InputGroup, {
2033
- className: "d-flex align-items"
2034
- }, React.createElement(Input, {
2035
- innerRef: inputRef,
2036
- value: text,
2037
- placeholder: "Enter something",
2038
- onKeyUp: handleKeyPressEnter,
2039
- className: "rounded-pill px-3",
2040
- onChange: handleInputChange
2569
+ return React.createElement(Grid, {
2570
+ item: true,
2571
+ xs: 12,
2572
+ padding: "16px"
2573
+ }, React.createElement(Box, {
2574
+ display: "flex",
2575
+ flexDirection: "row",
2576
+ gap: "24px"
2577
+ }, React.createElement(Box, {
2578
+ display: "flex",
2579
+ flexDirection: "column",
2580
+ gap: "7px",
2581
+ width: "100%"
2582
+ }, React.createElement(Box, {
2583
+ display: "flex",
2584
+ border: "1px solid #97A1AF",
2585
+ borderRadius: "6px",
2586
+ flexDirection: "column"
2587
+ }, selectedFile && React.createElement("div", {
2588
+ style: {
2589
+ position: "relative",
2590
+ margin: "10px",
2591
+ width: "fit-content"
2592
+ }
2593
+ }, React.createElement("img", {
2594
+ src: selectedFile === null || selectedFile === void 0 ? void 0 : selectedFile.content,
2595
+ style: {
2596
+ backgroundRepeat: "no-repeat",
2597
+ width: "100px",
2598
+ height: "100px",
2599
+ backgroundSize: "cover"
2600
+ }
2041
2601
  }), React.createElement("div", {
2042
- className: "p-2 pointer d-flex align-items-center",
2602
+ style: {
2603
+ position: "absolute",
2604
+ right: 0,
2605
+ top: 0,
2606
+ cursor: "pointer"
2607
+ },
2608
+ onClick: handleDeleteSelectedImage
2609
+ }, React.createElement(IoCloseOutline, {
2610
+ color: "#fff",
2611
+ size: 30
2612
+ }))), React.createElement("input", {
2613
+ className: styles["input-chat"],
2614
+ style: {
2615
+ border: "none"
2616
+ },
2617
+ placeholder: t("send_message"),
2618
+ ref: inputRef,
2619
+ value: text,
2620
+ width: "100%",
2621
+ onKeyPress: handleKeyPressEnter,
2622
+ onChange: handleInputChange,
2623
+ disabled: isCompleted
2624
+ })), React.createElement(Typography, {
2625
+ fontWeight: 500,
2626
+ fontSize: "10px",
2627
+ lineHeight: "11.93px",
2628
+ color: "#97A1AF"
2629
+ }, "\uC548\uB0B4 \uD14D\uC2A4\uD2B8\uC785\uB2C8\uB2E4.")), React.createElement(Box, {
2630
+ display: "flex",
2631
+ justifyContent: "flex-end",
2632
+ alignItems: "flex-start",
2633
+ gap: "8px"
2634
+ }, React.createElement(Button$1, {
2635
+ variant: "outlined",
2636
+ component: "label"
2637
+ }, React.createElement(FaImage, null), React.createElement("input", {
2638
+ type: "file",
2639
+ hidden: true,
2640
+ ref: fileInputRef,
2641
+ accept: "image/png, image/gif, image/jpeg",
2642
+ onChangeCapture: handleSelectedFile
2643
+ })), React.createElement(Button$1, {
2644
+ variant: "contained",
2645
+ sx: {
2646
+ bgcolor: isCompleted ? "#EBEBFF !important" : "#5458D5 !important"
2647
+ },
2648
+ className: styles["btn-send"],
2649
+ disabled: isCompleted,
2043
2650
  onClick: handleSubmit
2044
- }, React.createElement(IoMdSend, {
2045
- className: "text-primary fs-4"
2046
- }))));
2651
+ }, React.createElement(iconSendMessage, null), React.createElement(Typography, {
2652
+ fontWeight: 700,
2653
+ fontSize: "13px",
2654
+ lineHeight: "15.51px"
2655
+ }, t("button.send"))))));
2047
2656
  };
2048
2657
 
2049
- var ChatHeader = function ChatHeader(_ref) {
2050
- var name = _ref.name,
2051
- avatar = _ref.avatar,
2052
- options = _ref.options,
2053
- selectedOption = _ref.selectedOption,
2054
- onChangeOption = _ref.onChangeOption;
2055
- var wrapperRef = useRef(null);
2056
- var actionRef = useRef(null);
2057
- var language = useSelector(function (state) {
2058
- var _state$common;
2059
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.language;
2658
+ var iconChecked = function iconChecked(_ref) {
2659
+ var _ref$width = _ref.width,
2660
+ width = _ref$width === void 0 ? "16" : _ref$width,
2661
+ _ref$height = _ref.height,
2662
+ height = _ref$height === void 0 ? "16" : _ref$height,
2663
+ color = _ref.color;
2664
+ return React.createElement("svg", {
2665
+ width: width,
2666
+ height: height,
2667
+ viewBox: "0 0 16 16",
2668
+ fill: color,
2669
+ xmlns: "http://www.w3.org/2000/svg"
2670
+ }, React.createElement("path", {
2671
+ d: "M8 1.5C4.41594 1.5 1.5 4.41594 1.5 8C1.5 11.5841 4.41594 14.5 8 14.5C11.5841 14.5 14.5 11.5841 14.5 8C14.5 4.41594 11.5841 1.5 8 1.5ZM11.3828 5.82156L7.18281 10.8216C7.13674 10.8764 7.07941 10.9208 7.01471 10.9516C6.95001 10.9823 6.87945 10.9989 6.80781 11H6.79938C6.72929 11 6.66 10.9852 6.59599 10.9567C6.53198 10.9282 6.47468 10.8865 6.42781 10.8344L4.62781 8.83438C4.5821 8.78589 4.54654 8.72876 4.52322 8.66633C4.4999 8.60391 4.4893 8.53745 4.49203 8.47087C4.49477 8.40429 4.51078 8.33892 4.53914 8.27862C4.56749 8.21831 4.60761 8.16429 4.65715 8.11971C4.70668 8.07514 4.76463 8.04091 4.82757 8.01905C4.89052 7.99719 4.95721 7.98813 5.02371 7.9924C5.09021 7.99668 5.15518 8.01421 5.21481 8.04396C5.27444 8.0737 5.32752 8.11507 5.37094 8.16562L6.78625 9.73812L10.6172 5.17844C10.7031 5.07909 10.8247 5.01754 10.9556 5.00711C11.0866 4.99668 11.2164 5.03819 11.317 5.12268C11.4175 5.20717 11.4808 5.32784 11.4931 5.45862C11.5055 5.5894 11.4658 5.71977 11.3828 5.82156Z",
2672
+ fill: "#5458D5"
2673
+ }));
2674
+ };
2675
+
2676
+ var CONVERSATION_URL = BASE_URL + "/api/conversation";
2677
+ var apiAddMessage = function apiAddMessage(conversationId, message) {
2678
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
2679
+ };
2680
+ var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
2681
+ return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
2682
+ params: filter
2060
2683
  });
2684
+ };
2685
+ var completeConversation = function completeConversation(conversationId) {
2686
+ return api.post(CONVERSATION_URL + "/" + conversationId + "/finish");
2687
+ };
2688
+ var apiUploadFile = function apiUploadFile(file) {
2689
+ return apiUpload.post(BASE_URL + "/api/file/upload", file);
2690
+ };
2691
+
2692
+ var useDialog = function useDialog() {
2693
+ var _useState = useState(false),
2694
+ openConfirmDialog = _useState[0],
2695
+ setOpenConfirmDialog = _useState[1];
2696
+ var toggleConfirmDialog = function toggleConfirmDialog() {
2697
+ setOpenConfirmDialog(function (state) {
2698
+ return !state;
2699
+ });
2700
+ };
2701
+ var handleConfirm = function handleConfirm(conversationId) {
2702
+ try {
2703
+ var _temp2 = function _temp2() {
2704
+ setLoading(false);
2705
+ };
2706
+ setLoading(true);
2707
+ var _temp = _catch(function () {
2708
+ return Promise.resolve(completeConversation(conversationId)).then(function () {
2709
+ toggleConfirmDialog();
2710
+ toast.success("Complete conversation success");
2711
+ });
2712
+ }, function () {
2713
+ toast.error("Failed to complete conversation");
2714
+ });
2715
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
2716
+ } catch (e) {
2717
+ return Promise.reject(e);
2718
+ }
2719
+ };
2720
+ return {
2721
+ openConfirmDialog: openConfirmDialog,
2722
+ toggleConfirmDialog: toggleConfirmDialog,
2723
+ handleConfirm: handleConfirm
2724
+ };
2725
+ };
2726
+
2727
+ var ChatHeader = function ChatHeader(_ref) {
2728
+ var fullName = _ref.fullName,
2729
+ examTitle = _ref.examTitle,
2730
+ questionOrder = _ref.questionOrder,
2731
+ conversationId = _ref.conversationId,
2732
+ isCompleted = _ref.isCompleted,
2733
+ durationExam = _ref.durationExam,
2734
+ createdAt = _ref.createdAt,
2735
+ teacherName = _ref.teacherName,
2736
+ roles = _ref.roles;
2737
+ var _useDialog = useDialog(),
2738
+ openConfirmDialog = _useDialog.openConfirmDialog,
2739
+ toggleConfirmDialog = _useDialog.toggleConfirmDialog,
2740
+ handleConfirm = _useDialog.handleConfirm;
2061
2741
  var _useTranslation = useTranslation(),
2062
2742
  t = _useTranslation.t;
2063
- var handleChangeOption = function handleChangeOption(val) {
2064
- onChangeOption === null || onChangeOption === void 0 ? void 0 : onChangeOption(val);
2743
+ var isStudent = roles === null || roles === void 0 ? void 0 : roles.includes(Roles.Student);
2744
+ var filterDurationExam = useMemo(function () {
2745
+ if (!durationExam) return;
2746
+ return moment.duration(durationExam);
2747
+ }, [durationExam]);
2748
+ var renderHeader = function renderHeader() {
2749
+ return isStudent ? React.createElement(Grid, {
2750
+ item: true,
2751
+ xs: 12,
2752
+ borderTop: "1px solid #E4E7EC",
2753
+ borderBottom: "1px solid #E4E7EC",
2754
+ minHeight: "64px",
2755
+ padding: "16px 8px",
2756
+ display: "flex",
2757
+ alignItems: "center",
2758
+ justifyContent: "space-between"
2759
+ }, React.createElement(Box, {
2760
+ padding: "8px 12px",
2761
+ display: "flex",
2762
+ alignItems: "center",
2763
+ gap: "24px",
2764
+ border: "1px solid #EBEBFF",
2765
+ borderRadius: "6px"
2766
+ }, React.createElement(Box, {
2767
+ display: "flex",
2768
+ alignItems: "center",
2769
+ flexDirection: "row",
2770
+ gap: "8px"
2771
+ }, React.createElement(iconPersonNoActive, null), React.createElement(Typography, {
2772
+ fontWeight: 500,
2773
+ fontSize: "14px",
2774
+ lineHeight: "16.71px",
2775
+ color: "#5458D5"
2776
+ }, t("counselor"))), React.createElement(Typography, {
2777
+ fontWeight: 700,
2778
+ fontSize: "14px",
2779
+ lineHeight: "16.71px",
2780
+ color: "#5458D5"
2781
+ }, teacherName)), React.createElement(Box, {
2782
+ display: "flex",
2783
+ alignItems: "start",
2784
+ color: "#5458D5",
2785
+ gap: "6px",
2786
+ flexDirection: "column"
2787
+ }, React.createElement(Typography, {
2788
+ fontWeight: 600,
2789
+ fontSize: "12px",
2790
+ lineHeight: "14.32px"
2791
+ }, examTitle), React.createElement(Box, {
2792
+ display: "flex",
2793
+ flexDirection: "row",
2794
+ gap: "4px"
2795
+ }, React.createElement(Typography, {
2796
+ fontWeight: 600,
2797
+ fontSize: "12px",
2798
+ lineHeight: "14.2px"
2799
+ }, "LIVE \uC2DC\uD5D8"), filterDurationExam && React.createElement(Typography, {
2800
+ fontWeight: 500,
2801
+ fontSize: "12px",
2802
+ lineHeight: "14.32px"
2803
+ }, (!!filterDurationExam.hours() ? filterDurationExam.hours() + " " + t("hour") : "") + " " + (!!filterDurationExam.minutes() ? filterDurationExam.minutes() + " " + t("minute") : "") + " " + (!!filterDurationExam.seconds() ? filterDurationExam.seconds() + " " + t("second") : "")))), React.createElement(Box, {
2804
+ display: "flex",
2805
+ alignItems: "center",
2806
+ gap: "6px",
2807
+ flexDirection: "column"
2808
+ }, React.createElement(Typography, {
2809
+ fontWeight: 700,
2810
+ fontSize: "12px",
2811
+ lineHeight: "14.32px",
2812
+ color: "#5458D5"
2813
+ }, questionOrder != undefined ? t("problem_number_question", {
2814
+ number: questionOrder + 1
2815
+ }) : t("class_inquiry")), React.createElement(Typography, {
2816
+ fontWeight: 500,
2817
+ fontSize: "12px",
2818
+ lineHeight: "14.32px",
2819
+ color: "#97A1AF"
2820
+ }, utcToLocalTime(createdAt, t("date_time_format"))))) : React.createElement(Grid, {
2821
+ item: true,
2822
+ xs: 12,
2823
+ borderTop: "1px solid #E4E7EC",
2824
+ borderBottom: "1px solid #E4E7EC",
2825
+ minHeight: "64px",
2826
+ padding: "16px 8px",
2827
+ display: "flex",
2828
+ alignItems: "center",
2829
+ justifyContent: "space-between"
2830
+ }, React.createElement(Box, {
2831
+ display: "flex",
2832
+ alignItems: "center",
2833
+ gap: "24px",
2834
+ color: "#5458D5"
2835
+ }, React.createElement(Box, {
2836
+ display: "flex",
2837
+ justifyContent: "space-between",
2838
+ alignItems: "center",
2839
+ gap: "8px"
2840
+ }, React.createElement(iconPersonNoActive, null), React.createElement(Typography, {
2841
+ fontWeight: 500,
2842
+ fontSize: "14px",
2843
+ lineHeight: "16.71px"
2844
+ }, t("student"))), React.createElement(Typography, {
2845
+ fontWeight: 700,
2846
+ fontSize: "14px",
2847
+ lineHeight: "16.71px"
2848
+ }, fullName)), React.createElement(Box, {
2849
+ display: "flex",
2850
+ alignItems: "center",
2851
+ gap: "24px",
2852
+ color: "#5458D5"
2853
+ }, examTitle && React.createElement(Typography, {
2854
+ fontWeight: 600,
2855
+ fontSize: "12px",
2856
+ lineHeight: "14.32px"
2857
+ }, examTitle), React.createElement(Typography, {
2858
+ fontWeight: 700,
2859
+ fontSize: "14px",
2860
+ lineHeight: "16.71px"
2861
+ }, questionOrder != undefined ? t("problem_number_question", {
2862
+ number: questionOrder + 1
2863
+ }) : t("class_inquiry"))), !isCompleted ? React.createElement("div", {
2864
+ onClick: toggleConfirmDialog
2865
+ }, React.createElement(Box, {
2866
+ padding: "8px 12px",
2867
+ display: "flex",
2868
+ alignItems: "center",
2869
+ gap: "8px",
2870
+ border: "1px solid #5458D5",
2871
+ borderRadius: "6px"
2872
+ }, React.createElement(iconChecked, null), React.createElement(Typography, {
2873
+ fontWeight: 700,
2874
+ fontSize: "13px",
2875
+ lineHeight: "15.51px",
2876
+ color: "#5458D5"
2877
+ }, "\uC644\uB8CC \uCC98\uB9AC"))) : React.createElement("div", null));
2065
2878
  };
2066
- useEffect(function () {
2067
- var handleClickOutside = function handleClickOutside(event) {
2068
- if (wrapperRef.current && !wrapperRef.current.contains(event.target) && actionRef.current && !actionRef.current.contains(event.target)) ;
2069
- };
2070
- document.addEventListener("mousedown", handleClickOutside);
2071
- return function () {
2072
- document.removeEventListener("mousedown", handleClickOutside);
2073
- };
2074
- }, [wrapperRef, actionRef]);
2075
- var selectOptions = useMemo(function () {
2076
- return options === null || options === void 0 ? void 0 : options.map(function (i) {
2077
- return {
2078
- value: i.id,
2079
- label: i.title + " (" + utcToLocalTime(i.startTime, t("date_time_format")) + ")"
2080
- };
2081
- });
2082
- }, [JSON.stringify(options), language]);
2083
- return React.createElement("div", {
2084
- className: "d-flex bg-light rounded-3 p-3"
2085
- }, React.createElement("div", null, React.createElement("img", {
2086
- className: "rounded-circle " + styles$1["header__avatar"],
2087
- src: avatar,
2088
- alt: name
2089
- })), React.createElement("div", {
2090
- className: "flex-grow-1 px-3 d-flex align-items-center"
2091
- }, React.createElement("p", {
2092
- className: "mb-0 text-primary fw-medium"
2093
- }, name)), React.createElement("div", {
2094
- className: "d-flex align-items-center"
2095
- }, selectOptions !== undefined && React.createElement("div", {
2096
- className: styles$1["header__select"] + " mx-3"
2097
- }, React.createElement(CustomSelect, {
2098
- value: selectedOption,
2099
- options: selectOptions,
2100
- onChange: handleChangeOption,
2101
- isClearable: true
2102
- })), React.createElement("div", {
2103
- className: "actions d-flex align-items-center"
2104
- })));
2879
+ return React.createElement(Grid, {
2880
+ container: true
2881
+ }, React.createElement(Grid, {
2882
+ item: true,
2883
+ xs: 12,
2884
+ paddingLeft: "32px",
2885
+ paddingTop: "20px",
2886
+ paddingBottom: "16px",
2887
+ minHeight: "60px"
2888
+ }, React.createElement(Typography, {
2889
+ fontWeight: 800,
2890
+ fontSize: "20px",
2891
+ color: "#5458D5",
2892
+ lineHeight: "23.87px"
2893
+ }, t("question_and_answer"))), renderHeader(), React.createElement(ConfirmDialog, {
2894
+ open: openConfirmDialog,
2895
+ toggle: toggleConfirmDialog,
2896
+ text: "정말로 이 채팅 베팅을 완료하시겠습니까?",
2897
+ onConfirm: function onConfirm() {
2898
+ return handleConfirm(conversationId || 0);
2899
+ },
2900
+ title: t("confirmation"),
2901
+ okText: t("yes"),
2902
+ cancelText: t("no")
2903
+ }));
2105
2904
  };
2106
2905
 
2107
2906
  var ChatContainer = function ChatContainer(_ref) {
@@ -2113,55 +2912,47 @@ var ChatContainer = function ChatContainer(_ref) {
2113
2912
  _ref$isLoading = _ref.isLoading,
2114
2913
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
2115
2914
  isScrollToEnd = _ref.isScrollToEnd,
2116
- onRead = _ref.onRead,
2117
2915
  onReachTop = _ref.onReachTop,
2118
2916
  onReachBottom = _ref.onReachBottom,
2119
2917
  onEndScrollToEnd = _ref.onEndScrollToEnd;
2120
- var onReply = chatListProps.onReply,
2121
- onAddExamMessage = chatListProps.onAddExamMessage;
2122
- var onChangeOption = chatHeaderProps.onChangeOption;
2123
2918
  var inputRef = useRef(null);
2124
2919
  var listRef = useRef(null);
2125
2920
  var listItemRef = useRef(null);
2126
2921
  var scrollRef = useRef();
2127
- var focusRef = useRef();
2128
2922
  var addEventTimeout = useRef();
2129
- var handleReply = function handleReply(id, content, examId) {
2130
- var _inputRef$current;
2131
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
2132
- onReply === null || onReply === void 0 ? void 0 : onReply(id, content, examId);
2133
- };
2134
- var handleAddExamMessage = function handleAddExamMessage(examId, examTitle, examCode) {
2135
- var _inputRef$current2;
2136
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
2137
- onAddExamMessage(examId, examTitle, examCode);
2138
- };
2139
- var handleChangeExamOption = function handleChangeExamOption(val) {
2140
- var _inputRef$current3;
2141
- if (!!(val !== null && val !== void 0 && val.value)) (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus();
2142
- onChangeOption === null || onChangeOption === void 0 ? void 0 : onChangeOption(val);
2143
- };
2144
2923
  var handleScroll = function handleScroll() {
2145
- if (listRef.current) {
2146
- var scrollTop = listRef.current.scrollTop;
2147
- var scrollHeight = listRef.current.scrollHeight;
2148
- var clientHeight = listRef.current.clientHeight;
2149
- if (scrollTop + clientHeight + scrollOffset >= scrollHeight) {
2150
- onReachBottom === null || onReachBottom === void 0 ? void 0 : onReachBottom();
2151
- } else if (scrollTop <= scrollOffset) {
2152
- onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop();
2153
- }
2924
+ try {
2925
+ var _temp4 = function _temp4() {
2926
+ if (scrollRef.current) clearTimeout(scrollRef.current);
2927
+ };
2928
+ var _temp3 = function () {
2929
+ if (listRef.current) {
2930
+ var scrollTop = listRef.current.scrollTop;
2931
+ var scrollHeight = listRef.current.scrollHeight;
2932
+ var clientHeight = listRef.current.clientHeight;
2933
+ var _temp2 = function () {
2934
+ if (scrollTop + clientHeight + scrollOffset >= scrollHeight) {
2935
+ onReachBottom === null || onReachBottom === void 0 ? void 0 : onReachBottom();
2936
+ } else {
2937
+ var _temp5 = function () {
2938
+ if (scrollTop <= scrollOffset) {
2939
+ return Promise.resolve(onReachTop === null || onReachTop === void 0 ? void 0 : onReachTop()).then(function (isSuccessLoad) {
2940
+ if (isSuccessLoad) {
2941
+ listRef.current.scrollTop = listRef.current.scrollHeight - scrollHeight;
2942
+ }
2943
+ });
2944
+ }
2945
+ }();
2946
+ if (_temp5 && _temp5.then) return _temp5.then(function () {});
2947
+ }
2948
+ }();
2949
+ if (_temp2 && _temp2.then) return _temp2.then(function () {});
2950
+ }
2951
+ }();
2952
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
2953
+ } catch (e) {
2954
+ return Promise.reject(e);
2154
2955
  }
2155
- if (scrollRef.current) clearTimeout(scrollRef.current);
2156
- scrollRef.current = setTimeout(function () {
2157
- onRead === null || onRead === void 0 ? void 0 : onRead();
2158
- }, 800);
2159
- };
2160
- var handleFocus = function handleFocus() {
2161
- if (focusRef.current) clearTimeout(focusRef.current);
2162
- focusRef.current = setTimeout(function () {
2163
- onRead === null || onRead === void 0 ? void 0 : onRead();
2164
- }, 300);
2165
2956
  };
2166
2957
  useEffect(function () {
2167
2958
  var _listRef$current, _chatListProps$messag, _listRef$current3;
@@ -2179,137 +2970,40 @@ var ChatContainer = function ChatContainer(_ref) {
2179
2970
  (_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.addEventListener("scroll", handleScroll);
2180
2971
  }, 800);
2181
2972
  } else (_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : _listRef$current3.addEventListener("scroll", handleScroll);
2182
- return function () {
2183
- var _listRef$current4;
2184
- (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : _listRef$current4.removeEventListener("scroll", handleScroll);
2185
- scrollRef.current && clearTimeout(scrollRef.current);
2186
- addEventTimeout.current && clearTimeout(addEventTimeout.current);
2187
- };
2188
- }, [JSON.stringify(chatListProps.messages), scrollOffset, isLoading, onEndScrollToEnd, onRead, isScrollToEnd]);
2189
- useEffect(function () {
2190
- var _inputRef$current4;
2191
- (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.addEventListener("focus", handleFocus);
2192
- return function () {
2193
- var _inputRef$current5;
2194
- (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.removeEventListener("focus", handleFocus);
2195
- focusRef.current && clearTimeout(focusRef.current);
2196
- };
2197
- }, [onRead]);
2198
- return React.createElement("div", {
2199
- className: "d-flex flex-column w-100 h-100 border border-1 border-light rounded-3 shadow-sm"
2200
- }, React.createElement("div", null, React.createElement(ChatHeader, Object.assign({}, chatHeaderProps, {
2201
- onChangeOption: handleChangeExamOption
2202
- }))), React.createElement("div", {
2203
- ref: listRef,
2204
- className: "flex-grow-1 " + styles$1["body"]
2205
- }, isLoading && React.createElement("div", {
2206
- className: "d-flex justify-content-center"
2207
- }, React.createElement(Spinner, {
2208
- color: "secondary",
2209
- className: "my-2"
2210
- }, "Loading...")), React.createElement(ChatList, Object.assign({}, chatListProps, {
2211
- listItemRef: listItemRef,
2212
- onReply: handleReply,
2213
- onAddExamMessage: handleAddExamMessage
2214
- }))), React.createElement("div", null, React.createElement(InputChat, Object.assign({}, inputProps, {
2215
- inputRef: inputRef
2216
- }))));
2217
- };
2218
-
2219
- var CONVERSATION_URL = BASE_URL + "/api/conversation";
2220
- var getListConversation = function getListConversation(query) {
2221
- return api.get("" + CONVERSATION_URL, {
2222
- params: query
2223
- });
2224
- };
2225
- var createConversation = function createConversation(studentId) {
2226
- return api.post("" + CONVERSATION_URL, {
2227
- targetUserId: "" + studentId
2228
- });
2229
- };
2230
- var apiAddMessage = function apiAddMessage(conversationId, message) {
2231
- return api.post(CONVERSATION_URL + "/" + conversationId + "/messages", message);
2232
- };
2233
- var getMessagesByConversation = function getMessagesByConversation(conversationId, filter) {
2234
- return api.get(CONVERSATION_URL + "/" + conversationId + "/messages", {
2235
- params: filter
2236
- });
2237
- };
2238
- var apiMarkReadMessage = function apiMarkReadMessage(conversationId, messageId) {
2239
- return api.put(CONVERSATION_URL + "/" + conversationId + "/messages/" + messageId + "/mark-read");
2240
- };
2241
- var apiGetConversationByUserId = function apiGetConversationByUserId(userId) {
2242
- return api.get(CONVERSATION_URL + "/users/" + userId);
2243
- };
2244
-
2245
- var ExamStatus;
2246
- (function (ExamStatus) {
2247
- ExamStatus["Default"] = "Default";
2248
- ExamStatus["Pending"] = "Pending";
2249
- ExamStatus["Inprogress"] = "Inprogress";
2250
- ExamStatus["Completed"] = "Completed";
2251
- })(ExamStatus || (ExamStatus = {}));
2252
- var CONVERSATION_DEFAULT_FILTER = {
2253
- currentPage: 1,
2254
- pageSize: -1,
2255
- textSearch: ""
2256
- };
2257
- var MESSAGE_DEFAULT_FILTER = {
2258
- currentPage: 1,
2259
- pageSize: 12,
2260
- textSearch: "",
2261
- sortColumnDirection: OrderBy.DESC,
2262
- sortColumnName: MessageSortBy.CreatedAt
2263
- };
2264
-
2265
- var EXAM_URL = BASE_URL + "/api/exam";
2266
- var getListExamApi = function getListExamApi(query) {
2267
- return api.get(EXAM_URL + "/getList", {
2268
- params: query
2269
- });
2270
- };
2271
-
2272
- var useExamList = function useExamList(isStudent) {
2273
- if (isStudent === void 0) {
2274
- isStudent = true;
2275
- }
2276
- var _useState = useState(),
2277
- exams = _useState[0],
2278
- setExams = _useState[1];
2279
- var getListExam = function getListExam(userId) {
2280
- try {
2281
- setExams([]);
2282
- var _temp = _catch(function () {
2283
- return Promise.resolve(getListExamApi({
2284
- currentPage: 1,
2285
- pageSize: -1,
2286
- sortColumnDirection: "DESC",
2287
- sortColumnName: "CreatedAt",
2288
- statuses: [ExamStatus.Completed],
2289
- studentId: !isStudent ? userId : undefined,
2290
- teacherId: isStudent ? userId : undefined
2291
- })).then(function (res) {
2292
- var _res$data;
2293
- var data = ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.items) || [];
2294
- setExams(data);
2295
- });
2296
- }, function (error) {
2297
- console.log({
2298
- error: error
2299
- });
2300
- });
2301
- return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
2302
- } catch (e) {
2303
- return Promise.reject(e);
2973
+ return function () {
2974
+ var _listRef$current4;
2975
+ (_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : _listRef$current4.removeEventListener("scroll", handleScroll);
2976
+ scrollRef.current && clearTimeout(scrollRef.current);
2977
+ addEventTimeout.current && clearTimeout(addEventTimeout.current);
2978
+ };
2979
+ }, [JSON.stringify(chatListProps.messages), scrollOffset, isLoading, onEndScrollToEnd, isScrollToEnd]);
2980
+ useEffect(function () {
2981
+ onReachBottom === null || onReachBottom === void 0 ? void 0 : onReachBottom();
2982
+ }, [JSON.stringify(chatListProps.messages)]);
2983
+ return React.createElement(Grid, {
2984
+ container: true
2985
+ }, React.createElement(ChatHeader, Object.assign({}, chatHeaderProps)), React.createElement("div", {
2986
+ ref: listRef,
2987
+ className: "flex-grow-1 " + styles["body"],
2988
+ style: {
2989
+ height: "60vh",
2990
+ overflowY: "scroll",
2991
+ background: "#F9FAFB"
2304
2992
  }
2305
- };
2306
- return {
2307
- getListExam: getListExam,
2308
- exams: exams
2309
- };
2993
+ }, isLoading && React.createElement("div", {
2994
+ style: {
2995
+ height: "100%",
2996
+ width: "100%"
2997
+ },
2998
+ className: "d-flex justify-content-center align-items-center"
2999
+ }, React.createElement(CircularProgress, null)), React.createElement(ChatList, Object.assign({}, chatListProps, {
3000
+ listItemRef: listItemRef
3001
+ }))), React.createElement(InputChat, Object.assign({}, inputProps, {
3002
+ inputRef: inputRef
3003
+ })));
2310
3004
  };
2311
3005
 
2312
- var useMessageList = function useMessageList(userId, getListExamOptions) {
3006
+ var useMessageList = function useMessageList() {
2313
3007
  var _useState = useState([]),
2314
3008
  messages = _useState[0],
2315
3009
  setMessages = _useState[1];
@@ -2319,58 +3013,70 @@ var useMessageList = function useMessageList(userId, getListExamOptions) {
2319
3013
  var _useState3 = useState(false),
2320
3014
  isLoading = _useState3[0],
2321
3015
  setLoading = _useState3[1];
2322
- var getMessageList = function getMessageList(conversationId, examId) {
3016
+ var getMessageList = function getMessageList(conversationId) {
2323
3017
  try {
2324
- var _temp3 = function _temp3() {
3018
+ var _temp2 = function _temp2() {
2325
3019
  setLoading(false);
2326
3020
  };
2327
3021
  setLoading(true);
2328
- var _temp2 = _catch(function () {
2329
- var filter = _extends({}, messageFilter, {
2330
- examId: !examId ? messageFilter.examId : examId
2331
- });
3022
+ var _temp = _catch(function () {
3023
+ var filter = _extends({}, messageFilter);
2332
3024
  return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
2333
- var _res$data$items2;
2334
- function _temp(_getListExamOptions) {
2335
- _getListExamOptions;
2336
- }
2337
- if (messageFilter.beforeDate) setMessages(function (state) {
3025
+ setMessages(function (prev) {
2338
3026
  var _res$data$items;
2339
- return [].concat(((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse()) || [], state);
2340
- });else setMessages((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse());
2341
- return getListExamOptions ? Promise.resolve(!!getListExamOptions && getListExamOptions(userId)).then(_temp) : _temp(!!getListExamOptions && getListExamOptions(userId));
2342
- });
2343
- }, function (error) {
2344
- console.log({
2345
- error: error
3027
+ return [].concat((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items.reverse(), prev);
3028
+ });
3029
+ setMessageFilter(function (prev) {
3030
+ return _extends({}, prev, {
3031
+ totalItems: res.data.totalItems,
3032
+ totalPages: res.data.totalPages
3033
+ });
3034
+ });
2346
3035
  });
3036
+ }, function () {
3037
+ toast.error("Fail to fetch data!");
2347
3038
  });
2348
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
3039
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
2349
3040
  } catch (e) {
2350
3041
  return Promise.reject(e);
2351
3042
  }
2352
3043
  };
2353
- var handleLoadMore = function handleLoadMore() {
2354
- if (isLoading) return;
2355
- var lastItem = messages[0];
2356
- if (!lastItem) return;
2357
- var newFilter = _extends({}, messageFilter, {
2358
- currentPage: 1,
2359
- beforeDate: lastItem.createdAt
2360
- });
2361
- setMessageFilter(newFilter);
2362
- return JSON.stringify(newFilter) === JSON.stringify(messageFilter);
2363
- };
2364
- var handleMarkReadMessage = function handleMarkReadMessage(conversationId, messageId) {
3044
+ var handleLoadMore = function handleLoadMore(conversationId) {
2365
3045
  try {
2366
- var _temp4 = _catch(function () {
2367
- return Promise.resolve(apiMarkReadMessage(conversationId, messageId)).then(function () {});
2368
- }, function (error) {
2369
- console.log({
2370
- error: error
3046
+ var _temp4 = function _temp4(_result) {
3047
+ if (_exit) return _result;
3048
+ setLoading(false);
3049
+ return true;
3050
+ };
3051
+ var _exit = false;
3052
+ if (isLoading) return Promise.resolve();
3053
+ var filter = _extends({}, messageFilter, {
3054
+ currentPage: ((messageFilter === null || messageFilter === void 0 ? void 0 : messageFilter.currentPage) || 1) + 1
3055
+ });
3056
+ setMessageFilter(filter);
3057
+ setLoading(true);
3058
+ var _temp3 = _catch(function () {
3059
+ return Promise.resolve(getMessagesByConversation(conversationId, filter)).then(function (res) {
3060
+ setMessages(function (prev) {
3061
+ var _res$data$items2;
3062
+ var data = [].concat((_res$data$items2 = res.data.items) === null || _res$data$items2 === void 0 ? void 0 : _res$data$items2.reverse(), prev);
3063
+ var dataFilter = new Set(data);
3064
+ return Array.from(dataFilter);
3065
+ });
3066
+ if (res.data.items) {
3067
+ setMessageFilter(function (prev) {
3068
+ return _extends({}, prev, {
3069
+ totalItems: res.data.totalItems,
3070
+ totalPages: res.data.totalPages
3071
+ });
3072
+ });
3073
+ }
2371
3074
  });
3075
+ }, function () {
3076
+ toast.error("Fail to fetch data!");
3077
+ _exit = true;
2372
3078
  });
2373
- return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function () {}) : void 0);
3079
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
2374
3080
  } catch (e) {
2375
3081
  return Promise.reject(e);
2376
3082
  }
@@ -2379,12 +3085,6 @@ var useMessageList = function useMessageList(userId, getListExamOptions) {
2379
3085
  setMessageFilter(MESSAGE_DEFAULT_FILTER);
2380
3086
  setMessages([]);
2381
3087
  };
2382
- var handleChangeExamId = function handleChangeExamId(value) {
2383
- setMessageFilter(_extends({}, messageFilter, {
2384
- examId: value === null || value === void 0 ? void 0 : value.value,
2385
- currentPage: 1
2386
- }));
2387
- };
2388
3088
  return {
2389
3089
  isLoading: isLoading,
2390
3090
  messageFilter: messageFilter,
@@ -2392,53 +3092,45 @@ var useMessageList = function useMessageList(userId, getListExamOptions) {
2392
3092
  getMessageList: getMessageList,
2393
3093
  setMessages: setMessages,
2394
3094
  resetMessages: resetMessages,
2395
- handleChangeExamId: handleChangeExamId,
2396
- handleMarkReadMessage: handleMarkReadMessage,
2397
3095
  handleLoadMore: handleLoadMore
2398
3096
  };
2399
3097
  };
2400
3098
 
2401
3099
  var useChatContainer = function useChatContainer(props) {
2402
- var _selectedConversation, _selectedConversation2, _selectedConversation3, _selectedConversation4, _selectedConversation5, _selectedConversation6;
3100
+ var _selectedConversation;
2403
3101
  var conversation = props.conversation,
2404
- userId = props.userId,
2405
- examId = props.examId,
2406
- onUpdateLastMessage = props.onUpdateLastMessage,
2407
- onCreateConversationSuccess = props.onCreateConversationSuccess,
2408
- onGetMessagesSuccess = props.onGetMessagesSuccess;
3102
+ student = props.student;
2409
3103
  var pusher = useRef();
2410
3104
  var channel = useRef();
2411
3105
  var channelName = useRef();
2412
3106
  var loadingRef = useRef(false);
2413
- var firstLoadRef = useRef(true);
2414
- var dispatch = useDispatch();
3107
+ var infoUser = useSelector(function (state) {
3108
+ var _state$common;
3109
+ return (state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user) || {};
3110
+ });
3111
+ var academyDomain = infoUser === null || infoUser === void 0 ? void 0 : infoUser.academyDomain;
2415
3112
  var roles = useSelector(function (state) {
2416
- var _state$common, _state$common$user;
2417
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : (_state$common$user = _state$common.user) === null || _state$common$user === void 0 ? void 0 : _state$common$user.roles;
2418
- }) || [];
2419
- var isStudent = roles.includes("Student");
3113
+ var _state$common2, _state$common2$user;
3114
+ return (state === null || state === void 0 ? void 0 : (_state$common2 = state.common) === null || _state$common2 === void 0 ? void 0 : (_state$common2$user = _state$common2.user) === null || _state$common2$user === void 0 ? void 0 : _state$common2$user.roles) || [];
3115
+ });
2420
3116
  var _useState = useState(),
2421
3117
  selectedConversation = _useState[0],
2422
3118
  setSelectedConversation = _useState[1];
2423
3119
  var _useState2 = useState(),
2424
- message = _useState2[0],
2425
- setMessage = _useState2[1];
2426
- var _useState3 = useState(MessageStatus.Default),
2427
- messageStatus = _useState3[0],
2428
- setMessageStatus = _useState3[1];
3120
+ selectedFile = _useState2[0],
3121
+ setSelectedFile = _useState2[1];
3122
+ var _useState3 = useState(),
3123
+ message = _useState3[0],
3124
+ setMessage = _useState3[1];
2429
3125
  var _useState4 = useState(true),
2430
3126
  isScrollToEnd = _useState4[0],
2431
3127
  setScrollToEnd = _useState4[1];
2432
- var _useExamList = useExamList(isStudent),
2433
- exams = _useExamList.exams,
2434
- getListExam = _useExamList.getListExam;
2435
- var _useMessageList = useMessageList(isStudent ? selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation = selectedConversation.teacher) === null || _selectedConversation === void 0 ? void 0 : _selectedConversation.id : selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation2 = selectedConversation.student) === null || _selectedConversation2 === void 0 ? void 0 : _selectedConversation2.id, !userId ? getListExam : undefined),
3128
+ var _useMessageList = useMessageList(),
2436
3129
  isLoadingMessages = _useMessageList.isLoading,
2437
3130
  messages = _useMessageList.messages,
2438
3131
  messageFilter = _useMessageList.messageFilter,
2439
3132
  getMessageList = _useMessageList.getMessageList,
2440
3133
  resetMessages = _useMessageList.resetMessages,
2441
- handleChangeExamId = _useMessageList.handleChangeExamId,
2442
3134
  setMessages = _useMessageList.setMessages,
2443
3135
  handleLoadMore = _useMessageList.handleLoadMore;
2444
3136
  var handleToggleScrollToEnd = function handleToggleScrollToEnd() {
@@ -2448,309 +3140,150 @@ var useChatContainer = function useChatContainer(props) {
2448
3140
  };
2449
3141
  var handleAddMessage = function handleAddMessage() {
2450
3142
  try {
2451
- var _message$content, _message$content$trim;
2452
- var _temp2 = function _temp2() {
3143
+ var _temp6 = function _temp6() {
2453
3144
  loadingRef.current = false;
2454
3145
  };
2455
3146
  if (loadingRef.current) return Promise.resolve();
2456
- if (messages.some(function (i) {
2457
- return i.id === 0;
2458
- })) return Promise.resolve();
2459
3147
  loadingRef.current = true;
2460
- if (!(selectedConversation !== null && selectedConversation !== void 0 && selectedConversation.id) || !(message !== null && message !== void 0 && (_message$content = message.content) !== null && _message$content !== void 0 && (_message$content$trim = _message$content.trim()) !== null && _message$content$trim !== void 0 && _message$content$trim.length)) return Promise.resolve();
3148
+ if (!(selectedConversation !== null && selectedConversation !== void 0 && selectedConversation.id)) return Promise.resolve();
2461
3149
  setScrollToEnd(true);
2462
- setMessages(function (state) {
2463
- return [].concat(state, [{
2464
- id: 0,
2465
- isStudent: isStudent,
2466
- content: message.content,
2467
- examId: message.examId,
2468
- parentId: message.parentId,
2469
- parentContent: message.parentContent,
2470
- exam: message.examId ? {
2471
- id: message.examId,
2472
- startTime: moment().format("YYYY-MM-DDTHH:mm:ss"),
2473
- title: message.examTitle || "",
2474
- code: message.examCode || "",
2475
- createdAt: moment().format("YYYY-MM-DDTHH:mm:ss")
2476
- } : undefined,
2477
- isRead: false,
2478
- createdAt: moment().format("YYYY-MM-DDTHH:mm:ss")
2479
- }]);
2480
- });
2481
- setMessage(function (state) {
2482
- if (!state) return undefined;
2483
- return _extends({}, state, {
2484
- content: "",
2485
- parentId: undefined,
2486
- parentContent: "",
2487
- examId: messageFilter.examId,
2488
- examTitle: messageFilter.examId ? message.examTitle : ""
2489
- });
2490
- });
2491
- setMessageStatus(MessageStatus.Sending);
2492
- var _temp = _catch(function () {
2493
- return Promise.resolve(apiAddMessage(selectedConversation.id, _extends({}, message, {
2494
- examId: !!userId ? examId : message.examId
2495
- }))).then(function () {});
3150
+ var _temp5 = _catch(function () {
3151
+ function _temp4() {
3152
+ function _temp2() {
3153
+ handleChangeInput('');
3154
+ setSelectedFile(null);
3155
+ }
3156
+ var _temp = function (_message$content) {
3157
+ if (message !== null && message !== void 0 && (_message$content = message.content) !== null && _message$content !== void 0 && _message$content.trim().length) {
3158
+ return Promise.resolve(apiAddMessage(selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, _extends({}, message))).then(function () {});
3159
+ }
3160
+ }();
3161
+ return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
3162
+ }
3163
+ var _temp3 = function () {
3164
+ if (selectedFile !== null && selectedFile !== void 0 && selectedFile.content) {
3165
+ return Promise.resolve(apiAddMessage(selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, _extends({}, selectedFile, {
3166
+ contentType: 1
3167
+ }))).then(function () {});
3168
+ }
3169
+ }();
3170
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
2496
3171
  }, function (error) {
2497
3172
  var _error$response;
2498
- console.log({
2499
- error: error
2500
- });
2501
- setMessageStatus(MessageStatus.SentError);
2502
3173
  setMessages(function (state) {
2503
3174
  return [].concat(state.filter(function (i) {
2504
- return i.id !== 0;
3175
+ return (i === null || i === void 0 ? void 0 : i.id) !== 0;
2505
3176
  }));
2506
3177
  });
2507
3178
  toast.error((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data);
2508
3179
  });
2509
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
3180
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
2510
3181
  } catch (e) {
2511
3182
  return Promise.reject(e);
2512
3183
  }
2513
3184
  };
2514
- var handleAddExamMessage = function handleAddExamMessage(examId, title, examCode) {
2515
- setMessage(!!message ? _extends({}, message, {
2516
- examId: examId,
2517
- examCode: examCode,
2518
- examTitle: title,
2519
- parentId: undefined,
2520
- parentContent: ""
2521
- }) : {
2522
- examId: examId,
2523
- examCode: examCode,
2524
- content: "",
2525
- examTitle: title,
2526
- parentId: undefined,
2527
- parentContent: ""
2528
- });
2529
- };
2530
- var handleReplyMessage = function handleReplyMessage(parentId, content, examId) {
2531
- setMessage({
2532
- content: "",
2533
- examId: examId,
2534
- parentId: parentId,
2535
- parentContent: content,
2536
- examTitle: message === null || message === void 0 ? void 0 : message.examTitle
2537
- });
2538
- };
2539
- var handleClearReply = function handleClearReply() {
2540
- message && setMessage(_extends({}, message, {
2541
- parentId: undefined,
2542
- examId: messageFilter.examId ? messageFilter.examId : undefined,
2543
- parentContent: "",
2544
- examTitle: messageFilter.examId ? message.examTitle : ""
2545
- }));
3185
+ var handleUploadImage = function handleUploadImage(file) {
3186
+ try {
3187
+ console.log({
3188
+ file: file
3189
+ });
3190
+ if (!file) return Promise.resolve();
3191
+ return Promise.resolve(_finally(function () {
3192
+ return _catch(function () {
3193
+ var formData = new FormData();
3194
+ formData.append("upload", file);
3195
+ return Promise.resolve(apiUploadFile(formData)).then(function (res) {
3196
+ var _res$data;
3197
+ setSelectedFile({
3198
+ content: res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.url
3199
+ });
3200
+ });
3201
+ }, function (error) {
3202
+ var _error$response2;
3203
+ setMessages(function (state) {
3204
+ return [].concat(state.filter(function (i) {
3205
+ return (i === null || i === void 0 ? void 0 : i.id) !== 0;
3206
+ }));
3207
+ });
3208
+ toast.error((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data);
3209
+ });
3210
+ }, function () {}));
3211
+ } catch (e) {
3212
+ return Promise.reject(e);
3213
+ }
2546
3214
  };
2547
3215
  var handleChangeInput = function handleChangeInput(text) {
2548
- setMessage(_extends({}, message, {
2549
- content: text
2550
- }));
2551
- };
2552
- var handleFilterExam = function handleFilterExam(val) {
2553
- var _val$label, _val$label$split;
2554
- var examTitle = val === null || val === void 0 ? void 0 : (_val$label = val.label) === null || _val$label === void 0 ? void 0 : (_val$label$split = _val$label.split(" ")) === null || _val$label$split === void 0 ? void 0 : _val$label$split.slice(0, -1).join(" ");
2555
3216
  setMessage({
2556
- examId: val === null || val === void 0 ? void 0 : val.value,
2557
- content: "",
2558
- examTitle: examTitle,
2559
- parentId: undefined,
2560
- parentContent: ""
3217
+ content: text
2561
3218
  });
2562
- handleChangeExamId(val);
2563
3219
  };
2564
- var messageList = useMemo(function () {
2565
- if (!selectedConversation) return [];
2566
- var examCode = undefined;
2567
- var results = messages.map(function (i, index) {
2568
- var _i$exam, _i$exam4, _i$exam5, _i$exam6, _i$exam7, _i$exam8, _i$exam9, _i$exam10, _i$exam11;
2569
- var isFirst = index === 0;
2570
- var isLast = index === messages.length - 1;
2571
- if (index > 0 && (messages[index - 1].isStudent !== i.isStudent && !i.isSystemLog || i.isSystemLog || messages[index - 1].examId !== i.examId)) isFirst = true;
2572
- if (index < messages.length - 1 && (messages[index + 1].isStudent !== i.isStudent && i.examId !== messages[index + 1].examId || i.examId !== messages[index + 1].examId || messages[index + 1].isSystemLog)) isLast = true;
2573
- var name = isStudent ? "You" : selectedConversation.student.displayName;
2574
- var content = i === null || i === void 0 ? void 0 : i.content;
2575
- var showExamHeader = false;
2576
- if (examCode != ((_i$exam = i.exam) === null || _i$exam === void 0 ? void 0 : _i$exam.code) && !messageFilter.examId && !userId) {
2577
- var _i$exam2, _i$exam3;
2578
- if ((_i$exam2 = i.exam) !== null && _i$exam2 !== void 0 && _i$exam2.code) showExamHeader = true;
2579
- examCode = (_i$exam3 = i.exam) === null || _i$exam3 === void 0 ? void 0 : _i$exam3.code;
2580
- }
2581
- switch (i.type) {
2582
- case MessageSourceType.Exam:
2583
- switch (i.action) {
2584
- case MessageAction.Took:
2585
- content = name + " took the exam " + ((_i$exam4 = i.exam) === null || _i$exam4 === void 0 ? void 0 : _i$exam4.title);
2586
- break;
2587
- }
2588
- break;
2589
- }
2590
- return {
2591
- id: i.id,
2592
- isMe: isStudent === i.isStudent,
2593
- avatar: isStudent ? selectedConversation.teacher.avatar : selectedConversation.student.avatar,
2594
- name: selectedConversation.student.displayName,
2595
- isRead: i.isRead,
2596
- createdAt: i.createdAt,
2597
- content: content,
2598
- isFirst: isFirst,
2599
- isLast: isLast,
2600
- isSystemLog: i.isSystemLog,
2601
- examCode: !messageFilter.examId && !userId ? (_i$exam5 = i.exam) === null || _i$exam5 === void 0 ? void 0 : _i$exam5.code : undefined,
2602
- examId: (_i$exam6 = i.exam) === null || _i$exam6 === void 0 ? void 0 : _i$exam6.id,
2603
- examTitle: (_i$exam7 = i.exam) === null || _i$exam7 === void 0 ? void 0 : _i$exam7.title,
2604
- type: (_i$exam8 = i.exam) !== null && _i$exam8 !== void 0 && _i$exam8.code ? ChatItemType.Exam : undefined,
2605
- showExamHeader: showExamHeader,
2606
- actionLink: ((_i$exam9 = i.exam) === null || _i$exam9 === void 0 ? void 0 : _i$exam9.code) && (isStudent ? "/student/check/live-result?examCode=" + ((_i$exam10 = i.exam) === null || _i$exam10 === void 0 ? void 0 : _i$exam10.code) : "/teacher/exam-status/main?examCode=" + ((_i$exam11 = i.exam) === null || _i$exam11 === void 0 ? void 0 : _i$exam11.code)),
2607
- parentId: i.parentId,
2608
- parentContent: i.parentContent,
2609
- status: i.id ? MessageStatus.Default : messageStatus
2610
- };
2611
- });
2612
- return results;
2613
- }, [JSON.stringify(messages), JSON.stringify(message), isStudent, JSON.stringify(selectedConversation), messageFilter.examId, isStudent, userId, messageStatus]);
2614
3220
  var handleNewMessageSent = function handleNewMessageSent(data) {
2615
- if (!messageFilter.examId && !examId || messageFilter.examId && data.examId === messageFilter.examId || examId && examId === data.examId) {
2616
- setScrollToEnd(true);
2617
- setMessages(function (state) {
2618
- if (state.some(function (i) {
2619
- return i.id === 0;
2620
- })) return [].concat(state.filter(function (i) {
2621
- return i.id !== 0;
2622
- }), [data]);else return [].concat(state, [data]);
2623
- });
2624
- }
2625
- onUpdateLastMessage === null || onUpdateLastMessage === void 0 ? void 0 : onUpdateLastMessage(data);
2626
- };
2627
- var handleMessageMarkRead = function handleMessageMarkRead(data) {
3221
+ if (!data) return;
3222
+ setScrollToEnd(true);
2628
3223
  setMessages(function (state) {
2629
- return [].concat(state.map(function (i) {
2630
- return _extends({}, i, {
2631
- isRead: data.includes(i.id || 0) ? true : i.isRead
2632
- });
2633
- }));
3224
+ return [].concat(state, [data]);
2634
3225
  });
2635
3226
  };
3227
+ var handleCompletedConversation = function handleCompletedConversation(data) {
3228
+ if (!data) return;
3229
+ setSelectedConversation(JSON.parse(data));
3230
+ };
2636
3231
  var handleLoadMoreMessages = function handleLoadMoreMessages() {
2637
- if (handleLoadMore()) {
2638
- getMessageConversation();
3232
+ try {
3233
+ if ((selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id) === undefined) return Promise.resolve();
3234
+ return Promise.resolve(handleLoadMore(selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id));
3235
+ } catch (e) {
3236
+ return Promise.reject(e);
2639
3237
  }
2640
3238
  };
3239
+ var handleDeleteSelectedImage = function handleDeleteSelectedImage() {
3240
+ setSelectedFile(null);
3241
+ };
2641
3242
  var cleanupPusher = function cleanupPusher() {
2642
- var _pusher$current, _pusher$current2;
3243
+ var _pusher$current;
2643
3244
  (_pusher$current = pusher.current) === null || _pusher$current === void 0 ? void 0 : _pusher$current.unbind("new-message-event", handleNewMessageSent);
2644
- (_pusher$current2 = pusher.current) === null || _pusher$current2 === void 0 ? void 0 : _pusher$current2.unbind("message-read-event", handleMessageMarkRead);
2645
3245
  channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
2646
3246
  };
2647
3247
  useEffect(function () {
2648
- if (PUSHER_CONFIG.cluster && PUSHER_CONFIG.key && !!(selectedConversation !== null && selectedConversation !== void 0 && selectedConversation.id)) {
3248
+ if (PUSHER_CONFIG.cluster && PUSHER_CONFIG.key && academyDomain && !!(selectedConversation !== null && selectedConversation !== void 0 && selectedConversation.id)) {
3249
+ var _headers;
2649
3250
  var token = getAccessToken();
2650
3251
  pusher.current = new Pusher(PUSHER_CONFIG.key, {
2651
3252
  cluster: PUSHER_CONFIG.cluster,
2652
3253
  authEndpoint: BASE_URL + "/api/auth/pusher",
2653
3254
  auth: {
2654
3255
  params: {},
2655
- headers: {
3256
+ headers: (_headers = {
2656
3257
  Authorization: "Bearer " + token
2657
- }
3258
+ }, _headers[AcademyHeaders] = academyDomain, _headers)
2658
3259
  }
2659
3260
  });
2660
3261
  channelName.current = "presence-conversation-channel-" + (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id);
2661
3262
  channel.current = pusher.current.subscribe(channelName.current);
2662
3263
  pusher.current.bind("new-message-event", handleNewMessageSent);
2663
- pusher.current.bind("message-read-event", handleMessageMarkRead);
3264
+ pusher.current.bind("completed-conversation-event", handleCompletedConversation);
2664
3265
  }
2665
3266
  return cleanupPusher;
2666
- }, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, messageFilter.examId, examId]);
3267
+ }, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id, academyDomain]);
2667
3268
  useEffect(function () {
2668
3269
  var getConversation = function getConversation() {
2669
3270
  try {
2670
- var _temp6 = function _temp6() {
2671
- dispatch(setLoading(false));
2672
- };
2673
3271
  resetMessages();
2674
3272
  setScrollToEnd(true);
2675
- if ((conversation === null || conversation === void 0 ? void 0 : conversation.id) !== undefined) {
2676
- setSelectedConversation(conversation);
2677
- return Promise.resolve();
2678
- }
2679
- if (!userId) return Promise.resolve();
2680
- dispatch(setLoading(true));
2681
- var _temp5 = _catch(function () {
2682
- return Promise.resolve(apiGetConversationByUserId(userId)).then(function (res) {
2683
- function _temp4() {
2684
- setSelectedConversation(res.data.data);
2685
- }
2686
- var _temp3 = function () {
2687
- if (!res.data.data) {
2688
- return Promise.resolve(createConversation(userId)).then(function (_createConversation) {
2689
- res = _createConversation;
2690
- });
2691
- }
2692
- }();
2693
- return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
2694
- });
2695
- }, function (error) {
2696
- console.log({
2697
- error: error
2698
- });
2699
- });
2700
- return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
3273
+ if (!(conversation !== null && conversation !== void 0 && conversation.id)) return Promise.resolve();
3274
+ setSelectedConversation(conversation);
3275
+ return Promise.resolve();
2701
3276
  } catch (e) {
2702
3277
  return Promise.reject(e);
2703
3278
  }
2704
3279
  };
2705
3280
  getConversation();
2706
- }, [conversation === null || conversation === void 0 ? void 0 : conversation.id, userId]);
2707
- var handleMarkRead = useCallback(function () {
2708
- try {
2709
- if (!(selectedConversation !== null && selectedConversation !== void 0 && selectedConversation.id)) return Promise.resolve();
2710
- var _temp7 = _catch(function () {
2711
- return Promise.resolve(apiMarkReadMessage(selectedConversation.id, -1)).then(function () {});
2712
- }, function (error) {
2713
- console.log({
2714
- error: error
2715
- });
2716
- });
2717
- return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function () {}) : void 0);
2718
- } catch (e) {
2719
- return Promise.reject(e);
2720
- }
2721
- }, [selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id]);
3281
+ }, [conversation === null || conversation === void 0 ? void 0 : conversation.id]);
2722
3282
  var getMessageConversation = function getMessageConversation() {
2723
3283
  try {
2724
- if (!roles.length) return Promise.resolve();
2725
3284
  if ((selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id) === undefined) return Promise.resolve();
2726
- return Promise.resolve(_catch(function () {
2727
- var _temp10 = function () {
2728
- if (selectedConversation.id === 0) {
2729
- var _userId = isStudent ? selectedConversation.teacher.id : selectedConversation.student.id;
2730
- return Promise.resolve(createConversation(_userId)).then(function (res) {
2731
- var _res$data$data;
2732
- return Promise.resolve(onCreateConversationSuccess === null || onCreateConversationSuccess === void 0 ? void 0 : onCreateConversationSuccess((_res$data$data = res.data.data) === null || _res$data$data === void 0 ? void 0 : _res$data$data.id)).then(function () {});
2733
- });
2734
- } else {
2735
- var _temp9 = function _temp9() {
2736
- return Promise.resolve(getMessageList(selectedConversation.id, examId)).then(function () {
2737
- onGetMessagesSuccess === null || onGetMessagesSuccess === void 0 ? void 0 : onGetMessagesSuccess();
2738
- });
2739
- };
2740
- var _temp8 = function () {
2741
- if (firstLoadRef.current) {
2742
- return Promise.resolve(handleMarkRead()).then(function () {
2743
- firstLoadRef.current = false;
2744
- });
2745
- }
2746
- }();
2747
- return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
2748
- }
2749
- }();
2750
- if (_temp10 && _temp10.then) return _temp10.then(function () {});
2751
- }, function () {
2752
- toast.error("Fail to fetch data!");
2753
- }));
3285
+ getMessageList(selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id);
3286
+ return Promise.resolve();
2754
3287
  } catch (e) {
2755
3288
  return Promise.reject(e);
2756
3289
  }
@@ -2759,231 +3292,55 @@ var useChatContainer = function useChatContainer(props) {
2759
3292
  resetMessages();
2760
3293
  setScrollToEnd(true);
2761
3294
  };
3295
+ var messageList = useMemo(function () {
3296
+ var results = messages.map(function (i) {
3297
+ var _i$sender;
3298
+ return _extends({}, i, {
3299
+ isMe: (infoUser === null || infoUser === void 0 ? void 0 : infoUser.id) === ((_i$sender = i.sender) === null || _i$sender === void 0 ? void 0 : _i$sender.id)
3300
+ });
3301
+ });
3302
+ return results;
3303
+ }, [JSON.stringify(messages)]);
2762
3304
  useEffect(function () {
2763
3305
  getMessageConversation();
2764
- }, [JSON.stringify(selectedConversation), JSON.stringify(roles), JSON.stringify(messageFilter), examId]);
2765
- var userName = (isStudent ? selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation3 = selectedConversation.teacher) === null || _selectedConversation3 === void 0 ? void 0 : _selectedConversation3.displayName : selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation4 = selectedConversation.student) === null || _selectedConversation4 === void 0 ? void 0 : _selectedConversation4.displayName) || "";
2766
- var userAvatar = (isStudent ? selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation5 = selectedConversation.teacher) === null || _selectedConversation5 === void 0 ? void 0 : _selectedConversation5.avatar : selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation6 = selectedConversation.student) === null || _selectedConversation6 === void 0 ? void 0 : _selectedConversation6.avatar) || "";
3306
+ }, [JSON.stringify(selectedConversation)]);
2767
3307
  return {
2768
3308
  chatHeaderProps: {
2769
- name: userName,
2770
- avatar: userAvatar,
2771
- options: exams,
2772
- selectedOption: messageFilter.examId,
2773
- onChangeOption: handleFilterExam
3309
+ fullName: student === null || student === void 0 ? void 0 : student.fullName,
3310
+ examTitle: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.examTitle,
3311
+ questionOrder: selectedConversation === null || selectedConversation === void 0 ? void 0 : (_selectedConversation = selectedConversation.question) === null || _selectedConversation === void 0 ? void 0 : _selectedConversation.questionOrder,
3312
+ conversationId: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.id,
3313
+ isCompleted: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.isCompleted,
3314
+ durationExam: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.duration,
3315
+ createdAt: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.createdAt,
3316
+ teacherName: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.teacherName,
3317
+ roles: roles
2774
3318
  },
2775
3319
  chatListProps: {
2776
3320
  messages: messageList,
2777
- onAddExamMessage: handleAddExamMessage,
2778
- onReply: handleReplyMessage,
2779
- onReTrySendMessage: handleAddMessage
3321
+ onReTrySendMessage: handleAddMessage,
3322
+ roles: roles
2780
3323
  },
2781
3324
  inputProps: {
3325
+ selectedFile: selectedFile,
2782
3326
  text: (message === null || message === void 0 ? void 0 : message.content) || "",
2783
- parentText: message === null || message === void 0 ? void 0 : message.parentContent,
2784
- examTitle: message === null || message === void 0 ? void 0 : message.examTitle,
2785
3327
  onChangeInput: handleChangeInput,
2786
3328
  onSubmit: handleAddMessage,
2787
- onClearReply: !messageFilter.examId || message !== null && message !== void 0 && message.parentContent ? handleClearReply : undefined
3329
+ handleDeleteSelectedImage: handleDeleteSelectedImage,
3330
+ handleUploadImage: handleUploadImage,
3331
+ isCompleted: selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.isCompleted
2788
3332
  },
2789
3333
  isScrollToEnd: isScrollToEnd,
2790
3334
  isLoadingMessages: isLoadingMessages,
2791
- exams: exams,
2792
3335
  messageList: messageList,
2793
3336
  selectedConversation: selectedConversation,
2794
- messageStatus: messageStatus,
2795
3337
  messageFilter: messageFilter,
2796
3338
  handleToggleScrollToEnd: handleToggleScrollToEnd,
2797
3339
  handleLoadMoreMessages: handleLoadMoreMessages,
2798
3340
  getMessageList: getMessageList,
2799
- handleFilterExam: handleFilterExam,
2800
3341
  setMessage: setMessage,
2801
3342
  resetMessages: handleConversationChange,
2802
- getMessageConversation: getMessageConversation,
2803
- handleMarkRead: handleMarkRead
2804
- };
2805
- };
2806
-
2807
- var STUDENT_STATUS_URL = BASE_URL + "/api/user";
2808
- var getStudentConversationListApi = function getStudentConversationListApi(query) {
2809
- return api.get(STUDENT_STATUS_URL + "/GetStudentConversations", {
2810
- params: query
2811
- });
2812
- };
2813
-
2814
- var isFirstLoad = true;
2815
- var useConversationList = function useConversationList() {
2816
- var dispatch = useDispatch();
2817
- var user = useSelector(function (state) {
2818
- var _state$common;
2819
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
2820
- });
2821
- var roles = (user === null || user === void 0 ? void 0 : user.roles) || [];
2822
- var isStudent = roles.includes("Student");
2823
- var _useState = useState(),
2824
- selectedConversation = _useState[0],
2825
- setSelectedConversation = _useState[1];
2826
- var _useState2 = useState([]),
2827
- conversations = _useState2[0],
2828
- setConversations = _useState2[1];
2829
- var _useState3 = useState(CONVERSATION_DEFAULT_FILTER),
2830
- conversationFilter = _useState3[0],
2831
- setConversationFilter = _useState3[1];
2832
- var handleChangeSelectedConversation = function handleChangeSelectedConversation(val) {
2833
- setSelectedConversation(val);
2834
- };
2835
- var handleNewMessageConversation = function handleNewMessageConversation(val) {
2836
- setConversations(function (state) {
2837
- var index = state.findIndex(function (i) {
2838
- return i.id === val.id;
2839
- });
2840
- if (index > -1 && JSON.stringify(val) !== JSON.stringify(state[index])) {
2841
- return [val].concat(state.slice(0, index), state.slice(index + 1));
2842
- } else return [val].concat(state);
2843
- });
2844
- setSelectedConversation(function (state) {
2845
- if (!state) return val;
2846
- return state;
2847
- });
2848
- };
2849
- var handleMessageReadConversation = function handleMessageReadConversation(id, totalUnread) {
2850
- setConversations(function (state) {
2851
- var index = state.findIndex(function (i) {
2852
- return i.id === id;
2853
- });
2854
- if (index === -1 || totalUnread === state[index].totalUnReadMessage) return state;
2855
- return [].concat(state.slice(0, index), [_extends({}, state[index], {
2856
- totalUnReadMessage: totalUnread
2857
- })], state.slice(index + 1));
2858
- });
2859
- setSelectedConversation(function (state) {
2860
- if (!!state) return _extends({}, state, {
2861
- totalUnReadMessage: totalUnread
2862
- });
2863
- return state;
2864
- });
2865
- };
2866
- var handleChangeTextSearch = function handleChangeTextSearch(e) {
2867
- setConversationFilter(function (state) {
2868
- return _extends({}, state, {
2869
- textSearch: e.target.value
2870
- });
2871
- });
2872
- };
2873
- var handleChangeFilter = function handleChangeFilter(filter) {
2874
- setConversationFilter(function (state) {
2875
- return _extends({}, state, filter);
2876
- });
2877
- };
2878
- var formatConversationLastMessageContent = function formatConversationLastMessageContent(conversation) {
2879
- var _conversation$lastMes;
2880
- if (!(conversation !== null && conversation !== void 0 && conversation.lastMessage)) return "";
2881
- var content = conversation.lastMessage.content;
2882
- switch (conversation.lastMessage.type) {
2883
- case MessageSourceType.Exam:
2884
- switch (conversation.lastMessage.action) {
2885
- case MessageAction.Took:
2886
- content = (isStudent ? "You" : conversation.student.displayName) + " took the exam " + ((_conversation$lastMes = conversation.lastMessage.exam) === null || _conversation$lastMes === void 0 ? void 0 : _conversation$lastMes.title);
2887
- break;
2888
- }
2889
- break;
2890
- }
2891
- return content;
2892
- };
2893
- var getConversationList = function getConversationList() {
2894
- try {
2895
- var _temp2 = function _temp2() {
2896
- isFirstLoad && dispatch(setLoading(false));
2897
- if (isFirstLoad) isFirstLoad = false;
2898
- };
2899
- if (!roles.length) return Promise.resolve();
2900
- isFirstLoad && dispatch(setLoading(true));
2901
- var _temp = _catch(function () {
2902
- var apiGetConversations = isStudent ? getListConversation : getStudentConversationListApi;
2903
- return Promise.resolve(apiGetConversations(conversationFilter)).then(function (res) {
2904
- var _res$data$items;
2905
- setConversations(res.data.items || []);
2906
- !selectedConversation && setSelectedConversation((_res$data$items = res.data.items) === null || _res$data$items === void 0 ? void 0 : _res$data$items[0]);
2907
- });
2908
- }, function () {
2909
- setSelectedConversation(undefined);
2910
- dispatch(setAlert({
2911
- type: "danger",
2912
- message: "Fail to fetch data!"
2913
- }));
2914
- });
2915
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
2916
- } catch (e) {
2917
- return Promise.reject(e);
2918
- }
2919
- };
2920
- var handleUpdateTotalUnreadMessage = function handleUpdateTotalUnreadMessage() {
2921
- if (!(selectedConversation !== null && selectedConversation !== void 0 && selectedConversation.id)) return;
2922
- setConversations(function (state) {
2923
- var updateIndex = state.findIndex(function (i) {
2924
- return i.id === selectedConversation.id;
2925
- });
2926
- if (updateIndex < 0) return state;
2927
- return [].concat(state.slice(0, updateIndex), [_extends({}, state[updateIndex], {
2928
- totalUnReadMessage: 0
2929
- })], state.slice(updateIndex + 1));
2930
- });
2931
- };
2932
- var handleUpdateLastMessage = function handleUpdateLastMessage(lastMessage) {
2933
- setConversations(function (state) {
2934
- var updateIndex = state.findIndex(function (i) {
2935
- return i.id === lastMessage.conversationId;
2936
- });
2937
- if (updateIndex < 0) return state;
2938
- console.log({
2939
- lastMessage: lastMessage
2940
- });
2941
- return [_extends({}, state[updateIndex], {
2942
- lastMessage: lastMessage
2943
- })].concat(state.slice(0, updateIndex), state.slice(updateIndex + 1));
2944
- });
2945
- };
2946
- var handleCreateConversationSuccess = function handleCreateConversationSuccess(id) {
2947
- try {
2948
- if (!selectedConversation) return Promise.resolve();
2949
- setSelectedConversation(_extends({}, selectedConversation, {
2950
- id: id
2951
- }));
2952
- var index = conversations.findIndex(function (i) {
2953
- return i.student.id === (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.student.id) && i.teacher.id === (selectedConversation === null || selectedConversation === void 0 ? void 0 : selectedConversation.teacher.id);
2954
- });
2955
- if (index > -1) {
2956
- setConversations([].concat(conversations.slice(0, index), [_extends({}, selectedConversation, {
2957
- id: id
2958
- })], conversations.slice(index + 1)));
2959
- }
2960
- return Promise.resolve();
2961
- } catch (e) {
2962
- return Promise.reject(e);
2963
- }
2964
- };
2965
- useEffect(function () {
2966
- getConversationList();
2967
- }, [JSON.stringify(conversationFilter), roles.length]);
2968
- useEffect(function () {
2969
- window.document.title = "Q&A";
2970
- }, []);
2971
- return {
2972
- isStudent: isStudent,
2973
- conversationFilter: conversationFilter,
2974
- selectedConversation: selectedConversation,
2975
- conversations: conversations,
2976
- handleUpdateTotalUnreadMessage: handleUpdateTotalUnreadMessage,
2977
- handleChangeFilter: handleChangeFilter,
2978
- handleChangeSelectedConversation: handleChangeSelectedConversation,
2979
- handleChangeTextSearch: handleChangeTextSearch,
2980
- setSelectedConversation: setSelectedConversation,
2981
- handleUpdateLastMessage: handleUpdateLastMessage,
2982
- getConversationList: getConversationList,
2983
- formatConversationLastMessageContent: formatConversationLastMessageContent,
2984
- handleNewMessageConversation: handleNewMessageConversation,
2985
- handleCreateConversationSuccess: handleCreateConversationSuccess,
2986
- handleMessageReadConversation: handleMessageReadConversation
3343
+ getMessageConversation: getMessageConversation
2987
3344
  };
2988
3345
  };
2989
3346
 
@@ -2991,10 +3348,12 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
2991
3348
  var pusher = useRef();
2992
3349
  var channel = useRef();
2993
3350
  var channelName = useRef();
2994
- var userId = useSelector(function (state) {
2995
- var _state$common, _state$common$user;
2996
- return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : (_state$common$user = _state$common.user) === null || _state$common$user === void 0 ? void 0 : _state$common$user.id;
3351
+ var user = useSelector(function (state) {
3352
+ var _state$common;
3353
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
2997
3354
  });
3355
+ var userId = user === null || user === void 0 ? void 0 : user.id;
3356
+ var academyDomain = user === null || user === void 0 ? void 0 : user.academyDomain;
2998
3357
  var handleNewMessageConversationCreated = function handleNewMessageConversationCreated(data) {
2999
3358
  onNewMessageConversation === null || onNewMessageConversation === void 0 ? void 0 : onNewMessageConversation(data);
3000
3359
  };
@@ -3007,16 +3366,17 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
3007
3366
  channelName.current && pusher.current && pusher.current.unsubscribe(channelName.current);
3008
3367
  };
3009
3368
  useEffect(function () {
3010
- if (PUSHER_CONFIG.cluster && PUSHER_CONFIG.key && !!userId) {
3369
+ if (PUSHER_CONFIG.cluster && PUSHER_CONFIG.key && academyDomain && !!userId) {
3370
+ var _headers;
3011
3371
  var token = getAccessToken$1();
3012
3372
  pusher.current = new Pusher(PUSHER_CONFIG.key, {
3013
3373
  cluster: PUSHER_CONFIG.cluster,
3014
3374
  authEndpoint: BASE_URL + "/api/auth/pusher",
3015
3375
  auth: {
3016
3376
  params: {},
3017
- headers: {
3377
+ headers: (_headers = {
3018
3378
  Authorization: "Bearer " + token
3019
- }
3379
+ }, _headers[AcademyHeaders] = academyDomain, _headers)
3020
3380
  }
3021
3381
  });
3022
3382
  channelName.current = "presence-conversation-channel-userId-" + userId;
@@ -3025,18 +3385,18 @@ var usePusherConversation = function usePusherConversation(onNewMessageConversat
3025
3385
  channel.current.bind("message-conversation-read-event", handleReadMessageConversation);
3026
3386
  }
3027
3387
  return cleanupPusher;
3028
- }, [userId]);
3388
+ }, [userId, academyDomain]);
3029
3389
  return {};
3030
3390
  };
3031
3391
 
3032
- var _excluded$1 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3392
+ var _excluded$2 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3033
3393
  var CustomCreatable = function CustomCreatable(_ref) {
3034
3394
  var options = _ref.options,
3035
3395
  isDisabled = _ref.isDisabled,
3036
3396
  scrollBottom = _ref.scrollBottom,
3037
3397
  value = _ref.value,
3038
3398
  isMulti = _ref.isMulti,
3039
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
3399
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3040
3400
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3041
3401
  return value.includes(i.value);
3042
3402
  }) : isMulti ? options.filter(function (i) {
@@ -3054,7 +3414,7 @@ var CustomCreatable = function CustomCreatable(_ref) {
3054
3414
  }, rest));
3055
3415
  };
3056
3416
 
3057
- var _excluded$2 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3417
+ var _excluded$3 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3058
3418
  var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3059
3419
  var isDefault = _ref.isDefault,
3060
3420
  options = _ref.options,
@@ -3062,7 +3422,7 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3062
3422
  scrollBottom = _ref.scrollBottom,
3063
3423
  value = _ref.value,
3064
3424
  isMulti = _ref.isMulti,
3065
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3425
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
3066
3426
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3067
3427
  return value.includes(i.value);
3068
3428
  }) : isMulti ? options.filter(function (i) {
@@ -3080,7 +3440,7 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3080
3440
  }, rest));
3081
3441
  };
3082
3442
 
3083
- var styles$2 = {"question":"_2uc_W","question-article":"_2p7kY","question-title":"_2tHmc","question--active":"_3IHYm","question-label":"_26ATj","question-input":"_3R8PR","question-btn":"_1VZac"};
3443
+ var styles$1 = {"question":"_2uc_W","question-article":"_2p7kY","question-title":"_2tHmc","question--active":"_3IHYm","question-label":"_26ATj","question-input":"_3R8PR","question-btn":"_1VZac"};
3084
3444
 
3085
3445
  var DURATION_OPTIONS = Array.from({
3086
3446
  length: 120
@@ -3093,7 +3453,7 @@ var SCORE_OPTIONS = Array.from({
3093
3453
  return i + 1;
3094
3454
  });
3095
3455
  var QUESTION_OPTIONS = Array.from({
3096
- length: 40
3456
+ length: 10
3097
3457
  }, function (_, i) {
3098
3458
  return i + 1;
3099
3459
  });
@@ -3123,7 +3483,7 @@ var QuestionView = function QuestionView(_ref) {
3123
3483
  }, React.createElement("div", {
3124
3484
  className: "d-flex flex-grow-1"
3125
3485
  }, React.createElement("div", {
3126
- className: styles$2["question-title"] + " me-2"
3486
+ className: styles$1["question-title"] + " me-2"
3127
3487
  }, "\uBB38\uC81C ", question.questionOrder + 1, "\uBC88"), React.createElement("div", {
3128
3488
  className: "d-flex flex-grow-1"
3129
3489
  }, Array.from({
@@ -3132,15 +3492,16 @@ var QuestionView = function QuestionView(_ref) {
3132
3492
  return i + 1;
3133
3493
  }).map(function (i) {
3134
3494
  return React.createElement(FormGroup, {
3135
- className: "d-flex flex-column px-4"
3495
+ className: "d-flex flex-column px-4",
3496
+ key: i
3136
3497
  }, React.createElement(Label, {
3137
3498
  htmlFor: "answer-" + i,
3138
- className: "" + styles$2["question-label"]
3499
+ className: "" + styles$1["question-label"]
3139
3500
  }, i, "\uBC88"), React.createElement(Input, {
3140
3501
  id: "answer-" + i,
3141
3502
  type: "radio",
3142
3503
  checked: question.correctAnswers.includes(i),
3143
- onClick: function onClick() {
3504
+ onChange: function onChange() {
3144
3505
  return onChangeCorrectAnswers(i, index);
3145
3506
  },
3146
3507
  disabled: isDisabled
@@ -3206,7 +3567,7 @@ var ArticleGroupView = function ArticleGroupView(_ref) {
3206
3567
  };
3207
3568
  });
3208
3569
  return React.createElement("div", {
3209
- className: "d-flex " + styles$2["question"] + " " + (isActive ? styles$2["question--active"] : "")
3570
+ className: "d-flex " + styles$1["question"] + " " + (isActive ? styles$1["question--active"] : "")
3210
3571
  }, React.createElement("div", {
3211
3572
  className: "py-1"
3212
3573
  }, React.createElement(PiDotsNineLight, {
@@ -3216,16 +3577,16 @@ var ArticleGroupView = function ArticleGroupView(_ref) {
3216
3577
  }, React.createElement(Row, null, React.createElement(Col, {
3217
3578
  xs: 12
3218
3579
  }, React.createElement("p", {
3219
- className: "mb-0 " + styles$2["question-article"]
3580
+ className: "mb-0 " + styles$1["question-article"]
3220
3581
  }, "\uBB38\uD56D"), React.createElement("p", {
3221
- className: "text-center " + styles$2["question-article"]
3582
+ className: "text-center " + styles$1["question-article"]
3222
3583
  }, article)))), React.createElement("div", {
3223
3584
  className: "flex-grow-1"
3224
3585
  }, React.createElement(Row, null, React.createElement(Col, {
3225
3586
  xs: 3
3226
3587
  }, React.createElement(FormGroup, null, React.createElement(Label, {
3227
3588
  htmlFor: "question_count",
3228
- className: "" + styles$2["question-label"]
3589
+ className: "" + styles$1["question-label"]
3229
3590
  }, t("question_count")), React.createElement(CustomSelect, {
3230
3591
  inputId: "question_count",
3231
3592
  value: questionCount,
@@ -3236,7 +3597,7 @@ var ArticleGroupView = function ArticleGroupView(_ref) {
3236
3597
  xs: 3
3237
3598
  }, React.createElement(FormGroup, null, React.createElement(Label, {
3238
3599
  htmlFor: "category",
3239
- className: "" + styles$2["question-label"]
3600
+ className: "" + styles$1["question-label"]
3240
3601
  }, t("category")), React.createElement(CustomSelect, {
3241
3602
  inputId: "category",
3242
3603
  value: categoryId,
@@ -3247,7 +3608,7 @@ var ArticleGroupView = function ArticleGroupView(_ref) {
3247
3608
  xs: 3
3248
3609
  }, React.createElement(FormGroup, null, React.createElement(Label, {
3249
3610
  htmlFor: "answer_count",
3250
- className: "" + styles$2["question-label"]
3611
+ className: "" + styles$1["question-label"]
3251
3612
  }, t("answer_count")), React.createElement(CustomSelect, {
3252
3613
  inputId: "answer_count",
3253
3614
  value: answerCount,
@@ -3360,9 +3721,10 @@ var useExamDetailView = function useExamDetailView(props) {
3360
3721
  } else {
3361
3722
  onChangeExam(_extends({}, exam, {
3362
3723
  questions: [].concat(otherQuestions, questions.map(function (q) {
3724
+ var _q$correctAnswers;
3363
3725
  return _extends({}, q, {
3364
3726
  numberOfAnswers: newAnswerCount,
3365
- correctAnswers: q.correctAnswers.filter(function (i) {
3727
+ correctAnswers: (_q$correctAnswers = q.correctAnswers) === null || _q$correctAnswers === void 0 ? void 0 : _q$correctAnswers.filter(function (i) {
3366
3728
  return i <= newAnswerCount;
3367
3729
  })
3368
3730
  });
@@ -3503,24 +3865,28 @@ var ExamDetailView = function ExamDetailView(_ref) {
3503
3865
  handleChangeAnswerCount = _useExamDetailView.handleChangeAnswerCount,
3504
3866
  handleChangeQuestionCount = _useExamDetailView.handleChangeQuestionCount,
3505
3867
  handleChangeCategory = _useExamDetailView.handleChangeCategory;
3506
- return React.createElement(Row, {
3507
- className: "" + className
3508
- }, React.createElement(Col, {
3509
- xs: 5
3510
- }, React.createElement(FormGroup, null, React.createElement(Label, {
3511
- className: "" + styles$2["question-label"],
3868
+ return React.createElement("div", {
3869
+ className: className + " " + stylesGlobal["custom-row"]
3870
+ }, React.createElement("div", {
3871
+ className: stylesGlobal["custom-col-5"]
3872
+ }, React.createElement("div", {
3873
+ className: 'mb-3'
3874
+ }, React.createElement("label", {
3875
+ className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
3512
3876
  htmlFor: "title"
3513
- }, t("title")), React.createElement(Input, {
3877
+ }, t("title")), React.createElement("input", {
3514
3878
  disabled: isDisabled,
3515
- className: "w-100 rounded-2 " + styles$2["question-input"],
3879
+ className: "" + stylesGlobal["form-control"],
3516
3880
  value: exam.title,
3517
3881
  id: "title",
3518
3882
  placeholder: t("enter_title"),
3519
3883
  onChange: handleChangeTitle
3520
- }))), React.createElement(Col, {
3521
- xs: 3
3522
- }, React.createElement(FormGroup, null, React.createElement(Label, {
3523
- className: "" + styles$2["question-label"],
3884
+ }))), React.createElement("div", {
3885
+ className: stylesGlobal["custom-col-3"]
3886
+ }, React.createElement("div", {
3887
+ className: 'mb-3'
3888
+ }, React.createElement("label", {
3889
+ className: stylesGlobal["form-label"] + " " + styles$1["question-label"],
3524
3890
  htmlFor: "duration"
3525
3891
  }, t("duration")), React.createElement(CustomSelect, {
3526
3892
  inputId: "duration",
@@ -3528,13 +3894,10 @@ var ExamDetailView = function ExamDetailView(_ref) {
3528
3894
  options: durationOptions,
3529
3895
  onChange: handleChangeDuration,
3530
3896
  isDisabled: isDisabled
3531
- }))), React.createElement(Col, {
3532
- xs: 4
3533
- }), examGroupByArticle.map(function (i, index) {
3534
- return React.createElement(Col, {
3535
- xs: 12,
3897
+ }))), examGroupByArticle.map(function (i, index) {
3898
+ return React.createElement("div", {
3536
3899
  key: i.article,
3537
- className: (index === 0 && !isUsingMui ? "mt-3" : "") + " " + (!isUsingMui ? "mb-4" : "")
3900
+ className: stylesGlobal["custom-col-12"] + " " + (index === 0 && !isUsingMui ? "mt-3" : "") + " " + (!isUsingMui ? "mb-4" : "")
3538
3901
  }, React.createElement(ArticleGroupView, Object.assign({}, i, {
3539
3902
  categoryOptions: categoryOptions,
3540
3903
  isActive: index === examGroupByArticle.length - 1,
@@ -3545,20 +3908,74 @@ var ExamDetailView = function ExamDetailView(_ref) {
3545
3908
  onChangeScoreAnswer: handleChangeScoreAnswer,
3546
3909
  isDisabled: isDisabled
3547
3910
  })));
3548
- }), React.createElement(Col, {
3549
- xs: 12
3550
- }, React.createElement(Button, {
3911
+ }), React.createElement("div", {
3912
+ className: stylesGlobal["custom-col-12"]
3913
+ }, React.createElement("button", {
3551
3914
  disabled: isDisabled,
3552
- className: "w-100 d-flex justify-content-center align-items-center " + styles$2["question-btn"],
3553
- color: "primary",
3554
- outline: true,
3915
+ className: stylesGlobal["btn-outline-primary"] + " w-100 d-flex justify-content-center align-items-center " + styles$1["question-btn"] + " mt-3",
3555
3916
  onClick: handleAddArticle
3556
3917
  }, React.createElement(FaPlusCircle, {
3557
3918
  className: "me-2"
3558
3919
  }), "\uBB38\uD56D \uCD94\uAC00\uD558\uAE30")));
3559
3920
  };
3560
3921
 
3922
+ var useAutoAcademyDomain = function useAutoAcademyDomain(logout, history, superUrls, homeUrl, homeAcademyUrl) {
3923
+ var searchParams = new URLSearchParams(window.location.search);
3924
+ var user = useSelector(function (state) {
3925
+ var _state$common;
3926
+ return state === null || state === void 0 ? void 0 : (_state$common = state.common) === null || _state$common === void 0 ? void 0 : _state$common.user;
3927
+ });
3928
+ var initialAcademySearchParam = function initialAcademySearchParam() {
3929
+ var paramAcademyDomain = searchParams.get("domain");
3930
+ var domain = getAcademyDomain();
3931
+ var pathname = window.location.pathname.toLowerCase();
3932
+ if (!user) return;
3933
+ var academyDomain = user.academyDomain;
3934
+ if (!academyDomain) {
3935
+ if (!superUrls.some(function (i) {
3936
+ return pathname.startsWith(i);
3937
+ })) {
3938
+ pushTo({
3939
+ pathname: homeUrl,
3940
+ search: ""
3941
+ });
3942
+ }
3943
+ if (domain) {
3944
+ searchParams.append("domain", domain);
3945
+ pushTo({
3946
+ pathname: homeUrl,
3947
+ search: ""
3948
+ });
3949
+ }
3950
+ } else {
3951
+ if (superUrls.some(function (i) {
3952
+ return pathname.startsWith(i);
3953
+ })) {
3954
+ pushTo({
3955
+ pathname: homeAcademyUrl,
3956
+ search: ""
3957
+ });
3958
+ }
3959
+ if (paramAcademyDomain && academyDomain.trim().toLocaleLowerCase() != (paramAcademyDomain === null || paramAcademyDomain === void 0 ? void 0 : paramAcademyDomain.trim().toLocaleLowerCase())) {
3960
+ logout();
3961
+ }
3962
+ if (!paramAcademyDomain && academyDomain) {
3963
+ searchParams.append("domain", academyDomain);
3964
+ pushTo(_extends({}, window.location, {
3965
+ search: searchParams.toString()
3966
+ }));
3967
+ }
3968
+ }
3969
+ };
3970
+ var pushTo = function pushTo(data) {
3971
+ if (history.push) history.push(data);else history(data);
3972
+ };
3973
+ useEffect(function () {
3974
+ initialAcademySearchParam();
3975
+ }, [window.location.pathname, user === null || user === void 0 ? void 0 : user.academyDomain]);
3976
+ };
3977
+
3561
3978
  var historyCore = createBrowserHistory();
3562
3979
 
3563
- export { ACCESS_TOKEN, BASE_URL, ChatContainer, ChatItemType, CommonAlert, CommonDialog, ConfirmDialog, CustomAsyncSelect, CustomCreatable, CustomPagination, CustomSelect, DATE_MIN_VALUE, DATE_TIME_MIN_VALUE, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, ExamDetailView, ExamEvent, LANGUAGES, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, Role, TheLanguageDropdown, api, canAccess as canAccessRoute, diffFromNow, formatTime, getAccessToken$1 as getAccessToken, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useChatContainer, useConversationList, useGoogleSignOut, useLanguage, usePusherConversation, utcToLocalTime };
3980
+ export { ACADEMY_DOMAIN, ACCESS_TOKEN, AcademyHeaders, BASE_URL, ChatContainer, ChatItemType, types as ChatTypes, CommonAlert, CommonDialog, ConfirmDialog, CustomAsyncSelect, CustomCreatable, CustomPagination, CustomSelect, DATE_MIN_VALUE, DATE_TIME_MIN_VALUE, EXAM_CHANNEL, EXAM_STUDENT_CHANNEL, ExamDetailView, ExamEvent, LANGUAGES, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, Role, SUPER_ADMIN_BASE_URL, TheAcademyDropdown, TheLanguageDropdown, api, apiUpload, canAccess as canAccessRoute, diffFromNow, formatTime, getAcademyDomain, getAccessToken$1 as getAccessToken, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setReFetchUserAcademies, setUser, store, toISOString, useAutoAcademyDomain, useChatContainer, useGoogleSignOut, useLanguage, useLogin, usePusherConversation, useSwitchAcademy, utcToLocalTime };
3564
3981
  //# sourceMappingURL=index.modern.js.map