Skip to content

Commit

Permalink
Fix bug in front-end with desk drop-in prereservations. (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan authored Mar 18, 2024
1 parent da7cf0a commit caaba34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/services/coworking/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self): ...

def walkin_window(self, _subject: User) -> timedelta:
"""How far into the future can walkins be reserved?"""
return timedelta(minutes=30)
return timedelta(minutes=10)

def walkin_initial_duration(self, _subject: User) -> timedelta:
"""When making a walkin, this sets how long the initial reservation is for."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ export class RoomReservationService extends ReservationService {
r: Reservation
) => {
let now = new Date();
let soon = new Date(
Date.now() + 10 /* minutes */ * 60 /* seconds */ * 1000 /* milliseconds */
);
const activeStates = ['CONFIRMED', 'CHECKED_IN'];
return r.start <= now && r.end > now && activeStates.includes(r.state);
return r.start <= soon && r.end > now && activeStates.includes(r.state);
};

constructor(http: HttpClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ class SeatCategory {
to server and client sharing the same system clock, but experienced in
prod on day 0 with many laptops having slightly drifted system clocks. */
const now = new Date(Date.now() + epsilon);
const preReservableAt = new Date(
Date.now() + 10 /*minutes*/ * 60 /*seconds*/ * 1000 /*milliseconds*/
); // Currently set by backend/services/coworking/policy.py
if (seat.availability[0].start <= now) {
this.seats_available_now.push(seat);
if (this.seats_available_now.length === 1) {
this.reservable_now = true;
this.next_available = seat;
}
} else {
} else if (seat.availability[0].start <= preReservableAt) {
this.seats_available_soon.push(seat);
if (!this.reservable_now && this.seats_available_soon.length === 1) {
this.reservable_soon = true;
this.next_available = seat;
}
} else {
// Ignore seats that are not pre-reservable
}
}

Expand Down

0 comments on commit caaba34

Please sign in to comment.