'use client'; import type { ReactNode } from 'react'; import { FileWarning } from 'lucide-react'; import type { UseQueryResult } from '@tanstack/react-query'; import { useAuth } from '@/components/providers/auth-provider'; import { EmptyStateWithBorder } from '@/components/layout/empty'; import { ErrorInline } from '@/components/layout/error'; import { LoadingStateWithBorder } from '@/components/layout/loading'; type ErrorPageGateProps = { optionsQuery: UseQueryResult, Error>; children: ReactNode; }; export function ErrorPageGate({ optionsQuery, children }: ErrorPageGateProps) { const { user, loading: authLoading } = useAuth(); if (authLoading) { return (
); } if (!user?.is_admin) { return (
); } if (optionsQuery.isLoading) { return (
); } if (optionsQuery.isError) { return (
void optionsQuery.refetch()} />
); } return <>{children}; }