import React, { useEffect } from 'react'; import { useNavigate, useSearchParams } from 'react-router-dom'; import { useAuth } from '../../contexts/AuthContext'; import toast from 'react-hot-toast'; import logger from '../../utils/logger'; const OAuthCallback: React.FC = () => { const navigate = useNavigate(); const [searchParams] = useSearchParams(); const { handleOAuthCallback } = useAuth(); useEffect(() => { const token = searchParams.get('token'); const provider = searchParams.get('provider'); const error = searchParams.get('error'); if (error) { toast.error('OAuth authentication failed'); navigate('/login'); return; } if (token && provider) { handleOAuthCallback(token, provider) .then(() => { toast.success(`Successfully logged in with ${provider}`); navigate('/dashboard'); }) .catch((error: any) => { logger.error('OAuth callback error:', error); toast.error('Authentication failed'); navigate('/login'); }); } else { toast.error('Invalid OAuth callback'); navigate('/login'); } }, [searchParams, navigate, handleOAuthCallback]); return (

Processing authentication...

); }; export default OAuthCallback;