diff --git a/cypress/fixtures/material/open-order/open-order-accepted.json b/cypress/fixtures/material/open-order/open-order-accepted.json index d0d756a202..cc07b8c71c 100644 --- a/cypress/fixtures/material/open-order/open-order-accepted.json +++ b/cypress/fixtures/material/open-order/open-order-accepted.json @@ -1,9 +1,9 @@ { "data": { "submitOrder": { - "status": "OWNED_ACCEPTED", - "message": "Item available at pickupAgency, order accepted", - "orderId": "1234" + "status": "NOT_OWNED_ILL_LOC", + "message": "Item not available at pickupAgency, item localised for ILL", + "orderId": "1048265231" } } } diff --git a/src/apps/material/material.dev.tsx b/src/apps/material/material.dev.tsx index f0e48b60a0..a9031c3e2a 100644 --- a/src/apps/material/material.dev.tsx +++ b/src/apps/material/material.dev.tsx @@ -86,9 +86,14 @@ export default { defaultValue: "Reserve", control: { type: "text" } }, + reserveWithMaterialTypeText: { + name: "Reserve", + defaultValue: "Reserve @materialType", + control: { type: "text" } + }, reservableFromAnotherLibraryText: { name: "Reservable on another library", - defaultValue: "Reservable on another library", + defaultValue: "Ordered from another library.", control: { type: "text" } }, findOnBookshelfText: { @@ -769,7 +774,7 @@ export default { }, openOrderNotOwnedIllLocText: { name: "Open order item localized for ILL text", - defaultValue: "Item not available at pickup agency but localized for ILL", + defaultValue: "Your material has been ordered from another library", control: { type: "text" } }, openOrderNotOwnedNoIllLocText: { diff --git a/src/apps/material/material.entry.tsx b/src/apps/material/material.entry.tsx index 91a5817f70..0d9c9c136a 100644 --- a/src/apps/material/material.entry.tsx +++ b/src/apps/material/material.entry.tsx @@ -153,6 +153,7 @@ interface MaterialEntryTextProps { reservationSuccesTitleText: string; reserveBookText: string; reserveText: string; + reserveWithMaterialTypeText: string; reviewsText: string; saveButtonText: string; seeOnlineText: string; diff --git a/src/apps/material/open-order.test.ts b/src/apps/material/open-order.test.ts index 9feaa9b456..e73fb888ad 100644 --- a/src/apps/material/open-order.test.ts +++ b/src/apps/material/open-order.test.ts @@ -9,7 +9,7 @@ const navigateToMaterial = () => { cy.getBySel("material-button-reservable-on-another-library") .first() .should("be.visible") - .and("contain", "Reservable on another library") + .and("contain", "Reserve bog") .click(); cy.getBySel("material-description").scrollIntoView(); cy.getBySel("reservation-modal-submit-button", true) @@ -45,7 +45,7 @@ describe("Open Order Functionality", () => { cy.getBySel("open-oprder-response-status-text") .should("be.visible") - .and("contain", "Your order is accepted"); + .and("contain", "Your material has been ordered from another library"); closeModal(); }); diff --git a/src/components/material/MaterialAvailabilityText/MaterialAvailabilityText.tsx b/src/components/material/MaterialAvailabilityText/MaterialAvailabilityText.tsx index aae18fb572..63460975cf 100644 --- a/src/components/material/MaterialAvailabilityText/MaterialAvailabilityText.tsx +++ b/src/components/material/MaterialAvailabilityText/MaterialAvailabilityText.tsx @@ -10,17 +10,30 @@ import { Manifestation } from "../../../core/utils/types/entities"; import { hasCorrectAccessType } from "../material-buttons/helper"; import MaterialAvailabilityTextOnline from "./online/MaterialAvailabilityTextOnline"; import MaterialAvailabilityTextPhysical from "./physical/MaterialAvailabilityTextPhysical"; +import useReservableFromAnotherLibrary from "../../../core/utils/useReservableFromAnotherLibrary"; +import MaterialAvailabilityTextParagraph from "./generic/MaterialAvailabilityTextParagraph"; +import { useText } from "../../../core/utils/text"; interface Props { manifestations: Manifestation[]; } const MaterialAvailabilityText: React.FC = ({ manifestations }) => { + const t = useText(); const materialType = head(getMaterialTypes(manifestations)); const isbns = getAllIdentifiers(manifestations); + const { materialIsReservableFromAnotherLibrary } = + useReservableFromAnotherLibrary(manifestations); if (hasCorrectAccessType(AccessTypeCode.Physical, manifestations)) { const pids = getAllPids(manifestations); + if (materialIsReservableFromAnotherLibrary) { + return ( + + {t("reservableFromAnotherLibraryText")} + + ); + } return ; } diff --git a/src/components/material/material-buttons/MaterialButtons.tsx b/src/components/material/material-buttons/MaterialButtons.tsx index 1773040a14..73146bc03b 100644 --- a/src/components/material/material-buttons/MaterialButtons.tsx +++ b/src/components/material/material-buttons/MaterialButtons.tsx @@ -35,10 +35,10 @@ const MaterialButtons: FC = ({ // articles appear as a part of journal/periodical publications and can't be // physically loaned for themseleves. - const reservablePidsFromAnotherLibrary = + const { materialIsReservableFromAnotherLibrary } = useReservableFromAnotherLibrary(manifestations); - if (reservablePidsFromAnotherLibrary.length > 0) { + if (materialIsReservableFromAnotherLibrary) { return ( = ({ label={ size === "small" ? t("reserveText") - : `${t("reserveText")} ${manifestationMaterialType}` + : `${t("reserveWithMaterialTypeText", { + placeholders: { "@materialType": manifestationMaterialType } + })}` } buttonType="none" variant="filled" diff --git a/src/components/material/material-buttons/physical/MaterialButtonReservableFromAnotherLibrary.tsx b/src/components/material/material-buttons/physical/MaterialButtonReservableFromAnotherLibrary.tsx index 97241373b6..6c978fba86 100644 --- a/src/components/material/material-buttons/physical/MaterialButtonReservableFromAnotherLibrary.tsx +++ b/src/components/material/material-buttons/physical/MaterialButtonReservableFromAnotherLibrary.tsx @@ -40,10 +40,10 @@ const MaterialButtonReservableFromAnotherLibrary: FC< dataCy={dataCy} label={ size === "small" - ? t("reservableFromAnotherLibraryText") - : `${t( - "reservableFromAnotherLibraryText" - )} ${manifestationMaterialType}` + ? t("reserveText") + : `${t("reserveWithMaterialTypeText", { + placeholders: { "@materialType": manifestationMaterialType } + })}` } buttonType="none" variant="filled" diff --git a/src/components/reservation/ReservationModalBody.tsx b/src/components/reservation/ReservationModalBody.tsx index 1f0b63477f..e7f49487df 100644 --- a/src/components/reservation/ReservationModalBody.tsx +++ b/src/components/reservation/ReservationModalBody.tsx @@ -41,7 +41,8 @@ import { getInstantLoanBranchHoldings, getInstantLoanBranchHoldingsAboveThreshold, removePrefixFromBranchId, - translateOpenOrderStatus + translateOpenOrderStatus, + getFutureDateStringISO } from "./helper"; import UseReservableManifestations from "../../core/utils/UseReservableManifestations"; import { PeriodicalEdition } from "../material/periodical/helper"; @@ -134,9 +135,10 @@ export const ReservationModalBody = ({ !!selectedPeriodical ); - const reservablePidsFromAnotherLibrary = useReservableFromAnotherLibrary( - selectedManifestations - ); + const { + reservablePidsFromAnotherLibrary, + materialIsReservableFromAnotherLibrary + } = useReservableFromAnotherLibrary(selectedManifestations); // If we don't have all data for displaying the view render nothing. if (!userResponse.data || !holdingsResponse.data) { @@ -185,19 +187,20 @@ export const ReservationModalBody = ({ ); } - if (reservablePidsFromAnotherLibrary?.length && patron) { + if (materialIsReservableFromAnotherLibrary && patron) { const { patronId, name, emailAddress, preferredPickupBranch } = patron; + // Save reservation to open order. mutateOpenOrder( { input: { - pids: [...reservablePidsFromAnotherLibrary], + pids: reservablePidsFromAnotherLibrary, pickUpBranch: selectedBranch ? removePrefixFromBranchId(selectedBranch) : removePrefixFromBranchId(preferredPickupBranch), - expires: - selectedInterest?.toString() || - defaultInterestDaysForOpenOrder.toString(), + expires: getFutureDateStringISO( + Number(selectedInterest ?? defaultInterestDaysForOpenOrder) + ), userParameters: { userId: patronId.toString(), userName: name, @@ -259,10 +262,14 @@ export const ReservationModalBody = ({
- + {materialIsReservableFromAnotherLibrary ? ( + t("reservableFromAnotherLibraryText") + ) : ( + + )}