From 27f14f60f99945975dd039690b52ff49efa01aa8 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Sun, 14 Jan 2024 00:42:51 +0100 Subject: [PATCH] Found more issing materialTypeSpecific references In code and in tests. Since work.manifestationss[0].materialType.specific was refactored to work.manifestations[0].materialType.materialTypeSpecific.display we need change all occurences. And it appears to be a lot! We could use a general pointer to the value in manifesations! --- src/apps/loan-list/list/loan-list.test.ts | 2 +- src/apps/loan-list/modal/modals.test.tsx | 2 +- src/apps/material/helper.ts | 9 +++++---- .../list/reservation-list-pagination.test.ts | 2 +- .../modal/delete-reservation/delete-reservation.test.ts | 2 +- src/components/find-on-shelf/FindOnShelfModalBody.tsx | 2 +- src/components/instant-loan/InstantLoan.tsx | 2 +- src/components/material/MaterialMainfestationItem.tsx | 2 +- src/components/material/material-buttons/helper.ts | 3 ++- .../online/MaterialButtonOnlineExternal.tsx | 4 ++-- 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/apps/loan-list/list/loan-list.test.ts b/src/apps/loan-list/list/loan-list.test.ts index 3c70879404..6330e22182 100644 --- a/src/apps/loan-list/list/loan-list.test.ts +++ b/src/apps/loan-list/list/loan-list.test.ts @@ -182,7 +182,7 @@ describe("Loan list", () => { display: "2006" } }, - materialTypes: [{ specific: "Dummy bog" }], + materialTypes: [{ materialTypeSpecific: { display: "Dummy bog" } }], creators: [ { display: "Dummy Jens Jensen" }, { display: "Dummy Some Corporation" } diff --git a/src/apps/loan-list/modal/modals.test.tsx b/src/apps/loan-list/modal/modals.test.tsx index 9876a01773..8f1f35951c 100644 --- a/src/apps/loan-list/modal/modals.test.tsx +++ b/src/apps/loan-list/modal/modals.test.tsx @@ -53,7 +53,7 @@ describe("Modals", () => { display: "2006" } }, - materialTypes: [{ specific: "Dummy bog" }], + materialTypes: [{ materialTypeSpecific: { display: "Dummy bog" } }], creators: [ { display: "Dummy Jens Jensen" }, { display: "Dummy Some Corporation" } diff --git a/src/apps/material/helper.ts b/src/apps/material/helper.ts index cb042c4e22..2e8af28efd 100644 --- a/src/apps/material/helper.ts +++ b/src/apps/material/helper.ts @@ -45,7 +45,7 @@ export const getManifestationsOrderByTypeAndYear = ( const materialsMappedBytype = groupBy( orderedByYear, // all manifestations that not have a material type will be grouped under "unknown" - (m) => m?.materialTypes[0]?.specific ?? "unknown" + (m) => m?.materialTypes[0]?.materialTypeSpecific.display ?? "unknown" ); return ( @@ -347,7 +347,8 @@ export const isABook = (manifestations: Manifestation[]) => { return manifestations.some((manifestation) => { return manifestation.materialTypes.some( (materialType) => - materialType.specific.toLowerCase() === ManifestationMaterialType.book + materialType.materialTypeSpecific.display.toLowerCase() === + ManifestationMaterialType.book ); }); }; @@ -358,7 +359,7 @@ export const getBestMaterialTypeForManifestation = ( if (isABook([manifestation])) { return ManifestationMaterialType.book; } - return manifestation.materialTypes[0].specific; + return manifestation.materialTypes[0].materialTypeSpecific.display; }; export const getBestMaterialTypeForWork = (work: Work) => { @@ -377,7 +378,7 @@ export const getBestMaterialTypeForWork = (work: Work) => { return ManifestationMaterialType.book; } return getManifestationsWithMaterialType(work.manifestations.all)[0] - .materialTypes[0].specific; + .materialTypes[0].materialTypeSpecific.display; }; export const reservationModalId = (faustIds: FaustId[]) => { diff --git a/src/apps/reservation-list/list/reservation-list-pagination.test.ts b/src/apps/reservation-list/list/reservation-list-pagination.test.ts index 47f3956639..c5cdb42edd 100644 --- a/src/apps/reservation-list/list/reservation-list-pagination.test.ts +++ b/src/apps/reservation-list/list/reservation-list-pagination.test.ts @@ -302,7 +302,7 @@ describe("Reservation list pagination", () => { display: "2006" } }, - materialTypes: [{ specific: "Dummy bog" }], + materialTypes: [{ materialTypeSpecific: { display: "Dummy bog" } }], creators: [ { display: "Dummy Jens Jensen" }, { display: "Dummy Some Corporation" } diff --git a/src/apps/reservation-list/modal/delete-reservation/delete-reservation.test.ts b/src/apps/reservation-list/modal/delete-reservation/delete-reservation.test.ts index 382441c8e0..0168492309 100644 --- a/src/apps/reservation-list/modal/delete-reservation/delete-reservation.test.ts +++ b/src/apps/reservation-list/modal/delete-reservation/delete-reservation.test.ts @@ -169,7 +169,7 @@ describe("Delete reservation modal", () => { display: "2006" } }, - materialTypes: [{ specific: "Dummy bog" }], + materialTypes: [{ materialTypeSpecific: { display: "Dummy bog" } }], creators: [ { display: "Dummy Jens Jensen" }, { display: "Dummy Some Corporation" } diff --git a/src/components/find-on-shelf/FindOnShelfModalBody.tsx b/src/components/find-on-shelf/FindOnShelfModalBody.tsx index 4d280f94f1..7039d139dd 100644 --- a/src/components/find-on-shelf/FindOnShelfModalBody.tsx +++ b/src/components/find-on-shelf/FindOnShelfModalBody.tsx @@ -57,7 +57,7 @@ const FindOnShelfModalBody: FC = ({ const title = workTitles.join(", "); const isPeriodical = manifestations.some((manifestation) => { return manifestation.materialTypes.some((materialType) => { - return materialType.specific.includes("tidsskrift"); + return materialType.materialTypeSpecific.display === "tidsskrift"; }); }); diff --git a/src/components/instant-loan/InstantLoan.tsx b/src/components/instant-loan/InstantLoan.tsx index 6bb66dcd3f..ef89b86ae1 100644 --- a/src/components/instant-loan/InstantLoan.tsx +++ b/src/components/instant-loan/InstantLoan.tsx @@ -15,7 +15,7 @@ const InstantLoan: React.FunctionComponent = ({ instantLoanBranchHoldings }) => { const { pid, materialTypes } = manifestation; - const materialType = materialTypes[0].specific; + const materialType = materialTypes[0].materialTypeSpecific.display; return ( = ({
identifier.value)} accessTypes={accessTypesCodes} diff --git a/src/components/material/material-buttons/helper.ts b/src/components/material/material-buttons/helper.ts index 8d50a6f536..0ae4721e7d 100644 --- a/src/components/material/material-buttons/helper.ts +++ b/src/components/material/material-buttons/helper.ts @@ -36,7 +36,8 @@ export const hasCorrectMaterialType = ( return manifestations.some((manifestation) => { return manifestation.materialTypes.some( (type) => - type.specific.toLowerCase() === desiredMaterialType.toLowerCase() + type.materialTypeSpecific.display.toLowerCase() === + desiredMaterialType.toLowerCase() ); }); }; diff --git a/src/components/material/material-buttons/online/MaterialButtonOnlineExternal.tsx b/src/components/material/material-buttons/online/MaterialButtonOnlineExternal.tsx index c4ed227d7a..3c59db6146 100644 --- a/src/components/material/material-buttons/online/MaterialButtonOnlineExternal.tsx +++ b/src/components/material/material-buttons/online/MaterialButtonOnlineExternal.tsx @@ -23,7 +23,7 @@ export interface MaterialButtonOnlineExternalProps { export const getOnlineMaterialType = ( sourceName: AccessUrl["origin"], - materialTypes: MaterialType["specific"][] + materialTypes: MaterialType["materialTypeSpecific"]["display"][] ) => { if (sourceName.toLowerCase().includes("ereol")) { return "ebook"; @@ -77,7 +77,7 @@ const MaterialButtonOnlineExternal: FC = ({ const label = ( sourceName: AccessUrl["origin"], - materialTypes: MaterialType["specific"][] + materialTypes: MaterialType["materialTypeSpecific"]["display"][] ) => { const onlineMaterialType = getOnlineMaterialType(sourceName, materialTypes); switch (onlineMaterialType) {