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