mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-25 13:45:54 +00:00
Create useVersions.ts
This commit is contained in:
21
frontend/src/hooks/useVersions.ts
Normal file
21
frontend/src/hooks/useVersions.ts
Normal 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 [];
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user