mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
UI landing page route fix
This commit is contained in:
@@ -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" />;
|
||||
}
|
||||
|
||||
@@ -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" />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user