diff --git a/src/apps/loan-list/materials/selectable-material/selectable-material.tsx b/src/apps/loan-list/materials/selectable-material/selectable-material.tsx index af2289a8b1..a476365c1b 100644 --- a/src/apps/loan-list/materials/selectable-material/selectable-material.tsx +++ b/src/apps/loan-list/materials/selectable-material/selectable-material.tsx @@ -13,9 +13,11 @@ import ArrowButton from "../../../../components/Buttons/ArrowButton"; import { isDigital } from "../../utils/helpers"; import { listId, ListType } from "../../../../core/utils/types/list-type"; import SelectableMaterialSkeleton from "./selectable-material-skeleton"; +import { ILLBibliographicRecord } from "../../../../core/fbs/model"; interface SelectableMaterialProps { identifier?: string | null; + ilBibliographicRecord?: ILLBibliographicRecord; disabled?: boolean; item?: ListType; onMaterialChecked?: (listItem: ListType) => void; @@ -32,6 +34,7 @@ interface SelectableMaterialProps { const SelectableMaterial: FC = ({ material, + ilBibliographicRecord, disabled, onMaterialChecked, selected, @@ -48,7 +51,7 @@ const SelectableMaterial: FC = ({ const t = useText(); if (!item) return null; - const { + let { authorsShort = "", materialType, year = "", @@ -56,6 +59,16 @@ const SelectableMaterial: FC = ({ lang } = material || {}; + // There is a chance material isn't provided, if corresponding reservation PID is + // incorrect (that's unfortunately possible). Then we use ilBibliographicRecord data. + if (!material) { + authorsShort = ilBibliographicRecord?.author || ""; + materialType = ""; + year = ilBibliographicRecord?.publicationDate || ""; + title = ilBibliographicRecord?.title || ""; + lang = ilBibliographicRecord?.language || ""; + } + // The reason why the handlers are used on multiple containers is because of multiple reasons: // * We cannot attach them to the li or the list-materials container because it prevents the checkbox from being checked. // * We cannot make a container for the rest of the content with the handlers because it breaks the flexbox layout. @@ -110,9 +123,14 @@ const SelectableMaterial: FC = ({ tabIndex={0} >
-
- {materialType} -
+ {materialType && materialType !== "" && ( +
+ {materialType} +
+ )} + {(!materialType || materialType === "") && ( + + )}
{statusBadgeComponentMobile || null}

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..0c46e93f28 100644 --- a/src/apps/loan-list/materials/utils/material-fetch-hoc.tsx +++ b/src/apps/loan-list/materials/utils/material-fetch-hoc.tsx @@ -8,12 +8,14 @@ import { Product } from "../../../../core/publizon/model"; import { BasicDetailsType } from "../../../../core/utils/types/basic-details-type"; import { mapManifestationToBasicDetailsType } from "../../../../core/utils/helpers/list-mapper"; import { ListType } from "../../../../core/utils/types/list-type"; +import { ILLBibliographicRecord } from "../../../../core/fbs/model"; export interface MaterialProps { material?: BasicDetailsType | null; } type InputProps = { + ilBibliographicRecord?: ILLBibliographicRecord; digitalMaterial?: Product | null; item?: ListType; }; @@ -72,8 +74,9 @@ const fetchMaterial = return FallbackComponent ? : null; } - // in cases where the material is not found we return null, else we would load forever - if (!manifestation) return null; + // In cases where the material is not found AND we don't have fallback data + // we return null, else we would load forever. + if (!manifestation && !props.ilBibliographicRecord) return null; return ( ); } diff --git a/src/components/GroupModal/GroupModalReservationsList.tsx b/src/components/GroupModal/GroupModalReservationsList.tsx index 3a4e54b7f1..6b8dad5943 100644 --- a/src/components/GroupModal/GroupModalReservationsList.tsx +++ b/src/components/GroupModal/GroupModalReservationsList.tsx @@ -10,6 +10,7 @@ import { import StatusBadge from "../../apps/loan-list/materials/utils/status-badge"; import { ListType } from "../../core/utils/types/list-type"; import { getStatusText } from "../../apps/reservation-list/utils/helpers"; +import { ILLBibliographicRecord } from "../../core/fbs/model"; export interface GroupModalReservationsListProps { materials: ReservationType[]; @@ -75,9 +76,7 @@ const GroupModalReservationsList: FC = ({ const selected = selectedMaterials?.some((selectedMaterial) => isEqual(selectedMaterial, material) ); - const statusText: string = getStatusText(material, t); - const statusBadgeComponent = statusText ? ( = ({ disabled={false} statusMessageComponentMobile={null} statusMessageComponentDesktop={null} + // material.ilBibliographicRecord is of the ILLBibliographicRecord type, + // we just make it nullable in the code defining ReservationType. + ilBibliographicRecord={ + material.ilBibliographicRecord as ILLBibliographicRecord + } /> ) );