Reduce retry count and show errors on admin pages
TanStack Query's default 3 retries + exponential backoff hid backend errors behind 5-8s of "Loading…". Now retries once and surfaces the error message immediately on failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,9 +15,10 @@ import {
|
||||
|
||||
export default function AdminGroupsPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const { data: groups = [], isLoading } = useQuery({
|
||||
const { data: groups = [], isLoading, isError, error } = useQuery({
|
||||
queryKey: ["admin-groups"],
|
||||
queryFn: adminListGroups,
|
||||
retry: 1,
|
||||
});
|
||||
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
@@ -97,6 +98,11 @@ export default function AdminGroupsPage() {
|
||||
|
||||
{isLoading ? (
|
||||
<p>Loading…</p>
|
||||
) : isError ? (
|
||||
<p style={{ color: "red" }}>
|
||||
Failed to load groups:{" "}
|
||||
{(error as any)?.response?.data?.detail ?? (error as any)?.message ?? "Unknown error"}
|
||||
</p>
|
||||
) : (
|
||||
<table style={{ width: "100%", borderCollapse: "collapse", marginBottom: 24 }}>
|
||||
<thead>
|
||||
|
||||
@@ -13,9 +13,10 @@ import {
|
||||
export default function AdminUsersPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const { data: me } = useQuery({ queryKey: ["me"], queryFn: getMe });
|
||||
const { data: users = [], isLoading } = useQuery({
|
||||
const { data: users = [], isLoading, isError, error } = useQuery({
|
||||
queryKey: ["admin-users"],
|
||||
queryFn: adminGetUsers,
|
||||
retry: 1,
|
||||
});
|
||||
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
@@ -71,6 +72,11 @@ export default function AdminUsersPage() {
|
||||
|
||||
{isLoading ? (
|
||||
<p>Loading…</p>
|
||||
) : isError ? (
|
||||
<p style={{ color: "red" }}>
|
||||
Failed to load users:{" "}
|
||||
{(error as any)?.response?.data?.detail ?? (error as any)?.message ?? "Unknown error"}
|
||||
</p>
|
||||
) : (
|
||||
<table style={{ width: "100%", borderCollapse: "collapse", marginBottom: 24 }}>
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user