-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIREC-411: ECS - fix user with no affiliation to the location in POL …
…can not add pieces to the receiving title related to that POL (#598) * UIOR-1324: ECS - fix user with no affiliation to the location in POL can not add pieces to the receiving title related to that POL * test: fix failing tests * refactor: useHoldingsAndLocations options using custom `useReceivingTenantIdsAndLocations` hook * update changelog * test: fix failing tests * UIREC-407: upgrade `holdings-storage` to 8.0 * UIREC-370: Disable pieces dropdown button when "Save and close" button is disabled * fix includes not found issue
- Loading branch information
1 parent
9a5d568
commit bb6e05c
Showing
12 changed files
with
125 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import uniq from 'lodash/uniq'; | ||
import { useMemo } from 'react'; | ||
|
||
import { useCurrentUserTenants } from '@folio/stripes-acq-components'; | ||
|
||
export const useReceivingTenantIdsAndLocations = ({ | ||
currentReceivingTenantId, | ||
currentLocationId: locationId, | ||
receivingTenantIds = [], | ||
}) => { | ||
const currentUserTenants = useCurrentUserTenants(); | ||
|
||
const receivingTenants = useMemo(() => { | ||
if (receivingTenantIds.length) { | ||
const currentUserTenantIds = currentUserTenants?.map(({ id: tenantId }) => tenantId); | ||
|
||
// should get unique tenantIds from poLine locations and filter out tenantIds where the current user has assigned | ||
return uniq([ | ||
...receivingTenantIds, | ||
currentReceivingTenantId, | ||
].filter((tenantId) => currentUserTenantIds?.includes(tenantId)) | ||
.filter(Boolean)); | ||
} | ||
|
||
return []; | ||
}, [receivingTenantIds, currentUserTenants, currentReceivingTenantId]); | ||
|
||
const additionalLocations = useMemo(() => { | ||
const locationIds = locationId ? [locationId] : []; | ||
const tenantLocationIdsMap = currentReceivingTenantId ? { [currentReceivingTenantId]: locationIds } : {}; | ||
|
||
return { | ||
additionalLocationIds: locationIds, | ||
additionalTenantLocationIdsMap: tenantLocationIdsMap, | ||
}; | ||
}, [locationId, currentReceivingTenantId]); | ||
|
||
return { | ||
receivingTenantIds: receivingTenants, | ||
tenantId: currentReceivingTenantId, | ||
...additionalLocations, | ||
}; | ||
}; |