acsi-core 1.2.19 → 1.2.21

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