acsi-core 0.1.40 → 0.1.41
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/containers/Login/apiClient/index.d.ts +2 -0
- package/dist/containers/Login/hooks/useLogin.d.ts +9 -3
- package/dist/index.css +8 -0
- package/dist/index.js +192 -35
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +193 -36
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const getGoogleClientId: () => Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
2
|
export declare const apiLoginGoogle: (body: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
export declare const apiSendEmailCode: (body: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
|
+
export declare const apiCheckEmailCode: (params: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -5,13 +5,19 @@ declare type LoginInfo = {
|
|
|
5
5
|
captcha: string;
|
|
6
6
|
rememberMe: boolean;
|
|
7
7
|
};
|
|
8
|
-
declare const useLogin: () => {
|
|
8
|
+
declare const useLogin: (onNavigate: any) => {
|
|
9
9
|
defaultInfo: LoginInfo;
|
|
10
10
|
openLogin: boolean;
|
|
11
11
|
toggle: () => void;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
email: string;
|
|
13
|
+
setEmail: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
14
|
+
loginWithEmail: () => Promise<void>;
|
|
14
15
|
infoUser: any;
|
|
15
16
|
setInfoUser: import("react").Dispatch<any>;
|
|
17
|
+
code: string;
|
|
18
|
+
setCode: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
19
|
+
isScreenCode: boolean;
|
|
20
|
+
formatTime: () => string;
|
|
21
|
+
loginWithEmailCode: () => Promise<void>;
|
|
16
22
|
};
|
|
17
23
|
export default useLogin;
|
package/dist/index.css
CHANGED
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
right: 0; }
|
|
57
57
|
._1KLz9 ._2Jo1o ._3zXRp {
|
|
58
58
|
margin-top: 17px; }
|
|
59
|
+
._1KLz9 ._2Jo1o ._3zXRp ._8NJga {
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
color: #a6a6ad;
|
|
62
|
+
text-align: left;
|
|
63
|
+
margin-top: 10px; }
|
|
64
|
+
._1KLz9 ._2Jo1o ._3zXRp ._8NJga span {
|
|
65
|
+
color: #ff0000;
|
|
66
|
+
font-size: 14px; }
|
|
59
67
|
._1KLz9 ._2Jo1o ._3zXRp input {
|
|
60
68
|
width: 100%;
|
|
61
69
|
outline: none;
|
package/dist/index.js
CHANGED
|
@@ -86,7 +86,7 @@ var COLORS = {
|
|
|
86
86
|
var ORGANIZATION_TENANT = "ORGANIZATION_TENANT";
|
|
87
87
|
var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
88
88
|
|
|
89
|
-
var styleGlobal = {"signup_wrap":"_1KLz9","box-signin":"_2Jo1o","signin_title":"_3egBO","signup_link":"_1DoIT","google_button":"_34hK_","box-field":"_2e9xO","box-input":"_3zXRp","box-button-email":"_21FPk","box-signin-container":"_1QERu","box-signin-text":"_2-znH","box-signin-logo":"_1aB2m","box-right":"_3qndF","box-right-body":"_JzdCr","box-right-footer":"_19aCA","pr-30":"_2HB5r"};
|
|
89
|
+
var styleGlobal = {"signup_wrap":"_1KLz9","box-signin":"_2Jo1o","signin_title":"_3egBO","signup_link":"_1DoIT","google_button":"_34hK_","box-field":"_2e9xO","box-input":"_3zXRp","box-text":"_8NJga","box-button-email":"_21FPk","box-signin-container":"_1QERu","box-signin-text":"_2-znH","box-signin-logo":"_1aB2m","box-right":"_3qndF","box-right-body":"_JzdCr","box-right-footer":"_19aCA","pr-30":"_2HB5r"};
|
|
90
90
|
|
|
91
91
|
var api = axios.create({
|
|
92
92
|
baseURL: BASE_URL,
|
|
@@ -136,12 +136,28 @@ var apiUpload = axios.create({
|
|
|
136
136
|
var apiLoginGoogle = function apiLoginGoogle(body) {
|
|
137
137
|
return api.post(BASE_URL + "/api/Auth/login", body);
|
|
138
138
|
};
|
|
139
|
+
var apiSendEmailCode = function apiSendEmailCode(body) {
|
|
140
|
+
return api.post(BASE_URL + "/api/Auth/send-code-email", body);
|
|
141
|
+
};
|
|
142
|
+
var apiCheckEmailCode = function apiCheckEmailCode(params) {
|
|
143
|
+
return api.get(BASE_URL + "/api/Auth/check-code-email", {
|
|
144
|
+
params: params
|
|
145
|
+
});
|
|
146
|
+
};
|
|
139
147
|
|
|
140
148
|
var itemLogin = ['Seamless lesson planning', 'Flexibility and customization', 'Data protection and security', 'Standards alignment', 'AI smart assist'];
|
|
141
149
|
|
|
142
150
|
var BlockLogin = function BlockLogin(_ref) {
|
|
143
151
|
var onNavigate = _ref.onNavigate,
|
|
144
|
-
role = _ref.role
|
|
152
|
+
role = _ref.role,
|
|
153
|
+
email = _ref.email,
|
|
154
|
+
setEmail = _ref.setEmail,
|
|
155
|
+
loginWithEmail = _ref.loginWithEmail,
|
|
156
|
+
code = _ref.code,
|
|
157
|
+
setCode = _ref.setCode,
|
|
158
|
+
isScreenCode = _ref.isScreenCode,
|
|
159
|
+
formatTime = _ref.formatTime,
|
|
160
|
+
loginWithEmailCode = _ref.loginWithEmailCode;
|
|
145
161
|
var dispatch = reactRedux.useDispatch();
|
|
146
162
|
var googleLogin = google.useGoogleLogin({
|
|
147
163
|
onSuccess: function (tokenResponse) {
|
|
@@ -154,7 +170,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
154
170
|
return function () {
|
|
155
171
|
if (userInfo && userInfo.data) {
|
|
156
172
|
var _userInfo$data = userInfo.data,
|
|
157
|
-
|
|
173
|
+
_email = _userInfo$data.email,
|
|
158
174
|
picture = _userInfo$data.picture,
|
|
159
175
|
family_name = _userInfo$data.family_name,
|
|
160
176
|
given_name = _userInfo$data.given_name,
|
|
@@ -166,7 +182,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
166
182
|
fullName: name,
|
|
167
183
|
firstName: family_name,
|
|
168
184
|
lastName: given_name,
|
|
169
|
-
email:
|
|
185
|
+
email: _email,
|
|
170
186
|
token: accessToken,
|
|
171
187
|
googleId: sub,
|
|
172
188
|
role: role
|
|
@@ -240,13 +256,40 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
240
256
|
src: "/images/icons/Google__G__logo.png"
|
|
241
257
|
}), "Sign in with Google")), role != "Admin" && React__default.createElement(React__default.Fragment, null, React__default.createElement("span", {
|
|
242
258
|
className: "" + styleGlobal["box-field"]
|
|
243
|
-
}, "OR"), React__default.createElement(
|
|
259
|
+
}, "OR"), isScreenCode ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
260
|
+
className: "" + styleGlobal["box-input"]
|
|
261
|
+
}, React__default.createElement("input", {
|
|
262
|
+
type: "text",
|
|
263
|
+
placeholder: "Code OTP",
|
|
264
|
+
value: code,
|
|
265
|
+
onChange: function onChange(event) {
|
|
266
|
+
setCode(event.target.value);
|
|
267
|
+
}
|
|
268
|
+
}), React__default.createElement("p", {
|
|
269
|
+
className: styleGlobal["box-text"]
|
|
270
|
+
}, "Your code will expire: ", React__default.createElement("span", null, formatTime()))), React__default.createElement("button", {
|
|
271
|
+
onClick: function onClick() {
|
|
272
|
+
return loginWithEmailCode();
|
|
273
|
+
},
|
|
274
|
+
className: "" + styleGlobal["box-button-email"]
|
|
275
|
+
}, React__default.createElement("img", {
|
|
276
|
+
width: 20,
|
|
277
|
+
height: 20,
|
|
278
|
+
alt: "Email sign-in",
|
|
279
|
+
src: "/images/icons/Login_icon.png"
|
|
280
|
+
}), "Login")) : React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
244
281
|
className: "" + styleGlobal["box-input"]
|
|
245
282
|
}, React__default.createElement("input", {
|
|
246
283
|
type: "email",
|
|
247
|
-
placeholder: "Email"
|
|
284
|
+
placeholder: "Email",
|
|
285
|
+
value: email,
|
|
286
|
+
onChange: function onChange(event) {
|
|
287
|
+
setEmail(event.target.value.trim());
|
|
288
|
+
}
|
|
248
289
|
})), React__default.createElement("button", {
|
|
249
|
-
|
|
290
|
+
onClick: function onClick() {
|
|
291
|
+
!!email && loginWithEmail();
|
|
292
|
+
},
|
|
250
293
|
className: "" + styleGlobal["box-button-email"]
|
|
251
294
|
}, React__default.createElement("img", {
|
|
252
295
|
width: 20,
|
|
@@ -311,46 +354,179 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
311
354
|
}))))))));
|
|
312
355
|
};
|
|
313
356
|
|
|
357
|
+
// A type of promise-like that resolves synchronously and supports only one observer
|
|
358
|
+
|
|
359
|
+
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
360
|
+
|
|
361
|
+
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
362
|
+
|
|
363
|
+
// Asynchronously call a function and send errors to recovery continuation
|
|
364
|
+
function _catch(body, recover) {
|
|
365
|
+
try {
|
|
366
|
+
var result = body();
|
|
367
|
+
} catch(e) {
|
|
368
|
+
return recover(e);
|
|
369
|
+
}
|
|
370
|
+
if (result && result.then) {
|
|
371
|
+
return result.then(void 0, recover);
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
|
|
314
376
|
var defaultInfo = {
|
|
315
377
|
email: "",
|
|
316
378
|
password: "",
|
|
317
379
|
captcha: "",
|
|
318
380
|
rememberMe: false
|
|
319
381
|
};
|
|
320
|
-
var
|
|
382
|
+
var minutes = 15;
|
|
383
|
+
var useLogin = function useLogin(onNavigate) {
|
|
321
384
|
var _useState = React.useState(false),
|
|
322
385
|
openLogin = _useState[0],
|
|
323
386
|
setOpenLogin = _useState[1];
|
|
324
387
|
var _useState2 = React.useState(),
|
|
325
388
|
infoUser = _useState2[0],
|
|
326
389
|
setInfoUser = _useState2[1];
|
|
390
|
+
var dispatch = reactRedux.useDispatch();
|
|
327
391
|
var toggle = React.useCallback(function () {
|
|
328
392
|
setOpenLogin(!openLogin);
|
|
329
393
|
}, [openLogin]);
|
|
330
|
-
var _useState3 = React.useState(
|
|
331
|
-
|
|
332
|
-
|
|
394
|
+
var _useState3 = React.useState(""),
|
|
395
|
+
email = _useState3[0],
|
|
396
|
+
setEmail = _useState3[1];
|
|
397
|
+
var _useState4 = React.useState(""),
|
|
398
|
+
code = _useState4[0],
|
|
399
|
+
setCode = _useState4[1];
|
|
400
|
+
var _useState5 = React.useState(false),
|
|
401
|
+
isScreenCode = _useState5[0],
|
|
402
|
+
setIsScreenCode = _useState5[1];
|
|
403
|
+
var _useState6 = React.useState(minutes * 60),
|
|
404
|
+
timeLeft = _useState6[0],
|
|
405
|
+
setTimeLeft = _useState6[1];
|
|
406
|
+
var loginWithEmail = function loginWithEmail() {
|
|
407
|
+
try {
|
|
408
|
+
var _temp2 = function _temp2() {
|
|
409
|
+
dispatch(setLoading(false));
|
|
410
|
+
};
|
|
411
|
+
dispatch(setLoading(true));
|
|
412
|
+
var _temp = _catch(function () {
|
|
413
|
+
return Promise.resolve(apiSendEmailCode(email)).then(function (res) {
|
|
414
|
+
var data = res.data;
|
|
415
|
+
if (data.status == 1) {
|
|
416
|
+
if (data.data.token != null) {
|
|
417
|
+
var tokenJWT = data.data.token;
|
|
418
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
419
|
+
onNavigate("/dashboard");
|
|
420
|
+
} else {
|
|
421
|
+
setIsScreenCode(true);
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
dispatch(setLoading(false));
|
|
425
|
+
alert("Please contact admin.");
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}, function (e) {
|
|
429
|
+
console.log(e);
|
|
430
|
+
});
|
|
431
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
|
432
|
+
} catch (e) {
|
|
433
|
+
return Promise.reject(e);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
var loginWithEmailCode = function loginWithEmailCode() {
|
|
437
|
+
try {
|
|
438
|
+
var _temp4 = function _temp4() {
|
|
439
|
+
dispatch(setLoading(false));
|
|
440
|
+
};
|
|
441
|
+
dispatch(setLoading(true));
|
|
442
|
+
var _temp3 = _catch(function () {
|
|
443
|
+
return Promise.resolve(apiCheckEmailCode({
|
|
444
|
+
email: email,
|
|
445
|
+
code: code
|
|
446
|
+
})).then(function (res) {
|
|
447
|
+
var data = res.data;
|
|
448
|
+
if (data.status == 1) {
|
|
449
|
+
var tokenJWT = data.data.token;
|
|
450
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
451
|
+
onNavigate("/dashboard");
|
|
452
|
+
} else {
|
|
453
|
+
dispatch(setLoading(false));
|
|
454
|
+
alert("The code is not accurate. Please check again.");
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}, function (e) {
|
|
458
|
+
console.log(e);
|
|
459
|
+
});
|
|
460
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
|
|
461
|
+
} catch (e) {
|
|
462
|
+
return Promise.reject(e);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
var formatTime = function formatTime() {
|
|
466
|
+
var m = Math.floor(timeLeft / 60);
|
|
467
|
+
var s = timeLeft % 60;
|
|
468
|
+
return m.toString().padStart(2, '0') + ":" + s.toString().padStart(2, '0');
|
|
469
|
+
};
|
|
470
|
+
React.useEffect(function () {
|
|
471
|
+
if (isScreenCode) {
|
|
472
|
+
var timer = setInterval(function () {
|
|
473
|
+
setTimeLeft(function (prev) {
|
|
474
|
+
if (prev <= 1) {
|
|
475
|
+
clearInterval(timer);
|
|
476
|
+
return 0;
|
|
477
|
+
}
|
|
478
|
+
return prev - 1;
|
|
479
|
+
});
|
|
480
|
+
}, 1000);
|
|
481
|
+
return function () {
|
|
482
|
+
return clearInterval(timer);
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return;
|
|
486
|
+
}, [isScreenCode]);
|
|
333
487
|
return {
|
|
334
488
|
defaultInfo: defaultInfo,
|
|
335
489
|
openLogin: openLogin,
|
|
336
490
|
toggle: toggle,
|
|
337
|
-
|
|
338
|
-
|
|
491
|
+
email: email,
|
|
492
|
+
setEmail: setEmail,
|
|
493
|
+
loginWithEmail: loginWithEmail,
|
|
339
494
|
infoUser: infoUser,
|
|
340
|
-
setInfoUser: setInfoUser
|
|
495
|
+
setInfoUser: setInfoUser,
|
|
496
|
+
code: code,
|
|
497
|
+
setCode: setCode,
|
|
498
|
+
isScreenCode: isScreenCode,
|
|
499
|
+
formatTime: formatTime,
|
|
500
|
+
loginWithEmailCode: loginWithEmailCode
|
|
341
501
|
};
|
|
342
502
|
};
|
|
343
503
|
|
|
344
504
|
var Login = function Login(props) {
|
|
345
505
|
var onNavigate = props.onNavigate,
|
|
346
506
|
role = props.role;
|
|
347
|
-
var _useLogin = useLogin(),
|
|
348
|
-
defaultInfo = _useLogin.defaultInfo
|
|
507
|
+
var _useLogin = useLogin(onNavigate),
|
|
508
|
+
defaultInfo = _useLogin.defaultInfo,
|
|
509
|
+
email = _useLogin.email,
|
|
510
|
+
setEmail = _useLogin.setEmail,
|
|
511
|
+
loginWithEmail = _useLogin.loginWithEmail,
|
|
512
|
+
code = _useLogin.code,
|
|
513
|
+
setCode = _useLogin.setCode,
|
|
514
|
+
isScreenCode = _useLogin.isScreenCode,
|
|
515
|
+
formatTime = _useLogin.formatTime,
|
|
516
|
+
loginWithEmailCode = _useLogin.loginWithEmailCode;
|
|
349
517
|
return React__default.createElement("div", {
|
|
350
518
|
className: styleGlobal["signup_wrap"] + " container-fluid font-family-lato"
|
|
351
519
|
}, React__default.createElement(BlockLogin, {
|
|
352
520
|
defaultInfo: defaultInfo,
|
|
521
|
+
email: email,
|
|
522
|
+
setEmail: setEmail,
|
|
523
|
+
loginWithEmail: loginWithEmail,
|
|
524
|
+
code: code,
|
|
525
|
+
setCode: setCode,
|
|
526
|
+
formatTime: formatTime,
|
|
527
|
+
isScreenCode: isScreenCode,
|
|
353
528
|
onNavigate: onNavigate,
|
|
529
|
+
loginWithEmailCode: loginWithEmailCode,
|
|
354
530
|
role: role
|
|
355
531
|
}));
|
|
356
532
|
};
|
|
@@ -593,25 +769,6 @@ var getAccessToken$1 = (function () {
|
|
|
593
769
|
}
|
|
594
770
|
});
|
|
595
771
|
|
|
596
|
-
// A type of promise-like that resolves synchronously and supports only one observer
|
|
597
|
-
|
|
598
|
-
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
599
|
-
|
|
600
|
-
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
601
|
-
|
|
602
|
-
// Asynchronously call a function and send errors to recovery continuation
|
|
603
|
-
function _catch(body, recover) {
|
|
604
|
-
try {
|
|
605
|
-
var result = body();
|
|
606
|
-
} catch(e) {
|
|
607
|
-
return recover(e);
|
|
608
|
-
}
|
|
609
|
-
if (result && result.then) {
|
|
610
|
-
return result.then(void 0, recover);
|
|
611
|
-
}
|
|
612
|
-
return result;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
772
|
var encodeParams$1 = (function (params) {
|
|
616
773
|
return Object.keys(params).filter(function (key) {
|
|
617
774
|
return params[key] || params[key] === 0 || params[key] === false;
|