Skip to content

Commit

Permalink
fix(pickup): fix map markers not reloading properly on address change (
Browse files Browse the repository at this point in the history
…#237)

INT-590
  • Loading branch information
EdieLemoine authored Aug 16, 2024
1 parent 47df655 commit e43142c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
10 changes: 3 additions & 7 deletions apps/sandbox/src/composables/useAddressSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>);

form.setValues(obj);
form.values[`${KEY_ADDRESS}.${key}`] = matchingAddress?.[key];
});
}),
);

Expand Down

0 comments on commit e43142c

Please sign in to comment.