Fallback to nearest offers when calculations unavailable
Some checks failed
Build Docker Image / build (push) Failing after 24s
Some checks failed
Build Docker Image / build (push) Failing after 24s
This commit is contained in:
@@ -397,6 +397,9 @@ const relatedPoints = computed(() => {
|
|||||||
// Offers data for quote results
|
// Offers data for quote results
|
||||||
const offers = ref<QuoteOffer[]>([])
|
const offers = ref<QuoteOffer[]>([])
|
||||||
const quoteCalculations = ref<QuoteCalculation[]>([])
|
const quoteCalculations = ref<QuoteCalculation[]>([])
|
||||||
|
|
||||||
|
const buildCalculationsFromOffers = (list: QuoteOffer[]) =>
|
||||||
|
list.map((offer) => ({ offers: [offer] })) as QuoteCalculation[]
|
||||||
const offersLoading = ref(false)
|
const offersLoading = ref(false)
|
||||||
const showQuoteResults = ref(false)
|
const showQuoteResults = ref(false)
|
||||||
|
|
||||||
@@ -585,6 +588,7 @@ const onSearch = async () => {
|
|||||||
const hubData = await execute(GetNodeDocument, { uuid: hubId.value }, 'public', 'geo')
|
const hubData = await execute(GetNodeDocument, { uuid: hubId.value }, 'public', 'geo')
|
||||||
const hub = hubData?.node
|
const hub = hubData?.node
|
||||||
if (hub?.latitude != null && hub?.longitude != null) {
|
if (hub?.latitude != null && hub?.longitude != null) {
|
||||||
|
try {
|
||||||
const calcData = await execute(
|
const calcData = await execute(
|
||||||
QuoteCalculationsDocument,
|
QuoteCalculationsDocument,
|
||||||
{
|
{
|
||||||
@@ -610,6 +614,29 @@ const onSearch = async () => {
|
|||||||
|
|
||||||
quoteCalculations.value = calculations
|
quoteCalculations.value = calculations
|
||||||
offers.value = calculations.flatMap(calc => (calc.offers || []).filter((offer): offer is QuoteOffer => offer !== null))
|
offers.value = calculations.flatMap(calc => (calc.offers || []).filter((offer): offer is QuoteOffer => offer !== null))
|
||||||
|
} catch (error) {
|
||||||
|
const geoData = await execute(
|
||||||
|
NearestOffersDocument,
|
||||||
|
{
|
||||||
|
lat: hub.latitude,
|
||||||
|
lon: hub.longitude,
|
||||||
|
productUuid: productId.value,
|
||||||
|
hubUuid: hubId.value,
|
||||||
|
radius: 500,
|
||||||
|
limit: 12
|
||||||
|
},
|
||||||
|
'public',
|
||||||
|
'geo'
|
||||||
|
)
|
||||||
|
|
||||||
|
let nearest = (geoData?.nearestOffers || []).filter((o): o is QuoteOffer => o !== null)
|
||||||
|
if (supplierId.value) {
|
||||||
|
nearest = nearest.filter(o => o?.supplierUuid === supplierId.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
offers.value = nearest
|
||||||
|
quoteCalculations.value = buildCalculationsFromOffers(nearest)
|
||||||
|
}
|
||||||
|
|
||||||
const first = offers.value[0]
|
const first = offers.value[0]
|
||||||
if (first?.productName) {
|
if (first?.productName) {
|
||||||
@@ -639,9 +666,7 @@ const onSearch = async () => {
|
|||||||
locationName: offer.locationName,
|
locationName: offer.locationName,
|
||||||
locationCountry: offer.locationCountry
|
locationCountry: offer.locationCountry
|
||||||
}))
|
}))
|
||||||
quoteCalculations.value = offers.value.map((offer) => ({
|
quoteCalculations.value = buildCalculationsFromOffers(offers.value)
|
||||||
offers: [offer]
|
|
||||||
})) as QuoteCalculation[]
|
|
||||||
|
|
||||||
// Update labels from response
|
// Update labels from response
|
||||||
const first = offers.value[0]
|
const first = offers.value[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user