Skip to content

Commit

Permalink
update: gql types after unused model removal
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Nov 29, 2024
1 parent 18d2ae5 commit b0781f1
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 1,035 deletions.
238 changes: 2 additions & 236 deletions apps/admin-ui/gql/gql-types.ts

Large diffs are not rendered by default.

242 changes: 2 additions & 240 deletions apps/ui/gql/gql-types.ts

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions apps/ui/modules/__tests__/reservation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function createMockReservationUnit({
reservationsMinDaysBefore,
reservationEnds,
canBeCancelledTimeBefore,
needsHandling,
}: {
reservationsMinDaysBefore?: number;
reservationEnds?: Date;
Expand All @@ -46,7 +45,6 @@ function createMockReservationUnit({
canBeCancelledTimeBefore: canBeCancelledTimeBefore ?? 0,
id: "fr8ejifod",
name: "Cancellation rule",
needsHandling: needsHandling ?? false,
};
return {
authentication: Authentication.Weak,
Expand Down Expand Up @@ -85,7 +83,6 @@ function createMockReservationUnit({
qualifiers: [],
equipments: [],
resources: [],
services: [],
spaces: [],
cancellationRule,
reservations: [],
Expand Down Expand Up @@ -256,20 +253,17 @@ describe("isReservationCancellable", () => {
function constructInput({
begin,
state,
needsHandling,
canBeCancelledTimeBefore,
}: {
begin: Date; // reservation begin time
state?: ReservationStateChoice; // reservation state
needsHandling?: boolean; // if the reservation unit needs handling
canBeCancelledTimeBefore?: number; // in seconds
}) {
return {
...createMockReservation({
begin,
state: state ?? ReservationStateChoice.Confirmed,
reservationUnit: createMockReservationUnit({
needsHandling: needsHandling ?? false,
canBeCancelledTimeBefore: canBeCancelledTimeBefore ?? 0,
}),
}),
Expand Down Expand Up @@ -308,14 +302,6 @@ describe("isReservationCancellable", () => {
expect(isReservationCancellable(input)).toBe(false);
});

test("NO for reservation unit that needs handling", () => {
const input = constructInput({
begin: addDays(new Date(), 1),
needsHandling: true,
});
expect(isReservationCancellable(input)).toBe(false);
});

test("YES for reservation that does not need handling", () => {
const input = constructInput({
begin: addDays(new Date(), 1),
Expand Down
1 change: 0 additions & 1 deletion apps/ui/modules/__tests__/reservationUnit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,6 @@ describe("isReservationUnitReservable", () => {
reservationPendingInstructions: "",
reservationStartInterval: ReservationStartInterval.Interval_15Mins,
resources: [],
services: [],
spaces: [],
maxPersons: 10,
uuid: "be4fa7a2-05b7-11ee-be56-0242ac120004",
Expand Down
1 change: 0 additions & 1 deletion apps/ui/modules/queries/reservation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const CANCELLATION_RULE_FRAGMENT = gql`
cancellationRule {
id
canBeCancelledTimeBefore
needsHandling
}
}
`;
Expand Down
7 changes: 1 addition & 6 deletions apps/ui/modules/reservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ export function isReservationCancellable(
// TODO why can't user cancel if the reservation is waiting for handling?
if (reservation.state !== ReservationStateChoice.Confirmed) return false;
if (reservationUnit.cancellationRule == null) return false;
// TODO why isn't the user allowed to cancel if the reservation has been handled?
if (reservationUnit.cancellationRule.needsHandling) return false;
if (isTooCloseToCancel(reservation)) {
return false;
}
Expand Down Expand Up @@ -276,10 +274,7 @@ export function getWhyReservationCantBeChanged(
}

const reservationUnit = reservation.reservationUnits?.[0];
if (
reservationUnit?.cancellationRule == null ||
reservationUnit.cancellationRule.needsHandling
) {
if (reservationUnit?.cancellationRule == null) {
return "CANCELLATION_NOT_ALLOWED";
}

Expand Down
Loading

0 comments on commit b0781f1

Please sign in to comment.