Files
slp-modular-cms/frontend/src/features/contact/components/ContactAvailabilityGuard.tsx
T

23 lines
901 B
TypeScript

import type { ReactNode } from 'react';
import { NotFoundPage } from '@/pages/NotFoundPage';
import { useContactSettings } from '../services/useContactSettings';
/**
* The module can be loaded while the management routes are closed (host switch off: every route answers 404 with an
* empty body). In that case the screen does not exist: the usual "not found" page is shown.
*/
export function ContactAvailabilityGuard({ children }: { children: ReactNode }) {
const { data, isPending, isError } = useContactSettings();
if (isPending) {
return (
<div className="flex min-h-40 items-center justify-center text-muted-foreground">
<span className="h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent" />
</div>
);
}
if (isError || data === null) return <NotFoundPage />;
return <>{children}</>;
}