= ({
onSelectRole={onSelectRow}
onUnselectRole={onUnselectRow}
initialRoleId={initialRoleId}
+ hashSegment={1}
/>
{selectedRole !== undefined &&
(canViewRoleAccess || canViewRoleUsers) && (
- {tabs}
+
+ {tabs}
+
)}
diff --git a/src/utils/HashNavigationContext.tsx b/src/utils/HashNavigationContext.tsx
new file mode 100644
index 0000000..4049bc2
--- /dev/null
+++ b/src/utils/HashNavigationContext.tsx
@@ -0,0 +1,44 @@
+import React, { createContext, useContext, useMemo } from "react";
+import { useLocation } from "react-router-dom";
+
+interface HashNavigationContextValue {
+ segments: string[];
+ getSegment: (index: number) => string | undefined;
+}
+
+const HashNavigationContext = createContext({
+ segments: [],
+ getSegment: () => undefined,
+});
+
+export const HashNavigationProvider: React.FC<{
+ children: React.ReactNode;
+}> = ({ children }) => {
+ const location = useLocation();
+
+ const value = useMemo(() => {
+ // Parse hash into segments, removing the leading #
+ const hash = location.hash.slice(1);
+ const segments = hash ? hash.split("/") : [];
+
+ return {
+ segments,
+ getSegment: (index: number) => segments[index],
+ };
+ }, [location.hash]);
+
+ return (
+
+ {children}
+
+ );
+};
+
+export const useHashNavigation = () => {
+ return useContext(HashNavigationContext);
+};
+
+export const useHashSegment = (index: number): string | undefined => {
+ const { getSegment } = useHashNavigation();
+ return getSegment(index);
+};