From affe468a4916cd7b4f7152c95da6a8b305f4df69 Mon Sep 17 00:00:00 2001
From: Dosseh91 <98787470+Dosseh91@users.noreply.github.com>
Date: Mon, 23 Jun 2025 20:23:20 +0200
Subject: [PATCH] Update App.tsx
---
src/App.tsx | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/App.tsx b/src/App.tsx
index e845272..de235aa 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -12,29 +12,26 @@ import { AuthProvider, useAuth } from './contexts/AuthContext';
import { ListingProvider } from './contexts/ListingContext';
import Register from './pages/Register';
-//register button route
-} />
-
// Protected route component
-const ProtectedRoute: React.FC<{
+const ProtectedRoute: React.FC<{
children: React.ReactNode;
allowedRoles?: string[];
}> = ({ children, allowedRoles }) => {
const { user, loading } = useAuth();
const location = useLocation();
-
+
if (loading) {
return
Loading...
;
}
-
+
if (!user) {
return ;
}
-
+
if (allowedRoles && !allowedRoles.includes(user.role)) {
return ;
}
-
+
return <>{children}>;
};
@@ -62,26 +59,29 @@ function App() {
} />
} />
+ {/* ADD THIS LINE - The fix for your button */}
+ } />
+
{/* Protected admin routes */}
-
- }
+ }
/>
-
+
{/* Protected agency routes */}
-
- }
+ }
/>
-
+
{/* Redirect unknown routes to home */}
} />