jett.admin.npmpackage 2.0.31 → 2.0.33

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
@@ -843,6 +843,30 @@ var encryptForSwitchProfile = (plainText) => {
843
843
  };
844
844
 
845
845
  // src/utils/switchProfileApi.js
846
+ var PROFILE_SWITCH_FLAG_KEY = "jett_profile_switch_done";
847
+ var hasSwitchedProfileThisSession = () => {
848
+ try {
849
+ return typeof localStorage !== "undefined" && localStorage.getItem(PROFILE_SWITCH_FLAG_KEY) === "true";
850
+ } catch {
851
+ return false;
852
+ }
853
+ };
854
+ var markProfileSwitched = () => {
855
+ try {
856
+ if (typeof localStorage !== "undefined") {
857
+ localStorage.setItem(PROFILE_SWITCH_FLAG_KEY, "true");
858
+ }
859
+ } catch {
860
+ }
861
+ };
862
+ var clearProfileSwitchFlag = () => {
863
+ try {
864
+ if (typeof localStorage !== "undefined") {
865
+ localStorage.removeItem(PROFILE_SWITCH_FLAG_KEY);
866
+ }
867
+ } catch {
868
+ }
869
+ };
846
870
  var buildRequestContext = () => ({
847
871
  UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
848
872
  TrackingId: crypto.randomUUID(),
@@ -852,6 +876,7 @@ var buildRequestContext = () => ({
852
876
  // Client IP cannot be retrieved from browser
853
877
  });
854
878
  var switchProfile = async (profile) => {
879
+ markProfileSwitched();
855
880
  const encryptedRequest = encryptForSwitchProfile(
856
881
  JSON.stringify({
857
882
  ProfileToken: profile.ProfileToken,
@@ -941,11 +966,9 @@ var SwitchProfileSection = ({
941
966
  const jettIdData = getJettIdCookieData();
942
967
  const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
943
968
  const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
944
- const cookieProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
969
+ const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
945
970
  const allMarkets = getProfilesFromJettIdCookie(true);
946
- const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: cookieProfileId, EntityName: jettIdData.EntityName }] : [];
947
- const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
948
- const currentProfileId = tmcProfile ? tmcProfile.ProfileId : cookieProfileId;
971
+ const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
949
972
  const handleProfileSwitch = async (profile) => {
950
973
  var _a, _b, _c;
951
974
  if (switchingProfileId) return;
@@ -1189,6 +1212,7 @@ var AppSideBar = ({
1189
1212
  }
1190
1213
  }, []);
1191
1214
  (0, import_react14.useEffect)(() => {
1215
+ if (hasSwitchedProfileThisSession()) return;
1192
1216
  const jettIdData = getJettIdCookieData();
1193
1217
  const allProfiles = getProfilesFromJettIdCookie(true);
1194
1218
  if (allProfiles.length <= 1) return;
@@ -1573,6 +1597,7 @@ var AppSideBar = ({
1573
1597
  },
1574
1598
  onLogout: () => {
1575
1599
  setIsSwitchProfileOpen(false);
1600
+ clearProfileSwitchFlag();
1576
1601
  if (onLogout) {
1577
1602
  onLogout();
1578
1603
  } else {
package/dist/index.mjs CHANGED
@@ -809,6 +809,30 @@ var encryptForSwitchProfile = (plainText) => {
809
809
  };
810
810
 
811
811
  // src/utils/switchProfileApi.js
812
+ var PROFILE_SWITCH_FLAG_KEY = "jett_profile_switch_done";
813
+ var hasSwitchedProfileThisSession = () => {
814
+ try {
815
+ return typeof localStorage !== "undefined" && localStorage.getItem(PROFILE_SWITCH_FLAG_KEY) === "true";
816
+ } catch {
817
+ return false;
818
+ }
819
+ };
820
+ var markProfileSwitched = () => {
821
+ try {
822
+ if (typeof localStorage !== "undefined") {
823
+ localStorage.setItem(PROFILE_SWITCH_FLAG_KEY, "true");
824
+ }
825
+ } catch {
826
+ }
827
+ };
828
+ var clearProfileSwitchFlag = () => {
829
+ try {
830
+ if (typeof localStorage !== "undefined") {
831
+ localStorage.removeItem(PROFILE_SWITCH_FLAG_KEY);
832
+ }
833
+ } catch {
834
+ }
835
+ };
812
836
  var buildRequestContext = () => ({
813
837
  UserAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Mozilla/5.0",
814
838
  TrackingId: crypto.randomUUID(),
@@ -818,6 +842,7 @@ var buildRequestContext = () => ({
818
842
  // Client IP cannot be retrieved from browser
819
843
  });
820
844
  var switchProfile = async (profile) => {
845
+ markProfileSwitched();
821
846
  const encryptedRequest = encryptForSwitchProfile(
822
847
  JSON.stringify({
823
848
  ProfileToken: profile.ProfileToken,
@@ -907,11 +932,9 @@ var SwitchProfileSection = ({
907
932
  const jettIdData = getJettIdCookieData();
908
933
  const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
909
934
  const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
910
- const cookieProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
935
+ const currentProfileId = jettIdData == null ? void 0 : jettIdData.ProfileId;
911
936
  const allMarkets = getProfilesFromJettIdCookie(true);
912
- const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: cookieProfileId, EntityName: jettIdData.EntityName }] : [];
913
- const tmcProfile = allMarkets.find((profile) => profile.Scope === "TMC");
914
- const currentProfileId = tmcProfile ? tmcProfile.ProfileId : cookieProfileId;
937
+ const markets = allMarkets.length ? allMarkets : (jettIdData == null ? void 0 : jettIdData.EntityName) ? [{ ProfileId: currentProfileId, EntityName: jettIdData.EntityName }] : [];
915
938
  const handleProfileSwitch = async (profile) => {
916
939
  var _a, _b, _c;
917
940
  if (switchingProfileId) return;
@@ -1155,6 +1178,7 @@ var AppSideBar = ({
1155
1178
  }
1156
1179
  }, []);
1157
1180
  useEffect2(() => {
1181
+ if (hasSwitchedProfileThisSession()) return;
1158
1182
  const jettIdData = getJettIdCookieData();
1159
1183
  const allProfiles = getProfilesFromJettIdCookie(true);
1160
1184
  if (allProfiles.length <= 1) return;
@@ -1539,6 +1563,7 @@ var AppSideBar = ({
1539
1563
  },
1540
1564
  onLogout: () => {
1541
1565
  setIsSwitchProfileOpen(false);
1566
+ clearProfileSwitchFlag();
1542
1567
  if (onLogout) {
1543
1568
  onLogout();
1544
1569
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jett.admin.npmpackage",
3
- "version": "2.0.31",
3
+ "version": "2.0.33",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "exports": {