import { useHandleSignInCallback } from '@logto/react';
import { useNavigate } from 'react-router';
import { Spinner } from '@cameleer/design-system';

export function CallbackPage() {
  const navigate = useNavigate();

  const { isLoading } = useHandleSignInCallback(() => {
    navigate('/', { replace: true });
  });

  if (isLoading) {
    return (
      <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh' }}>
        <Spinner />
      </div>
    );
  }

  return null;
}
