import type { ReactNode } from "react"; import { ApiError } from "@/api/fetcher"; import { Button } from "@/components/ui/button"; import { Spinner } from "@/components/ui/spinner"; import { m } from "@/paraglide/messages"; interface QueryStateProps { isLoading: boolean; error: unknown; refetch?: () => void; children: ReactNode; } /** Uniform loading/error wrapper for a query-backed view. */ export function QueryState({ isLoading, error, refetch, children, }: QueryStateProps) { if (isLoading) { return (
{unauthorized ? m.common_unauthorized() : m.common_error()}
{refetch && !unauthorized && ( )}