feat: add public catalog web foundation

This commit is contained in:
2026-09-08 19:37:59 -04:00
parent a76d777a6b
commit 3d17637711
13 changed files with 2001 additions and 1 deletions
@@ -0,0 +1,30 @@
import { ref, watch } from 'vue';
import { searchCatalog } from '@/services/catalog-service.js';
export function useCatalogSearch() {
const query = ref('');
const result = ref({ items: [], pagination: { page: 1, limit: 20, total: 0, totalPages: 0 } });
const isLoading = ref(false);
const error = ref(null);
let requestId = 0;
async function load() {
const currentRequestId = ++requestId;
isLoading.value = true;
error.value = null;
try {
const nextResult = await searchCatalog({ query: query.value });
if (currentRequestId === requestId) result.value = nextResult;
} catch (requestError) {
if (currentRequestId === requestId) error.value = requestError;
} finally {
if (currentRequestId === requestId) isLoading.value = false;
}
}
watch(query, load);
return { query, result, isLoading, error, load };
}