Route tenant admin PWA via /event-admin
This commit is contained in:
@@ -8,6 +8,7 @@ import EventPhotosPage from './pages/EventPhotosPage';
|
||||
import EventDetailPage from './pages/EventDetailPage';
|
||||
import AuthCallbackPage from './pages/AuthCallbackPage';
|
||||
import { useAuth } from './auth/context';
|
||||
import { ADMIN_AUTH_CALLBACK_PATH, ADMIN_BASE_PATH, ADMIN_LOGIN_PATH } from './constants';
|
||||
|
||||
function RequireAuth() {
|
||||
const { status } = useAuth();
|
||||
@@ -16,23 +17,23 @@ function RequireAuth() {
|
||||
if (status === 'loading') {
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center text-sm text-muted-foreground">
|
||||
Bitte warten <EFBFBD>
|
||||
Bitte warten ...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (status === 'unauthenticated') {
|
||||
return <Navigate to="/admin/login" state={{ from: location }} replace />;
|
||||
return <Navigate to={ADMIN_LOGIN_PATH} state={{ from: location }} replace />;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{ path: '/admin/login', element: <LoginPage /> },
|
||||
{ path: '/admin/auth/callback', element: <AuthCallbackPage /> },
|
||||
{ path: ADMIN_LOGIN_PATH, element: <LoginPage /> },
|
||||
{ path: ADMIN_AUTH_CALLBACK_PATH, element: <AuthCallbackPage /> },
|
||||
{
|
||||
path: '/admin',
|
||||
path: ADMIN_BASE_PATH,
|
||||
element: <RequireAuth />,
|
||||
children: [
|
||||
{ index: true, element: <EventsPage /> },
|
||||
@@ -44,5 +45,7 @@ export const router = createBrowserRouter([
|
||||
{ path: 'settings', element: <SettingsPage /> },
|
||||
],
|
||||
},
|
||||
{ path: '*', element: <Navigate to="/admin" replace /> },
|
||||
{ path: '*', element: <Navigate to={ADMIN_BASE_PATH} replace /> },
|
||||
]);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user