From 241325b932b987cf04829bc0b1dbaaa7df3ff8b9 Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Fri, 12 Apr 2024 12:13:25 +0400 Subject: [PATCH] UIOR-1251 Align 'useIsFundRestrictedByLocationIds' with the schema changes --- .../useIsFundsRestrictedByLocationIds.js | 2 +- .../useIsFundsRestrictedByLocationIds.test.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.js b/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.js index f45f4188a..5863b8328 100644 --- a/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.js +++ b/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.js @@ -30,7 +30,7 @@ export const useIsFundsRestrictedByLocationIds = ({ const fundsWithRestrictedLocations = useMemo(() => { return funds .filter(({ restrictByLocations }) => restrictByLocations) - .map(({ locationIds }) => locationIds); + .map(({ locations }) => locations.map(({ locationId }) => locationId)); }, [funds]); const isFundNotRestricted = useCallback(() => { diff --git a/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.test.js b/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.test.js index 809341489..c0f91d0a7 100644 --- a/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.test.js +++ b/src/components/POLine/hooks/useIsFundsRestrictedByLocationIds/useIsFundsRestrictedByLocationIds.test.js @@ -25,9 +25,9 @@ const restrictedFund = { 'id': 'e3f68402-5570-4839-a54a-cecd5fd799e5', 'name': 'Location restricted', 'restrictByLocations': true, - 'locationIds': [ - '53cf956f-c1df-410b-8bea-27f712cca7c0', - '184aae84-a5bf-4c6a-85ba-4a7c73026cd5', + 'locations': [ + { locationId: '53cf956f-c1df-410b-8bea-27f712cca7c0' }, + { locationId: '184aae84-a5bf-4c6a-85ba-4a7c73026cd5' }, ], }; @@ -35,7 +35,7 @@ const fundIds = [restrictedFund.id]; const holdingData = { 'id': '53cf956f-c1df-410b-8bea-27f712cca7c0', - 'permanentLocationId': restrictedFund.locationIds[0], + 'permanentLocationId': restrictedFund.locations[0].locationId, }; describe('useIsFundsRestrictedByLocationIds', () => { @@ -57,7 +57,7 @@ describe('useIsFundsRestrictedByLocationIds', () => { it('should return hasLocationRestrictedFund as true', async () => { const { result } = renderHook(() => useIsFundsRestrictedByLocationIds({ fundIds, - locationIds: ['testId'], + locations: ['testId'], holdingIds: [], }), { wrapper }); @@ -69,7 +69,7 @@ describe('useIsFundsRestrictedByLocationIds', () => { it('should return hasLocationRestrictedFund as false', async () => { const { result } = renderHook(() => useIsFundsRestrictedByLocationIds({ fundIds, - locationIds: restrictedFund.locationIds, + locationIds: restrictedFund.locations.map(({ locationId }) => locationId), holdingIds: [], }), { wrapper });