From 789d32627352863a0f7fb7ae772ff8f6cf440efb Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Thu, 28 Aug 2025 10:09:03 +0200 Subject: [PATCH] ui/queries: add list tags query --- pkgs/clan-app/ui/src/hooks/queries.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkgs/clan-app/ui/src/hooks/queries.ts b/pkgs/clan-app/ui/src/hooks/queries.ts index 085335716..e678517b3 100644 --- a/pkgs/clan-app/ui/src/hooks/queries.ts +++ b/pkgs/clan-app/ui/src/hooks/queries.ts @@ -42,6 +42,7 @@ export const DefaultQueryClient = new QueryClient({ }, }); +export type MachinesQuery = ReturnType; export const useMachinesQuery = (clanURI: string) => { const client = useApiClient(); @@ -117,6 +118,27 @@ export const useMachineQuery = (clanURI: string, machineName: string) => { })); }; +export type TagsQuery = ReturnType; +export const useTags = (clanURI: string) => { + const client = useApiClient(); + return useQuery(() => ({ + queryKey: ["clans", encodeBase64(clanURI), "tags"], + queryFn: async () => { + const apiCall = client.fetch("list_tags", { + flake: { + identifier: clanURI, + }, + }); + + const result = await apiCall.result; + if (result.status === "error") { + throw new Error("Error fetching tags: " + result.errors[0].message); + } + return result.data; + }, + })); +}; + export const useMachineStateQuery = (clanURI: string, machineName: string) => { const client = useApiClient(); return useQuery(() => ({