acsi-core 0.1.97 → 0.1.99
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/CoreSelectCompact/index.d.ts +1 -0
- package/dist/index.js +181 -40
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +182 -41
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,10 +13,10 @@ var ReactSelect = require('react-select');
|
|
|
13
13
|
var ReactSelect__default = _interopDefault(ReactSelect);
|
|
14
14
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
15
15
|
var moment = _interopDefault(require('moment'));
|
|
16
|
+
var msalBrowser = require('@azure/msal-browser');
|
|
16
17
|
var reactToastify = require('react-toastify');
|
|
17
18
|
var reactGoogleLogin = require('@leecheuk/react-google-login');
|
|
18
19
|
var material = require('@mui/material');
|
|
19
|
-
require('@azure/msal-browser');
|
|
20
20
|
var amplitude = require('@amplitude/analytics-browser');
|
|
21
21
|
var Sentry = require('@sentry/react');
|
|
22
22
|
var fa = require('react-icons/fa');
|
|
@@ -80,25 +80,6 @@ var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
|
80
80
|
|
|
81
81
|
var styleGlobal = {"signup_wrap":"_1KLz9","box-signin":"_2Jo1o","signin_title":"_3egBO","signup_link":"_1DoIT","google_button":"_34hK_","microsoft_button":"_19ESb","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","image-slideshow":"_1aM7m","active":"_Vx1zf","box-right-body":"_JzdCr","box-right-footer":"_19aCA","pr-30":"_2HB5r","width-400":"_4ehXP"};
|
|
82
82
|
|
|
83
|
-
// A type of promise-like that resolves synchronously and supports only one observer
|
|
84
|
-
|
|
85
|
-
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
86
|
-
|
|
87
|
-
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
88
|
-
|
|
89
|
-
// Asynchronously call a function and send errors to recovery continuation
|
|
90
|
-
function _catch(body, recover) {
|
|
91
|
-
try {
|
|
92
|
-
var result = body();
|
|
93
|
-
} catch(e) {
|
|
94
|
-
return recover(e);
|
|
95
|
-
}
|
|
96
|
-
if (result && result.then) {
|
|
97
|
-
return result.then(void 0, recover);
|
|
98
|
-
}
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
83
|
function _extends() {
|
|
103
84
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
104
85
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -118,6 +99,25 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
118
99
|
return t;
|
|
119
100
|
}
|
|
120
101
|
|
|
102
|
+
// A type of promise-like that resolves synchronously and supports only one observer
|
|
103
|
+
|
|
104
|
+
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
105
|
+
|
|
106
|
+
const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
|
|
107
|
+
|
|
108
|
+
// Asynchronously call a function and send errors to recovery continuation
|
|
109
|
+
function _catch(body, recover) {
|
|
110
|
+
try {
|
|
111
|
+
var result = body();
|
|
112
|
+
} catch(e) {
|
|
113
|
+
return recover(e);
|
|
114
|
+
}
|
|
115
|
+
if (result && result.then) {
|
|
116
|
+
return result.then(void 0, recover);
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
121
|
var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
|
|
122
122
|
|
|
123
123
|
var _excluded = ["type", "children", "onClick", "icon", "disabled", "htmlType"];
|
|
@@ -413,7 +413,10 @@ var CoreInput$1 = function CoreInput(props) {
|
|
|
413
413
|
className: "" + styles$4["core-checkbox"]
|
|
414
414
|
}, React__default.createElement(reactstrap.FormGroup, {
|
|
415
415
|
check: true,
|
|
416
|
-
|
|
416
|
+
cssModule: {
|
|
417
|
+
display: "flex",
|
|
418
|
+
alignItems: "center"
|
|
419
|
+
}
|
|
417
420
|
}, React__default.createElement(reactstrap.Input, {
|
|
418
421
|
id: "core-checkbox-" + name,
|
|
419
422
|
type: "checkbox",
|
|
@@ -423,9 +426,11 @@ var CoreInput$1 = function CoreInput(props) {
|
|
|
423
426
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(name, e.target.checked);
|
|
424
427
|
},
|
|
425
428
|
disabled: disabled
|
|
426
|
-
}), React__default.createElement(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
}), React__default.createElement("p", {
|
|
430
|
+
style: {
|
|
431
|
+
marginTop: "2px",
|
|
432
|
+
marginBottom: 0
|
|
433
|
+
}
|
|
429
434
|
}, label)));
|
|
430
435
|
};
|
|
431
436
|
|
|
@@ -774,7 +779,8 @@ var CoreSelectCompact = function CoreSelectCompact(props) {
|
|
|
774
779
|
isShowDropdown = _props$isShowDropdown === void 0 ? false : _props$isShowDropdown,
|
|
775
780
|
_props$error = props.error,
|
|
776
781
|
error = _props$error === void 0 ? false : _props$error,
|
|
777
|
-
_noOptionsMessage = props.noOptionsMessage
|
|
782
|
+
_noOptionsMessage = props.noOptionsMessage,
|
|
783
|
+
border = props.border;
|
|
778
784
|
var handleChange = function handleChange(value) {
|
|
779
785
|
var newValue = isMulti ? value === null || value === void 0 ? void 0 : value.map(function (item) {
|
|
780
786
|
return item.value;
|
|
@@ -785,11 +791,12 @@ var CoreSelectCompact = function CoreSelectCompact(props) {
|
|
|
785
791
|
var styles = _extends({}, base, {
|
|
786
792
|
fontSize: "14px",
|
|
787
793
|
fontWeight: "400",
|
|
788
|
-
padding: "0",
|
|
789
794
|
backgroundColor: state.isDisabled ? "transparent" : error ? COLORS.lightYellow : COLORS.white,
|
|
790
|
-
border: "none",
|
|
795
|
+
border: border ? state.isFocused ? "2px solid " + (!error ? COLORS.brandBlue : COLORS.red) : "1px solid " + (!error ? COLORS.grayLines : COLORS.red) : "none",
|
|
796
|
+
borderRadius: border ? "8px" : undefined,
|
|
791
797
|
height: isMulti ? undefined : "26px",
|
|
792
|
-
minHeight: "
|
|
798
|
+
minHeight: "32px",
|
|
799
|
+
padding: border ? "4px 11px" : 0,
|
|
793
800
|
boxShadow: "none",
|
|
794
801
|
cursor: "pointer",
|
|
795
802
|
"&:hover": {
|
|
@@ -1223,6 +1230,55 @@ var TypeLogin;
|
|
|
1223
1230
|
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
1224
1231
|
})(TypeLogin || (TypeLogin = {}));
|
|
1225
1232
|
|
|
1233
|
+
var AuthenticationMessage;
|
|
1234
|
+
(function (AuthenticationMessage) {
|
|
1235
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
1236
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
1237
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
1238
|
+
(function (Role) {
|
|
1239
|
+
Role["Student"] = "Student";
|
|
1240
|
+
Role["Teacher"] = "Teacher";
|
|
1241
|
+
Role["Admin"] = "Admin";
|
|
1242
|
+
})(exports.Role || (exports.Role = {}));
|
|
1243
|
+
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
1244
|
+
return {
|
|
1245
|
+
auth: {
|
|
1246
|
+
clientId: clientId,
|
|
1247
|
+
authority: "https://login.microsoftonline.com/common",
|
|
1248
|
+
redirectUri: redirectUri
|
|
1249
|
+
},
|
|
1250
|
+
cache: {
|
|
1251
|
+
cacheLocation: "sessionStorage",
|
|
1252
|
+
storeAuthStateInCookie: false
|
|
1253
|
+
},
|
|
1254
|
+
system: {
|
|
1255
|
+
loggerOptions: {
|
|
1256
|
+
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
1257
|
+
if (containsPii) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
switch (level) {
|
|
1261
|
+
case msalBrowser.LogLevel.Error:
|
|
1262
|
+
console.error(message);
|
|
1263
|
+
return;
|
|
1264
|
+
case msalBrowser.LogLevel.Info:
|
|
1265
|
+
console.info(message);
|
|
1266
|
+
return;
|
|
1267
|
+
case msalBrowser.LogLevel.Verbose:
|
|
1268
|
+
console.debug(message);
|
|
1269
|
+
return;
|
|
1270
|
+
case msalBrowser.LogLevel.Warning:
|
|
1271
|
+
console.warn(message);
|
|
1272
|
+
return;
|
|
1273
|
+
default:
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1226
1282
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1227
1283
|
var onNavigate = _ref.onNavigate,
|
|
1228
1284
|
role = _ref.role,
|
|
@@ -1357,6 +1413,91 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1357
1413
|
return console.log(errorResponse);
|
|
1358
1414
|
}
|
|
1359
1415
|
});
|
|
1416
|
+
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
1417
|
+
try {
|
|
1418
|
+
var msalInstance = new msalBrowser.PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1419
|
+
if (!msalInstance) {
|
|
1420
|
+
console.error("MSAL instance not initialized");
|
|
1421
|
+
return Promise.resolve();
|
|
1422
|
+
}
|
|
1423
|
+
return Promise.resolve(_catch(function () {
|
|
1424
|
+
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
1425
|
+
var loginRequest = {
|
|
1426
|
+
scopes: ["openid", "profile", "email"]
|
|
1427
|
+
};
|
|
1428
|
+
var silentRequest = _extends({}, loginRequest, {
|
|
1429
|
+
prompt: "select_account"
|
|
1430
|
+
});
|
|
1431
|
+
return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
|
|
1432
|
+
return function () {
|
|
1433
|
+
if (response && response.account) {
|
|
1434
|
+
var account = response.account;
|
|
1435
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1436
|
+
var infoLogin = {
|
|
1437
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1438
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1439
|
+
fullName: fullName,
|
|
1440
|
+
imageUrl: "",
|
|
1441
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1442
|
+
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1443
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1444
|
+
role: role,
|
|
1445
|
+
type: TypeLogin.Microsoft
|
|
1446
|
+
};
|
|
1447
|
+
dispatch(setLoading(true));
|
|
1448
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1449
|
+
var _authResult$data2;
|
|
1450
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1451
|
+
dispatch(setLoading(false));
|
|
1452
|
+
alert("Please contact admin.");
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
localStorage.clear();
|
|
1456
|
+
var tokenJWT = authResult.data.token;
|
|
1457
|
+
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1458
|
+
eventName: exports.AmplitudeEvent.LOGIN,
|
|
1459
|
+
eventProperties: {
|
|
1460
|
+
email: email,
|
|
1461
|
+
login_method: 'google',
|
|
1462
|
+
user_role: authResult.data.role,
|
|
1463
|
+
success: true,
|
|
1464
|
+
timestamp: new Date().toISOString()
|
|
1465
|
+
}
|
|
1466
|
+
});
|
|
1467
|
+
if (role === "LandingPage") {
|
|
1468
|
+
CookieService.setAuthCookie({
|
|
1469
|
+
token: tokenJWT,
|
|
1470
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1471
|
+
});
|
|
1472
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1473
|
+
switch (role) {
|
|
1474
|
+
case "Admin":
|
|
1475
|
+
return ADMIN_ORIGIN;
|
|
1476
|
+
case "Teacher":
|
|
1477
|
+
return TEACHER_ORIGIN;
|
|
1478
|
+
default:
|
|
1479
|
+
return role + "." + REQUEST_ORIGIN;
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1483
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
1484
|
+
dispatch(setLoading(false));
|
|
1485
|
+
}
|
|
1486
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1487
|
+
onNavigate("/dashboard");
|
|
1488
|
+
dispatch(setLoading(false));
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
}();
|
|
1492
|
+
});
|
|
1493
|
+
});
|
|
1494
|
+
}, function (error) {
|
|
1495
|
+
console.error("Microsoft login error:", error);
|
|
1496
|
+
}));
|
|
1497
|
+
} catch (e) {
|
|
1498
|
+
return Promise.reject(e);
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1360
1501
|
React__default.useEffect(function () {
|
|
1361
1502
|
return function () {
|
|
1362
1503
|
if (resendTimer) {
|
|
@@ -1464,7 +1605,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1464
1605
|
height: 24,
|
|
1465
1606
|
alt: "Google sign-in",
|
|
1466
1607
|
src: "/images/icons/Google__G__logo.png"
|
|
1467
|
-
}), "Sign in with Google")), React__default.createElement("
|
|
1608
|
+
}), "Sign in with Google")), React__default.createElement("div", {
|
|
1609
|
+
className: "" + styleGlobal["microsoft_button"]
|
|
1610
|
+
}, React__default.createElement("button", {
|
|
1611
|
+
onClick: function onClick() {
|
|
1612
|
+
return fnLoginMicrosoft();
|
|
1613
|
+
}
|
|
1614
|
+
}, React__default.createElement("img", {
|
|
1615
|
+
width: 24,
|
|
1616
|
+
height: 24,
|
|
1617
|
+
alt: "Google sign-in",
|
|
1618
|
+
src: "/images/Single-Sign-On-logo.png"
|
|
1619
|
+
}), "Sign in with Microsoft")), React__default.createElement("span", {
|
|
1468
1620
|
className: "" + styleGlobal["box-field"]
|
|
1469
1621
|
}, "OR"), React__default.createElement("div", {
|
|
1470
1622
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2294,17 +2446,6 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2294
2446
|
}, title)), children);
|
|
2295
2447
|
};
|
|
2296
2448
|
|
|
2297
|
-
var AuthenticationMessage;
|
|
2298
|
-
(function (AuthenticationMessage) {
|
|
2299
|
-
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
2300
|
-
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
2301
|
-
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
2302
|
-
(function (Role) {
|
|
2303
|
-
Role["Student"] = "Student";
|
|
2304
|
-
Role["Teacher"] = "Teacher";
|
|
2305
|
-
Role["Admin"] = "Admin";
|
|
2306
|
-
})(exports.Role || (exports.Role = {}));
|
|
2307
|
-
|
|
2308
2449
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2309
2450
|
var currentPage = _ref.currentPage,
|
|
2310
2451
|
totalPage = _ref.totalPage,
|