import { Navigate } from 'react-router-dom';
import { useAuth } from '../context/AuthContext';

export default function RoleRedirect() {
  const { role, loading } = useAuth();

  if (loading) return null;

  if (role === 'admin') return <Navigate to="/admin" replace />;
  if (role === 'firmenleiter') return <Navigate to="/firmenleiter" replace />;
  if (role === 'filialleiter') return <Navigate to="/filialleiter" replace />;
  return <Navigate to="/tracker" replace />;
}
