From 5aaed89e948b83cc3974e3d7bdb789d3314571cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Garn=C3=A6s?= Date: Fri, 5 Jul 2024 14:41:55 +0200 Subject: [PATCH 1/6] Create basic details for materials based on FBS information This can the be used as fallback information for physical materials in case these cannot be retrieved from FBI in the material fetch higher-order component. Without this then the material will not be rendered at all. One known situation where this occurs is interlibrary loans from the Royal Danish Library. --- .../materials/utils/material-fetch-hoc.tsx | 4 ++- src/core/utils/helpers/list-mapper.ts | 28 +++++++++++++++++-- src/core/utils/types/list-type.ts | 9 +++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/apps/loan-list/materials/utils/material-fetch-hoc.tsx b/src/apps/loan-list/materials/utils/material-fetch-hoc.tsx index 150cce20f4..75c04981a1 100644 --- a/src/apps/loan-list/materials/utils/material-fetch-hoc.tsx +++ b/src/apps/loan-list/materials/utils/material-fetch-hoc.tsx @@ -64,6 +64,8 @@ const fetchMaterial = useEffect(() => { if (manifestation) { setMaterial(mapManifestationToBasicDetailsType(manifestation)); + } else if (item.details) { + setMaterial(item.details); } }, [manifestation]); @@ -73,7 +75,7 @@ const fetchMaterial = } // in cases where the material is not found we return null, else we would load forever - if (!manifestation) return null; + if (!material) return null; return ( { loanType: loanDetails.loanType, identifier: null, faust: (loanDetails.recordId as FaustId) || null, - loanId: loanDetails.loanId + loanId: loanDetails.loanId, + details: loanDetails.ilBibliographicRecord + ? { + title: loanDetails.ilBibliographicRecord.title, + authors: loanDetails.ilBibliographicRecord.author, + authorsShort: loanDetails.ilBibliographicRecord.author, + firstAuthor: loanDetails.ilBibliographicRecord.author, + year: loanDetails.ilBibliographicRecord.publicationDate, + lang: loanDetails.ilBibliographicRecord.language + } + : null }; }); }; @@ -249,7 +259,8 @@ export const mapFBSReservationGroupToReservationType = ( pickupDeadline, pickupNumber, periodical, - records + records, + ilBibliographicRecord }) => { return { periodical: periodical?.displayText || "", @@ -261,7 +272,18 @@ export const mapFBSReservationGroupToReservationType = ( pickupBranch, pickupDeadline, pickupNumber, - reservationIds: values(records) + reservationIds: values(records), + details: ilBibliographicRecord + ? { + title: ilBibliographicRecord.title, + authors: ilBibliographicRecord.author, + authorsShort: ilBibliographicRecord.author, + firstAuthor: ilBibliographicRecord.author, + year: ilBibliographicRecord.publicationDate, + lang: ilBibliographicRecord.language, + isbn: ilBibliographicRecord.isbn + } + : null }; } ); diff --git a/src/core/utils/types/list-type.ts b/src/core/utils/types/list-type.ts index 631c3fa749..953058a635 100644 --- a/src/core/utils/types/list-type.ts +++ b/src/core/utils/types/list-type.ts @@ -1,5 +1,6 @@ import { FaustId, LoanId } from "./ids"; import { Nullable } from "./nullable"; +import { BasicDetailsType } from "./basic-details-type"; export type ListIdsType = { faust: FaustId; @@ -8,7 +9,13 @@ export type ListIdsType = { loanId: LoanId | null; }; -export type ListType = Nullable>; +export type ListType = Nullable< + Partial< + ListIdsType & { + details: BasicDetailsType; + } + > +>; export function listId(listItem: ListType): string { if (listItem?.reservationIds && listItem.reservationIds.length > 0) { From d1d360f2e550f3acc10e220ac93538984ec14cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Garn=C3=A6s?= Date: Mon, 8 Jul 2024 13:47:09 +0200 Subject: [PATCH 2/6] Ensure vertical alignment for reservations and loans titles in list We want material titles to have the same position even if there are no material types available. Positioning is based on the available child elements of list-reservation__information so add an div for the types even if there are none available. This is especially relevant for interlibrary loans where we get the basic material information from FBS instead of FBI. --- .../stackable-material/material-info.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/apps/loan-list/materials/stackable-material/material-info.tsx b/src/apps/loan-list/materials/stackable-material/material-info.tsx index 0bcef22799..a1a788660d 100644 --- a/src/apps/loan-list/materials/stackable-material/material-info.tsx +++ b/src/apps/loan-list/materials/stackable-material/material-info.tsx @@ -50,13 +50,16 @@ const MaterialInfo: FC = ({ />
- {materialType && ( -
-
- {materialType} + {/* Add a div for material types even if there are none to ensure element alignment */} +
+ {materialType && ( +
+
+ {materialType} +
-
- )} + )} +