import Cookies from 'js-cookie';
import { LandingPage } from '@ema-platform/ui';
import { authStorage } from '@ema-platform/auth';

/**
 * Public `/` — mounts the shared landing page with portal-specific routes.
 * Auth state is read the same way ProtectedRoute does (token cookie or
 * storage fallback) so the header can show "Go to dashboard" instead of
 * Login/Sign Up without gating the route itself.
 */
export function LandingRoute() {
  const token = authStorage.getToken() ?? Cookies.get('auth-token');

  return <LandingPage primaryHref={token ? '/dashboard' : '/login'} signupHref="/signup" />;
}
