acsi-core 1.2.19 → 1.2.22

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.js CHANGED
@@ -2485,7 +2485,6 @@ var useLogin = function useLogin(onNavigate, trackEvent) {
2485
2485
  if (data.success) {
2486
2486
  localStorage.clear();
2487
2487
  var tokenJWT = data.data.token;
2488
- localStorage.setItem(ACCESS_TOKEN, tokenJWT);
2489
2488
  trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
2490
2489
  eventName: exports.AmplitudeEvent.LOGIN,
2491
2490
  eventProperties: {
@@ -2494,7 +2493,22 @@ var useLogin = function useLogin(onNavigate, trackEvent) {
2494
2493
  timestamp: new Date().toISOString()
2495
2494
  }
2496
2495
  });
2497
- onNavigate("/dashboard");
2496
+ var isRootDomain = window.location.hostname === REQUEST_ORIGIN || window.location.hostname === "www." + REQUEST_ORIGIN;
2497
+ if (isRootDomain) {
2498
+ var _data$data$roles;
2499
+ CookieService.setAuthCookie({
2500
+ token: tokenJWT,
2501
+ expiresAt: Date.now() + 24 * 60 * 60 * 1000
2502
+ });
2503
+ var domain = TEACHER_ORIGIN;
2504
+ if ((_data$data$roles = data.data.roles) !== null && _data$data$roles !== void 0 && _data$data$roles.includes("Admin")) {
2505
+ domain = ADMIN_ORIGIN;
2506
+ }
2507
+ window.location.href = domain + "/dashboard";
2508
+ } else {
2509
+ localStorage.setItem(ACCESS_TOKEN, tokenJWT);
2510
+ onNavigate("/dashboard");
2511
+ }
2498
2512
  } else {
2499
2513
  reactToastify.toast.error("The code is not correct. Please check again.");
2500
2514
  }
@@ -3498,25 +3512,43 @@ var CustomSelectOption = function CustomSelectOption(_ref) {
3498
3512
  }, rest));
3499
3513
  };
3500
3514
 
3515
+ var isDateOnlyFormat = function isDateOnlyFormat(fmt) {
3516
+ return !/[Hhms]/.test(fmt);
3517
+ };
3518
+ var parseOffsetToMinutes = function parseOffsetToMinutes(cleanOffset) {
3519
+ if (/^[+-]?\d+$/.test(cleanOffset)) {
3520
+ return parseInt(cleanOffset, 10) * 60;
3521
+ }
3522
+ return moment().utcOffset(cleanOffset).utcOffset();
3523
+ };
3501
3524
  var utcToLocalTime = (function (time, FORMAT) {
3502
3525
  if (time === DATE_MIN_VALUE || time == null) return "";
3503
3526
  var timezone = localStorage.getItem(TIMEZONE_ID) || "";
3527
+ var fmt = FORMAT || "yyyy-MM-DD";
3504
3528
  try {
3505
3529
  if (!timezone) {
3506
- return moment.utc(time).local().format(FORMAT || "yyyy-MM-DD");
3530
+ if (isDateOnlyFormat(fmt)) {
3531
+ var localOffset = moment().utcOffset();
3532
+ if (localOffset <= 0) return moment.utc(time).format(fmt);
3533
+ }
3534
+ return moment.utc(time).local().format(fmt);
3507
3535
  }
3508
3536
  var isOffset = /^(UTC|GMT)?[+-]/.test(timezone);
3509
3537
  if (isOffset) {
3510
3538
  var cleanOffset = timezone.replace(/UTC|GMT/gi, "").trim();
3511
- var offsetMinutes;
3512
- if (/^[+-]?\d+$/.test(cleanOffset)) {
3513
- offsetMinutes = parseInt(cleanOffset, 10) * 60;
3514
- } else {
3515
- offsetMinutes = cleanOffset;
3539
+ var offsetMinutes = parseOffsetToMinutes(cleanOffset);
3540
+ if (isDateOnlyFormat(fmt) && offsetMinutes <= 0) {
3541
+ return moment.utc(time).format(fmt);
3542
+ }
3543
+ return moment.utc(time).utcOffset(offsetMinutes).format(fmt);
3544
+ }
3545
+ if (isDateOnlyFormat(fmt)) {
3546
+ var tzOffset = moment.utc(time).tz(timezone).utcOffset();
3547
+ if (tzOffset <= 0) {
3548
+ return moment.utc(time).format(fmt);
3516
3549
  }
3517
- return moment.utc(time).utcOffset(offsetMinutes).format(FORMAT || "yyyy-MM-DD");
3518
3550
  }
3519
- return moment.utc(time).tz(timezone).format(FORMAT || "yyyy-MM-DD");
3551
+ return moment.utc(time).tz(timezone).format(fmt);
3520
3552
  } catch (_unused) {
3521
3553
  return "";
3522
3554
  }