From e43142c1bdad8f34aed8d5a3bcc613f599d825bf Mon Sep 17 00:00:00 2001 From: Edie Lemoine Date: Fri, 16 Aug 2024 16:19:18 +0200 Subject: [PATCH] fix(pickup): fix map markers not reloading properly on address change (#237) INT-590 --- .../src/composables/useResolvedPickupLocations.ts | 13 +------------ apps/sandbox/src/composables/useAddressSelector.ts | 10 +++------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/apps/delivery-options/src/composables/useResolvedPickupLocations.ts b/apps/delivery-options/src/composables/useResolvedPickupLocations.ts index 249b7b59..fbb4d118 100644 --- a/apps/delivery-options/src/composables/useResolvedPickupLocations.ts +++ b/apps/delivery-options/src/composables/useResolvedPickupLocations.ts @@ -14,7 +14,6 @@ import {type PickupLocation} from '@myparcel/sdk'; import {DeliveryTypeName} from '@myparcel/constants'; import {createLatLngParameters, createGetDeliveryOptionsParameters} from '../utils'; import {type ResolvedPickupLocation, type LatLng} from '../types'; -import {useAddressStore} from '../stores'; import {type UseResolvedCarrier} from './useResolvedCarrier'; import {useActiveCarriers} from './useActiveCarriers'; @@ -147,14 +146,4 @@ const callback = (): UseResolvedPickupLocations => { }; }; -export const useResolvedPickupLocations = useMemoize(callback, { - /** - * Cache per address, so the locations are reloaded when the address changes. Not ideal, but otherwise the address - * would have to be passed as a parameter to the composable - */ - getKey() { - const addressStore = useAddressStore(); - - return JSON.stringify(addressStore.$state); - }, -}); +export const useResolvedPickupLocations = useMemoize(callback); diff --git a/apps/sandbox/src/composables/useAddressSelector.ts b/apps/sandbox/src/composables/useAddressSelector.ts index c0271d59..d9585cfe 100644 --- a/apps/sandbox/src/composables/useAddressSelector.ts +++ b/apps/sandbox/src/composables/useAddressSelector.ts @@ -94,14 +94,10 @@ export const useAddressSelector = (): UseAddressSelector => { const matchingAddress = sampleAddresses.find((address) => address[AddressField.Country] === value); - const obj = Object.values(AddressField).reduce((acc, key: AddressField) => { + Object.values(AddressField).forEach((key: AddressField) => { // @ts-expect-error todo - acc[`${KEY_ADDRESS}.${key}`] = matchingAddress?.[key]; - - return acc; - }, {} as Record); - - form.setValues(obj); + form.values[`${KEY_ADDRESS}.${key}`] = matchingAddress?.[key]; + }); }), );