Fix supplier info and catalog filtering bugs
All checks were successful
Build Docker Image / build (push) Successful in 3m22s
All checks were successful
Build Docker Image / build (push) Successful in 3m22s
1. Add latitude/longitude to GetSupplierProfile query - Without coordinates, supplier merge overwrites geo node data - Causes "Supplier has no coordinates" warning and no offers loading - Affects: useCatalogInfo.ts loadSupplierInfo() and useCatalogProducts.ts fetchProducts() 2. Add bounds validation in catalog composables - Validate bounds coordinates before passing to GraphQL or using in filters - Prevents 400 errors when bounds contain NaN/undefined/Infinity - Fixed in: useCatalogHubs.ts and useCatalogSuppliers.ts Fixes: - https://optovia.ru/catalog?info=supplier:c7f2e3f1-b16a-423d-a947-359e30858d94 - https://optovia.ru/catalog?select=hub 400 error Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,17 +49,25 @@ export function useCatalogSuppliers() {
|
||||
// If bounds filter is active, fetch more and filter client-side
|
||||
// TODO: Add bounds support to exchange backend for proper server-side filtering
|
||||
const bounds = filterBounds.value
|
||||
const fetchLimit = bounds ? 500 : PAGE_SIZE
|
||||
|
||||
// Validate bounds coordinates
|
||||
const validBounds = bounds &&
|
||||
typeof bounds.west === 'number' && isFinite(bounds.west) &&
|
||||
typeof bounds.south === 'number' && isFinite(bounds.south) &&
|
||||
typeof bounds.east === 'number' && isFinite(bounds.east) &&
|
||||
typeof bounds.north === 'number' && isFinite(bounds.north)
|
||||
|
||||
const fetchLimit = validBounds ? 500 : PAGE_SIZE
|
||||
const data = await execute(
|
||||
GetSupplierProfilesDocument,
|
||||
{ limit: fetchLimit, offset: bounds ? 0 : offset },
|
||||
{ limit: fetchLimit, offset: validBounds ? 0 : offset },
|
||||
'public',
|
||||
'exchange'
|
||||
)
|
||||
let next = data?.getSupplierProfiles || []
|
||||
|
||||
// Client-side bounds filtering (until exchange backend supports it)
|
||||
if (bounds) {
|
||||
if (validBounds) {
|
||||
next = next.filter((s: any) => {
|
||||
if (!s.latitude || !s.longitude) return false
|
||||
const lat = Number(s.latitude)
|
||||
@@ -70,7 +78,7 @@ export function useCatalogSuppliers() {
|
||||
}
|
||||
|
||||
items.value = replace ? next : items.value.concat(next)
|
||||
total.value = bounds ? next.length : (data?.getSupplierProfilesCount ?? total.value)
|
||||
total.value = validBounds ? next.length : (data?.getSupplierProfilesCount ?? total.value)
|
||||
isInitialized.value = true
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
|
||||
Reference in New Issue
Block a user