UI landing page route fix

This commit is contained in:
estifanos
2026-08-15 07:02:37 +00:00
parent 57682188de
commit 51cf0fbd17
2 changed files with 14 additions and 8 deletions

View File

@@ -1,12 +1,16 @@
import { Navigate } from 'react-router-dom';
import { LandingPage } from '@ema-platform/ui'; import { LandingPage } from '@ema-platform/ui';
import { useAuthToken } from '@ema-platform/auth'; import { useAuthToken } from '@ema-platform/auth';
/** /**
* Public `/` — mounts the shared landing page. Backoffice has no /signup * Public `/`. Signed-in visitors skip the landing page entirely and go
* (enableSignup: false) and no /verify route, so those props are omitted. * straight to the dashboard. Backoffice has no /signup (enableSignup: false)
* and no /verify route, so those props are omitted.
*/ */
export function LandingRoute() { export function LandingRoute() {
const token = useAuthToken(); const token = useAuthToken();
return <LandingPage primaryHref={token ? '/dashboard' : '/login'} />; if (token) return <Navigate to="/dashboard" replace />;
return <LandingPage primaryHref="/login" />;
} }

View File

@@ -1,14 +1,16 @@
import { Navigate } from 'react-router-dom';
import { LandingPage } from '@ema-platform/ui'; import { LandingPage } from '@ema-platform/ui';
import { useAuthToken } from '@ema-platform/auth'; import { useAuthToken } from '@ema-platform/auth';
/** /**
* Public `/` — mounts the shared landing page with portal-specific routes. * Public `/`. Signed-in visitors skip the landing page entirely and go
* Auth state is read via `useAuthToken`, the same hook ProtectedRoute uses, * straight to the dashboard — the landing page is a front door for people
* so the header can show "Go to dashboard" instead of Login/Sign Up without * who aren't in yet, not a screen for people who already are.
* gating the route itself.
*/ */
export function LandingRoute() { export function LandingRoute() {
const token = useAuthToken(); const token = useAuthToken();
return <LandingPage primaryHref={token ? '/dashboard' : '/login'} signupHref="/signup" />; if (token) return <Navigate to="/dashboard" replace />;
return <LandingPage primaryHref="/login" signupHref="/signup" />;
} }