import {JSX} from 'react';
import {AuthorizedOnly} from '../AuthorizedOnly';

interface ProtectedRouteProps {
  children: JSX.Element;
  fallback?: JSX.Element;
  redirectTo?: string;
}

export function ProtectedRoute({children, fallback, redirectTo = '/login'}: ProtectedRouteProps): JSX.Element {
  return (
    <AuthorizedOnly fallback={fallback} redirectTo={redirectTo}>
      {children}
    </AuthorizedOnly>
  );
}
