// @File: src/pages/AuthCallback.tsx
// @Desc: Legacy Atoms OIDC callback route. The portal now uses a standalone
//        email/password flow, so any traffic that lands here should be sent
//        to our own /login page — NOT to the Atoms OIDC entry point.
import { useEffect } from 'react';
import { Navigate } from 'react-router-dom';

export default function AuthCallback() {
  useEffect(() => {
    // If the SDK or an old link dropped a `token` into the URL, preserve it
    // for the standalone flow so we don't lose a freshly minted session.
    try {
      const params = new URLSearchParams(window.location.search);
      const token = params.get('token');
      if (token) {
        localStorage.setItem('token', token);
        localStorage.setItem('isLougOutManual', 'false');
      }
    } catch {
      /* ignore */
    }
  }, []);

  return <Navigate to="/login" replace />;
}