Files
bookhoard/web/src/tag-dropdown.ts
T
John O'Keefe c52b514036 chore: formatting sweep — vp fmt on drifted web files, templ regen
Pre-existing format drift in seven web/src files (blank-line and
indent normalization by vp fmt) plus templ generate normalization
across the generated _templ.go files; both swept up while committing
the filter-builder fix. No behavior changes.
2026-10-31 23:27:21 -04:00

28 lines
627 B
TypeScript

import { authHeaders } from "./storage";
export interface TagSuggestion {
value: string;
count: number;
}
export async function searchTagSuggestions(
query: string,
libraryId: string,
): Promise<TagSuggestion[]> {
if (!query || query.length < 2 || !libraryId) return [];
try {
const response = await fetch(
`/api/media-items/search?tags=${encodeURIComponent(query)}&library_id=${libraryId}&limit=20`,
{ headers: authHeaders() },
);
if (!response.ok) return [];
const data = await response.json();
return (data.results || []) as TagSuggestion[];
} catch {
return [];
}
}