feat(catalog): two-level offers navigation + map auto-centering
All checks were successful
Build Docker Image / build (push) Successful in 3m45s
All checks were successful
Build Docker Image / build (push) Successful in 3m45s
- Add fitBounds to CatalogMap for auto-centering on all points - Add productUuid filter to useCatalogOffers composable - Create useCatalogProducts composable for products list - Update offers/index.vue: show products first, then offers by product - Update offers/map.vue: same two-level navigation - Add translations for new UI elements Navigation flow: /catalog/offers → product selection → offers for that product 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,38 @@
|
||||
<template>
|
||||
<NuxtLayout name="map">
|
||||
<template #sidebar>
|
||||
<!-- Product selection mode -->
|
||||
<CatalogMapSidebar
|
||||
:title="t('catalogOffersSection.header.title')"
|
||||
v-if="!selectedProductUuid"
|
||||
:title="t('catalogOffersSection.header.select_product')"
|
||||
:back-link="localePath('/catalog/offers')"
|
||||
:back-label="t('catalogMap.actions.list_view')"
|
||||
:items-count="products.length"
|
||||
:loading="productsLoading"
|
||||
:empty-text="t('catalogOffersSection.empty.no_products')"
|
||||
>
|
||||
<template #cards>
|
||||
<Card
|
||||
v-for="product in products"
|
||||
:key="product.uuid"
|
||||
padding="sm"
|
||||
interactive
|
||||
@click="selectProduct(product)"
|
||||
>
|
||||
<Stack gap="2">
|
||||
<Text size="base" weight="semibold">{{ product.name }}</Text>
|
||||
<Text tone="muted">{{ product.categoryName || t('catalogProduct.labels.category_unknown') }}</Text>
|
||||
</Stack>
|
||||
</Card>
|
||||
</template>
|
||||
</CatalogMapSidebar>
|
||||
|
||||
<!-- Offers for selected product -->
|
||||
<CatalogMapSidebar
|
||||
v-else
|
||||
:title="sidebarTitle"
|
||||
:back-link="localePath('/catalog/offers/map')"
|
||||
:back-label="t('common.back')"
|
||||
:items-count="items.length"
|
||||
:filters="filters"
|
||||
:selected-filter="selectedFilter"
|
||||
@@ -42,17 +70,59 @@ definePageMeta({
|
||||
|
||||
const { t } = useI18n()
|
||||
const localePath = useLocalePath()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
// Products
|
||||
const {
|
||||
items: products,
|
||||
isLoading: productsLoading,
|
||||
init: initProducts
|
||||
} = useCatalogProducts()
|
||||
|
||||
// Offers
|
||||
const {
|
||||
items,
|
||||
selectedFilter,
|
||||
filters,
|
||||
isLoading,
|
||||
itemsWithCoords,
|
||||
init
|
||||
init: initOffers,
|
||||
setProductUuid
|
||||
} = useCatalogOffers()
|
||||
|
||||
await init()
|
||||
// Product from query
|
||||
const selectedProductUuid = computed(() => route.query.product as string | undefined)
|
||||
|
||||
const selectedProduct = computed(() => {
|
||||
if (!selectedProductUuid.value) return null
|
||||
return products.value.find(p => p.uuid === selectedProductUuid.value)
|
||||
})
|
||||
|
||||
const sidebarTitle = computed(() => {
|
||||
if (selectedProduct.value) {
|
||||
return `${t('catalogOffersSection.header.title')}: ${selectedProduct.value.name}`
|
||||
}
|
||||
return t('catalogOffersSection.header.title')
|
||||
})
|
||||
|
||||
// Initialize products
|
||||
await initProducts()
|
||||
|
||||
// Watch for product changes
|
||||
watch(selectedProductUuid, async (uuid) => {
|
||||
setProductUuid(uuid || null)
|
||||
if (uuid) {
|
||||
await initOffers()
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
const selectProduct = (product: any) => {
|
||||
router.push({
|
||||
path: route.path,
|
||||
query: { product: product.uuid }
|
||||
})
|
||||
}
|
||||
|
||||
const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void } | null>(null)
|
||||
const selectedItemId = ref<string | null>(null)
|
||||
|
||||
Reference in New Issue
Block a user