/* eslint-disable react-hooks/exhaustive-deps */
import { Outlet, useNavigate } from 'react-router-dom';
import React, { useEffect } from 'react';
import { useUserSelector } from '@/store/userStore';

const ProtectedRoute = (): React.JSX.Element => {
  const navigate = useNavigate();
  const user = useUserSelector();

  useEffect(() => {
    if (!user?.id) {
      navigate('/login');
    }
  }, [user]);

  return <Outlet />;
};
export default ProtectedRoute;
