touchstudy-core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Commons/NotFound.d.ts +3 -0
- package/dist/components/Dialogs/CommonDialog.d.ts +10 -0
- package/dist/components/Dialogs/ConfirmDialog.d.ts +12 -0
- package/dist/components/Loading/Loading.d.ts +3 -0
- package/dist/components/Paginations/CustomPagination.d.ts +8 -0
- package/dist/containers/Login/apiClient/index.d.ts +1 -0
- package/dist/containers/Login/hooks/useLogin.d.ts +0 -3
- package/dist/containers/Login/views/Login.d.ts +5 -8
- package/dist/containers/Login/views/block/BlockLogin.d.ts +3 -2
- package/dist/index.css +17 -695
- package/dist/index.d.ts +15 -2
- package/dist/index.js +1495 -12
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1480 -12
- package/dist/index.modern.js.map +1 -1
- package/dist/layouts/LayoutContext.d.ts +6 -0
- package/dist/redux/commons/action.d.ts +1 -0
- package/dist/services/accountService.d.ts +1 -0
- package/dist/services/api.d.ts +3 -0
- package/dist/store.d.ts +2 -0
- package/dist/utils/canAccessRoute.d.ts +2 -0
- package/dist/utils/constants.d.ts +5 -1
- package/dist/utils/diffFromNow.d.ts +3 -0
- package/dist/utils/encodeParams.d.ts +2 -0
- package/dist/utils/formatTime.d.ts +2 -0
- package/dist/utils/getAccessToken.d.ts +2 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/utcToLocalTime.d.ts +2 -0
- package/package.json +6 -2
- package/dist/components/Alerts/ReactNotification.d.ts +0 -4
- package/dist/components/Alerts/SandboxAlert.d.ts +0 -3
package/dist/index.js
CHANGED
@@ -1,36 +1,1519 @@
|
|
1
1
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
2
2
|
|
3
3
|
var toolkit = require('@reduxjs/toolkit');
|
4
|
-
var
|
4
|
+
var moment = _interopDefault(require('moment'));
|
5
|
+
var React = require('react');
|
6
|
+
var React__default = _interopDefault(React);
|
7
|
+
var reactGoogleRecaptchaV3 = require('react-google-recaptcha-v3');
|
5
8
|
var reactstrap = require('reactstrap');
|
9
|
+
var formik = require('formik');
|
10
|
+
var yup = require('yup');
|
11
|
+
var GoogleLogin = _interopDefault(require('@leecheuk/react-google-login'));
|
12
|
+
var axios = _interopDefault(require('axios'));
|
13
|
+
var reactRedux = require('react-redux');
|
14
|
+
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
|
+
}
|
6
606
|
|
7
607
|
var setLoading = toolkit.createAction("common/setLoading");
|
8
608
|
var setAlert = toolkit.createAction("common/setAlert");
|
609
|
+
var setUser = toolkit.createAction("common/setUser");
|
9
610
|
|
611
|
+
var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
|
612
|
+
var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
|
10
613
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
11
|
-
var
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
614
|
+
var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
|
615
|
+
var BASE_URL = "https://ec0e-123-24-205-68.ngrok-free.app";
|
616
|
+
var getAccessToken = function getAccessToken() {
|
617
|
+
try {
|
618
|
+
return localStorage.getItem(ACCESS_TOKEN);
|
619
|
+
} catch (err) {
|
620
|
+
return null;
|
621
|
+
}
|
622
|
+
};
|
623
|
+
var encodeParams = function encodeParams(params) {
|
624
|
+
return Object.keys(params).filter(function (key) {
|
625
|
+
return params[key] || params[key] === 0 || params[key] === false;
|
626
|
+
}).map(function (key) {
|
627
|
+
if (Array.isArray(params[key])) {
|
628
|
+
return params[key].map(function (i) {
|
629
|
+
return encodeURIComponent(key) + "=" + encodeURIComponent(i);
|
630
|
+
}).join('&');
|
631
|
+
}
|
632
|
+
return encodeURIComponent(key) + "=" + encodeURIComponent(params[key]);
|
633
|
+
}).join('&');
|
634
|
+
};
|
635
|
+
|
636
|
+
var utcToLocalTime = (function (time, FORMAT) {
|
637
|
+
if (time === DATE_MIN_VALUE) return "";
|
638
|
+
try {
|
639
|
+
return moment.utc(time).local().format(FORMAT || "yyyy-MM-DD");
|
640
|
+
} catch (_unused) {
|
641
|
+
return "";
|
642
|
+
}
|
643
|
+
});
|
644
|
+
|
645
|
+
// A type of promise-like that resolves synchronously and supports only one observer
|
646
|
+
|
647
|
+
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
648
|
+
|
649
|
+
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
650
|
+
|
651
|
+
// Asynchronously call a function and send errors to recovery continuation
|
652
|
+
function _catch(body, recover) {
|
653
|
+
try {
|
654
|
+
var result = body();
|
655
|
+
} catch(e) {
|
656
|
+
return recover(e);
|
657
|
+
}
|
658
|
+
if (result && result.then) {
|
659
|
+
return result.then(void 0, recover);
|
660
|
+
}
|
661
|
+
return result;
|
662
|
+
}
|
663
|
+
|
664
|
+
var styles = {"btn-login-google":"_2HqmH","block-login":"_wWIyO","box-login":"_38Lo1"};
|
665
|
+
|
666
|
+
var api = axios.create({
|
667
|
+
baseURL: BASE_URL,
|
668
|
+
timeout: 0,
|
669
|
+
headers: {
|
670
|
+
"Content-Type": "application/json"
|
671
|
+
},
|
672
|
+
paramsSerializer: function paramsSerializer(params) {
|
673
|
+
return encodeParams(params);
|
674
|
+
}
|
675
|
+
});
|
676
|
+
var apiUpload = axios.create({
|
677
|
+
baseURL: BASE_URL,
|
678
|
+
timeout: 60000,
|
679
|
+
headers: {
|
680
|
+
"Content-Type": "multipart/form-data"
|
681
|
+
}
|
682
|
+
});
|
683
|
+
[api, apiUpload].forEach(function (i) {
|
684
|
+
return i.interceptors.request.use(function (config) {
|
685
|
+
var token = getAccessToken();
|
686
|
+
if (token) {
|
687
|
+
config.headers.Authorization = "Bearer " + token;
|
688
|
+
localStorage.setItem("LAST_TIME_REQUETST", moment().utc().format("YYYY-MM-DD HH:mm:ss"));
|
689
|
+
}
|
690
|
+
return config;
|
691
|
+
}, function (error) {
|
692
|
+
return Promise.reject(error);
|
693
|
+
});
|
694
|
+
});
|
695
|
+
[api, apiUpload].forEach(function (i) {
|
696
|
+
return i.interceptors.response.use(function (response) {
|
697
|
+
return response;
|
698
|
+
}, function (error) {
|
699
|
+
console.log({
|
700
|
+
error: error
|
701
|
+
});
|
702
|
+
if (error.response.status === 401) {
|
703
|
+
window.location.href = "/login";
|
704
|
+
}
|
705
|
+
if (error.response.status == 403) {
|
706
|
+
localStorage.removeItem(ACCESS_TOKEN);
|
707
|
+
localStorage.removeItem("USER_EMAIL");
|
708
|
+
window.location.href = "/login";
|
709
|
+
}
|
710
|
+
return Promise.reject(error);
|
711
|
+
});
|
712
|
+
});
|
16
713
|
|
17
|
-
var
|
714
|
+
var apiLoginGoogle = function apiLoginGoogle(body) {
|
715
|
+
return api.post(BASE_URL + "/api/auth/login", body);
|
716
|
+
};
|
717
|
+
|
718
|
+
var ERROR_MESSAGE = "Login fail!";
|
719
|
+
var schema = yup.object({
|
720
|
+
email: yup.string().email("Email is invalid").required("Email is required"),
|
721
|
+
password: yup.string().required("Password is required"),
|
722
|
+
rememberMe: yup.boolean()
|
723
|
+
});
|
724
|
+
var BlockLogin = function BlockLogin(_ref) {
|
725
|
+
var defaultInfo = _ref.defaultInfo,
|
726
|
+
onNavigate = _ref.onNavigate,
|
727
|
+
isTeacher = _ref.isTeacher;
|
728
|
+
var dispatch = reactRedux.useDispatch();
|
729
|
+
var _useGoogleReCaptcha = reactGoogleRecaptchaV3.useGoogleReCaptcha(),
|
730
|
+
executeRecaptcha = _useGoogleReCaptcha.executeRecaptcha;
|
731
|
+
var clickHandler = React.useCallback(function () {
|
732
|
+
try {
|
733
|
+
if (!executeRecaptcha) {
|
734
|
+
console.log("execute recaptcha undefined");
|
735
|
+
return Promise.resolve();
|
736
|
+
}
|
737
|
+
return Promise.resolve(executeRecaptcha("login"));
|
738
|
+
} catch (e) {
|
739
|
+
return Promise.reject(e);
|
740
|
+
}
|
741
|
+
}, [executeRecaptcha]);
|
742
|
+
var handleVerify = React.useCallback(function () {}, []);
|
743
|
+
var onSuccessGoogle = function onSuccessGoogle(res) {
|
744
|
+
try {
|
745
|
+
var _exit = false;
|
746
|
+
console.log("success");
|
747
|
+
console.log({
|
748
|
+
res: res
|
749
|
+
});
|
750
|
+
return Promise.resolve(function () {
|
751
|
+
if (!!(res !== null && res !== void 0 && res.accessToken)) {
|
752
|
+
var _temp2 = function _temp2(_result) {
|
753
|
+
if (_exit) return _result;
|
754
|
+
dispatch(setLoading(false));
|
755
|
+
};
|
756
|
+
var _res$profileObj = res.profileObj,
|
757
|
+
email = _res$profileObj.email,
|
758
|
+
imageUrl = _res$profileObj.imageUrl,
|
759
|
+
name = _res$profileObj.name;
|
760
|
+
var accessToken = res.tokenObj.id_token;
|
761
|
+
var googleId = res.googleId;
|
762
|
+
var infoLogin = {
|
763
|
+
imageUrl: imageUrl,
|
764
|
+
fullName: name,
|
765
|
+
email: email,
|
766
|
+
token: accessToken,
|
767
|
+
googleId: googleId,
|
768
|
+
role: isTeacher ? "Teacher" : "Student"
|
769
|
+
};
|
770
|
+
console.log({
|
771
|
+
infoLogin: infoLogin
|
772
|
+
});
|
773
|
+
dispatch(setLoading(true));
|
774
|
+
var _temp = _catch(function () {
|
775
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (res1) {
|
776
|
+
var isFirstLogin = res1.data.isFirstLogin;
|
777
|
+
var tokenJWT = res1.data.token;
|
778
|
+
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
779
|
+
console.log({
|
780
|
+
res1: res1
|
781
|
+
});
|
782
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
783
|
+
if (isTeacher) {
|
784
|
+
onNavigate("/teacher/overall-status/main");
|
785
|
+
_exit = true;
|
786
|
+
return;
|
787
|
+
}
|
788
|
+
if (isFirstLogin) {
|
789
|
+
onNavigate("/register/info");
|
790
|
+
} else {
|
791
|
+
onNavigate("/student/check/main");
|
792
|
+
}
|
793
|
+
});
|
794
|
+
}, function (error) {
|
795
|
+
var _error$response;
|
796
|
+
dispatch(setAlert({
|
797
|
+
type: "danger",
|
798
|
+
message: ((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || ERROR_MESSAGE
|
799
|
+
}));
|
800
|
+
});
|
801
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
802
|
+
}
|
803
|
+
}());
|
804
|
+
} catch (e) {
|
805
|
+
return Promise.reject(e);
|
806
|
+
}
|
807
|
+
};
|
808
|
+
var onFailureGoogle = function onFailureGoogle(err) {
|
809
|
+
console.log("error: login google", err);
|
810
|
+
onNavigate("/login");
|
811
|
+
};
|
812
|
+
return React__default.createElement(formik.Formik, {
|
813
|
+
initialValues: defaultInfo,
|
814
|
+
validationSchema: schema,
|
815
|
+
onSubmit: function (values) {
|
816
|
+
try {
|
817
|
+
return Promise.resolve(_catch(function () {
|
818
|
+
return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
|
819
|
+
if (!clickHandlerRes) return;
|
820
|
+
values.captcha = clickHandlerRes;
|
821
|
+
});
|
822
|
+
}, function (err) {
|
823
|
+
console.error(err);
|
824
|
+
}));
|
825
|
+
} catch (e) {
|
826
|
+
return Promise.reject(e);
|
827
|
+
}
|
828
|
+
}
|
829
|
+
}, function (formikProps) {
|
830
|
+
var handleSubmit = formikProps.handleSubmit;
|
831
|
+
return React__default.createElement(reactstrap.Row, {
|
832
|
+
className: "" + styles["box-login"]
|
833
|
+
}, React__default.createElement(reactstrap.Col, {
|
834
|
+
className: "p-0 d-flex justify-content-center"
|
835
|
+
}, React__default.createElement(reactstrap.Form, {
|
836
|
+
className: "" + styles["block-login"],
|
837
|
+
onSubmit: handleSubmit
|
838
|
+
}, React__default.createElement("div", {
|
839
|
+
className: "" + styles["block-form"]
|
840
|
+
}, React__default.createElement("img", {
|
841
|
+
src: "/images/logo.jpeg",
|
842
|
+
className: "" + styles["img-login-rectangle"]
|
843
|
+
}), React__default.createElement(reactstrap.FormGroup, null, React__default.createElement(reactGoogleRecaptchaV3.GoogleReCaptcha, {
|
844
|
+
action: "login",
|
845
|
+
onVerify: handleVerify
|
846
|
+
})), React__default.createElement(reactstrap.Col, {
|
847
|
+
className: "p-0 mt-1 mb-4"
|
848
|
+
}, React__default.createElement(GoogleLogin, {
|
849
|
+
clientId: GOOGLE_CLIENT_ID,
|
850
|
+
buttonText: "Google \uACC4\uC815\uC73C\uB85C \uB85C\uADF8\uC778",
|
851
|
+
onSuccess: onSuccessGoogle,
|
852
|
+
onFailure: onFailureGoogle,
|
853
|
+
cookiePolicy: "single_host_origin",
|
854
|
+
className: "" + styles["btn-login-google"]
|
855
|
+
}))))));
|
856
|
+
});
|
857
|
+
};
|
18
858
|
|
19
|
-
var
|
20
|
-
|
859
|
+
var defaultInfo = {
|
860
|
+
email: "",
|
861
|
+
password: "",
|
862
|
+
captcha: "",
|
863
|
+
rememberMe: false
|
864
|
+
};
|
865
|
+
var useLogin = function useLogin() {
|
866
|
+
var _useState = React.useState(false),
|
867
|
+
openLogin = _useState[0],
|
868
|
+
setOpenLogin = _useState[1];
|
869
|
+
var _useState2 = React.useState(),
|
870
|
+
infoUser = _useState2[0],
|
871
|
+
setInfoUser = _useState2[1];
|
872
|
+
var toggle = React.useCallback(function () {
|
873
|
+
setOpenLogin(!openLogin);
|
874
|
+
}, [openLogin]);
|
875
|
+
var _useState3 = React.useState(false),
|
876
|
+
isShowPassword = _useState3[0],
|
877
|
+
setIsShowPassword = _useState3[1];
|
878
|
+
React.useEffect(function () {
|
879
|
+
var start = function start() {
|
880
|
+
gapiScript.gapi.client.init({
|
881
|
+
clientId: GOOGLE_CLIENT_ID,
|
882
|
+
scope: 'email'
|
883
|
+
});
|
884
|
+
};
|
885
|
+
gapiScript.gapi.load('client:auth2', start);
|
886
|
+
}, []);
|
887
|
+
return {
|
888
|
+
defaultInfo: defaultInfo,
|
889
|
+
openLogin: openLogin,
|
890
|
+
toggle: toggle,
|
891
|
+
isShowPassword: isShowPassword,
|
892
|
+
setIsShowPassword: setIsShowPassword,
|
893
|
+
infoUser: infoUser,
|
894
|
+
setInfoUser: setInfoUser
|
895
|
+
};
|
896
|
+
};
|
897
|
+
|
898
|
+
var Login = function Login(_ref) {
|
899
|
+
var onNavigate = _ref.onNavigate,
|
900
|
+
isTeacher = _ref.isTeacher;
|
901
|
+
var _useLogin = useLogin(),
|
902
|
+
defaultInfo = _useLogin.defaultInfo;
|
903
|
+
return React__default.createElement("div", {
|
21
904
|
className: styles["login"] + " container-fluid font-family-lato"
|
22
|
-
},
|
905
|
+
}, React__default.createElement(reactstrap.Row, {
|
23
906
|
className: "h-100"
|
24
|
-
},
|
907
|
+
}, React__default.createElement(reactstrap.Col, {
|
25
908
|
lg: 12,
|
26
909
|
md: 12,
|
27
910
|
xs: 12,
|
28
911
|
className: "d-flex justify-content-center h-100 align-items-center"
|
29
|
-
},
|
912
|
+
}, React__default.createElement(reactGoogleRecaptchaV3.GoogleReCaptchaProvider, {
|
913
|
+
useRecaptchaNet: true,
|
914
|
+
reCaptchaKey: GOOGLE_RECAPTCHA_ID,
|
915
|
+
scriptProps: {
|
916
|
+
async: true,
|
917
|
+
defer: true,
|
918
|
+
appendTo: "body"
|
919
|
+
}
|
920
|
+
}, React__default.createElement(BlockLogin, {
|
921
|
+
defaultInfo: defaultInfo,
|
922
|
+
onNavigate: onNavigate,
|
923
|
+
isTeacher: isTeacher
|
924
|
+
})))));
|
925
|
+
};
|
926
|
+
|
927
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
928
|
+
|
929
|
+
function unwrapExports (x) {
|
930
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
931
|
+
}
|
932
|
+
|
933
|
+
function createCommonjsModule(fn, module) {
|
934
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
935
|
+
}
|
936
|
+
|
937
|
+
var reduxLogger = createCommonjsModule(function (module, exports) {
|
938
|
+
!function(e,t){t(exports);}(commonjsGlobal,function(e){function t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}});}function r(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:!0}),t&&t.length&&Object.defineProperty(this,"path",{value:t,enumerable:!0});}function n(e,t,r){n.super_.call(this,"E",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0}),Object.defineProperty(this,"rhs",{value:r,enumerable:!0});}function o(e,t){o.super_.call(this,"N",e),Object.defineProperty(this,"rhs",{value:t,enumerable:!0});}function i(e,t){i.super_.call(this,"D",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0});}function a(e,t,r){a.super_.call(this,"A",e),Object.defineProperty(this,"index",{value:t,enumerable:!0}),Object.defineProperty(this,"item",{value:r,enumerable:!0});}function f(e,t,r){var n=e.slice((r||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,n),e}function u(e){var t="undefined"==typeof e?"undefined":N(e);return "object"!==t?t:e===Math?"math":null===e?"null":Array.isArray(e)?"array":"[object Date]"===Object.prototype.toString.call(e)?"date":"function"==typeof e.toString&&/^\/.*\//.test(e.toString())?"regexp":"object"}function l(e,t,r,c,s,d,p){s=s||[],p=p||[];var g=s.slice(0);if("undefined"!=typeof d){if(c){if("function"==typeof c&&c(g,d))return;if("object"===("undefined"==typeof c?"undefined":N(c))){if(c.prefilter&&c.prefilter(g,d))return;if(c.normalize){var h=c.normalize(g,d,e,t);h&&(e=h[0],t=h[1]);}}}g.push(d);}"regexp"===u(e)&&"regexp"===u(t)&&(e=e.toString(),t=t.toString());var y="undefined"==typeof e?"undefined":N(e),v="undefined"==typeof t?"undefined":N(t),b="undefined"!==y||p&&p[p.length-1].lhs&&p[p.length-1].lhs.hasOwnProperty(d),m="undefined"!==v||p&&p[p.length-1].rhs&&p[p.length-1].rhs.hasOwnProperty(d);if(!b&&m)r(new o(g,t));else if(!m&&b)r(new i(g,e));else if(u(e)!==u(t))r(new n(g,e,t));else if("date"===u(e)&&e-t!==0)r(new n(g,e,t));else if("object"===y&&null!==e&&null!==t)if(p.filter(function(t){return t.lhs===e}).length)e!==t&&r(new n(g,e,t));else {if(p.push({lhs:e,rhs:t}),Array.isArray(e)){var w;for(w=0;w<e.length;w++)w>=t.length?r(new a(g,w,new i(void 0,e[w]))):l(e[w],t[w],r,c,g,w,p);for(;w<t.length;)r(new a(g,w,new o(void 0,t[w++])));}else {var x=Object.keys(e),S=Object.keys(t);x.forEach(function(n,o){var i=S.indexOf(n);i>=0?(l(e[n],t[n],r,c,g,n,p),S=f(S,i)):l(e[n],void 0,r,c,g,n,p);}),S.forEach(function(e){l(void 0,t[e],r,c,g,e,p);});}p.length=p.length-1;}else e!==t&&("number"===y&&isNaN(e)&&isNaN(t)||r(new n(g,e,t)));}function c(e,t,r,n){return n=n||[],l(e,t,function(e){e&&n.push(e);},r),n.length?n:void 0}function s(e,t,r){if(r.path&&r.path.length){var n,o=e[t],i=r.path.length-1;for(n=0;n<i;n++)o=o[r.path[n]];switch(r.kind){case"A":s(o[r.path[n]],r.index,r.item);break;case"D":delete o[r.path[n]];break;case"E":case"N":o[r.path[n]]=r.rhs;}}else switch(r.kind){case"A":s(e[t],r.index,r.item);break;case"D":e=f(e,t);break;case"E":case"N":e[t]=r.rhs;}return e}function d(e,t,r){if(e&&t&&r&&r.kind){for(var n=e,o=-1,i=r.path?r.path.length-1:0;++o<i;)"undefined"==typeof n[r.path[o]]&&(n[r.path[o]]="number"==typeof r.path[o]?[]:{}),n=n[r.path[o]];switch(r.kind){case"A":s(r.path?n[r.path[o]]:n,r.index,r.item);break;case"D":delete n[r.path[o]];break;case"E":case"N":n[r.path[o]]=r.rhs;}}}function p(e,t,r){if(r.path&&r.path.length){var n,o=e[t],i=r.path.length-1;for(n=0;n<i;n++)o=o[r.path[n]];switch(r.kind){case"A":p(o[r.path[n]],r.index,r.item);break;case"D":o[r.path[n]]=r.lhs;break;case"E":o[r.path[n]]=r.lhs;break;case"N":delete o[r.path[n]];}}else switch(r.kind){case"A":p(e[t],r.index,r.item);break;case"D":e[t]=r.lhs;break;case"E":e[t]=r.lhs;break;case"N":e=f(e,t);}return e}function g(e,t,r){if(e&&t&&r&&r.kind){var n,o,i=e;for(o=r.path.length-1,n=0;n<o;n++)"undefined"==typeof i[r.path[n]]&&(i[r.path[n]]={}),i=i[r.path[n]];switch(r.kind){case"A":p(i[r.path[n]],r.index,r.item);break;case"D":i[r.path[n]]=r.lhs;break;case"E":i[r.path[n]]=r.lhs;break;case"N":delete i[r.path[n]];}}}function h(e,t,r){if(e&&t){var n=function(n){r&&!r(e,t,n)||d(e,t,n);};l(e,t,n);}}function y(e){return "color: "+F[e].color+"; font-weight: bold"}function v(e){var t=e.kind,r=e.path,n=e.lhs,o=e.rhs,i=e.index,a=e.item;switch(t){case"E":return [r.join("."),n,"→",o];case"N":return [r.join("."),o];case"D":return [r.join(".")];case"A":return [r.join(".")+"["+i+"]",a];default:return []}}function b(e,t,r,n){var o=c(e,t);try{n?r.groupCollapsed("diff"):r.group("diff");}catch(e){r.log("diff");}o?o.forEach(function(e){var t=e.kind,n=v(e);r.log.apply(r,["%c "+F[t].text,y(t)].concat(P(n)));}):r.log("—— no diff ——");try{r.groupEnd();}catch(e){r.log("—— diff end —— ");}}function m(e,t,r,n){switch("undefined"==typeof e?"undefined":N(e)){case"object":return "function"==typeof e[n]?e[n].apply(e,P(r)):e[n];case"function":return e(t);default:return e}}function w(e){var t=e.timestamp,r=e.duration;return function(e,n,o){var i=["action"];return i.push("%c"+String(e.type)),t&&i.push("%c@ "+n),r&&i.push("%c(in "+o.toFixed(2)+" ms)"),i.join(" ")}}function x(e,t){var r=t.logger,n=t.actionTransformer,o=t.titleFormatter,i=void 0===o?w(t):o,a=t.collapsed,f=t.colors,u=t.level,l=t.diff,c="undefined"==typeof t.titleFormatter;e.forEach(function(o,s){var d=o.started,p=o.startedTime,g=o.action,h=o.prevState,y=o.error,v=o.took,w=o.nextState,x=e[s+1];x&&(w=x.prevState,v=x.started-d);var S=n(g),k="function"==typeof a?a(function(){return w},g,o):a,j=D(p),E=f.title?"color: "+f.title(S)+";":"",A=["color: gray; font-weight: lighter;"];A.push(E),t.timestamp&&A.push("color: gray; font-weight: lighter;"),t.duration&&A.push("color: gray; font-weight: lighter;");var O=i(S,j,v);try{k?f.title&&c?r.groupCollapsed.apply(r,["%c "+O].concat(A)):r.groupCollapsed(O):f.title&&c?r.group.apply(r,["%c "+O].concat(A)):r.group(O);}catch(e){r.log(O);}var N=m(u,S,[h],"prevState"),P=m(u,S,[S],"action"),C=m(u,S,[y,h],"error"),F=m(u,S,[w],"nextState");if(N)if(f.prevState){var L="color: "+f.prevState(h)+"; font-weight: bold";r[N]("%c prev state",L,h);}else r[N]("prev state",h);if(P)if(f.action){var T="color: "+f.action(S)+"; font-weight: bold";r[P]("%c action ",T,S);}else r[P]("action ",S);if(y&&C)if(f.error){var M="color: "+f.error(y,h)+"; font-weight: bold;";r[C]("%c error ",M,y);}else r[C]("error ",y);if(F)if(f.nextState){var _="color: "+f.nextState(w)+"; font-weight: bold";r[F]("%c next state",_,w);}else r[F]("next state",w);l&&b(h,w,r,k);try{r.groupEnd();}catch(e){r.log("—— log end ——");}});}function S(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},L,e),r=t.logger,n=t.stateTransformer,o=t.errorTransformer,i=t.predicate,a=t.logErrors,f=t.diffPredicate;if("undefined"==typeof r)return function(){return function(e){return function(t){return e(t)}}};if(e.getState&&e.dispatch)return console.error("[redux-logger] redux-logger not installed. Make sure to pass logger instance as middleware:\n// Logger with default options\nimport { logger } from 'redux-logger'\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n// Or you can create your own logger with custom options http://bit.ly/redux-logger-options\nimport createLogger from 'redux-logger'\nconst logger = createLogger({\n // ...options\n});\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n"),function(){return function(e){return function(t){return e(t)}}};var u=[];return function(e){var r=e.getState;return function(e){return function(l){if("function"==typeof i&&!i(r,l))return e(l);var c={};u.push(c),c.started=O.now(),c.startedTime=new Date,c.prevState=n(r()),c.action=l;var s=void 0;if(a)try{s=e(l);}catch(e){c.error=o(e);}else s=e(l);c.took=O.now()-c.started,c.nextState=n(r());var d=t.diff&&"function"==typeof f?f(r,l):t.diff;if(x(u,Object.assign({},t,{diff:d})),u.length=0,c.error)throw c.error;return s}}}}var k,j,E=function(e,t){return new Array(t+1).join(e)},A=function(e,t){return E("0",t-e.toString().length)+e},D=function(e){return A(e.getHours(),2)+":"+A(e.getMinutes(),2)+":"+A(e.getSeconds(),2)+"."+A(e.getMilliseconds(),3)},O="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance:Date,N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},C=[];k="object"===("undefined"==typeof commonjsGlobal?"undefined":N(commonjsGlobal))&&commonjsGlobal?commonjsGlobal:"undefined"!=typeof window?window:{},j=k.DeepDiff,j&&C.push(function(){"undefined"!=typeof j&&k.DeepDiff===c&&(k.DeepDiff=j,j=void 0);}),t(n,r),t(o,r),t(i,r),t(a,r),Object.defineProperties(c,{diff:{value:c,enumerable:!0},observableDiff:{value:l,enumerable:!0},applyDiff:{value:h,enumerable:!0},applyChange:{value:d,enumerable:!0},revertChange:{value:g,enumerable:!0},isConflict:{value:function(){return "undefined"!=typeof j},enumerable:!0},noConflict:{value:function(){return C&&(C.forEach(function(e){e();}),C=null),c},enumerable:!0}});var F={E:{color:"#2196F3",text:"CHANGED:"},N:{color:"#4CAF50",text:"ADDED:"},D:{color:"#F44336",text:"DELETED:"},A:{color:"#2196F3",text:"ARRAY:"}},L={level:"log",logger:console,logErrors:!0,collapsed:void 0,predicate:void 0,duration:!1,timestamp:!0,stateTransformer:function(e){return e},actionTransformer:function(e){return e},errorTransformer:function(e){return e},colors:{title:function(){return "inherit"},prevState:function(){return "#9E9E9E"},action:function(){return "#03A9F4"},nextState:function(){return "#4CAF50"},error:function(){return "#F20404"}},diff:!1,diffPredicate:void 0,transformer:void 0},T=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.dispatch,r=e.getState;return "function"==typeof t||"function"==typeof r?S()({dispatch:t,getState:r}):void console.error("\n[redux-logger v3] BREAKING CHANGE\n[redux-logger v3] Since 3.0.0 redux-logger exports by default logger with default settings.\n[redux-logger v3] Change\n[redux-logger v3] import createLogger from 'redux-logger'\n[redux-logger v3] to\n[redux-logger v3] import { createLogger } from 'redux-logger'\n")};e.defaults=L,e.createLogger=S,e.logger=T,e.default=T,Object.defineProperty(e,"__esModule",{value:!0});});
|
939
|
+
});
|
940
|
+
|
941
|
+
var logger = unwrapExports(reduxLogger);
|
942
|
+
|
943
|
+
// src/utils/formatProdErrorMessage.ts
|
944
|
+
function formatProdErrorMessage(code) {
|
945
|
+
return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
|
946
|
+
}
|
947
|
+
|
948
|
+
// src/utils/actionTypes.ts
|
949
|
+
var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
|
950
|
+
var ActionTypes = {
|
951
|
+
INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
|
952
|
+
REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
|
953
|
+
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
|
954
|
+
};
|
955
|
+
var actionTypes_default = ActionTypes;
|
956
|
+
|
957
|
+
// src/utils/isPlainObject.ts
|
958
|
+
function isPlainObject(obj) {
|
959
|
+
if (typeof obj !== "object" || obj === null)
|
960
|
+
return false;
|
961
|
+
let proto = obj;
|
962
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
963
|
+
proto = Object.getPrototypeOf(proto);
|
964
|
+
}
|
965
|
+
return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
|
966
|
+
}
|
967
|
+
|
968
|
+
// src/utils/kindOf.ts
|
969
|
+
function miniKindOf(val) {
|
970
|
+
if (val === void 0)
|
971
|
+
return "undefined";
|
972
|
+
if (val === null)
|
973
|
+
return "null";
|
974
|
+
const type = typeof val;
|
975
|
+
switch (type) {
|
976
|
+
case "boolean":
|
977
|
+
case "string":
|
978
|
+
case "number":
|
979
|
+
case "symbol":
|
980
|
+
case "function": {
|
981
|
+
return type;
|
982
|
+
}
|
983
|
+
}
|
984
|
+
if (Array.isArray(val))
|
985
|
+
return "array";
|
986
|
+
if (isDate(val))
|
987
|
+
return "date";
|
988
|
+
if (isError(val))
|
989
|
+
return "error";
|
990
|
+
const constructorName = ctorName(val);
|
991
|
+
switch (constructorName) {
|
992
|
+
case "Symbol":
|
993
|
+
case "Promise":
|
994
|
+
case "WeakMap":
|
995
|
+
case "WeakSet":
|
996
|
+
case "Map":
|
997
|
+
case "Set":
|
998
|
+
return constructorName;
|
999
|
+
}
|
1000
|
+
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
|
1001
|
+
}
|
1002
|
+
function ctorName(val) {
|
1003
|
+
return typeof val.constructor === "function" ? val.constructor.name : null;
|
1004
|
+
}
|
1005
|
+
function isError(val) {
|
1006
|
+
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
1007
|
+
}
|
1008
|
+
function isDate(val) {
|
1009
|
+
if (val instanceof Date)
|
1010
|
+
return true;
|
1011
|
+
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
1012
|
+
}
|
1013
|
+
function kindOf(val) {
|
1014
|
+
let typeOfVal = typeof val;
|
1015
|
+
if (process.env.NODE_ENV !== "production") {
|
1016
|
+
typeOfVal = miniKindOf(val);
|
1017
|
+
}
|
1018
|
+
return typeOfVal;
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
// src/utils/warning.ts
|
1022
|
+
function warning$1(message) {
|
1023
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
1024
|
+
console.error(message);
|
1025
|
+
}
|
1026
|
+
try {
|
1027
|
+
throw new Error(message);
|
1028
|
+
} catch (e) {
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
// src/combineReducers.ts
|
1033
|
+
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
1034
|
+
const reducerKeys = Object.keys(reducers);
|
1035
|
+
const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
1036
|
+
if (reducerKeys.length === 0) {
|
1037
|
+
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
1038
|
+
}
|
1039
|
+
if (!isPlainObject(inputState)) {
|
1040
|
+
return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
|
1041
|
+
}
|
1042
|
+
const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
|
1043
|
+
unexpectedKeys.forEach((key) => {
|
1044
|
+
unexpectedKeyCache[key] = true;
|
1045
|
+
});
|
1046
|
+
if (action && action.type === actionTypes_default.REPLACE)
|
1047
|
+
return;
|
1048
|
+
if (unexpectedKeys.length > 0) {
|
1049
|
+
return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
|
1050
|
+
}
|
1051
|
+
}
|
1052
|
+
function assertReducerShape(reducers) {
|
1053
|
+
Object.keys(reducers).forEach((key) => {
|
1054
|
+
const reducer = reducers[key];
|
1055
|
+
const initialState = reducer(void 0, {
|
1056
|
+
type: actionTypes_default.INIT
|
1057
|
+
});
|
1058
|
+
if (typeof initialState === "undefined") {
|
1059
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
|
1060
|
+
}
|
1061
|
+
if (typeof reducer(void 0, {
|
1062
|
+
type: actionTypes_default.PROBE_UNKNOWN_ACTION()
|
1063
|
+
}) === "undefined") {
|
1064
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
|
1065
|
+
}
|
1066
|
+
});
|
1067
|
+
}
|
1068
|
+
function combineReducers(reducers) {
|
1069
|
+
const reducerKeys = Object.keys(reducers);
|
1070
|
+
const finalReducers = {};
|
1071
|
+
for (let i = 0; i < reducerKeys.length; i++) {
|
1072
|
+
const key = reducerKeys[i];
|
1073
|
+
if (process.env.NODE_ENV !== "production") {
|
1074
|
+
if (typeof reducers[key] === "undefined") {
|
1075
|
+
warning$1(`No reducer provided for key "${key}"`);
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
if (typeof reducers[key] === "function") {
|
1079
|
+
finalReducers[key] = reducers[key];
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
const finalReducerKeys = Object.keys(finalReducers);
|
1083
|
+
let unexpectedKeyCache;
|
1084
|
+
if (process.env.NODE_ENV !== "production") {
|
1085
|
+
unexpectedKeyCache = {};
|
1086
|
+
}
|
1087
|
+
let shapeAssertionError;
|
1088
|
+
try {
|
1089
|
+
assertReducerShape(finalReducers);
|
1090
|
+
} catch (e) {
|
1091
|
+
shapeAssertionError = e;
|
1092
|
+
}
|
1093
|
+
return function combination(state = {}, action) {
|
1094
|
+
if (shapeAssertionError) {
|
1095
|
+
throw shapeAssertionError;
|
1096
|
+
}
|
1097
|
+
if (process.env.NODE_ENV !== "production") {
|
1098
|
+
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
1099
|
+
if (warningMessage) {
|
1100
|
+
warning$1(warningMessage);
|
1101
|
+
}
|
1102
|
+
}
|
1103
|
+
let hasChanged = false;
|
1104
|
+
const nextState = {};
|
1105
|
+
for (let i = 0; i < finalReducerKeys.length; i++) {
|
1106
|
+
const key = finalReducerKeys[i];
|
1107
|
+
const reducer = finalReducers[key];
|
1108
|
+
const previousStateForKey = state[key];
|
1109
|
+
const nextStateForKey = reducer(previousStateForKey, action);
|
1110
|
+
if (typeof nextStateForKey === "undefined") {
|
1111
|
+
const actionType = action && action.type;
|
1112
|
+
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
|
1113
|
+
}
|
1114
|
+
nextState[key] = nextStateForKey;
|
1115
|
+
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
1116
|
+
}
|
1117
|
+
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
1118
|
+
return hasChanged ? nextState : state;
|
1119
|
+
};
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
var initialState = {
|
1123
|
+
isLoading: false,
|
1124
|
+
alert: {
|
1125
|
+
type: "",
|
1126
|
+
message: ""
|
1127
|
+
},
|
1128
|
+
user: null
|
1129
|
+
};
|
1130
|
+
var commonReducer = toolkit.createReducer(initialState, function (builder) {
|
1131
|
+
builder.addCase(setLoading, function (state, action) {
|
1132
|
+
state.isLoading = action.payload;
|
1133
|
+
}).addCase(setAlert, function (state, action) {
|
1134
|
+
state.alert = action.payload;
|
1135
|
+
}).addCase(setUser, function (state, action) {
|
1136
|
+
state.user = action.payload;
|
1137
|
+
});
|
1138
|
+
});
|
1139
|
+
|
1140
|
+
var rootReducer = combineReducers({
|
1141
|
+
common: commonReducer
|
1142
|
+
});
|
1143
|
+
|
1144
|
+
var store = toolkit.configureStore({
|
1145
|
+
reducer: rootReducer,
|
1146
|
+
middleware: function middleware(getDefaultMiddleware) {
|
1147
|
+
return getDefaultMiddleware({
|
1148
|
+
serializableCheck: false
|
1149
|
+
}).concat(logger);
|
1150
|
+
}
|
1151
|
+
});
|
1152
|
+
|
1153
|
+
var TITLE = "Not found";
|
1154
|
+
var NotFound = function NotFound() {
|
1155
|
+
React.useEffect(function () {
|
1156
|
+
document.title = TITLE;
|
1157
|
+
});
|
1158
|
+
return React__default.createElement("div", {
|
1159
|
+
className: "not-found"
|
1160
|
+
}, React__default.createElement("div", {
|
1161
|
+
className: "clearfix"
|
1162
|
+
}, React__default.createElement("h1", {
|
1163
|
+
className: "float-left display-3 mr-4"
|
1164
|
+
}, "404"), React__default.createElement("div", {
|
1165
|
+
className: "float-left"
|
1166
|
+
}, React__default.createElement("h4", {
|
1167
|
+
className: "pt-3"
|
1168
|
+
}, "Oops! You are lost."), React__default.createElement("p", {
|
1169
|
+
className: "text-muted mb-2"
|
1170
|
+
}, "The page you are looking for was not found."), React__default.createElement("div", null))));
|
1171
|
+
};
|
1172
|
+
|
1173
|
+
var loadingStyle = {
|
1174
|
+
minWidth: "100vw",
|
1175
|
+
minHeight: "100vh",
|
1176
|
+
position: "fixed",
|
1177
|
+
top: 0,
|
1178
|
+
left: 0,
|
1179
|
+
zIndex: 999999999,
|
1180
|
+
backgroundColor: "rgba(0, 0, 0, 0.4)",
|
1181
|
+
display: "flex",
|
1182
|
+
justifyContent: "center",
|
1183
|
+
alignItems: "center"
|
1184
|
+
};
|
1185
|
+
var Loading = function Loading() {
|
1186
|
+
var isLoading = reactRedux.useSelector(function (state) {
|
1187
|
+
return state.common.isLoading;
|
1188
|
+
});
|
1189
|
+
localStorage.setItem("LAST_TIME_REQUETST", moment().utc().format("YYYY-MM-DD HH:mm:ss"));
|
1190
|
+
return isLoading ? React__default.createElement("div", {
|
1191
|
+
style: loadingStyle
|
1192
|
+
}, React__default.createElement("div", {
|
1193
|
+
className: "spinner-border text-secondary",
|
1194
|
+
role: "status"
|
1195
|
+
}, React__default.createElement("span", {
|
1196
|
+
className: "sr-only"
|
1197
|
+
}))) : null;
|
30
1198
|
};
|
31
1199
|
|
1200
|
+
var encodeParams$1 = (function (params) {
|
1201
|
+
return Object.keys(params).filter(function (key) {
|
1202
|
+
return params[key] || params[key] === 0 || params[key] === false;
|
1203
|
+
}).map(function (key) {
|
1204
|
+
if (Array.isArray(params[key])) {
|
1205
|
+
return params[key].map(function (i) {
|
1206
|
+
return encodeURIComponent(key) + "=" + encodeURIComponent(i);
|
1207
|
+
}).join('&');
|
1208
|
+
}
|
1209
|
+
return encodeURIComponent(key) + "=" + encodeURIComponent(params[key]);
|
1210
|
+
}).join('&');
|
1211
|
+
});
|
1212
|
+
|
1213
|
+
var getAccessToken$1 = (function () {
|
1214
|
+
try {
|
1215
|
+
return localStorage.getItem(ACCESS_TOKEN);
|
1216
|
+
} catch (err) {
|
1217
|
+
return null;
|
1218
|
+
}
|
1219
|
+
});
|
1220
|
+
|
1221
|
+
var api$1 = axios.create({
|
1222
|
+
baseURL: BASE_URL,
|
1223
|
+
timeout: 0,
|
1224
|
+
headers: {
|
1225
|
+
"Content-Type": "application/json"
|
1226
|
+
},
|
1227
|
+
paramsSerializer: function paramsSerializer(params) {
|
1228
|
+
return encodeParams$1(params);
|
1229
|
+
}
|
1230
|
+
});
|
1231
|
+
var apiUpload$1 = axios.create({
|
1232
|
+
baseURL: BASE_URL,
|
1233
|
+
timeout: 60000,
|
1234
|
+
headers: {
|
1235
|
+
"Content-Type": "multipart/form-data"
|
1236
|
+
}
|
1237
|
+
});
|
1238
|
+
[api$1, apiUpload$1].forEach(function (i) {
|
1239
|
+
return i.interceptors.request.use(function (config) {
|
1240
|
+
var token = getAccessToken$1();
|
1241
|
+
if (token) {
|
1242
|
+
config.headers.Authorization = "Bearer " + token;
|
1243
|
+
}
|
1244
|
+
return config;
|
1245
|
+
}, function (error) {
|
1246
|
+
return Promise.reject(error);
|
1247
|
+
});
|
1248
|
+
});
|
1249
|
+
[api$1, apiUpload$1].forEach(function (i) {
|
1250
|
+
return i.interceptors.response.use(function (response) {
|
1251
|
+
return response;
|
1252
|
+
}, function (error) {
|
1253
|
+
if (error.response.status === 401) {
|
1254
|
+
window.location.href = "/login";
|
1255
|
+
}
|
1256
|
+
if (error.response.status == 403) {
|
1257
|
+
localStorage.removeItem(ACCESS_TOKEN);
|
1258
|
+
localStorage.removeItem("USER_EMAIL");
|
1259
|
+
window.location.href = "/login";
|
1260
|
+
}
|
1261
|
+
return Promise.reject(error);
|
1262
|
+
});
|
1263
|
+
});
|
1264
|
+
|
1265
|
+
var AUTH_URL = BASE_URL + "/api/auth";
|
1266
|
+
var getInfo = function getInfo() {
|
1267
|
+
return api$1.get(AUTH_URL + "/info");
|
1268
|
+
};
|
1269
|
+
|
1270
|
+
var LayoutContext = function LayoutContext(_ref) {
|
1271
|
+
var children = _ref.children,
|
1272
|
+
onNavigate = _ref.onNavigate;
|
1273
|
+
var dispatch = reactRedux.useDispatch();
|
1274
|
+
var resetAuth = function resetAuth() {
|
1275
|
+
localStorage.removeItem(ACCESS_TOKEN);
|
1276
|
+
onNavigate("/login");
|
1277
|
+
};
|
1278
|
+
var loadInfo = function loadInfo() {
|
1279
|
+
try {
|
1280
|
+
var _temp2 = function _temp2() {
|
1281
|
+
dispatch(setLoading(false));
|
1282
|
+
};
|
1283
|
+
var token = getAccessToken();
|
1284
|
+
if (!token) {
|
1285
|
+
resetAuth();
|
1286
|
+
return Promise.resolve();
|
1287
|
+
}
|
1288
|
+
dispatch(setLoading(true));
|
1289
|
+
var _temp = _catch(function () {
|
1290
|
+
return Promise.resolve(getInfo()).then(function (info) {
|
1291
|
+
if (!info) {
|
1292
|
+
resetAuth();
|
1293
|
+
}
|
1294
|
+
dispatch(setUser(info.data));
|
1295
|
+
});
|
1296
|
+
}, function () {
|
1297
|
+
resetAuth();
|
1298
|
+
});
|
1299
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
1300
|
+
} catch (e) {
|
1301
|
+
return Promise.reject(e);
|
1302
|
+
}
|
1303
|
+
};
|
1304
|
+
React.useEffect(function () {
|
1305
|
+
loadInfo();
|
1306
|
+
}, []);
|
1307
|
+
return React__default.createElement(React.Fragment, null, children);
|
1308
|
+
};
|
1309
|
+
|
1310
|
+
var ConfirmDialog = function ConfirmDialog(_ref) {
|
1311
|
+
var open = _ref.open,
|
1312
|
+
text = _ref.text,
|
1313
|
+
_ref$cancelText = _ref.cancelText,
|
1314
|
+
cancelText = _ref$cancelText === void 0 ? "No" : _ref$cancelText,
|
1315
|
+
_ref$okText = _ref.okText,
|
1316
|
+
okText = _ref$okText === void 0 ? "Yes" : _ref$okText,
|
1317
|
+
isDelete = _ref.isDelete,
|
1318
|
+
toggle = _ref.toggle,
|
1319
|
+
onConfirm = _ref.onConfirm;
|
1320
|
+
return React__default.createElement(reactstrap.Modal, {
|
1321
|
+
isOpen: open,
|
1322
|
+
toggle: toggle,
|
1323
|
+
centered: true
|
1324
|
+
}, React__default.createElement(reactstrap.ModalHeader, {
|
1325
|
+
toggle: toggle
|
1326
|
+
}, "Confirmation"), React__default.createElement(reactstrap.ModalBody, null, text), React__default.createElement(reactstrap.ModalFooter, null, React__default.createElement(reactstrap.Button, {
|
1327
|
+
color: "secondary",
|
1328
|
+
onClick: toggle
|
1329
|
+
}, cancelText), React__default.createElement(reactstrap.Button, {
|
1330
|
+
color: isDelete ? "danger" : "primary",
|
1331
|
+
onClick: onConfirm
|
1332
|
+
}, okText)));
|
1333
|
+
};
|
1334
|
+
|
1335
|
+
var CommonDialog = function CommonDialog(_ref) {
|
1336
|
+
var open = _ref.open,
|
1337
|
+
children = _ref.children,
|
1338
|
+
centered = _ref.centered,
|
1339
|
+
title = _ref.title,
|
1340
|
+
_ref$size = _ref.size,
|
1341
|
+
size = _ref$size === void 0 ? "xs" : _ref$size,
|
1342
|
+
onClose = _ref.onClose;
|
1343
|
+
return React__default.createElement(reactstrap.Modal, {
|
1344
|
+
isOpen: open,
|
1345
|
+
toggle: onClose,
|
1346
|
+
centered: centered,
|
1347
|
+
size: size
|
1348
|
+
}, React__default.createElement(reactstrap.ModalHeader, {
|
1349
|
+
toggle: onClose
|
1350
|
+
}, title), children);
|
1351
|
+
};
|
1352
|
+
|
1353
|
+
var CommonAlert = function CommonAlert() {
|
1354
|
+
var _alert$message2;
|
1355
|
+
var dispatch = reactRedux.useDispatch();
|
1356
|
+
var alert = reactRedux.useSelector(function (state) {
|
1357
|
+
return state.common.alert;
|
1358
|
+
});
|
1359
|
+
var timeout = React.useRef();
|
1360
|
+
var onDismiss = function onDismiss() {
|
1361
|
+
dispatch(setAlert({
|
1362
|
+
message: ""
|
1363
|
+
}));
|
1364
|
+
timeout && timeout.current && clearTimeout(timeout.current);
|
1365
|
+
};
|
1366
|
+
React.useEffect(function () {
|
1367
|
+
var _alert$message;
|
1368
|
+
if (!!((_alert$message = alert.message) !== null && _alert$message !== void 0 && _alert$message.length)) {
|
1369
|
+
timeout && timeout.current && clearTimeout(timeout.current);
|
1370
|
+
timeout.current = setTimeout(function () {
|
1371
|
+
dispatch(setAlert({
|
1372
|
+
message: ""
|
1373
|
+
}));
|
1374
|
+
}, 3000);
|
1375
|
+
}
|
1376
|
+
}, [alert]);
|
1377
|
+
return ((_alert$message2 = alert.message) === null || _alert$message2 === void 0 ? void 0 : _alert$message2.length) > 0 ? React__default.createElement("div", {
|
1378
|
+
className: "app-alert"
|
1379
|
+
}, React__default.createElement(reactstrap.Alert, {
|
1380
|
+
color: alert.type,
|
1381
|
+
isOpen: alert.message.length > 0,
|
1382
|
+
toggle: onDismiss
|
1383
|
+
}, alert.message)) : null;
|
1384
|
+
};
|
1385
|
+
|
1386
|
+
var formatTime = (function (time, ORIGINAL_FORMAT, FORMAT) {
|
1387
|
+
if (time === DATE_MIN_VALUE) return "";
|
1388
|
+
try {
|
1389
|
+
return moment(time, ORIGINAL_FORMAT).format(FORMAT || "yyyy-MM-DD");
|
1390
|
+
} catch (_unused) {
|
1391
|
+
return "";
|
1392
|
+
}
|
1393
|
+
});
|
1394
|
+
|
1395
|
+
var diffFromNow = (function (time, unitOfTime) {
|
1396
|
+
if (time === DATE_MIN_VALUE) return 0;
|
1397
|
+
try {
|
1398
|
+
return moment().diff(moment.utc(time).local(), unitOfTime);
|
1399
|
+
} catch (_unused) {
|
1400
|
+
return "";
|
1401
|
+
}
|
1402
|
+
});
|
1403
|
+
|
1404
|
+
var CustomPagination = function CustomPagination(_ref) {
|
1405
|
+
var currentPage = _ref.currentPage,
|
1406
|
+
totalPage = _ref.totalPage,
|
1407
|
+
onChangePage = _ref.onChangePage;
|
1408
|
+
return React__default.createElement(reactstrap.Pagination, {
|
1409
|
+
className: "w-fit"
|
1410
|
+
}, React__default.createElement(reactstrap.PaginationItem, {
|
1411
|
+
disabled: currentPage <= 1
|
1412
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1413
|
+
onClick: function onClick(e) {
|
1414
|
+
e.preventDefault();
|
1415
|
+
onChangePage(currentPage - 1);
|
1416
|
+
},
|
1417
|
+
previous: true,
|
1418
|
+
href: "#"
|
1419
|
+
})), React__default.createElement(reactstrap.PaginationItem, {
|
1420
|
+
active: 1 === currentPage,
|
1421
|
+
key: 1
|
1422
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1423
|
+
onClick: function onClick(e) {
|
1424
|
+
e.preventDefault();
|
1425
|
+
onChangePage(1);
|
1426
|
+
},
|
1427
|
+
href: "#"
|
1428
|
+
}, 1)), totalPage > 2 && React__default.createElement(reactstrap.PaginationItem, {
|
1429
|
+
active: 2 === currentPage,
|
1430
|
+
key: 1
|
1431
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1432
|
+
onClick: function onClick(e) {
|
1433
|
+
e.preventDefault();
|
1434
|
+
onChangePage(2);
|
1435
|
+
},
|
1436
|
+
href: "#"
|
1437
|
+
}, 2)), currentPage > 4 && currentPage !== totalPage && totalPage !== 5 && React__default.createElement(reactstrap.PaginationItem, {
|
1438
|
+
disabled: true,
|
1439
|
+
key: "first"
|
1440
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1441
|
+
href: "#"
|
1442
|
+
}, "...")), (currentPage === 1 || currentPage === totalPage) && totalPage === 5 && React__default.createElement(reactstrap.PaginationItem, {
|
1443
|
+
key: 3
|
1444
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1445
|
+
onClick: function onClick(e) {
|
1446
|
+
e.preventDefault();
|
1447
|
+
onChangePage(3);
|
1448
|
+
},
|
1449
|
+
href: "#"
|
1450
|
+
}, "3")), [currentPage - 1, currentPage, currentPage + 1].filter(function (page) {
|
1451
|
+
return page > 2 && page < totalPage - 1;
|
1452
|
+
}).map(function (page) {
|
1453
|
+
return React__default.createElement(reactstrap.PaginationItem, {
|
1454
|
+
active: page === currentPage,
|
1455
|
+
key: page
|
1456
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1457
|
+
onClick: function onClick(e) {
|
1458
|
+
e.preventDefault();
|
1459
|
+
onChangePage(page);
|
1460
|
+
},
|
1461
|
+
href: "#"
|
1462
|
+
}, page));
|
1463
|
+
}), totalPage - currentPage > 4 && React__default.createElement(reactstrap.PaginationItem, {
|
1464
|
+
disabled: true,
|
1465
|
+
key: "last"
|
1466
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1467
|
+
href: "#"
|
1468
|
+
}, "...")), totalPage > 3 && React__default.createElement(reactstrap.PaginationItem, {
|
1469
|
+
active: totalPage - 1 === currentPage,
|
1470
|
+
key: totalPage - 1
|
1471
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1472
|
+
onClick: function onClick(e) {
|
1473
|
+
e.preventDefault();
|
1474
|
+
onChangePage(totalPage - 1);
|
1475
|
+
},
|
1476
|
+
href: "#"
|
1477
|
+
}, totalPage - 1)), totalPage > 1 && React__default.createElement(reactstrap.PaginationItem, {
|
1478
|
+
active: totalPage === currentPage,
|
1479
|
+
key: totalPage
|
1480
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1481
|
+
onClick: function onClick(e) {
|
1482
|
+
e.preventDefault();
|
1483
|
+
onChangePage(totalPage);
|
1484
|
+
},
|
1485
|
+
href: "#"
|
1486
|
+
}, totalPage)), React__default.createElement(reactstrap.PaginationItem, {
|
1487
|
+
disabled: currentPage >= totalPage
|
1488
|
+
}, React__default.createElement(reactstrap.PaginationLink, {
|
1489
|
+
onClick: function onClick(e) {
|
1490
|
+
e.preventDefault();
|
1491
|
+
onChangePage(currentPage + 1);
|
1492
|
+
},
|
1493
|
+
next: true,
|
1494
|
+
href: "#"
|
1495
|
+
})));
|
1496
|
+
};
|
1497
|
+
|
1498
|
+
var historyCore = createBrowserHistory();
|
1499
|
+
|
32
1500
|
exports.ACCESS_TOKEN = ACCESS_TOKEN;
|
33
1501
|
exports.BASE_URL = BASE_URL;
|
1502
|
+
exports.CommonAlert = CommonAlert;
|
1503
|
+
exports.CommonDialog = CommonDialog;
|
1504
|
+
exports.ConfirmDialog = ConfirmDialog;
|
1505
|
+
exports.CustomPagination = CustomPagination;
|
1506
|
+
exports.LayoutContext = LayoutContext;
|
1507
|
+
exports.Loading = Loading;
|
34
1508
|
exports.Login = Login;
|
1509
|
+
exports.NotFound = NotFound;
|
1510
|
+
exports.api = api$1;
|
1511
|
+
exports.diffFromNow = diffFromNow;
|
1512
|
+
exports.formatTime = formatTime;
|
1513
|
+
exports.historyCore = historyCore;
|
1514
|
+
exports.setAlert = setAlert;
|
35
1515
|
exports.setLoading = setLoading;
|
1516
|
+
exports.setUser = setUser;
|
1517
|
+
exports.store = store;
|
1518
|
+
exports.utcToLocalTime = utcToLocalTime;
|
36
1519
|
//# sourceMappingURL=index.js.map
|