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