feat(20-01): extend UIStore with FAB/catalog state, add useTags hook, update useGlobalItems

- Add fabMenuOpen, openFabMenu, closeFabMenu to UIStore
- Add catalogSearchOpen, catalogSearchMode, openCatalogSearch, closeCatalogSearch
- openCatalogSearch also closes FAB menu (natural flow)
- Create useTags hook with 5-min staleTime cache
- Add optional tags parameter to useGlobalItems for tag filtering
This commit is contained in:
2026-04-06 07:57:47 +02:00
parent 2ec1276849
commit 67facea338
6 changed files with 64 additions and 20 deletions

View File

@@ -23,13 +23,16 @@ interface ItemGlobalLink {
globalItemId: number;
}
export function useGlobalItems(query?: string) {
export function useGlobalItems(query?: string, tags?: string[]) {
const params = new URLSearchParams();
if (query) params.set("q", query);
if (tags && tags.length > 0) params.set("tags", tags.join(","));
const qs = params.toString();
return useQuery({
queryKey: ["global-items", query ?? ""],
queryKey: ["global-items", query ?? "", tags ?? []],
queryFn: () =>
apiGet<GlobalItem[]>(
`/api/global-items${query ? `?q=${encodeURIComponent(query)}` : ""}`,
),
apiGet<GlobalItem[]>(`/api/global-items${qs ? `?${qs}` : ""}`),
});
}

View File

@@ -0,0 +1,15 @@
import { useQuery } from "@tanstack/react-query";
import { apiGet } from "../lib/api";
export interface Tag {
id: number;
name: string;
}
export function useTags() {
return useQuery({
queryKey: ["tags"],
queryFn: () => apiGet<Tag[]>("/api/tags"),
staleTime: 5 * 60 * 1000,
});
}