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