Skip to content

Commit

Permalink
Update reservation list to use new reservation group hook
Browse files Browse the repository at this point in the history
Update the test accordingly by making one of the reservations a parallel
one.
  • Loading branch information
kasperg committed Oct 23, 2023
1 parent 5db6510 commit 92b4ab0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 16 additions & 1 deletion src/apps/reservation-list/list/reservation-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,22 @@ describe("Reservation list", () => {
pickupNumber: null,
ilBibliographicRecord: null,
transactionId: "cae4db22-e267-4087-bdaa-d880bef19b52",
reservationType: "normal"
reservationType: "parallel"
},
{
reservationId: 67843847,
recordId: "62485125",
state: "reserved",
pickupBranch: "DK-775100",
pickupDeadline: null,
expiryDate: "2022-12-12",
dateOfReservation: "2022-06-15T11:41:24.075",
numberInQueue: 206,
periodical: null,
pickupNumber: null,
ilBibliographicRecord: null,
transactionId: "cae4db22-e267-4087-bdaa-d880bef19b52",
reservationType: "parallel"
}
]
}
Expand Down
11 changes: 6 additions & 5 deletions src/apps/reservation-list/list/reservation-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {
} from "../../../core/utils/helpers/general";
import { useGetV1UserReservations } from "../../../core/publizon/publizon";
import {
mapFBSReservationToReservationType,
mapFBSReservationGroupToReservationType,
mapPublizonReservationToReservationType
} from "../../../core/utils/helpers/list-mapper";
import ReservationPauseToggler from "./reservation-pause-toggler";
import { useGetReservationsV2 } from "../../../core/fbs/fbs";
import { PatronV5, ReservationDetailsV2 } from "../../../core/fbs/model";
import EmptyReservations from "./EmptyReservations";
import PauseReservation from "../modal/pause-reservation/pause-reservation";
Expand All @@ -34,6 +33,7 @@ import { getUrlQueryParam } from "../../../core/utils/helpers/url";
import { getDetailsModalId } from "../../../core/utils/helpers/modal-helpers";
import { getFromListByKey } from "../../loan-list/utils/helpers";
import { usePatronData } from "../../../components/material/helper";
import useGetReservationGroups from "../../../core/utils/useGetReservationGroups";

export interface ReservationListProps {
pageSize: number;
Expand All @@ -56,7 +56,7 @@ const ReservationList: FC<ReservationListProps> = ({ pageSize }) => {
isSuccess: isSuccessFBS,
data,
isLoading: isLoadingFBS
} = useGetReservationsV2();
} = useGetReservationGroups();

const {
isSuccess: isSuccessPublizon,
Expand Down Expand Up @@ -119,12 +119,13 @@ const ReservationList: FC<ReservationListProps> = ({ pageSize }) => {
// "reserved"-reservations have their own list
useEffect(() => {
if (isSuccessFBS && data) {
const fbsToReservationType = mapFBSReservationToReservationType(data);
const fbsToReservationType =
mapFBSReservationGroupToReservationType(data);
const readyForPickup = getReadyForPickup(fbsToReservationType);
const sortedByOldest = sortByOldestPickupDeadline(readyForPickup);
setReadyForPickupReservationsFBS(sortedByOldest);
setReservedReservationsFBS(
getReservedPhysical(mapFBSReservationToReservationType(data))
getReservedPhysical(mapFBSReservationGroupToReservationType(data))
);
} else if (!isSuccessFBS) {
setReservedReservationsFBS([]);
Expand Down

0 comments on commit 92b4ab0

Please sign in to comment.