@@ -4,9 +4,9 @@ import { useTranslation } from "react-i18next";
44import get from "lodash/get" ;
55import type {
66 Query ,
7- QueryReservationUnitByPkArgs ,
7+ QueryReservationUnitArgs ,
88 QueryUnitsArgs ,
9- ReservationUnitByPkTypeReservationsArgs ,
9+ ReservationUnitTypeReservationsArgs ,
1010 ReservationUnitType ,
1111 ErrorType ,
1212 RecurringReservationCreateMutationInput ,
@@ -41,6 +41,7 @@ import { convertToDate } from "./utils";
4141import { CREATE_STAFF_RESERVATION } from "../create-reservation/queries" ;
4242import { ReservationMade } from "./RecurringReservationDone" ;
4343import { flattenMetadata } from "../create-reservation/utils" ;
44+ import { base64encode } from "common/src/helpers" ;
4445
4546export const useMultipleReservation = ( {
4647 form,
@@ -128,19 +129,21 @@ const useReservationsInInterval = ({
128129 // NOTE backend error, it returns all till 00:00 not 23:59
129130 const apiEnd = toApiDate ( addDays ( end , 1 ) ) ;
130131
132+ const typename = "ReservationUnitType" ;
133+ const id = base64encode ( `${ typename } :${ reservationUnitPk } ` ) ;
131134 // NOTE unlike array fetches this fetches a single element with an included array
132135 // so it doesn't have the 100 limitation of array fetch nor does it have pagination
133136 const { loading, data, refetch } = useQuery <
134137 Query ,
135- QueryReservationUnitByPkArgs & ReservationUnitByPkTypeReservationsArgs
138+ QueryReservationUnitArgs & ReservationUnitTypeReservationsArgs
136139 > ( GET_RESERVATIONS_IN_INTERVAL , {
137140 skip :
138141 ! reservationUnitPk ||
139142 Number . isNaN ( reservationUnitPk ) ||
140143 ! apiStart ||
141144 ! apiEnd ,
142145 variables : {
143- pk : reservationUnitPk ,
146+ id ,
144147 from : apiStart ,
145148 to : apiEnd ,
146149 } ,
@@ -150,7 +153,7 @@ const useReservationsInInterval = ({
150153 } ,
151154 } ) ;
152155
153- const reservations = ( data ?. reservationUnitByPk ?. reservations ?? [ ] )
156+ const reservations = ( data ?. reservationUnit ?. reservations ?? [ ] )
154157 . map ( ( x ) => ( x ? reservationToInterval ( x , reservationType ) : undefined ) )
155158 . filter ( ( x ) : x is CollisionInterval => x != null ) ;
156159
0 commit comments