Create useVersions.ts

This commit is contained in:
CanbiZ 2025-04-09 14:37:10 +02:00
parent 4c26269b68
commit 264d0a20ba

View File

@ -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<AppVersion[]>({
queryKey: ["versions"],
queryFn: async () => {
const fetchedVersions = await fetchVersions();
if (Array.isArray(fetchedVersions)) {
return fetchedVersions;
}
if (fetchedVersions && typeof fetchedVersions === "object") {
return [fetchedVersions];
}
return [];
},
});
}