Use graph-based offers and remove radius filters
Some checks failed
Build Docker Image / build (push) Has been cancelled
Some checks failed
Build Docker Image / build (push) Has been cancelled
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
||||
NearestOffersDocument
|
||||
} from '~/composables/graphql/public/geo-generated'
|
||||
import {
|
||||
GetSupplierProfileDocument
|
||||
GetSupplierOffersDocument
|
||||
} from '~/composables/graphql/public/exchange-generated'
|
||||
|
||||
// Type from codegen
|
||||
@@ -43,46 +43,26 @@ export function useCatalogProducts() {
|
||||
let data
|
||||
|
||||
if (filterSupplierUuid.value) {
|
||||
// Products from specific supplier - get supplier coordinates first
|
||||
const supplierData = await execute(
|
||||
GetSupplierProfileDocument,
|
||||
{ uuid: filterSupplierUuid.value },
|
||||
// Products from specific supplier - get offers directly (no geo radius)
|
||||
const offersData = await execute(
|
||||
GetSupplierOffersDocument,
|
||||
{ teamUuid: filterSupplierUuid.value },
|
||||
'public',
|
||||
'exchange'
|
||||
)
|
||||
const supplier = supplierData?.getSupplierProfile
|
||||
|
||||
if (!supplier?.latitude || !supplier?.longitude) {
|
||||
console.warn('Supplier has no coordinates')
|
||||
items.value = []
|
||||
} else {
|
||||
// Get offers near supplier and group by product
|
||||
const offersData = await execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: supplier.latitude,
|
||||
lon: supplier.longitude,
|
||||
radius: 500
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
)
|
||||
|
||||
// Group offers by product
|
||||
const productsMap = new Map<string, AggregatedProduct>()
|
||||
offersData?.nearestOffers?.forEach((offer) => {
|
||||
if (!offer?.productUuid) return
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
})
|
||||
items.value = Array.from(productsMap.values()) as ProductItem[]
|
||||
}
|
||||
const productsMap = new Map<string, AggregatedProduct>()
|
||||
offersData?.getOffers?.forEach((offer) => {
|
||||
if (!offer?.productUuid) return
|
||||
if (!productsMap.has(offer.productUuid)) {
|
||||
productsMap.set(offer.productUuid, {
|
||||
uuid: offer.productUuid,
|
||||
name: offer.productName,
|
||||
offersCount: 0
|
||||
})
|
||||
}
|
||||
productsMap.get(offer.productUuid)!.offersCount++
|
||||
})
|
||||
items.value = Array.from(productsMap.values()) as ProductItem[]
|
||||
} else if (filterHubUuid.value) {
|
||||
// Products near hub - get hub coordinates first
|
||||
const hubData = await execute(
|
||||
@@ -97,13 +77,14 @@ export function useCatalogProducts() {
|
||||
console.warn('Hub has no coordinates')
|
||||
items.value = []
|
||||
} else {
|
||||
// Get offers near hub and group by product
|
||||
// Get offers by graph from hub and group by product
|
||||
const offersData = await execute(
|
||||
NearestOffersDocument,
|
||||
{
|
||||
lat: hub.latitude,
|
||||
lon: hub.longitude,
|
||||
radius: 500
|
||||
hubUuid: filterHubUuid.value,
|
||||
limit: 500
|
||||
},
|
||||
'public',
|
||||
'geo'
|
||||
|
||||
Reference in New Issue
Block a user