diff --git a/app/components/catalog/CatalogFilterSelect.vue b/app/components/catalog/CatalogFilterSelect.vue new file mode 100644 index 0000000..39155ea --- /dev/null +++ b/app/components/catalog/CatalogFilterSelect.vue @@ -0,0 +1,31 @@ + + + diff --git a/app/composables/useCatalogOffers.ts b/app/composables/useCatalogOffers.ts index fb2a3c6..a8539a9 100644 --- a/app/composables/useCatalogOffers.ts +++ b/app/composables/useCatalogOffers.ts @@ -5,21 +5,14 @@ const PAGE_SIZE = 24 // Shared state across list and map views const items = ref([]) const total = ref(0) -const selectedFilter = ref('all') -const productUuid = ref(null) +const selectedProductUuid = ref(null) const isLoading = ref(false) const isLoadingMore = ref(false) const isInitialized = ref(false) export function useCatalogOffers() { - const { t } = useI18n() const { execute } = useGraphQL() - const filters = computed(() => [ - { id: 'all', label: t('catalogOffersSection.filters.all') }, - { id: 'active', label: t('catalogOffersSection.filters.active') } - ]) - const itemsWithCoords = computed(() => items.value .filter(offer => offer.locationLatitude && offer.locationLongitude) @@ -37,14 +30,13 @@ export function useCatalogOffers() { const fetchPage = async (offset: number, replace = false) => { if (replace) isLoading.value = true try { - const status = selectedFilter.value === 'active' ? 'active' : null const data = await execute( GetOffersDocument, { limit: PAGE_SIZE, offset, - status, - productUuid: productUuid.value + status: 'active', + productUuid: selectedProductUuid.value }, 'public', 'exchange' @@ -59,10 +51,11 @@ export function useCatalogOffers() { } const setProductUuid = (uuid: string | null) => { - if (productUuid.value !== uuid) { - productUuid.value = uuid - isInitialized.value = false - items.value = [] + if (selectedProductUuid.value !== uuid) { + selectedProductUuid.value = uuid + if (isInitialized.value) { + fetchPage(0, true) + } } } @@ -76,13 +69,6 @@ export function useCatalogOffers() { } } - // При смене фильтра - перезагрузка - watch(selectedFilter, () => { - if (isInitialized.value) { - fetchPage(0, true) - } - }) - // Initialize data if not already loaded const init = async () => { if (!isInitialized.value && items.value.length === 0) { @@ -93,9 +79,7 @@ export function useCatalogOffers() { return { items, total, - selectedFilter, - productUuid, - filters, + selectedProductUuid, isLoading, isLoadingMore, itemsWithCoords, diff --git a/app/pages/catalog/hubs/index.vue b/app/pages/catalog/hubs/index.vue index 61dcff6..3bd214c 100644 --- a/app/pages/catalog/hubs/index.vue +++ b/app/pages/catalog/hubs/index.vue @@ -8,7 +8,7 @@ @select="onSelectHub" >