diff --git a/frontend/src/hooks/useVersions.ts b/frontend/src/hooks/useVersions.ts new file mode 100644 index 0000000..44404f4 --- /dev/null +++ b/frontend/src/hooks/useVersions.ts @@ -0,0 +1,21 @@ +"use client"; + +import { fetchVersions } from "@/lib/data"; +import { AppVersion } from "@/lib/types"; +import { useQuery } from "@tanstack/react-query"; + +export function useVersions() { + return useQuery({ + queryKey: ["versions"], + queryFn: async () => { + const fetchedVersions = await fetchVersions(); + if (Array.isArray(fetchedVersions)) { + return fetchedVersions; + } + if (fetchedVersions && typeof fetchedVersions === "object") { + return [fetchedVersions]; + } + return []; + }, + }); +}