"use client"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { useState } from "react"; import { ApiError } from "@/lib/auth/api-client"; import { AuthProvider } from "@/lib/auth/auth-context"; export function Providers({ children }: { children: React.ReactNode }) { const [queryClient] = useState( () => new QueryClient({ defaultOptions: { // offlineFirst: serve cache / try the request even without a network // signal; 'always' mutations run so forms can queue instead of hanging. queries: { networkMode: "offlineFirst", retry: (failureCount, error) => !(error instanceof ApiError && error.status < 500) && failureCount < 1, }, mutations: { networkMode: "always", retry: false }, }, }), ); return ( {children} ); }