jett.admin.npmpackage 1.0.92 → 1.0.94
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 +126 -17
- package/dist/index.mjs +126 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -795,31 +795,119 @@ var AppSideBar = ({
|
|
|
795
795
|
const extractUrlFromOnClick = (onClick) => {
|
|
796
796
|
if (!onClick || typeof onClick !== "function") return null;
|
|
797
797
|
const funcString = onClick.toString();
|
|
798
|
-
|
|
798
|
+
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
799
|
+
if (!match) {
|
|
800
|
+
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
801
|
+
}
|
|
799
802
|
if (match && match[1]) {
|
|
800
803
|
try {
|
|
801
804
|
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
802
805
|
const url = new URL(match[1]);
|
|
803
|
-
return
|
|
806
|
+
return {
|
|
807
|
+
pathname: url.pathname,
|
|
808
|
+
search: url.search,
|
|
809
|
+
fullPath: url.pathname + url.search
|
|
810
|
+
};
|
|
804
811
|
}
|
|
805
812
|
if (match[1].startsWith("/")) {
|
|
806
813
|
const url = new URL(match[1], window.location.origin);
|
|
807
|
-
return
|
|
814
|
+
return {
|
|
815
|
+
pathname: url.pathname,
|
|
816
|
+
search: url.search,
|
|
817
|
+
fullPath: url.pathname + url.search
|
|
818
|
+
};
|
|
808
819
|
}
|
|
809
820
|
return null;
|
|
810
821
|
} catch {
|
|
811
|
-
const pathMatch = match[1].match(/^([^?]+)
|
|
812
|
-
|
|
822
|
+
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
823
|
+
if (pathMatch) {
|
|
824
|
+
return {
|
|
825
|
+
pathname: pathMatch[1],
|
|
826
|
+
search: pathMatch[2] || "",
|
|
827
|
+
fullPath: match[1]
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
return null;
|
|
813
831
|
}
|
|
814
832
|
}
|
|
815
833
|
return null;
|
|
816
834
|
};
|
|
817
|
-
const
|
|
818
|
-
if (!
|
|
819
|
-
const
|
|
835
|
+
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
836
|
+
if (!menuUrlData || !currentPath) return false;
|
|
837
|
+
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
820
838
|
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
821
|
-
if (
|
|
822
|
-
|
|
839
|
+
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
840
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
841
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
842
|
+
const menuRole = menuParams.get("role");
|
|
843
|
+
const currentRole = currentParams.get("role");
|
|
844
|
+
if (menuRole && currentRole) {
|
|
845
|
+
return menuRole === currentRole;
|
|
846
|
+
}
|
|
847
|
+
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
855
|
+
if (normalizedMenuPath === "/trips") {
|
|
856
|
+
if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
|
|
857
|
+
return true;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
|
|
861
|
+
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
862
|
+
if (menuPathParam) {
|
|
863
|
+
const pathRouteMap = {
|
|
864
|
+
"offer": "/offer/offer",
|
|
865
|
+
"voucher": "/voucher/voucher",
|
|
866
|
+
"tag": "/tags/tags",
|
|
867
|
+
"special-requests": "/corporate/special-requests",
|
|
868
|
+
"pricing-policy": "/policies/pricing-policy",
|
|
869
|
+
"users": "/users/users"
|
|
870
|
+
// Consumer Ecosystem Users (no role param)
|
|
871
|
+
};
|
|
872
|
+
const expectedRoute = pathRouteMap[menuPathParam];
|
|
873
|
+
if (expectedRoute) {
|
|
874
|
+
if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
|
|
875
|
+
if (menuPathParam === "users") {
|
|
876
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
877
|
+
const currentRole = currentParams.get("role");
|
|
878
|
+
return currentRole !== "admin";
|
|
879
|
+
}
|
|
880
|
+
return true;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (normalizedCurrentPath === "/orgselector") {
|
|
885
|
+
const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
|
|
886
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
887
|
+
if (menuPathParam2 && currentPathParam) {
|
|
888
|
+
return menuPathParam2 === currentPathParam;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
893
|
+
if (menuUrlData.search) {
|
|
894
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
895
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
896
|
+
for (const [key, value] of menuParams.entries()) {
|
|
897
|
+
if (key === "auth") {
|
|
898
|
+
continue;
|
|
899
|
+
}
|
|
900
|
+
if (currentParams.get(key) !== value) {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return true;
|
|
905
|
+
}
|
|
906
|
+
return true;
|
|
907
|
+
}
|
|
908
|
+
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
909
|
+
return true;
|
|
910
|
+
}
|
|
823
911
|
return false;
|
|
824
912
|
};
|
|
825
913
|
const navItemsLocal = navItems ?? navItemsConstant;
|
|
@@ -827,27 +915,28 @@ var AppSideBar = ({
|
|
|
827
915
|
const sideBarLogoLocal = sideBarLogo ?? logo_white_default;
|
|
828
916
|
const detectAndSetActiveMenu = (0, import_react12.useCallback)(() => {
|
|
829
917
|
const currentPath = window.location.pathname;
|
|
918
|
+
const currentSearch = window.location.search;
|
|
830
919
|
const newOpenMenus = /* @__PURE__ */ new Set();
|
|
831
920
|
let foundActivePath = null;
|
|
832
921
|
navItemsLocal.forEach((item, index) => {
|
|
833
922
|
if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
|
|
834
|
-
const
|
|
835
|
-
if (
|
|
923
|
+
const itemUrlData = extractUrlFromOnClick(item.onClick);
|
|
924
|
+
if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
|
|
836
925
|
foundActivePath = `menu-${index}`;
|
|
837
926
|
}
|
|
838
927
|
}
|
|
839
928
|
if (item.options && item.options.length > 0) {
|
|
840
929
|
item.options.forEach((option, optionsIndex) => {
|
|
841
930
|
if (option.onClick && typeof option.onClick === "function") {
|
|
842
|
-
const
|
|
843
|
-
if (
|
|
931
|
+
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
932
|
+
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
844
933
|
const menuKey = `menu-${index}`;
|
|
845
934
|
newOpenMenus.add(menuKey);
|
|
846
935
|
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
847
936
|
if (option.options && option.options.length > 0) {
|
|
848
937
|
option.options.forEach((subOption, subIndex) => {
|
|
849
|
-
const
|
|
850
|
-
if (
|
|
938
|
+
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
939
|
+
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
851
940
|
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
852
941
|
newOpenMenus.add(subMenuKey);
|
|
853
942
|
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
@@ -864,18 +953,38 @@ var AppSideBar = ({
|
|
|
864
953
|
setActiveMenuPath(foundActivePath);
|
|
865
954
|
}
|
|
866
955
|
}, [navItemsLocal]);
|
|
956
|
+
const [currentUrl, setCurrentUrl] = (0, import_react12.useState)(
|
|
957
|
+
() => window.location.pathname + window.location.search
|
|
958
|
+
);
|
|
867
959
|
(0, import_react12.useEffect)(() => {
|
|
868
960
|
detectAndSetActiveMenu();
|
|
961
|
+
setCurrentUrl(window.location.pathname + window.location.search);
|
|
869
962
|
}, [detectAndSetActiveMenu]);
|
|
870
963
|
(0, import_react12.useEffect)(() => {
|
|
964
|
+
let lastUrl = window.location.pathname + window.location.search;
|
|
871
965
|
const handleLocationChange = () => {
|
|
872
|
-
|
|
966
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
967
|
+
if (newUrl !== lastUrl) {
|
|
968
|
+
lastUrl = newUrl;
|
|
969
|
+
setCurrentUrl(newUrl);
|
|
970
|
+
detectAndSetActiveMenu();
|
|
971
|
+
}
|
|
873
972
|
};
|
|
874
973
|
window.addEventListener("popstate", handleLocationChange);
|
|
974
|
+
const checkInterval = setInterval(() => {
|
|
975
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
976
|
+
if (newUrl !== lastUrl) {
|
|
977
|
+
handleLocationChange();
|
|
978
|
+
}
|
|
979
|
+
}, 250);
|
|
875
980
|
return () => {
|
|
876
981
|
window.removeEventListener("popstate", handleLocationChange);
|
|
982
|
+
clearInterval(checkInterval);
|
|
877
983
|
};
|
|
878
984
|
}, [detectAndSetActiveMenu]);
|
|
985
|
+
(0, import_react12.useEffect)(() => {
|
|
986
|
+
detectAndSetActiveMenu();
|
|
987
|
+
}, [currentUrl, detectAndSetActiveMenu]);
|
|
879
988
|
const toggleMobileMenu = () => {
|
|
880
989
|
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
881
990
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -766,31 +766,119 @@ var AppSideBar = ({
|
|
|
766
766
|
const extractUrlFromOnClick = (onClick) => {
|
|
767
767
|
if (!onClick || typeof onClick !== "function") return null;
|
|
768
768
|
const funcString = onClick.toString();
|
|
769
|
-
|
|
769
|
+
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
770
|
+
if (!match) {
|
|
771
|
+
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
772
|
+
}
|
|
770
773
|
if (match && match[1]) {
|
|
771
774
|
try {
|
|
772
775
|
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
773
776
|
const url = new URL(match[1]);
|
|
774
|
-
return
|
|
777
|
+
return {
|
|
778
|
+
pathname: url.pathname,
|
|
779
|
+
search: url.search,
|
|
780
|
+
fullPath: url.pathname + url.search
|
|
781
|
+
};
|
|
775
782
|
}
|
|
776
783
|
if (match[1].startsWith("/")) {
|
|
777
784
|
const url = new URL(match[1], window.location.origin);
|
|
778
|
-
return
|
|
785
|
+
return {
|
|
786
|
+
pathname: url.pathname,
|
|
787
|
+
search: url.search,
|
|
788
|
+
fullPath: url.pathname + url.search
|
|
789
|
+
};
|
|
779
790
|
}
|
|
780
791
|
return null;
|
|
781
792
|
} catch {
|
|
782
|
-
const pathMatch = match[1].match(/^([^?]+)
|
|
783
|
-
|
|
793
|
+
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
794
|
+
if (pathMatch) {
|
|
795
|
+
return {
|
|
796
|
+
pathname: pathMatch[1],
|
|
797
|
+
search: pathMatch[2] || "",
|
|
798
|
+
fullPath: match[1]
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
return null;
|
|
784
802
|
}
|
|
785
803
|
}
|
|
786
804
|
return null;
|
|
787
805
|
};
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
790
|
-
const
|
|
806
|
+
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
807
|
+
if (!menuUrlData || !currentPath) return false;
|
|
808
|
+
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
791
809
|
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
792
|
-
if (
|
|
793
|
-
|
|
810
|
+
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
811
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
812
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
813
|
+
const menuRole = menuParams.get("role");
|
|
814
|
+
const currentRole = currentParams.get("role");
|
|
815
|
+
if (menuRole && currentRole) {
|
|
816
|
+
return menuRole === currentRole;
|
|
817
|
+
}
|
|
818
|
+
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
823
|
+
if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
if (normalizedMenuPath === "/trips") {
|
|
827
|
+
if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
|
|
832
|
+
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
833
|
+
if (menuPathParam) {
|
|
834
|
+
const pathRouteMap = {
|
|
835
|
+
"offer": "/offer/offer",
|
|
836
|
+
"voucher": "/voucher/voucher",
|
|
837
|
+
"tag": "/tags/tags",
|
|
838
|
+
"special-requests": "/corporate/special-requests",
|
|
839
|
+
"pricing-policy": "/policies/pricing-policy",
|
|
840
|
+
"users": "/users/users"
|
|
841
|
+
// Consumer Ecosystem Users (no role param)
|
|
842
|
+
};
|
|
843
|
+
const expectedRoute = pathRouteMap[menuPathParam];
|
|
844
|
+
if (expectedRoute) {
|
|
845
|
+
if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
|
|
846
|
+
if (menuPathParam === "users") {
|
|
847
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
848
|
+
const currentRole = currentParams.get("role");
|
|
849
|
+
return currentRole !== "admin";
|
|
850
|
+
}
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
if (normalizedCurrentPath === "/orgselector") {
|
|
856
|
+
const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
|
|
857
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
858
|
+
if (menuPathParam2 && currentPathParam) {
|
|
859
|
+
return menuPathParam2 === currentPathParam;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
864
|
+
if (menuUrlData.search) {
|
|
865
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
866
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
867
|
+
for (const [key, value] of menuParams.entries()) {
|
|
868
|
+
if (key === "auth") {
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (currentParams.get(key) !== value) {
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return true;
|
|
876
|
+
}
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
880
|
+
return true;
|
|
881
|
+
}
|
|
794
882
|
return false;
|
|
795
883
|
};
|
|
796
884
|
const navItemsLocal = navItems ?? navItemsConstant;
|
|
@@ -798,27 +886,28 @@ var AppSideBar = ({
|
|
|
798
886
|
const sideBarLogoLocal = sideBarLogo ?? logo_white_default;
|
|
799
887
|
const detectAndSetActiveMenu = useCallback(() => {
|
|
800
888
|
const currentPath = window.location.pathname;
|
|
889
|
+
const currentSearch = window.location.search;
|
|
801
890
|
const newOpenMenus = /* @__PURE__ */ new Set();
|
|
802
891
|
let foundActivePath = null;
|
|
803
892
|
navItemsLocal.forEach((item, index) => {
|
|
804
893
|
if (!item.isDropDown && item.onClick && typeof item.onClick === "function") {
|
|
805
|
-
const
|
|
806
|
-
if (
|
|
894
|
+
const itemUrlData = extractUrlFromOnClick(item.onClick);
|
|
895
|
+
if (itemUrlData && currentUrlMatches(itemUrlData, currentPath, currentSearch)) {
|
|
807
896
|
foundActivePath = `menu-${index}`;
|
|
808
897
|
}
|
|
809
898
|
}
|
|
810
899
|
if (item.options && item.options.length > 0) {
|
|
811
900
|
item.options.forEach((option, optionsIndex) => {
|
|
812
901
|
if (option.onClick && typeof option.onClick === "function") {
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
902
|
+
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
903
|
+
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
815
904
|
const menuKey = `menu-${index}`;
|
|
816
905
|
newOpenMenus.add(menuKey);
|
|
817
906
|
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
818
907
|
if (option.options && option.options.length > 0) {
|
|
819
908
|
option.options.forEach((subOption, subIndex) => {
|
|
820
|
-
const
|
|
821
|
-
if (
|
|
909
|
+
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
910
|
+
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
822
911
|
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
823
912
|
newOpenMenus.add(subMenuKey);
|
|
824
913
|
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
@@ -835,18 +924,38 @@ var AppSideBar = ({
|
|
|
835
924
|
setActiveMenuPath(foundActivePath);
|
|
836
925
|
}
|
|
837
926
|
}, [navItemsLocal]);
|
|
927
|
+
const [currentUrl, setCurrentUrl] = useState3(
|
|
928
|
+
() => window.location.pathname + window.location.search
|
|
929
|
+
);
|
|
838
930
|
useEffect(() => {
|
|
839
931
|
detectAndSetActiveMenu();
|
|
932
|
+
setCurrentUrl(window.location.pathname + window.location.search);
|
|
840
933
|
}, [detectAndSetActiveMenu]);
|
|
841
934
|
useEffect(() => {
|
|
935
|
+
let lastUrl = window.location.pathname + window.location.search;
|
|
842
936
|
const handleLocationChange = () => {
|
|
843
|
-
|
|
937
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
938
|
+
if (newUrl !== lastUrl) {
|
|
939
|
+
lastUrl = newUrl;
|
|
940
|
+
setCurrentUrl(newUrl);
|
|
941
|
+
detectAndSetActiveMenu();
|
|
942
|
+
}
|
|
844
943
|
};
|
|
845
944
|
window.addEventListener("popstate", handleLocationChange);
|
|
945
|
+
const checkInterval = setInterval(() => {
|
|
946
|
+
const newUrl = window.location.pathname + window.location.search;
|
|
947
|
+
if (newUrl !== lastUrl) {
|
|
948
|
+
handleLocationChange();
|
|
949
|
+
}
|
|
950
|
+
}, 250);
|
|
846
951
|
return () => {
|
|
847
952
|
window.removeEventListener("popstate", handleLocationChange);
|
|
953
|
+
clearInterval(checkInterval);
|
|
848
954
|
};
|
|
849
955
|
}, [detectAndSetActiveMenu]);
|
|
956
|
+
useEffect(() => {
|
|
957
|
+
detectAndSetActiveMenu();
|
|
958
|
+
}, [currentUrl, detectAndSetActiveMenu]);
|
|
850
959
|
const toggleMobileMenu = () => {
|
|
851
960
|
setIsMobileMenuOpen(!isMobileMenuOpen);
|
|
852
961
|
};
|