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,12 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<CatalogPage
|
<CatalogPage
|
||||||
:items="products"
|
:items="filteredProducts"
|
||||||
:map-items="mapItems"
|
:map-items="mapItems"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
|
:total-count="products.length"
|
||||||
with-map
|
with-map
|
||||||
map-id="hub-products-map"
|
map-id="hub-products-map"
|
||||||
point-color="#10b981"
|
point-color="#10b981"
|
||||||
>
|
>
|
||||||
|
<template #searchBar="{ displayedCount, totalCount }">
|
||||||
|
<CatalogSearchBar
|
||||||
|
v-model:search-query="searchQuery"
|
||||||
|
:displayed-count="displayedCount"
|
||||||
|
:total-count="totalCount"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<!-- Not Found -->
|
<!-- Not Found -->
|
||||||
<Card v-if="!isLoading && !hub" padding="lg">
|
<Card v-if="!isLoading && !hub" padding="lg">
|
||||||
@@ -70,6 +79,17 @@ const products = ref<Array<{ uuid: string; name: string }>>([])
|
|||||||
|
|
||||||
const hubId = computed(() => route.params.id as string)
|
const hubId = computed(() => route.params.id as string)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// Map items - show the hub itself
|
// Map items - show the hub itself
|
||||||
const mapItems = computed(() => {
|
const mapItems = computed(() => {
|
||||||
if (!hub.value?.latitude || !hub.value?.longitude) return []
|
if (!hub.value?.latitude || !hub.value?.longitude) return []
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<CatalogPage
|
<CatalogPage
|
||||||
:items="hubs"
|
:items="filteredHubs"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
|
:total-count="hubs.length"
|
||||||
with-map
|
with-map
|
||||||
map-id="offers-product-hubs-map"
|
map-id="offers-product-hubs-map"
|
||||||
point-color="#10b981"
|
point-color="#10b981"
|
||||||
@@ -9,6 +10,14 @@
|
|||||||
@update:hovered-id="hoveredHubId = $event"
|
@update:hovered-id="hoveredHubId = $event"
|
||||||
@select="onSelectHub"
|
@select="onSelectHub"
|
||||||
>
|
>
|
||||||
|
<template #searchBar="{ displayedCount, totalCount }">
|
||||||
|
<CatalogSearchBar
|
||||||
|
v-model:search-query="searchQuery"
|
||||||
|
:displayed-count="displayedCount"
|
||||||
|
:total-count="totalCount"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<!-- Product Not Found -->
|
<!-- Product Not Found -->
|
||||||
<Card v-if="!isLoading && !product" padding="lg">
|
<Card v-if="!isLoading && !product" padding="lg">
|
||||||
@@ -86,6 +95,18 @@ const hoveredHubId = ref<string>()
|
|||||||
|
|
||||||
const productId = computed(() => route.params.productId as string)
|
const productId = computed(() => route.params.productId as string)
|
||||||
|
|
||||||
|
// Search
|
||||||
|
const searchQuery = ref('')
|
||||||
|
|
||||||
|
const filteredHubs = computed(() => {
|
||||||
|
if (!searchQuery.value.trim()) return hubs.value
|
||||||
|
const q = searchQuery.value.toLowerCase()
|
||||||
|
return hubs.value.filter(hub =>
|
||||||
|
hub.name?.toLowerCase().includes(q) ||
|
||||||
|
hub.country?.toLowerCase().includes(q)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// Handle hub selection
|
// Handle hub selection
|
||||||
const onSelectHub = (hub: any) => {
|
const onSelectHub = (hub: any) => {
|
||||||
navigateTo(localePath(`/catalog/offers/${productId.value}/${hub.uuid}`))
|
navigateTo(localePath(`/catalog/offers/${productId.value}/${hub.uuid}`))
|
||||||
|
|||||||
@@ -1,11 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<CatalogPage
|
<CatalogPage
|
||||||
:items="products"
|
:items="filteredProducts"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
|
:total-count="products.length"
|
||||||
with-map
|
with-map
|
||||||
map-id="offers-products-map"
|
map-id="offers-products-map"
|
||||||
point-color="#3b82f6"
|
point-color="#3b82f6"
|
||||||
>
|
>
|
||||||
|
<template #searchBar="{ displayedCount, totalCount }">
|
||||||
|
<CatalogSearchBar
|
||||||
|
v-model:search-query="searchQuery"
|
||||||
|
:displayed-count="displayedCount"
|
||||||
|
:total-count="totalCount"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<!-- Empty -->
|
<!-- Empty -->
|
||||||
<Card v-if="!isLoading && products.length === 0" padding="lg">
|
<Card v-if="!isLoading && products.length === 0" padding="lg">
|
||||||
@@ -49,6 +58,17 @@ const { t } = useI18n()
|
|||||||
|
|
||||||
const { items: products, isLoading, init } = useCatalogProducts()
|
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
|
// Navigate to product detail
|
||||||
const goToProduct = (productId: string) => {
|
const goToProduct = (productId: string) => {
|
||||||
navigateTo(localePath(`/catalog/offers/${productId}`))
|
navigateTo(localePath(`/catalog/offers/${productId}`))
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<CatalogPage
|
<CatalogPage
|
||||||
:items="hubs"
|
:items="filteredHubs"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
|
:total-count="hubs.length"
|
||||||
with-map
|
with-map
|
||||||
map-id="supplier-product-hubs-map"
|
map-id="supplier-product-hubs-map"
|
||||||
point-color="#10b981"
|
point-color="#10b981"
|
||||||
@@ -9,6 +10,14 @@
|
|||||||
@update:hovered-id="hoveredHubId = $event"
|
@update:hovered-id="hoveredHubId = $event"
|
||||||
@select="onSelectHub"
|
@select="onSelectHub"
|
||||||
>
|
>
|
||||||
|
<template #searchBar="{ displayedCount, totalCount }">
|
||||||
|
<CatalogSearchBar
|
||||||
|
v-model:search-query="searchQuery"
|
||||||
|
:displayed-count="displayedCount"
|
||||||
|
:total-count="totalCount"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<!-- Not Found -->
|
<!-- Not Found -->
|
||||||
<Card v-if="!isLoading && (!supplier || !product)" padding="lg">
|
<Card v-if="!isLoading && (!supplier || !product)" padding="lg">
|
||||||
@@ -109,6 +118,18 @@ const hoveredHubId = ref<string>()
|
|||||||
const supplierId = computed(() => routeRef.params.supplierId as string)
|
const supplierId = computed(() => routeRef.params.supplierId as string)
|
||||||
const productId = computed(() => routeRef.params.productId as string)
|
const productId = computed(() => routeRef.params.productId as string)
|
||||||
|
|
||||||
|
// Search
|
||||||
|
const searchQuery = ref('')
|
||||||
|
|
||||||
|
const filteredHubs = computed(() => {
|
||||||
|
if (!searchQuery.value.trim()) return hubs.value
|
||||||
|
const q = searchQuery.value.toLowerCase()
|
||||||
|
return hubs.value.filter(hub =>
|
||||||
|
hub.name?.toLowerCase().includes(q) ||
|
||||||
|
hub.country?.toLowerCase().includes(q)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// Handle hub selection
|
// Handle hub selection
|
||||||
const onSelectHub = (hub: any) => {
|
const onSelectHub = (hub: any) => {
|
||||||
navigateTo(localePath(`/catalog/suppliers/${supplierId.value}/${productId.value}/${hub.uuid}`))
|
navigateTo(localePath(`/catalog/suppliers/${supplierId.value}/${productId.value}/${hub.uuid}`))
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<CatalogPage
|
<CatalogPage
|
||||||
:items="products"
|
:items="filteredProducts"
|
||||||
:map-items="mapItems"
|
:map-items="mapItems"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
|
:total-count="products.length"
|
||||||
with-map
|
with-map
|
||||||
map-id="supplier-products-map"
|
map-id="supplier-products-map"
|
||||||
point-color="#3b82f6"
|
point-color="#3b82f6"
|
||||||
>
|
>
|
||||||
|
<template #searchBar="{ displayedCount, totalCount }">
|
||||||
|
<CatalogSearchBar
|
||||||
|
v-model:search-query="searchQuery"
|
||||||
|
:displayed-count="displayedCount"
|
||||||
|
:total-count="totalCount"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<!-- Supplier Not Found -->
|
<!-- Supplier Not Found -->
|
||||||
<Card v-if="!isLoading && !supplier" padding="lg">
|
<Card v-if="!isLoading && !supplier" padding="lg">
|
||||||
@@ -91,6 +100,17 @@ const offers = ref<any[]>([])
|
|||||||
|
|
||||||
const supplierId = computed(() => route.params.supplierId as string)
|
const supplierId = computed(() => route.params.supplierId as string)
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
// Map items - show supplier location
|
// Map items - show supplier location
|
||||||
const mapItems = computed(() => {
|
const mapItems = computed(() => {
|
||||||
if (!supplier.value?.latitude || !supplier.value?.longitude) return []
|
if (!supplier.value?.latitude || !supplier.value?.longitude) return []
|
||||||
|
|||||||
Reference in New Issue
Block a user