v1.4 Collection Tools #9

Merged
makiolaj merged 17 commits from feature/v1.4-collection-tools into Develop 2026-04-03 18:05:24 +00:00
4 changed files with 24 additions and 4 deletions
Showing only changes of commit b993a0a831 - Show all commits

View File

@@ -1,6 +1,13 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { CreateItem } from "../../shared/types"; import type { CreateItem } from "../../shared/types";
import { apiDelete, apiGet, apiPost, apiPut, apiUpload } from "../lib/api"; import {
ApiError,
apiDelete,
apiGet,
apiPost,
apiPut,
apiUpload,
} from "../lib/api";
interface Item { interface Item {
id: number; id: number;
@@ -45,6 +52,8 @@ export function useItem(id: number | null) {
queryKey: ["items", id], queryKey: ["items", id],
queryFn: () => apiGet<ItemWithCategory>(`/api/items/${id}`), queryFn: () => apiGet<ItemWithCategory>(`/api/items/${id}`),
enabled: id != null, enabled: id != null,
retry: (count, error) =>
error instanceof ApiError && error.status === 404 ? false : count < 3,
}); });
} }

View File

@@ -1,5 +1,12 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiDelete, apiGet, apiPatch, apiPost, apiPut } from "../lib/api"; import {
ApiError,
apiDelete,
apiGet,
apiPatch,
apiPost,
apiPut,
} from "../lib/api";
interface SetupListItem { interface SetupListItem {
id: number; id: number;
@@ -50,6 +57,8 @@ export function useSetup(setupId: number | null) {
queryKey: ["setups", setupId], queryKey: ["setups", setupId],
queryFn: () => apiGet<SetupWithItems>(`/api/setups/${setupId}`), queryFn: () => apiGet<SetupWithItems>(`/api/setups/${setupId}`),
enabled: setupId != null, enabled: setupId != null,
retry: (count, error) =>
error instanceof ApiError && error.status === 404 ? false : count < 3,
}); });
} }

View File

@@ -1,5 +1,5 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiDelete, apiGet, apiPost, apiPut } from "../lib/api"; import { ApiError, apiDelete, apiGet, apiPost, apiPut } from "../lib/api";
interface ThreadListItem { interface ThreadListItem {
id: number; id: number;
@@ -61,6 +61,8 @@ export function useThread(threadId: number | null) {
queryKey: ["threads", threadId], queryKey: ["threads", threadId],
queryFn: () => apiGet<ThreadWithCandidates>(`/api/threads/${threadId}`), queryFn: () => apiGet<ThreadWithCandidates>(`/api/threads/${threadId}`),
enabled: threadId != null, enabled: threadId != null,
retry: (count, error) =>
error instanceof ApiError && error.status === 404 ? false : count < 3,
}); });
} }

View File

@@ -1,4 +1,4 @@
class ApiError extends Error { export class ApiError extends Error {
constructor( constructor(
message: string, message: string,
public status: number, public status: number,