mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 05:43:12 +00:00
- Gate the Revoke action on the approved queue row and the detail modal to admin users; non-admins get a disabled button with a plain 'Only admins can revoke uplifts' tooltip and the dialog cannot open. - Stop nesting an h2 inside DialogTitle in the uplift detail modal (hydration error) by rendering the title text as a non-heading. - Handle work-order detail/uplift query 403s quietly in the detail modal: sections fall back to 'Unavailable' and the queries suppress the global error toast (QueryCache now honors suppressErrorToast). - Extract UpliftDecisionDialogs and openUpliftEvidence from the page to meet the changed-file maintainability gate (complexity 23 -> pass).
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";
|
|
import { toast } from "react-toastify";
|
|
|
|
export function createAppQueryClient(): QueryClient {
|
|
return new QueryClient({
|
|
queryCache: new QueryCache({
|
|
onError: (error, query) => {
|
|
if (query.meta?.suppressErrorToast) return;
|
|
|
|
console.error("Query error:", error);
|
|
const message =
|
|
error instanceof Error ? error.message : "An error occurred while fetching data";
|
|
toast.error(message);
|
|
},
|
|
}),
|
|
mutationCache: new MutationCache({
|
|
onError: (error, _variables, _context, mutation) => {
|
|
if (mutation.options.meta?.suppressErrorToast) return;
|
|
|
|
console.error("Mutation error:", error);
|
|
const message =
|
|
error instanceof Error ? error.message : "An error occurred while updating data";
|
|
toast.error(message);
|
|
},
|
|
}),
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 5 * 60 * 1000,
|
|
gcTime: 10 * 60 * 1000,
|
|
retry: 1,
|
|
refetchOnWindowFocus: false,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export const queryClient = createAppQueryClient();
|
|
|
|
export default queryClient;
|