Refactor catalog filters: remove badges, use select dropdowns
All checks were successful
Build Docker Image / build (push) Successful in 4m21s
All checks were successful
Build Docker Image / build (push) Successful in 4m21s
- Remove filter from suppliers page (not needed) - Offers: show all active offers directly, add product type filter as select - Hubs: change filter from pills to select dropdown - Create CatalogFilterSelect component for dropdown filters - Update useCatalogOffers to always filter active, use product filter
This commit is contained in:
@@ -5,21 +5,14 @@ const PAGE_SIZE = 24
|
||||
// Shared state across list and map views
|
||||
const items = ref<any[]>([])
|
||||
const total = ref(0)
|
||||
const selectedFilter = ref('all')
|
||||
const productUuid = ref<string | null>(null)
|
||||
const selectedProductUuid = ref<string | null>(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,
|
||||
|
||||
Reference in New Issue
Block a user