diff --git a/src/components/reservation/ReservationModalBody.tsx b/src/components/reservation/ReservationModalBody.tsx index 8296cb563d..a7bd9a2765 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"; @@ -177,8 +178,9 @@ export const ReservationModalBody = ({ ); } - if (reservablePidsFromAnotherLibrary?.length && patron) { + if (reservablePidsFromAnotherLibrary?.length > 0 && patron) { const { patronId, name, emailAddress, preferredPickupBranch } = patron; + // Save reservation to open order. mutateOpenOrder( { @@ -187,9 +189,9 @@ export const ReservationModalBody = ({ pickUpBranch: selectedBranch ? removePrefixFromBranchId(selectedBranch) : removePrefixFromBranchId(preferredPickupBranch), - expires: - selectedInterest?.toString() || - defaultInterestDaysForOpenOrder.toString(), + expires: getFutureDateStringISO( + Number(selectedInterest ?? defaultInterestDaysForOpenOrder) + ), userParameters: { userId: patronId.toString(), userName: name, @@ -251,7 +253,7 @@ export const ReservationModalBody = ({
- {reservablePidsFromAnotherLibrary?.length ? ( + {reservablePidsFromAnotherLibrary?.length > 0 ? ( t("reservableFromAnotherLibraryText") ) : ( 0 && + selectedInterest === null + ? Number(defaultInterestDaysForOpenOrder) + : selectedInterest + } setSelectedInterest={setSelectedInterest} /> )} diff --git a/src/components/reservation/helper.ts b/src/components/reservation/helper.ts index c4ba5de80d..fee1627314 100644 --- a/src/components/reservation/helper.ts +++ b/src/components/reservation/helper.ts @@ -48,6 +48,12 @@ export const getFutureDateString = (num: number) => { const futureDate = dayjs().add(num, "day").format("YYYY-MM-DD"); return futureDate; }; + +export const getFutureDateStringISO = (num: number) => { + const futureDate = dayjs().add(num, "day").format("YYYY-MM-DDTHH:mm:ssZ"); + return futureDate; +}; + type Periodical = Pick; const constructReservation = ({