-
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.
Merge pull request #1433 from danskernesdigitalebibliotek/DDFBRA-49-v…
…i-har-xx-eksemplarer-af-materialet-hjemme-vises-kun-under-handleknap-for-indlogget-bruger We have XX specimens - fix business logic
- Loading branch information
Showing
4 changed files
with
64 additions
and
17 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,31 @@ | ||
import { AccessTypeCode } from "../../core/dbc-gateway/generated/graphql"; | ||
import { Manifestation } from "../../core/utils/types/entities"; | ||
import { ManifestationMaterialType } from "../../core/utils/types/material-type"; | ||
import { hasCorrectMaterialType, isArticle } from "./material-buttons/helper"; | ||
|
||
export const isPhysical = (manifestations: Manifestation[]) => { | ||
return manifestations.some((manifestation) => { | ||
return manifestation.accessTypes.some((acc) => { | ||
return acc.code === AccessTypeCode.Physical; | ||
}); | ||
}); | ||
}; | ||
|
||
export const isPeriodical = (manifestations: Manifestation[]) => { | ||
return hasCorrectMaterialType( | ||
ManifestationMaterialType.magazine, | ||
manifestations | ||
); | ||
}; | ||
|
||
export const shouldShowMaterialAvailabilityText = ( | ||
manifestations: Manifestation[] | ||
) => { | ||
return ( | ||
isPhysical(manifestations) && | ||
!isPeriodical(manifestations) && | ||
!isArticle(manifestations) | ||
); | ||
}; | ||
|
||
export default {}; |