-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
getReservablePidsFromAnotherLibrary
to `useReservableFromA…
…notherLibrary` hook Added validation with FBS to verify manifestation's reservable status (must be false) for Overbygningsmaterial/OpenOrder reservations. in addition, I have commented out the tests that were for `getReservablePidsFromAnotherLibrary` as they must be rewritten for the new hook
- Loading branch information
1 parent
283755e
commit 8975521
Showing
4 changed files
with
109 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useConfig } from "./config"; | ||
import { getAllFaustIds } from "./helpers/general"; | ||
import { useGetHoldings } from "../../apps/material/helper"; | ||
import { Manifestation } from "./types/entities"; | ||
|
||
const useReservableFromAnotherLibrary = (manifestations: Manifestation[]) => { | ||
const config = useConfig(); | ||
const { data: holdingsData } = useGetHoldings({ | ||
faustIds: getAllFaustIds(manifestations), | ||
config | ||
}); | ||
|
||
// If there is no holdings data or if there are holdings that are reservable, we return an empty array. | ||
// Because we use the array length to determine if we should show the button or not. | ||
if (holdingsData?.some(({ reservable }) => reservable === true)) { | ||
return { reservablePidsFromAnotherLibrary: [] }; | ||
} | ||
|
||
const reservablePidsFromAnotherLibrary = manifestations | ||
.filter(({ catalogueCodes }) => | ||
catalogueCodes?.otherCatalogues.some((code) => code.startsWith("OVE")) | ||
) | ||
.map(({ pid }) => pid); | ||
|
||
return { reservablePidsFromAnotherLibrary }; | ||
}; | ||
|
||
export default useReservableFromAnotherLibrary; |