Deploy to production

This commit is contained in:
AI Bot
2026-07-30 12:49:29 +05:30
parent 0d9c9eaadd
commit 07a1e8f37f
30 changed files with 6363 additions and 4887 deletions
+23
View File
@@ -0,0 +1,23 @@
import { Navigate, Outlet, useLocation } from 'react-router-dom';
import { useAuthStore } from '../store/authStore';
interface ProtectedRouteProps {
allowedRoles?: ('user' | 'admin')[];
}
export const ProtectedRoute = ({ allowedRoles = ['user', 'admin'] }: ProtectedRouteProps) => {
const { user, profile } = useAuthStore();
const location = useLocation();
if (!user) {
// Redirect to login but save the attempted url
return <Navigate to="/auth" state={{ from: location }} replace />;
}
if (profile && !allowedRoles.includes(profile.role)) {
// Role not authorized, go to dashboard
return <Navigate to="/dashboard" replace />;
}
return <Outlet />;
};