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 { 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" />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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" />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user