Skip to content

Commit

Permalink
Found more issing materialTypeSpecific references
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
spaceo committed Jan 14, 2024
1 parent 475be9d commit bda6888
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/apps/loan-list/list/loan-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/apps/loan-list/modal/modals.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
9 changes: 5 additions & 4 deletions src/apps/material/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
);
});
};
Expand All @@ -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) => {
Expand All @@ -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[]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/components/find-on-shelf/FindOnShelfModalBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const FindOnShelfModalBody: FC<FindOnShelfModalBodyProps> = ({
const title = workTitles.join(", ");
const isPeriodical = manifestations.some((manifestation) => {
return manifestation.materialTypes.some((materialType) => {
return materialType.specific.includes("tidsskrift");
return materialType.materialTypeSpecific.display === "tidsskrift";
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/instant-loan/InstantLoan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const InstantLoan: React.FunctionComponent<InstantLoanProps> = ({
instantLoanBranchHoldings
}) => {
const { pid, materialTypes } = manifestation;
const materialType = materialTypes[0].specific;
const materialType = materialTypes[0].materialTypeSpecific.display;

return (
<DisclosureControllable
Expand Down
2 changes: 1 addition & 1 deletion src/components/material/MaterialMainfestationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const MaterialMainfestationItem: FC<MaterialMainfestationItemProps> = ({
<div className="material-manifestation-item">
<div className="material-manifestation-item__availability">
<AvailabilityLabel
manifestText={materialTypes[0]?.specific}
manifestText={materialTypes[0]?.materialTypeSpecific.display}
faustIds={[faustId]}
isbns={identifiers.map((identifier) => identifier.value)}
accessTypes={accessTypesCodes}
Expand Down
3 changes: 2 additions & 1 deletion src/components/material/material-buttons/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -77,7 +77,7 @@ const MaterialButtonOnlineExternal: FC<MaterialButtonOnlineExternalProps> = ({

const label = (
sourceName: AccessUrl["origin"],
materialTypes: MaterialType["specific"][]
materialTypes: MaterialType["materialTypeSpecific"]["display"][]
) => {
const onlineMaterialType = getOnlineMaterialType(sourceName, materialTypes);
switch (onlineMaterialType) {
Expand Down

0 comments on commit bda6888

Please sign in to comment.