acsi-core 0.1.99 → 0.2.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/index.css +1 -2
- package/dist/index.js +38 -174
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +39 -175
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -11,11 +11,11 @@ import ReactSelect, { components } from 'react-select';
|
|
|
11
11
|
import Cookies from 'js-cookie';
|
|
12
12
|
export { default as Cookies } from 'js-cookie';
|
|
13
13
|
import moment from 'moment';
|
|
14
|
-
import { LogLevel, PublicClientApplication } from '@azure/msal-browser';
|
|
15
14
|
import { toast } from 'react-toastify';
|
|
16
15
|
export { ToastContainer, toast } from 'react-toastify';
|
|
17
16
|
import { useGoogleLogout } from '@leecheuk/react-google-login';
|
|
18
17
|
import { Box, Typography } from '@mui/material';
|
|
18
|
+
import '@azure/msal-browser';
|
|
19
19
|
import { Identify, identify, track, setUserId, reset as reset$1, init } from '@amplitude/analytics-browser';
|
|
20
20
|
import { init as init$1 } from '@sentry/react';
|
|
21
21
|
import { FaCaretDown } from 'react-icons/fa';
|
|
@@ -79,25 +79,6 @@ var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
|
79
79
|
|
|
80
80
|
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"};
|
|
81
81
|
|
|
82
|
-
function _extends() {
|
|
83
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
84
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
85
|
-
var t = arguments[e];
|
|
86
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
87
|
-
}
|
|
88
|
-
return n;
|
|
89
|
-
}, _extends.apply(null, arguments);
|
|
90
|
-
}
|
|
91
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
92
|
-
if (null == r) return {};
|
|
93
|
-
var t = {};
|
|
94
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
95
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
96
|
-
t[n] = r[n];
|
|
97
|
-
}
|
|
98
|
-
return t;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
82
|
// A type of promise-like that resolves synchronously and supports only one observer
|
|
102
83
|
|
|
103
84
|
const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
|
|
@@ -117,6 +98,25 @@ function _catch(body, recover) {
|
|
|
117
98
|
return result;
|
|
118
99
|
}
|
|
119
100
|
|
|
101
|
+
function _extends() {
|
|
102
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
103
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
104
|
+
var t = arguments[e];
|
|
105
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
106
|
+
}
|
|
107
|
+
return n;
|
|
108
|
+
}, _extends.apply(null, arguments);
|
|
109
|
+
}
|
|
110
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
111
|
+
if (null == r) return {};
|
|
112
|
+
var t = {};
|
|
113
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
114
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
115
|
+
t[n] = r[n];
|
|
116
|
+
}
|
|
117
|
+
return t;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
120
|
var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
|
|
121
121
|
|
|
122
122
|
var _excluded = ["type", "children", "onClick", "icon", "disabled", "htmlType"];
|
|
@@ -412,10 +412,7 @@ var CoreInput$1 = function CoreInput(props) {
|
|
|
412
412
|
className: "" + styles$4["core-checkbox"]
|
|
413
413
|
}, React.createElement(FormGroup, {
|
|
414
414
|
check: true,
|
|
415
|
-
|
|
416
|
-
display: "flex",
|
|
417
|
-
alignItems: "center"
|
|
418
|
-
}
|
|
415
|
+
inline: true
|
|
419
416
|
}, React.createElement(Input, {
|
|
420
417
|
id: "core-checkbox-" + name,
|
|
421
418
|
type: "checkbox",
|
|
@@ -425,10 +422,11 @@ var CoreInput$1 = function CoreInput(props) {
|
|
|
425
422
|
return _onChange === null || _onChange === void 0 ? void 0 : _onChange(name, e.target.checked);
|
|
426
423
|
},
|
|
427
424
|
disabled: disabled
|
|
428
|
-
}), React.createElement(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
425
|
+
}), React.createElement(Label, {
|
|
426
|
+
htmlFor: "core-checkbox-" + name,
|
|
427
|
+
check: true,
|
|
428
|
+
cssModule: {
|
|
429
|
+
marginTop: '0px'
|
|
432
430
|
}
|
|
433
431
|
}, label)));
|
|
434
432
|
};
|
|
@@ -1230,56 +1228,6 @@ var TypeLogin;
|
|
|
1230
1228
|
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
1231
1229
|
})(TypeLogin || (TypeLogin = {}));
|
|
1232
1230
|
|
|
1233
|
-
var AuthenticationMessage;
|
|
1234
|
-
(function (AuthenticationMessage) {
|
|
1235
|
-
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
1236
|
-
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
1237
|
-
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
1238
|
-
var Role;
|
|
1239
|
-
(function (Role) {
|
|
1240
|
-
Role["Student"] = "Student";
|
|
1241
|
-
Role["Teacher"] = "Teacher";
|
|
1242
|
-
Role["Admin"] = "Admin";
|
|
1243
|
-
})(Role || (Role = {}));
|
|
1244
|
-
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
1245
|
-
return {
|
|
1246
|
-
auth: {
|
|
1247
|
-
clientId: clientId,
|
|
1248
|
-
authority: "https://login.microsoftonline.com/common",
|
|
1249
|
-
redirectUri: redirectUri
|
|
1250
|
-
},
|
|
1251
|
-
cache: {
|
|
1252
|
-
cacheLocation: "sessionStorage",
|
|
1253
|
-
storeAuthStateInCookie: false
|
|
1254
|
-
},
|
|
1255
|
-
system: {
|
|
1256
|
-
loggerOptions: {
|
|
1257
|
-
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
1258
|
-
if (containsPii) {
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
switch (level) {
|
|
1262
|
-
case LogLevel.Error:
|
|
1263
|
-
console.error(message);
|
|
1264
|
-
return;
|
|
1265
|
-
case LogLevel.Info:
|
|
1266
|
-
console.info(message);
|
|
1267
|
-
return;
|
|
1268
|
-
case LogLevel.Verbose:
|
|
1269
|
-
console.debug(message);
|
|
1270
|
-
return;
|
|
1271
|
-
case LogLevel.Warning:
|
|
1272
|
-
console.warn(message);
|
|
1273
|
-
return;
|
|
1274
|
-
default:
|
|
1275
|
-
return;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
1231
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1284
1232
|
var onNavigate = _ref.onNavigate,
|
|
1285
1233
|
role = _ref.role,
|
|
@@ -1414,91 +1362,6 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1414
1362
|
return console.log(errorResponse);
|
|
1415
1363
|
}
|
|
1416
1364
|
});
|
|
1417
|
-
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
1418
|
-
try {
|
|
1419
|
-
var msalInstance = new PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1420
|
-
if (!msalInstance) {
|
|
1421
|
-
console.error("MSAL instance not initialized");
|
|
1422
|
-
return Promise.resolve();
|
|
1423
|
-
}
|
|
1424
|
-
return Promise.resolve(_catch(function () {
|
|
1425
|
-
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
1426
|
-
var loginRequest = {
|
|
1427
|
-
scopes: ["openid", "profile", "email"]
|
|
1428
|
-
};
|
|
1429
|
-
var silentRequest = _extends({}, loginRequest, {
|
|
1430
|
-
prompt: "select_account"
|
|
1431
|
-
});
|
|
1432
|
-
return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
|
|
1433
|
-
return function () {
|
|
1434
|
-
if (response && response.account) {
|
|
1435
|
-
var account = response.account;
|
|
1436
|
-
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1437
|
-
var infoLogin = {
|
|
1438
|
-
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1439
|
-
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1440
|
-
fullName: fullName,
|
|
1441
|
-
imageUrl: "",
|
|
1442
|
-
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1443
|
-
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1444
|
-
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1445
|
-
role: role,
|
|
1446
|
-
type: TypeLogin.Microsoft
|
|
1447
|
-
};
|
|
1448
|
-
dispatch(setLoading(true));
|
|
1449
|
-
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1450
|
-
var _authResult$data2;
|
|
1451
|
-
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1452
|
-
dispatch(setLoading(false));
|
|
1453
|
-
alert("Please contact admin.");
|
|
1454
|
-
return;
|
|
1455
|
-
}
|
|
1456
|
-
localStorage.clear();
|
|
1457
|
-
var tokenJWT = authResult.data.token;
|
|
1458
|
-
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1459
|
-
eventName: AmplitudeEvent.LOGIN,
|
|
1460
|
-
eventProperties: {
|
|
1461
|
-
email: email,
|
|
1462
|
-
login_method: 'google',
|
|
1463
|
-
user_role: authResult.data.role,
|
|
1464
|
-
success: true,
|
|
1465
|
-
timestamp: new Date().toISOString()
|
|
1466
|
-
}
|
|
1467
|
-
});
|
|
1468
|
-
if (role === "LandingPage") {
|
|
1469
|
-
CookieService.setAuthCookie({
|
|
1470
|
-
token: tokenJWT,
|
|
1471
|
-
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1472
|
-
});
|
|
1473
|
-
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1474
|
-
switch (role) {
|
|
1475
|
-
case "Admin":
|
|
1476
|
-
return ADMIN_ORIGIN;
|
|
1477
|
-
case "Teacher":
|
|
1478
|
-
return TEACHER_ORIGIN;
|
|
1479
|
-
default:
|
|
1480
|
-
return role + "." + REQUEST_ORIGIN;
|
|
1481
|
-
}
|
|
1482
|
-
};
|
|
1483
|
-
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1484
|
-
window.location.href = redirectUrl + "/dashboard";
|
|
1485
|
-
dispatch(setLoading(false));
|
|
1486
|
-
}
|
|
1487
|
-
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1488
|
-
onNavigate("/dashboard");
|
|
1489
|
-
dispatch(setLoading(false));
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
}();
|
|
1493
|
-
});
|
|
1494
|
-
});
|
|
1495
|
-
}, function (error) {
|
|
1496
|
-
console.error("Microsoft login error:", error);
|
|
1497
|
-
}));
|
|
1498
|
-
} catch (e) {
|
|
1499
|
-
return Promise.reject(e);
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
1365
|
React.useEffect(function () {
|
|
1503
1366
|
return function () {
|
|
1504
1367
|
if (resendTimer) {
|
|
@@ -1606,18 +1469,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1606
1469
|
height: 24,
|
|
1607
1470
|
alt: "Google sign-in",
|
|
1608
1471
|
src: "/images/icons/Google__G__logo.png"
|
|
1609
|
-
}), "Sign in with Google")), React.createElement("
|
|
1610
|
-
className: "" + styleGlobal["microsoft_button"]
|
|
1611
|
-
}, React.createElement("button", {
|
|
1612
|
-
onClick: function onClick() {
|
|
1613
|
-
return fnLoginMicrosoft();
|
|
1614
|
-
}
|
|
1615
|
-
}, React.createElement("img", {
|
|
1616
|
-
width: 24,
|
|
1617
|
-
height: 24,
|
|
1618
|
-
alt: "Google sign-in",
|
|
1619
|
-
src: "/images/Single-Sign-On-logo.png"
|
|
1620
|
-
}), "Sign in with Microsoft")), React.createElement("span", {
|
|
1472
|
+
}), "Sign in with Google")), React.createElement("span", {
|
|
1621
1473
|
className: "" + styleGlobal["box-field"]
|
|
1622
1474
|
}, "OR"), React.createElement("div", {
|
|
1623
1475
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2448,6 +2300,18 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2448
2300
|
}, title)), children);
|
|
2449
2301
|
};
|
|
2450
2302
|
|
|
2303
|
+
var AuthenticationMessage;
|
|
2304
|
+
(function (AuthenticationMessage) {
|
|
2305
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
2306
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
2307
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
2308
|
+
var Role;
|
|
2309
|
+
(function (Role) {
|
|
2310
|
+
Role["Student"] = "Student";
|
|
2311
|
+
Role["Teacher"] = "Teacher";
|
|
2312
|
+
Role["Admin"] = "Admin";
|
|
2313
|
+
})(Role || (Role = {}));
|
|
2314
|
+
|
|
2451
2315
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2452
2316
|
var currentPage = _ref.currentPage,
|
|
2453
2317
|
totalPage = _ref.totalPage,
|