touchstudy-core 0.1.1 → 0.1.2

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.
@@ -1,615 +1,35 @@
1
+ import { createBrowserHistory } from 'history';
1
2
  import { createAction, createReducer, configureStore } from '@reduxjs/toolkit';
2
3
  import moment from 'moment';
3
- import React, { useCallback, useState, useEffect, Fragment, useRef } from 'react';
4
+ import React, { useCallback, useState, useEffect, Fragment, useRef, useMemo } from 'react';
4
5
  import { useGoogleReCaptcha, GoogleReCaptcha, GoogleReCaptchaProvider } from 'react-google-recaptcha-v3';
5
- import { Row, Col, Form, FormGroup, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink } from 'reactstrap';
6
+ import { Row, Col, Form, FormGroup, Modal, ModalHeader, ModalBody, ModalFooter, Button, Alert, Pagination, PaginationItem, PaginationLink, Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
6
7
  import { Formik } from 'formik';
7
8
  import { object, string, boolean } from 'yup';
8
- import GoogleLogin from '@leecheuk/react-google-login';
9
+ import GoogleLogin, { useGoogleLogout } from '@leecheuk/react-google-login';
9
10
  import axios from 'axios';
10
11
  import { useDispatch, useSelector } from 'react-redux';
11
12
  import { gapi } from 'gapi-script';
12
-
13
- function _extends() {
14
- _extends = Object.assign ? Object.assign.bind() : function (target) {
15
- for (var i = 1; i < arguments.length; i++) {
16
- var source = arguments[i];
17
- for (var key in source) {
18
- if (Object.prototype.hasOwnProperty.call(source, key)) {
19
- target[key] = source[key];
20
- }
21
- }
22
- }
23
- return target;
24
- };
25
- return _extends.apply(this, arguments);
26
- }
27
-
28
- function isAbsolute(pathname) {
29
- return pathname.charAt(0) === '/';
30
- }
31
-
32
- // About 1.5x faster than the two-arg version of Array#splice()
33
- function spliceOne(list, index) {
34
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
35
- list[i] = list[k];
36
- }
37
-
38
- list.pop();
39
- }
40
-
41
- // This implementation is based heavily on node's url.parse
42
- function resolvePathname(to, from) {
43
- if (from === undefined) from = '';
44
-
45
- var toParts = (to && to.split('/')) || [];
46
- var fromParts = (from && from.split('/')) || [];
47
-
48
- var isToAbs = to && isAbsolute(to);
49
- var isFromAbs = from && isAbsolute(from);
50
- var mustEndAbs = isToAbs || isFromAbs;
51
-
52
- if (to && isAbsolute(to)) {
53
- // to is absolute
54
- fromParts = toParts;
55
- } else if (toParts.length) {
56
- // to is relative, drop the filename
57
- fromParts.pop();
58
- fromParts = fromParts.concat(toParts);
59
- }
60
-
61
- if (!fromParts.length) return '/';
62
-
63
- var hasTrailingSlash;
64
- if (fromParts.length) {
65
- var last = fromParts[fromParts.length - 1];
66
- hasTrailingSlash = last === '.' || last === '..' || last === '';
67
- } else {
68
- hasTrailingSlash = false;
69
- }
70
-
71
- var up = 0;
72
- for (var i = fromParts.length; i >= 0; i--) {
73
- var part = fromParts[i];
74
-
75
- if (part === '.') {
76
- spliceOne(fromParts, i);
77
- } else if (part === '..') {
78
- spliceOne(fromParts, i);
79
- up++;
80
- } else if (up) {
81
- spliceOne(fromParts, i);
82
- up--;
83
- }
84
- }
85
-
86
- if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');
87
-
88
- if (
89
- mustEndAbs &&
90
- fromParts[0] !== '' &&
91
- (!fromParts[0] || !isAbsolute(fromParts[0]))
92
- )
93
- fromParts.unshift('');
94
-
95
- var result = fromParts.join('/');
96
-
97
- if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
98
-
99
- return result;
100
- }
101
-
102
- var isProduction = process.env.NODE_ENV === 'production';
103
- function warning(condition, message) {
104
- if (!isProduction) {
105
- if (condition) {
106
- return;
107
- }
108
-
109
- var text = "Warning: " + message;
110
-
111
- if (typeof console !== 'undefined') {
112
- console.warn(text);
113
- }
114
-
115
- try {
116
- throw Error(text);
117
- } catch (x) {}
118
- }
119
- }
120
-
121
- var isProduction$1 = process.env.NODE_ENV === 'production';
122
- var prefix = 'Invariant failed';
123
- function invariant(condition, message) {
124
- if (condition) {
125
- return;
126
- }
127
- if (isProduction$1) {
128
- throw new Error(prefix);
129
- }
130
- var provided = typeof message === 'function' ? message() : message;
131
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
132
- throw new Error(value);
133
- }
134
-
135
- function addLeadingSlash(path) {
136
- return path.charAt(0) === '/' ? path : '/' + path;
137
- }
138
- function hasBasename(path, prefix) {
139
- return path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && '/?#'.indexOf(path.charAt(prefix.length)) !== -1;
140
- }
141
- function stripBasename(path, prefix) {
142
- return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
143
- }
144
- function stripTrailingSlash(path) {
145
- return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
146
- }
147
- function parsePath(path) {
148
- var pathname = path || '/';
149
- var search = '';
150
- var hash = '';
151
- var hashIndex = pathname.indexOf('#');
152
-
153
- if (hashIndex !== -1) {
154
- hash = pathname.substr(hashIndex);
155
- pathname = pathname.substr(0, hashIndex);
156
- }
157
-
158
- var searchIndex = pathname.indexOf('?');
159
-
160
- if (searchIndex !== -1) {
161
- search = pathname.substr(searchIndex);
162
- pathname = pathname.substr(0, searchIndex);
163
- }
164
-
165
- return {
166
- pathname: pathname,
167
- search: search === '?' ? '' : search,
168
- hash: hash === '#' ? '' : hash
169
- };
170
- }
171
- function createPath(location) {
172
- var pathname = location.pathname,
173
- search = location.search,
174
- hash = location.hash;
175
- var path = pathname || '/';
176
- if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
177
- if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
178
- return path;
179
- }
180
-
181
- function createLocation(path, state, key, currentLocation) {
182
- var location;
183
-
184
- if (typeof path === 'string') {
185
- // Two-arg form: push(path, state)
186
- location = parsePath(path);
187
- location.state = state;
188
- } else {
189
- // One-arg form: push(location)
190
- location = _extends({}, path);
191
- if (location.pathname === undefined) location.pathname = '';
192
-
193
- if (location.search) {
194
- if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
195
- } else {
196
- location.search = '';
197
- }
198
-
199
- if (location.hash) {
200
- if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
201
- } else {
202
- location.hash = '';
203
- }
204
-
205
- if (state !== undefined && location.state === undefined) location.state = state;
206
- }
207
-
208
- try {
209
- location.pathname = decodeURI(location.pathname);
210
- } catch (e) {
211
- if (e instanceof URIError) {
212
- throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
213
- } else {
214
- throw e;
215
- }
216
- }
217
-
218
- if (key) location.key = key;
219
-
220
- if (currentLocation) {
221
- // Resolve incomplete/relative pathname relative to current location.
222
- if (!location.pathname) {
223
- location.pathname = currentLocation.pathname;
224
- } else if (location.pathname.charAt(0) !== '/') {
225
- location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
226
- }
227
- } else {
228
- // When there is no prior location and pathname is empty, set it to /
229
- if (!location.pathname) {
230
- location.pathname = '/';
231
- }
232
- }
233
-
234
- return location;
235
- }
236
-
237
- function createTransitionManager() {
238
- var prompt = null;
239
-
240
- function setPrompt(nextPrompt) {
241
- process.env.NODE_ENV !== "production" ? warning(prompt == null, 'A history supports only one prompt at a time') : void 0;
242
- prompt = nextPrompt;
243
- return function () {
244
- if (prompt === nextPrompt) prompt = null;
245
- };
246
- }
247
-
248
- function confirmTransitionTo(location, action, getUserConfirmation, callback) {
249
- // TODO: If another transition starts while we're still confirming
250
- // the previous one, we may end up in a weird state. Figure out the
251
- // best way to handle this.
252
- if (prompt != null) {
253
- var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
254
-
255
- if (typeof result === 'string') {
256
- if (typeof getUserConfirmation === 'function') {
257
- getUserConfirmation(result, callback);
258
- } else {
259
- process.env.NODE_ENV !== "production" ? warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') : void 0;
260
- callback(true);
261
- }
262
- } else {
263
- // Return false from a transition hook to cancel the transition.
264
- callback(result !== false);
265
- }
266
- } else {
267
- callback(true);
268
- }
269
- }
270
-
271
- var listeners = [];
272
-
273
- function appendListener(fn) {
274
- var isActive = true;
275
-
276
- function listener() {
277
- if (isActive) fn.apply(void 0, arguments);
278
- }
279
-
280
- listeners.push(listener);
281
- return function () {
282
- isActive = false;
283
- listeners = listeners.filter(function (item) {
284
- return item !== listener;
285
- });
286
- };
287
- }
288
-
289
- function notifyListeners() {
290
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
291
- args[_key] = arguments[_key];
292
- }
293
-
294
- listeners.forEach(function (listener) {
295
- return listener.apply(void 0, args);
296
- });
297
- }
298
-
299
- return {
300
- setPrompt: setPrompt,
301
- confirmTransitionTo: confirmTransitionTo,
302
- appendListener: appendListener,
303
- notifyListeners: notifyListeners
304
- };
305
- }
306
-
307
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
308
- function getConfirmation(message, callback) {
309
- callback(window.confirm(message)); // eslint-disable-line no-alert
310
- }
311
- /**
312
- * Returns true if the HTML5 history API is supported. Taken from Modernizr.
313
- *
314
- * https://github.com/Modernizr/Modernizr/blob/master/LICENSE
315
- * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
316
- * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
317
- */
318
-
319
- function supportsHistory() {
320
- var ua = window.navigator.userAgent;
321
- if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
322
- return window.history && 'pushState' in window.history;
323
- }
324
- /**
325
- * Returns true if browser fires popstate on hash change.
326
- * IE10 and IE11 do not.
327
- */
328
-
329
- function supportsPopStateOnHashChange() {
330
- return window.navigator.userAgent.indexOf('Trident') === -1;
331
- }
332
- /**
333
- * Returns true if a given popstate event is an extraneous WebKit event.
334
- * Accounts for the fact that Chrome on iOS fires real popstate events
335
- * containing undefined state when pressing the back button.
336
- */
337
-
338
- function isExtraneousPopstateEvent(event) {
339
- return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
340
- }
341
-
342
- var PopStateEvent = 'popstate';
343
- var HashChangeEvent = 'hashchange';
344
-
345
- function getHistoryState() {
346
- try {
347
- return window.history.state || {};
348
- } catch (e) {
349
- // IE 11 sometimes throws when accessing window.history.state
350
- // See https://github.com/ReactTraining/history/pull/289
351
- return {};
352
- }
353
- }
354
- /**
355
- * Creates a history object that uses the HTML5 history API including
356
- * pushState, replaceState, and the popstate event.
357
- */
358
-
359
-
360
- function createBrowserHistory(props) {
361
- if (props === void 0) {
362
- props = {};
363
- }
364
-
365
- !canUseDOM ? process.env.NODE_ENV !== "production" ? invariant(false, 'Browser history needs a DOM') : invariant(false) : void 0;
366
- var globalHistory = window.history;
367
- var canUseHistory = supportsHistory();
368
- var needsHashChangeListener = !supportsPopStateOnHashChange();
369
- var _props = props,
370
- _props$forceRefresh = _props.forceRefresh,
371
- forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
372
- _props$getUserConfirm = _props.getUserConfirmation,
373
- getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
374
- _props$keyLength = _props.keyLength,
375
- keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
376
- var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
377
-
378
- function getDOMLocation(historyState) {
379
- var _ref = historyState || {},
380
- key = _ref.key,
381
- state = _ref.state;
382
-
383
- var _window$location = window.location,
384
- pathname = _window$location.pathname,
385
- search = _window$location.search,
386
- hash = _window$location.hash;
387
- var path = pathname + search + hash;
388
- process.env.NODE_ENV !== "production" ? warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0;
389
- if (basename) path = stripBasename(path, basename);
390
- return createLocation(path, state, key);
391
- }
392
-
393
- function createKey() {
394
- return Math.random().toString(36).substr(2, keyLength);
395
- }
396
-
397
- var transitionManager = createTransitionManager();
398
-
399
- function setState(nextState) {
400
- _extends(history, nextState);
401
-
402
- history.length = globalHistory.length;
403
- transitionManager.notifyListeners(history.location, history.action);
404
- }
405
-
406
- function handlePopState(event) {
407
- // Ignore extraneous popstate events in WebKit.
408
- if (isExtraneousPopstateEvent(event)) return;
409
- handlePop(getDOMLocation(event.state));
410
- }
411
-
412
- function handleHashChange() {
413
- handlePop(getDOMLocation(getHistoryState()));
414
- }
415
-
416
- var forceNextPop = false;
417
-
418
- function handlePop(location) {
419
- if (forceNextPop) {
420
- forceNextPop = false;
421
- setState();
422
- } else {
423
- var action = 'POP';
424
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
425
- if (ok) {
426
- setState({
427
- action: action,
428
- location: location
429
- });
430
- } else {
431
- revertPop(location);
432
- }
433
- });
434
- }
435
- }
436
-
437
- function revertPop(fromLocation) {
438
- var toLocation = history.location; // TODO: We could probably make this more reliable by
439
- // keeping a list of keys we've seen in sessionStorage.
440
- // Instead, we just default to 0 for keys we don't know.
441
-
442
- var toIndex = allKeys.indexOf(toLocation.key);
443
- if (toIndex === -1) toIndex = 0;
444
- var fromIndex = allKeys.indexOf(fromLocation.key);
445
- if (fromIndex === -1) fromIndex = 0;
446
- var delta = toIndex - fromIndex;
447
-
448
- if (delta) {
449
- forceNextPop = true;
450
- go(delta);
451
- }
452
- }
453
-
454
- var initialLocation = getDOMLocation(getHistoryState());
455
- var allKeys = [initialLocation.key]; // Public interface
456
-
457
- function createHref(location) {
458
- return basename + createPath(location);
459
- }
460
-
461
- function push(path, state) {
462
- process.env.NODE_ENV !== "production" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
463
- var action = 'PUSH';
464
- var location = createLocation(path, state, createKey(), history.location);
465
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
466
- if (!ok) return;
467
- var href = createHref(location);
468
- var key = location.key,
469
- state = location.state;
470
-
471
- if (canUseHistory) {
472
- globalHistory.pushState({
473
- key: key,
474
- state: state
475
- }, null, href);
476
-
477
- if (forceRefresh) {
478
- window.location.href = href;
479
- } else {
480
- var prevIndex = allKeys.indexOf(history.location.key);
481
- var nextKeys = allKeys.slice(0, prevIndex + 1);
482
- nextKeys.push(location.key);
483
- allKeys = nextKeys;
484
- setState({
485
- action: action,
486
- location: location
487
- });
488
- }
489
- } else {
490
- process.env.NODE_ENV !== "production" ? warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') : void 0;
491
- window.location.href = href;
492
- }
493
- });
494
- }
495
-
496
- function replace(path, state) {
497
- process.env.NODE_ENV !== "production" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
498
- var action = 'REPLACE';
499
- var location = createLocation(path, state, createKey(), history.location);
500
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
501
- if (!ok) return;
502
- var href = createHref(location);
503
- var key = location.key,
504
- state = location.state;
505
-
506
- if (canUseHistory) {
507
- globalHistory.replaceState({
508
- key: key,
509
- state: state
510
- }, null, href);
511
-
512
- if (forceRefresh) {
513
- window.location.replace(href);
514
- } else {
515
- var prevIndex = allKeys.indexOf(history.location.key);
516
- if (prevIndex !== -1) allKeys[prevIndex] = location.key;
517
- setState({
518
- action: action,
519
- location: location
520
- });
521
- }
522
- } else {
523
- process.env.NODE_ENV !== "production" ? warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') : void 0;
524
- window.location.replace(href);
525
- }
526
- });
527
- }
528
-
529
- function go(n) {
530
- globalHistory.go(n);
531
- }
532
-
533
- function goBack() {
534
- go(-1);
535
- }
536
-
537
- function goForward() {
538
- go(1);
539
- }
540
-
541
- var listenerCount = 0;
542
-
543
- function checkDOMListeners(delta) {
544
- listenerCount += delta;
545
-
546
- if (listenerCount === 1 && delta === 1) {
547
- window.addEventListener(PopStateEvent, handlePopState);
548
- if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
549
- } else if (listenerCount === 0) {
550
- window.removeEventListener(PopStateEvent, handlePopState);
551
- if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
552
- }
553
- }
554
-
555
- var isBlocked = false;
556
-
557
- function block(prompt) {
558
- if (prompt === void 0) {
559
- prompt = false;
560
- }
561
-
562
- var unblock = transitionManager.setPrompt(prompt);
563
-
564
- if (!isBlocked) {
565
- checkDOMListeners(1);
566
- isBlocked = true;
567
- }
568
-
569
- return function () {
570
- if (isBlocked) {
571
- isBlocked = false;
572
- checkDOMListeners(-1);
573
- }
574
-
575
- return unblock();
576
- };
577
- }
578
-
579
- function listen(listener) {
580
- var unlisten = transitionManager.appendListener(listener);
581
- checkDOMListeners(1);
582
- return function () {
583
- checkDOMListeners(-1);
584
- unlisten();
585
- };
586
- }
587
-
588
- var history = {
589
- length: globalHistory.length,
590
- action: 'POP',
591
- location: initialLocation,
592
- createHref: createHref,
593
- push: push,
594
- replace: replace,
595
- go: go,
596
- goBack: goBack,
597
- goForward: goForward,
598
- block: block,
599
- listen: listen
600
- };
601
- return history;
602
- }
13
+ 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';
603
17
 
604
18
  var setLoading = createAction("common/setLoading");
605
19
  var setAlert = createAction("common/setAlert");
606
20
  var setUser = createAction("common/setUser");
21
+ var setLanguage = createAction("common/setLanguage");
607
22
 
608
23
  var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
609
24
  var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
610
25
  var ACCESS_TOKEN = "ACCESS_TOKEN";
611
26
  var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
612
- var BASE_URL = "https://ec0e-123-24-205-68.ngrok-free.app";
27
+ var BASE_URL = "https://localhost:7045";
28
+ var PUSHER_CONFIG = {
29
+ cluster: "ap1",
30
+ key: "9018c77328885a14150b"
31
+ };
32
+ var EXAM_CHANNEL = "EXAM-CHANNEL";
613
33
  var getAccessToken = function getAccessToken() {
614
34
  try {
615
35
  return localStorage.getItem(ACCESS_TOKEN);
@@ -658,7 +78,7 @@ function _catch(body, recover) {
658
78
  return result;
659
79
  }
660
80
 
661
- var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1"};
81
+ 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"};
662
82
 
663
83
  var api = axios.create({
664
84
  baseURL: BASE_URL,
@@ -693,13 +113,14 @@ var apiUpload = axios.create({
693
113
  return i.interceptors.response.use(function (response) {
694
114
  return response;
695
115
  }, function (error) {
116
+ var _error$response, _error$response2;
696
117
  console.log({
697
118
  error: error
698
119
  });
699
- if (error.response.status === 401) {
120
+ if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
700
121
  window.location.href = "/login";
701
122
  }
702
- if (error.response.status == 403) {
123
+ if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) == 403) {
703
124
  localStorage.removeItem(ACCESS_TOKEN);
704
125
  localStorage.removeItem("USER_EMAIL");
705
126
  window.location.href = "/login";
@@ -708,8 +129,30 @@ var apiUpload = axios.create({
708
129
  });
709
130
  });
710
131
 
711
- var apiLoginGoogle = function apiLoginGoogle(body) {
712
- return api.post(BASE_URL + "/api/auth/login", body);
132
+ var apiLoginGoogle = function apiLoginGoogle(body, role) {
133
+ return api.post(BASE_URL + "/api/auth/" + role + "/login", body);
134
+ };
135
+
136
+ var AuthenticationMessage;
137
+ (function (AuthenticationMessage) {
138
+ AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
139
+ AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
140
+ })(AuthenticationMessage || (AuthenticationMessage = {}));
141
+
142
+ var useGoogleSignOut = function useGoogleSignOut(props) {
143
+ var onLogoutSuccess = props.onLogoutSuccess,
144
+ onFailure = props.onFailure;
145
+ var _useGoogleLogout = useGoogleLogout({
146
+ clientId: GOOGLE_CLIENT_ID,
147
+ onLogoutSuccess: onLogoutSuccess,
148
+ onFailure: onFailure
149
+ }),
150
+ signOut = _useGoogleLogout.signOut,
151
+ loaded = _useGoogleLogout.loaded;
152
+ return {
153
+ signOut: signOut,
154
+ loaded: loaded
155
+ };
713
156
  };
714
157
 
715
158
  var ERROR_MESSAGE = "Login fail!";
@@ -725,6 +168,8 @@ var BlockLogin = function BlockLogin(_ref) {
725
168
  var dispatch = useDispatch();
726
169
  var _useGoogleReCaptcha = useGoogleReCaptcha(),
727
170
  executeRecaptcha = _useGoogleReCaptcha.executeRecaptcha;
171
+ var _useGoogleSignOut = useGoogleSignOut({}),
172
+ signOut = _useGoogleSignOut.signOut;
728
173
  var clickHandler = useCallback(function () {
729
174
  try {
730
175
  if (!executeRecaptcha) {
@@ -740,10 +185,6 @@ var BlockLogin = function BlockLogin(_ref) {
740
185
  var onSuccessGoogle = function onSuccessGoogle(res) {
741
186
  try {
742
187
  var _exit = false;
743
- console.log("success");
744
- console.log({
745
- res: res
746
- });
747
188
  return Promise.resolve(function () {
748
189
  if (!!(res !== null && res !== void 0 && res.accessToken)) {
749
190
  var _temp2 = function _temp2(_result) {
@@ -761,21 +202,15 @@ var BlockLogin = function BlockLogin(_ref) {
761
202
  fullName: name,
762
203
  email: email,
763
204
  token: accessToken,
764
- googleId: googleId,
765
- role: isTeacher ? "Teacher" : "Student"
205
+ googleId: googleId
766
206
  };
767
- console.log({
768
- infoLogin: infoLogin
769
- });
207
+ var role = isTeacher ? "Teacher" : "Student";
770
208
  dispatch(setLoading(true));
771
209
  var _temp = _catch(function () {
772
- return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (res1) {
210
+ return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
773
211
  var isFirstLogin = res1.data.isFirstLogin;
774
212
  var tokenJWT = res1.data.token;
775
213
  localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
776
- console.log({
777
- res1: res1
778
- });
779
214
  localStorage.setItem(ACCESS_TOKEN, tokenJWT);
780
215
  if (isTeacher) {
781
216
  onNavigate("/teacher/overall-status/main");
@@ -789,10 +224,22 @@ var BlockLogin = function BlockLogin(_ref) {
789
224
  }
790
225
  });
791
226
  }, function (error) {
792
- var _error$response;
793
- dispatch(setAlert({
227
+ var _error$response, _error$response$data;
228
+ var message = undefined;
229
+ 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;
230
+ if (type === AuthenticationMessage.NotAllowedToRegister) {
231
+ alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
232
+ } else if (type) {
233
+ var _error$response2, _error$response2$data;
234
+ 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;
235
+ } else {
236
+ var _error$response3;
237
+ message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
238
+ }
239
+ signOut();
240
+ !!message && dispatch(setAlert({
794
241
  type: "danger",
795
- message: ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || ERROR_MESSAGE
242
+ message: message
796
243
  }));
797
244
  });
798
245
  return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
@@ -848,7 +295,8 @@ var BlockLogin = function BlockLogin(_ref) {
848
295
  onSuccess: onSuccessGoogle,
849
296
  onFailure: onFailureGoogle,
850
297
  cookiePolicy: "single_host_origin",
851
- className: "" + styles["btn-login-google"]
298
+ className: "" + styles["btn-login-google"],
299
+ isSignedIn: true
852
300
  }))))));
853
301
  });
854
302
  };
@@ -1016,7 +464,7 @@ function kindOf(val) {
1016
464
  }
1017
465
 
1018
466
  // src/utils/warning.ts
1019
- function warning$1(message) {
467
+ function warning(message) {
1020
468
  if (typeof console !== "undefined" && typeof console.error === "function") {
1021
469
  console.error(message);
1022
470
  }
@@ -1069,7 +517,7 @@ function combineReducers(reducers) {
1069
517
  const key = reducerKeys[i];
1070
518
  if (process.env.NODE_ENV !== "production") {
1071
519
  if (typeof reducers[key] === "undefined") {
1072
- warning$1(`No reducer provided for key "${key}"`);
520
+ warning(`No reducer provided for key "${key}"`);
1073
521
  }
1074
522
  }
1075
523
  if (typeof reducers[key] === "function") {
@@ -1094,7 +542,7 @@ function combineReducers(reducers) {
1094
542
  if (process.env.NODE_ENV !== "production") {
1095
543
  const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
1096
544
  if (warningMessage) {
1097
- warning$1(warningMessage);
545
+ warning(warningMessage);
1098
546
  }
1099
547
  }
1100
548
  let hasChanged = false;
@@ -1132,6 +580,8 @@ var commonReducer = createReducer(initialState, function (builder) {
1132
580
  state.alert = action.payload;
1133
581
  }).addCase(setUser, function (state, action) {
1134
582
  state.user = action.payload;
583
+ }).addCase(setLanguage, function (state, action) {
584
+ state.language = action.payload;
1135
585
  });
1136
586
  });
1137
587
 
@@ -1268,9 +718,12 @@ var getInfo = function getInfo() {
1268
718
  var LayoutContext = function LayoutContext(_ref) {
1269
719
  var children = _ref.children,
1270
720
  onNavigate = _ref.onNavigate;
721
+ var _useGoogleSignOut = useGoogleSignOut({}),
722
+ signOut = _useGoogleSignOut.signOut;
1271
723
  var dispatch = useDispatch();
1272
724
  var resetAuth = function resetAuth() {
1273
725
  localStorage.removeItem(ACCESS_TOKEN);
726
+ signOut();
1274
727
  onNavigate("/login");
1275
728
  };
1276
729
  var loadInfo = function loadInfo() {
@@ -1313,6 +766,8 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
1313
766
  _ref$okText = _ref.okText,
1314
767
  okText = _ref$okText === void 0 ? "Yes" : _ref$okText,
1315
768
  isDelete = _ref.isDelete,
769
+ _ref$title = _ref.title,
770
+ title = _ref$title === void 0 ? "Confirmation" : _ref$title,
1316
771
  toggle = _ref.toggle,
1317
772
  onConfirm = _ref.onConfirm;
1318
773
  return React.createElement(Modal, {
@@ -1321,7 +776,7 @@ var ConfirmDialog = function ConfirmDialog(_ref) {
1321
776
  centered: true
1322
777
  }, React.createElement(ModalHeader, {
1323
778
  toggle: toggle
1324
- }, "Confirmation"), React.createElement(ModalBody, null, text), React.createElement(ModalFooter, null, React.createElement(Button, {
779
+ }, title), React.createElement(ModalBody, null, text), React.createElement(ModalFooter, null, React.createElement(Button, {
1325
780
  color: "secondary",
1326
781
  onClick: toggle
1327
782
  }, cancelText), React.createElement(Button, {
@@ -1337,8 +792,10 @@ var CommonDialog = function CommonDialog(_ref) {
1337
792
  title = _ref.title,
1338
793
  _ref$size = _ref.size,
1339
794
  size = _ref$size === void 0 ? "xs" : _ref$size,
1340
- onClose = _ref.onClose;
795
+ onClose = _ref.onClose,
796
+ backdrop = _ref.backdrop;
1341
797
  return React.createElement(Modal, {
798
+ backdrop: backdrop,
1342
799
  isOpen: open,
1343
800
  toggle: onClose,
1344
801
  centered: centered,
@@ -1390,10 +847,11 @@ var formatTime = (function (time, ORIGINAL_FORMAT, FORMAT) {
1390
847
  }
1391
848
  });
1392
849
 
1393
- var diffFromNow = (function (time, unitOfTime) {
1394
- if (time === DATE_MIN_VALUE) return 0;
850
+ var diffFromNow = (function (time, unitOfTime, targetTime) {
851
+ if (time === DATE_MIN_VALUE || targetTime === DATE_MIN_VALUE) return 0;
1395
852
  try {
1396
- return moment().diff(moment.utc(time).local(), unitOfTime);
853
+ var now = !!targetTime ? moment() : moment.utc(targetTime).local();
854
+ return now.diff(moment.utc(time).local(), unitOfTime);
1397
855
  } catch (_unused) {
1398
856
  return "";
1399
857
  }
@@ -1493,7 +951,368 @@ var CustomPagination = function CustomPagination(_ref) {
1493
951
  })));
1494
952
  };
1495
953
 
954
+ var ExamEvent;
955
+ (function (ExamEvent) {
956
+ ExamEvent["StartExam"] = "start-exam";
957
+ ExamEvent["TerminateExam"] = "terminate-exam";
958
+ ExamEvent["JoinExam"] = "join-exam";
959
+ ExamEvent["AddExtraDuration"] = "add-extra-duration-exam";
960
+ ExamEvent["TeacherDisconnectChannel"] = "teacher-disconnect-channel";
961
+ ExamEvent["StudentDisconnectChannel"] = "student-disconnect-channel";
962
+ })(ExamEvent || (ExamEvent = {}));
963
+
964
+ var problem_solving = "문제풀기";
965
+ var my_story = "내 스토리";
966
+ var search_find = "검색하여 찾기";
967
+ var test_code = "시험코드 입력";
968
+ var login_success = "로그인 성공";
969
+ var welcome_success = "스터디 터치에 오신 것을 환영합니다!";
970
+ var description_success = "스터디 터치는 엄태욱 선생님의 수업에서 활용되는 학습 도구입니다.";
971
+ var logout = "로그 아웃";
972
+ var overall_status = "전체 현황";
973
+ var exam_status = "시험별 현";
974
+ var user_manager = "사용자 목록";
975
+ var recent_exam_results = "최근 시험 결과";
976
+ var instructor_name = "강사이름";
977
+ var academy_name = "학원 이름";
978
+ var total_students = "총 학생수";
979
+ var student = "명";
980
+ var students = "명";
981
+ var extra_time = "추가 시간";
982
+ var complete = "완료";
983
+ var current_exam = "현재 시험중";
984
+ var exam_time = "시험 시간";
985
+ var time_remaining = "남은 시간";
986
+ var number_results = "결과 {{number}}건";
987
+ var number_result = "결과 {{number}}건";
988
+ var mins_mins_seconds_seconds = "{{mins}}분 {{seconds}}초";
989
+ var mins_mins = "{{mins}}분";
990
+ var class_name = "반 이름";
991
+ var create_new_exam = "새 시험 생성";
992
+ var there_are_no_recent_exams = "최근 시험이 없습니다";
993
+ var you_have_created_a_exam_with_code_code_do_you_want_to_continue = "코드가 {{code}}인 시험을 생성했습니다. 계속하시겠습니까?";
994
+ var here = "여기";
995
+ var do_you_want_to_complete_the_exam = "시험을 완료처리 하시겠습니까?";
996
+ var are_you_sure_you_want_to_delete_the_exam = "시험을 삭제하시겠습니까?";
997
+ var yes = "예";
998
+ var no = "아니요";
999
+ var cancel = "취소";
1000
+ var confirmation = "확인";
1001
+ var student_name = "학생이름";
1002
+ var full_pool_time = "전체풀이시간";
1003
+ var number_question = "{{number}}번";
1004
+ var answer_rate = "정답률";
1005
+ var seconds = "초";
1006
+ var search_placeholder = "시험 이름으로 검색하기";
1007
+ var study_touch = "영어연구소";
1008
+ var exam_information = "시험정보";
1009
+ var issue_number = "문제번호";
1010
+ var incorrect_rate = "오답률";
1011
+ var question_time_for_each_student = "학생별 문항 시간";
1012
+ var correct_answer_for_each_student = "학생별 정답 여부";
1013
+ var information_by_question = "문항별 정보";
1014
+ var no_data = "데이터 없음";
1015
+ var internet_connection_was_lost = "인터넷 연결이 끊어졌습니다";
1016
+ var problem = "문제";
1017
+ var problem_solving_time = "문제풀이 시간";
1018
+ var lang_ko = {
1019
+ problem_solving: problem_solving,
1020
+ my_story: my_story,
1021
+ search_find: search_find,
1022
+ test_code: test_code,
1023
+ login_success: login_success,
1024
+ welcome_success: welcome_success,
1025
+ description_success: description_success,
1026
+ logout: logout,
1027
+ overall_status: overall_status,
1028
+ exam_status: exam_status,
1029
+ user_manager: user_manager,
1030
+ recent_exam_results: recent_exam_results,
1031
+ instructor_name: instructor_name,
1032
+ academy_name: academy_name,
1033
+ total_students: total_students,
1034
+ student: student,
1035
+ students: students,
1036
+ extra_time: extra_time,
1037
+ complete: complete,
1038
+ current_exam: current_exam,
1039
+ exam_time: exam_time,
1040
+ time_remaining: time_remaining,
1041
+ number_results: number_results,
1042
+ number_result: number_result,
1043
+ mins_mins_seconds_seconds: mins_mins_seconds_seconds,
1044
+ mins_mins: mins_mins,
1045
+ class_name: class_name,
1046
+ create_new_exam: create_new_exam,
1047
+ there_are_no_recent_exams: there_are_no_recent_exams,
1048
+ you_have_created_a_exam_with_code_code_do_you_want_to_continue: you_have_created_a_exam_with_code_code_do_you_want_to_continue,
1049
+ here: here,
1050
+ do_you_want_to_complete_the_exam: do_you_want_to_complete_the_exam,
1051
+ are_you_sure_you_want_to_delete_the_exam: are_you_sure_you_want_to_delete_the_exam,
1052
+ yes: yes,
1053
+ no: no,
1054
+ cancel: cancel,
1055
+ confirmation: confirmation,
1056
+ student_name: student_name,
1057
+ full_pool_time: full_pool_time,
1058
+ number_question: number_question,
1059
+ answer_rate: answer_rate,
1060
+ seconds: seconds,
1061
+ search_placeholder: search_placeholder,
1062
+ study_touch: study_touch,
1063
+ exam_information: exam_information,
1064
+ issue_number: issue_number,
1065
+ incorrect_rate: incorrect_rate,
1066
+ question_time_for_each_student: question_time_for_each_student,
1067
+ correct_answer_for_each_student: correct_answer_for_each_student,
1068
+ information_by_question: information_by_question,
1069
+ no_data: no_data,
1070
+ internet_connection_was_lost: internet_connection_was_lost,
1071
+ problem: problem,
1072
+ problem_solving_time: problem_solving_time
1073
+ };
1074
+
1075
+ var problem_solving$1 = "Problem Solving";
1076
+ var my_story$1 = "My Story";
1077
+ var search_find$1 = "Search and find";
1078
+ var test_code$1 = "Enter test code";
1079
+ var login_success$1 = "Login Success";
1080
+ var welcome_success$1 = "Welcome to Study Touch!";
1081
+ var description_success$1 = "Study Touch is a learning tool used in teacher Taewook Eom's classes.";
1082
+ var logout$1 = "Logout";
1083
+ var overall_status$1 = "Overall Status";
1084
+ var exam_status$1 = "Exam Status";
1085
+ var user_manager$1 = "User Manager";
1086
+ var recent_exam_results$1 = "Recent exam";
1087
+ var instructor_name$1 = "Instructor name";
1088
+ var academy_name$1 = "Academy name";
1089
+ var total_students$1 = "Total students";
1090
+ var students$1 = "Students";
1091
+ var student$1 = "Student";
1092
+ var extra_time$1 = "Extra time";
1093
+ var complete$1 = "Complete";
1094
+ var current_exam$1 = "Current exam";
1095
+ var exam_time$1 = "Extra time";
1096
+ var time_remaining$1 = "Time remaining";
1097
+ var number_results$1 = "{{number}} Results";
1098
+ var number_result$1 = "{{number}} Result";
1099
+ var mins_mins_seconds_seconds$1 = "{{mins}}m {{seconds}}s";
1100
+ var mins_mins$1 = "{{mins}}m";
1101
+ var class_name$1 = "Class name";
1102
+ var create_new_exam$1 = "Create exam";
1103
+ var there_are_no_recent_exams$1 = "There are no recent exams";
1104
+ var you_have_created_a_exam_with_code_code_do_you_want_to_continue$1 = "You have created a exam with code {{code}}, do you want to continue?";
1105
+ var here$1 = "here";
1106
+ var do_you_want_to_complete_the_exam$1 = "Do you want to complete the exam?";
1107
+ var are_you_sure_you_want_to_delete_the_exam$1 = "Are you sure you want to delete the exam?";
1108
+ var yes$1 = "Yes";
1109
+ var no$1 = "No";
1110
+ var cancel$1 = "Cancel";
1111
+ var confirmation$1 = "Confirmation";
1112
+ var student_name$1 = "Student name";
1113
+ var full_pool_time$1 = "Full pool time";
1114
+ var number_question$1 = "No.{{number}}";
1115
+ var answer_rate$1 = "Answer rate";
1116
+ var seconds$1 = "s";
1117
+ var search_placeholder$1 = "Search by exam name";
1118
+ var study_touch$1 = "Study touch";
1119
+ var exam_information$1 = "Exam information";
1120
+ var issue_number$1 = "Issue number";
1121
+ var incorrect_rate$1 = "Incorrect rate";
1122
+ var question_time_for_each_student$1 = "Question time for each student";
1123
+ var correct_answer_for_each_student$1 = "Correct answer for each student";
1124
+ var information_by_question$1 = "Information by question";
1125
+ var no_data$1 = "No data";
1126
+ var internet_connection_was_lost$1 = "Internet connection was lost";
1127
+ var problem$1 = "Problem ";
1128
+ var problem_solving_time$1 = "Problem solving time";
1129
+ var lang_en = {
1130
+ problem_solving: problem_solving$1,
1131
+ my_story: my_story$1,
1132
+ search_find: search_find$1,
1133
+ test_code: test_code$1,
1134
+ login_success: login_success$1,
1135
+ welcome_success: welcome_success$1,
1136
+ description_success: description_success$1,
1137
+ logout: logout$1,
1138
+ overall_status: overall_status$1,
1139
+ exam_status: exam_status$1,
1140
+ user_manager: user_manager$1,
1141
+ recent_exam_results: recent_exam_results$1,
1142
+ instructor_name: instructor_name$1,
1143
+ academy_name: academy_name$1,
1144
+ total_students: total_students$1,
1145
+ students: students$1,
1146
+ student: student$1,
1147
+ extra_time: extra_time$1,
1148
+ complete: complete$1,
1149
+ current_exam: current_exam$1,
1150
+ exam_time: exam_time$1,
1151
+ time_remaining: time_remaining$1,
1152
+ number_results: number_results$1,
1153
+ number_result: number_result$1,
1154
+ mins_mins_seconds_seconds: mins_mins_seconds_seconds$1,
1155
+ mins_mins: mins_mins$1,
1156
+ class_name: class_name$1,
1157
+ create_new_exam: create_new_exam$1,
1158
+ there_are_no_recent_exams: there_are_no_recent_exams$1,
1159
+ you_have_created_a_exam_with_code_code_do_you_want_to_continue: you_have_created_a_exam_with_code_code_do_you_want_to_continue$1,
1160
+ here: here$1,
1161
+ do_you_want_to_complete_the_exam: do_you_want_to_complete_the_exam$1,
1162
+ are_you_sure_you_want_to_delete_the_exam: are_you_sure_you_want_to_delete_the_exam$1,
1163
+ yes: yes$1,
1164
+ no: no$1,
1165
+ cancel: cancel$1,
1166
+ confirmation: confirmation$1,
1167
+ student_name: student_name$1,
1168
+ full_pool_time: full_pool_time$1,
1169
+ number_question: number_question$1,
1170
+ answer_rate: answer_rate$1,
1171
+ seconds: seconds$1,
1172
+ search_placeholder: search_placeholder$1,
1173
+ study_touch: study_touch$1,
1174
+ exam_information: exam_information$1,
1175
+ issue_number: issue_number$1,
1176
+ incorrect_rate: incorrect_rate$1,
1177
+ question_time_for_each_student: question_time_for_each_student$1,
1178
+ correct_answer_for_each_student: correct_answer_for_each_student$1,
1179
+ information_by_question: information_by_question$1,
1180
+ no_data: no_data$1,
1181
+ internet_connection_was_lost: internet_connection_was_lost$1,
1182
+ problem: problem$1,
1183
+ problem_solving_time: problem_solving_time$1
1184
+ };
1185
+
1186
+ i18n.use(initReactI18next).init({
1187
+ lng: "ko",
1188
+ fallbackLng: "ko",
1189
+ interpolation: {
1190
+ escapeValue: false
1191
+ },
1192
+ resources: {
1193
+ ko: {
1194
+ translation: lang_ko
1195
+ },
1196
+ en: {
1197
+ translation: lang_en
1198
+ }
1199
+ }
1200
+ });
1201
+
1202
+ var DEFAULT_LANGUAGE_CODE = "ko";
1203
+ var LANGUAGES = [{
1204
+ code: "ko",
1205
+ fullName: "Korean",
1206
+ shortName: "Korean",
1207
+ nativeName: "Korean",
1208
+ name: "Korean",
1209
+ image: "/images/korea.png"
1210
+ }, {
1211
+ code: "en",
1212
+ fullName: "English",
1213
+ shortName: "English",
1214
+ nativeName: "English",
1215
+ name: "English",
1216
+ image: "/images/usa.png"
1217
+ }];
1218
+ var SUPPORTED_LANGUAGES_CODE = LANGUAGES.map(function (i) {
1219
+ return i.code;
1220
+ });
1221
+
1222
+ var TheLanguageDropdown = function TheLanguageDropdown() {
1223
+ var defaultLanguage = !!localStorage.getItem("language") ? localStorage.getItem("language") : navigator.language || DEFAULT_LANGUAGE_CODE;
1224
+ var dispatch = useDispatch();
1225
+ var _useTranslation = useTranslation(),
1226
+ i18n = _useTranslation.i18n;
1227
+ var _useState = useState(false),
1228
+ dropdownOpen = _useState[0],
1229
+ setDropdownOpen = _useState[1];
1230
+ var _useState2 = useState(defaultLanguage),
1231
+ language = _useState2[0],
1232
+ setItemLanguage = _useState2[1];
1233
+ var toggle = function toggle() {
1234
+ return setDropdownOpen(function (prevState) {
1235
+ return !prevState;
1236
+ });
1237
+ };
1238
+ var changeLanguageApp = function changeLanguageApp(lang) {
1239
+ if (!SUPPORTED_LANGUAGES_CODE.includes(lang)) lang = DEFAULT_LANGUAGE_CODE;
1240
+ i18n.changeLanguage(lang);
1241
+ localStorage.setItem("language", lang);
1242
+ setItemLanguage(lang);
1243
+ dispatch(setLanguage(lang));
1244
+ };
1245
+ var currentLanguage = useMemo(function () {
1246
+ var currentLang = LANGUAGES.find(function (i) {
1247
+ return i.code === language;
1248
+ });
1249
+ if (!currentLang) return null;
1250
+ return React.createElement(React.Fragment, null, React.createElement("img", {
1251
+ className: "mr-2 " + styles['dropdown-menu-flag'],
1252
+ src: currentLang.image
1253
+ }), " ", currentLang.shortName);
1254
+ }, [language]);
1255
+ useEffect(function () {
1256
+ changeLanguageApp(language);
1257
+ }, [language]);
1258
+ return React.createElement(Dropdown, {
1259
+ isOpen: dropdownOpen,
1260
+ toggle: toggle,
1261
+ className: "" + styles["dropdown-menu"]
1262
+ }, React.createElement(DropdownToggle, {
1263
+ className: styles["header-avatar"] + " d-flex align-items-center"
1264
+ }, React.createElement("span", {
1265
+ style: {
1266
+ color: "#000",
1267
+ textTransform: "capitalize",
1268
+ display: 'flex',
1269
+ alignItems: 'center'
1270
+ }
1271
+ }, currentLanguage, React.createElement(IoChevronDown, {
1272
+ className: "ml-2",
1273
+ style: {
1274
+ fontSize: '15px',
1275
+ marginLeft: "5px",
1276
+ marginTop: "2px"
1277
+ }
1278
+ }))), React.createElement(DropdownMenu, {
1279
+ className: styles["dropdown-content-language"]
1280
+ }, LANGUAGES.map(function (lang, index) {
1281
+ return React.createElement(DropdownItem, {
1282
+ key: lang.code,
1283
+ className: styles["dropdown-change"] + " px-0 py-0 " + (index === LANGUAGES.length - 1 ? "pb-2" : "pt-2"),
1284
+ onClick: function onClick() {
1285
+ return setItemLanguage(lang.code);
1286
+ }
1287
+ }, React.createElement("div", {
1288
+ className: styles["dropdown-item-language"] + " " + styles["item-logout"] + " " + (language == lang.code ? styles['dropdown-item-language-active'] : "") + " d-flex align-items-center w-100"
1289
+ }, React.createElement("span", {
1290
+ className: "mr-2 d-flex hover-opacity"
1291
+ }, React.createElement("img", {
1292
+ style: {
1293
+ width: "30px",
1294
+ marginRight: "10px"
1295
+ },
1296
+ src: lang.image
1297
+ })), lang.name));
1298
+ })));
1299
+ };
1300
+
1301
+ var minutesToTimeSpan = (function (time) {
1302
+ var h = Math.floor(time / 60);
1303
+ var m = time % 60;
1304
+ return h.toString().padStart(2, "0") + ":" + m.toString().padStart(2, "0") + ":00";
1305
+ });
1306
+
1307
+ var toISOString = (function (time) {
1308
+ try {
1309
+ return moment(time).toISOString();
1310
+ } catch (_unused) {
1311
+ return "";
1312
+ }
1313
+ });
1314
+
1496
1315
  var historyCore = createBrowserHistory();
1497
1316
 
1498
- export { ACCESS_TOKEN, BASE_URL, CommonAlert, CommonDialog, ConfirmDialog, CustomPagination, LayoutContext, Loading, Login, NotFound, api$1 as api, diffFromNow, formatTime, historyCore, setAlert, setLoading, setUser, store, utcToLocalTime };
1317
+ export { ACCESS_TOKEN, BASE_URL, CommonAlert, CommonDialog, ConfirmDialog, CustomPagination, DATE_MIN_VALUE, EXAM_CHANNEL, ExamEvent, LayoutContext, Loading, Login, NotFound, PUSHER_CONFIG, TheLanguageDropdown, api$1 as api, diffFromNow, formatTime, historyCore, i18n, minutesToTimeSpan, setAlert, setLanguage, setLoading, setUser, store, toISOString, useGoogleSignOut, utcToLocalTime };
1499
1318
  //# sourceMappingURL=index.modern.js.map