acsi-core 0.1.94 → 0.1.95

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.
@@ -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"];
@@ -1223,56 +1223,6 @@ var TypeLogin;
1223
1223
  TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
1224
1224
  })(TypeLogin || (TypeLogin = {}));
1225
1225
 
1226
- var AuthenticationMessage;
1227
- (function (AuthenticationMessage) {
1228
- AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
1229
- AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
1230
- })(AuthenticationMessage || (AuthenticationMessage = {}));
1231
- var Role;
1232
- (function (Role) {
1233
- Role["Student"] = "Student";
1234
- Role["Teacher"] = "Teacher";
1235
- Role["Admin"] = "Admin";
1236
- })(Role || (Role = {}));
1237
- var msalConfig = function msalConfig(clientId, redirectUri) {
1238
- return {
1239
- auth: {
1240
- clientId: clientId,
1241
- authority: "https://login.microsoftonline.com/common",
1242
- redirectUri: redirectUri
1243
- },
1244
- cache: {
1245
- cacheLocation: "sessionStorage",
1246
- storeAuthStateInCookie: false
1247
- },
1248
- system: {
1249
- loggerOptions: {
1250
- loggerCallback: function loggerCallback(level, message, containsPii) {
1251
- if (containsPii) {
1252
- return;
1253
- }
1254
- switch (level) {
1255
- case LogLevel.Error:
1256
- console.error(message);
1257
- return;
1258
- case LogLevel.Info:
1259
- console.info(message);
1260
- return;
1261
- case LogLevel.Verbose:
1262
- console.debug(message);
1263
- return;
1264
- case LogLevel.Warning:
1265
- console.warn(message);
1266
- return;
1267
- default:
1268
- return;
1269
- }
1270
- }
1271
- }
1272
- }
1273
- };
1274
- };
1275
-
1276
1226
  var BlockLogin = function BlockLogin(_ref) {
1277
1227
  var onNavigate = _ref.onNavigate,
1278
1228
  role = _ref.role,
@@ -1407,91 +1357,6 @@ var BlockLogin = function BlockLogin(_ref) {
1407
1357
  return console.log(errorResponse);
1408
1358
  }
1409
1359
  });
1410
- var fnLoginMicrosoft = function fnLoginMicrosoft() {
1411
- try {
1412
- var msalInstance = new PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
1413
- if (!msalInstance) {
1414
- console.error("MSAL instance not initialized");
1415
- return Promise.resolve();
1416
- }
1417
- return Promise.resolve(_catch(function () {
1418
- return Promise.resolve(msalInstance.initialize()).then(function () {
1419
- var loginRequest = {
1420
- scopes: ["openid", "profile", "email"]
1421
- };
1422
- var silentRequest = _extends({}, loginRequest, {
1423
- prompt: "select_account"
1424
- });
1425
- return Promise.resolve(msalInstance.loginPopup(silentRequest)).then(function (response) {
1426
- return function () {
1427
- if (response && response.account) {
1428
- var account = response.account;
1429
- var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
1430
- var infoLogin = {
1431
- firstName: fullName.split(' ').slice(0, -1).join(' '),
1432
- lastName: fullName.split(' ').slice(-1).join(' '),
1433
- fullName: fullName,
1434
- imageUrl: "",
1435
- email: (account === null || account === void 0 ? void 0 : account.username) || "",
1436
- token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
1437
- googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
1438
- role: role,
1439
- type: TypeLogin.Microsoft
1440
- };
1441
- dispatch(setLoading(true));
1442
- return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
1443
- var _authResult$data2;
1444
- if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
1445
- dispatch(setLoading(false));
1446
- alert("Please contact admin.");
1447
- return;
1448
- }
1449
- localStorage.clear();
1450
- var tokenJWT = authResult.data.token;
1451
- trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
1452
- eventName: AmplitudeEvent.LOGIN,
1453
- eventProperties: {
1454
- email: email,
1455
- login_method: 'google',
1456
- user_role: authResult.data.role,
1457
- success: true,
1458
- timestamp: new Date().toISOString()
1459
- }
1460
- });
1461
- if (role === "LandingPage") {
1462
- CookieService.setAuthCookie({
1463
- token: tokenJWT,
1464
- expiresAt: Date.now() + 24 * 60 * 60 * 1000
1465
- });
1466
- var getRedirectUrl = function getRedirectUrl(role) {
1467
- switch (role) {
1468
- case "Admin":
1469
- return ADMIN_ORIGIN;
1470
- case "Teacher":
1471
- return TEACHER_ORIGIN;
1472
- default:
1473
- return role + "." + REQUEST_ORIGIN;
1474
- }
1475
- };
1476
- var redirectUrl = getRedirectUrl(authResult.data.role);
1477
- window.location.href = redirectUrl + "/dashboard";
1478
- dispatch(setLoading(false));
1479
- }
1480
- localStorage.setItem(ACCESS_TOKEN, tokenJWT);
1481
- onNavigate("/dashboard");
1482
- dispatch(setLoading(false));
1483
- });
1484
- }
1485
- }();
1486
- });
1487
- });
1488
- }, function (error) {
1489
- console.error("Microsoft login error:", error);
1490
- }));
1491
- } catch (e) {
1492
- return Promise.reject(e);
1493
- }
1494
- };
1495
1360
  React.useEffect(function () {
1496
1361
  return function () {
1497
1362
  if (resendTimer) {
@@ -1599,18 +1464,7 @@ var BlockLogin = function BlockLogin(_ref) {
1599
1464
  height: 24,
1600
1465
  alt: "Google sign-in",
1601
1466
  src: "/images/icons/Google__G__logo.png"
1602
- }), "Sign in with Google")), React.createElement("div", {
1603
- className: "" + styleGlobal["microsoft_button"]
1604
- }, React.createElement("button", {
1605
- onClick: function onClick() {
1606
- return fnLoginMicrosoft();
1607
- }
1608
- }, React.createElement("img", {
1609
- width: 24,
1610
- height: 24,
1611
- alt: "Google sign-in",
1612
- src: "/images/Single-Sign-On-logo.png"
1613
- }), "Sign in with Microsoft")), React.createElement("span", {
1467
+ }), "Sign in with Google")), React.createElement("span", {
1614
1468
  className: "" + styleGlobal["box-field"]
1615
1469
  }, "OR"), React.createElement("div", {
1616
1470
  className: "" + styleGlobal["box-input"]
@@ -2441,6 +2295,18 @@ var CommonDialog = function CommonDialog(_ref) {
2441
2295
  }, title)), children);
2442
2296
  };
2443
2297
 
2298
+ var AuthenticationMessage;
2299
+ (function (AuthenticationMessage) {
2300
+ AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
2301
+ AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
2302
+ })(AuthenticationMessage || (AuthenticationMessage = {}));
2303
+ var Role;
2304
+ (function (Role) {
2305
+ Role["Student"] = "Student";
2306
+ Role["Teacher"] = "Teacher";
2307
+ Role["Admin"] = "Admin";
2308
+ })(Role || (Role = {}));
2309
+
2444
2310
  var CustomPagination = function CustomPagination(_ref) {
2445
2311
  var currentPage = _ref.currentPage,
2446
2312
  totalPage = _ref.totalPage,