acsi-core 0.1.97 → 0.1.98
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 +172 -36
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +173 -37
- 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"];
|
|
@@ -774,7 +774,8 @@ var CoreSelectCompact = function CoreSelectCompact(props) {
|
|
|
774
774
|
isShowDropdown = _props$isShowDropdown === void 0 ? false : _props$isShowDropdown,
|
|
775
775
|
_props$error = props.error,
|
|
776
776
|
error = _props$error === void 0 ? false : _props$error,
|
|
777
|
-
_noOptionsMessage = props.noOptionsMessage
|
|
777
|
+
_noOptionsMessage = props.noOptionsMessage,
|
|
778
|
+
border = props.border;
|
|
778
779
|
var handleChange = function handleChange(value) {
|
|
779
780
|
var newValue = isMulti ? value === null || value === void 0 ? void 0 : value.map(function (item) {
|
|
780
781
|
return item.value;
|
|
@@ -785,11 +786,12 @@ var CoreSelectCompact = function CoreSelectCompact(props) {
|
|
|
785
786
|
var styles = _extends({}, base, {
|
|
786
787
|
fontSize: "14px",
|
|
787
788
|
fontWeight: "400",
|
|
788
|
-
padding: "0",
|
|
789
789
|
backgroundColor: state.isDisabled ? "transparent" : error ? COLORS.lightYellow : COLORS.white,
|
|
790
|
-
border: "none",
|
|
790
|
+
border: border ? state.isFocused ? "2px solid " + (!error ? COLORS.brandBlue : COLORS.red) : "1px solid " + (!error ? COLORS.grayLines : COLORS.red) : "none",
|
|
791
|
+
borderRadius: border ? "8px" : undefined,
|
|
791
792
|
height: isMulti ? undefined : "26px",
|
|
792
|
-
minHeight: "
|
|
793
|
+
minHeight: "32px",
|
|
794
|
+
padding: border ? "4px 11px" : 0,
|
|
793
795
|
boxShadow: "none",
|
|
794
796
|
cursor: "pointer",
|
|
795
797
|
"&:hover": {
|
|
@@ -1223,6 +1225,55 @@ var TypeLogin;
|
|
|
1223
1225
|
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
1224
1226
|
})(TypeLogin || (TypeLogin = {}));
|
|
1225
1227
|
|
|
1228
|
+
var AuthenticationMessage;
|
|
1229
|
+
(function (AuthenticationMessage) {
|
|
1230
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
1231
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
1232
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
1233
|
+
(function (Role) {
|
|
1234
|
+
Role["Student"] = "Student";
|
|
1235
|
+
Role["Teacher"] = "Teacher";
|
|
1236
|
+
Role["Admin"] = "Admin";
|
|
1237
|
+
})(exports.Role || (exports.Role = {}));
|
|
1238
|
+
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
1239
|
+
return {
|
|
1240
|
+
auth: {
|
|
1241
|
+
clientId: clientId,
|
|
1242
|
+
authority: "https://login.microsoftonline.com/common",
|
|
1243
|
+
redirectUri: redirectUri
|
|
1244
|
+
},
|
|
1245
|
+
cache: {
|
|
1246
|
+
cacheLocation: "sessionStorage",
|
|
1247
|
+
storeAuthStateInCookie: false
|
|
1248
|
+
},
|
|
1249
|
+
system: {
|
|
1250
|
+
loggerOptions: {
|
|
1251
|
+
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
1252
|
+
if (containsPii) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
switch (level) {
|
|
1256
|
+
case msalBrowser.LogLevel.Error:
|
|
1257
|
+
console.error(message);
|
|
1258
|
+
return;
|
|
1259
|
+
case msalBrowser.LogLevel.Info:
|
|
1260
|
+
console.info(message);
|
|
1261
|
+
return;
|
|
1262
|
+
case msalBrowser.LogLevel.Verbose:
|
|
1263
|
+
console.debug(message);
|
|
1264
|
+
return;
|
|
1265
|
+
case msalBrowser.LogLevel.Warning:
|
|
1266
|
+
console.warn(message);
|
|
1267
|
+
return;
|
|
1268
|
+
default:
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1226
1277
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1227
1278
|
var onNavigate = _ref.onNavigate,
|
|
1228
1279
|
role = _ref.role,
|
|
@@ -1357,6 +1408,91 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1357
1408
|
return console.log(errorResponse);
|
|
1358
1409
|
}
|
|
1359
1410
|
});
|
|
1411
|
+
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
1412
|
+
try {
|
|
1413
|
+
var msalInstance = new msalBrowser.PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1414
|
+
if (!msalInstance) {
|
|
1415
|
+
console.error("MSAL instance not initialized");
|
|
1416
|
+
return Promise.resolve();
|
|
1417
|
+
}
|
|
1418
|
+
return Promise.resolve(_catch(function () {
|
|
1419
|
+
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
1420
|
+
var loginRequest = {
|
|
1421
|
+
scopes: ["openid", "profile", "email"]
|
|
1422
|
+
};
|
|
1423
|
+
var silentRequest = _extends({}, loginRequest, {
|
|
1424
|
+
prompt: "select_account"
|
|
1425
|
+
});
|
|
1426
|
+
return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
|
|
1427
|
+
return function () {
|
|
1428
|
+
if (response && response.account) {
|
|
1429
|
+
var account = response.account;
|
|
1430
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1431
|
+
var infoLogin = {
|
|
1432
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1433
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1434
|
+
fullName: fullName,
|
|
1435
|
+
imageUrl: "",
|
|
1436
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1437
|
+
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1438
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1439
|
+
role: role,
|
|
1440
|
+
type: TypeLogin.Microsoft
|
|
1441
|
+
};
|
|
1442
|
+
dispatch(setLoading(true));
|
|
1443
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1444
|
+
var _authResult$data2;
|
|
1445
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1446
|
+
dispatch(setLoading(false));
|
|
1447
|
+
alert("Please contact admin.");
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
localStorage.clear();
|
|
1451
|
+
var tokenJWT = authResult.data.token;
|
|
1452
|
+
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1453
|
+
eventName: exports.AmplitudeEvent.LOGIN,
|
|
1454
|
+
eventProperties: {
|
|
1455
|
+
email: email,
|
|
1456
|
+
login_method: 'google',
|
|
1457
|
+
user_role: authResult.data.role,
|
|
1458
|
+
success: true,
|
|
1459
|
+
timestamp: new Date().toISOString()
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
if (role === "LandingPage") {
|
|
1463
|
+
CookieService.setAuthCookie({
|
|
1464
|
+
token: tokenJWT,
|
|
1465
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1466
|
+
});
|
|
1467
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1468
|
+
switch (role) {
|
|
1469
|
+
case "Admin":
|
|
1470
|
+
return ADMIN_ORIGIN;
|
|
1471
|
+
case "Teacher":
|
|
1472
|
+
return TEACHER_ORIGIN;
|
|
1473
|
+
default:
|
|
1474
|
+
return role + "." + REQUEST_ORIGIN;
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1478
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
1479
|
+
dispatch(setLoading(false));
|
|
1480
|
+
}
|
|
1481
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1482
|
+
onNavigate("/dashboard");
|
|
1483
|
+
dispatch(setLoading(false));
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
}();
|
|
1487
|
+
});
|
|
1488
|
+
});
|
|
1489
|
+
}, function (error) {
|
|
1490
|
+
console.error("Microsoft login error:", error);
|
|
1491
|
+
}));
|
|
1492
|
+
} catch (e) {
|
|
1493
|
+
return Promise.reject(e);
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1360
1496
|
React__default.useEffect(function () {
|
|
1361
1497
|
return function () {
|
|
1362
1498
|
if (resendTimer) {
|
|
@@ -1464,7 +1600,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1464
1600
|
height: 24,
|
|
1465
1601
|
alt: "Google sign-in",
|
|
1466
1602
|
src: "/images/icons/Google__G__logo.png"
|
|
1467
|
-
}), "Sign in with Google")), React__default.createElement("
|
|
1603
|
+
}), "Sign in with Google")), React__default.createElement("div", {
|
|
1604
|
+
className: "" + styleGlobal["microsoft_button"]
|
|
1605
|
+
}, React__default.createElement("button", {
|
|
1606
|
+
onClick: function onClick() {
|
|
1607
|
+
return fnLoginMicrosoft();
|
|
1608
|
+
}
|
|
1609
|
+
}, React__default.createElement("img", {
|
|
1610
|
+
width: 24,
|
|
1611
|
+
height: 24,
|
|
1612
|
+
alt: "Google sign-in",
|
|
1613
|
+
src: "/images/Single-Sign-On-logo.png"
|
|
1614
|
+
}), "Sign in with Microsoft")), React__default.createElement("span", {
|
|
1468
1615
|
className: "" + styleGlobal["box-field"]
|
|
1469
1616
|
}, "OR"), React__default.createElement("div", {
|
|
1470
1617
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2294,17 +2441,6 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2294
2441
|
}, title)), children);
|
|
2295
2442
|
};
|
|
2296
2443
|
|
|
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
2444
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2309
2445
|
var currentPage = _ref.currentPage,
|
|
2310
2446
|
totalPage = _ref.totalPage,
|