import { useEffect } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { useAuthModal } from '../contexts/AuthModalContext';

const ResetPasswordRouteHandler: React.FC = () => {
  const { token } = useParams<{ token: string }>();
  const navigate = useNavigate();
  const { openModal } = useAuthModal();

  useEffect(() => {
    if (token) {
      openModal('reset-password', { token });
      navigate('/', { replace: true });
    }
  }, [token, openModal, navigate]);

  return null;
};

export default ResetPasswordRouteHandler;

