feat(catalog): add search to all catalog pages
All checks were successful
Build Docker Image / build (push) Successful in 4m55s
All checks were successful
Build Docker Image / build (push) Successful in 4m55s
Add CatalogSearchBar component with filtering to: - /catalog/offers - search by product name - /catalog/offers/[productId] - search by hub name/country - /catalog/hubs/[id] - search by product name - /catalog/suppliers/[supplierId] - search by product name - /catalog/suppliers/[supplierId]/[productId] - search by hub name/country
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
<template>
|
||||
<CatalogPage
|
||||
:items="products"
|
||||
:items="filteredProducts"
|
||||
:loading="isLoading"
|
||||
:total-count="products.length"
|
||||
with-map
|
||||
map-id="offers-products-map"
|
||||
point-color="#3b82f6"
|
||||
>
|
||||
<template #searchBar="{ displayedCount, totalCount }">
|
||||
<CatalogSearchBar
|
||||
v-model:search-query="searchQuery"
|
||||
:displayed-count="displayedCount"
|
||||
:total-count="totalCount"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #header>
|
||||
<!-- Empty -->
|
||||
<Card v-if="!isLoading && products.length === 0" padding="lg">
|
||||
@@ -49,6 +58,17 @@ const { t } = useI18n()
|
||||
|
||||
const { items: products, isLoading, init } = useCatalogProducts()
|
||||
|
||||
// Search
|
||||
const searchQuery = ref('')
|
||||
|
||||
const filteredProducts = computed(() => {
|
||||
if (!searchQuery.value.trim()) return products.value
|
||||
const q = searchQuery.value.toLowerCase()
|
||||
return products.value.filter(item =>
|
||||
item.name?.toLowerCase().includes(q)
|
||||
)
|
||||
})
|
||||
|
||||
// Navigate to product detail
|
||||
const goToProduct = (productId: string) => {
|
||||
navigateTo(localePath(`/catalog/offers/${productId}`))
|
||||
|
||||
Reference in New Issue
Block a user