Skip to content

Commit

Permalink
Type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joeauyeung committed Aug 27, 2024
1 parent eb8d83f commit 0eed490
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/features/bookings/lib/handleNewBooking/loadUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const log = logger.getSubLogger({ prefix: ["[loadUsers]:handleNewBooking "] });

type EventType = Pick<NewBookingEventType, "hosts" | "users" | "id">;

type EventTypeUsers = NonNullable<NewBookingEventType["users"]>;

export const loadUsers = async (
eventType: EventType,
dynamicUserList: string[],
Expand Down Expand Up @@ -42,7 +44,7 @@ const loadUsersByEventType = async (
const rrUsernamePoolSize = rrUsernamePoolSet.size;
const hosts = eventType.hosts || [];

let users = hosts.reduce((userArray: NewBookingEventType["users"], host) => {
let users = hosts.reduce((userArray: EventTypeUsers, host) => {
const { user, isFixed, priority, weight, weightAdjustment } = host;
if (rrUsernamePoolSize && rrUsernamePoolSize === userArray.length) return userArray;

Expand All @@ -65,7 +67,7 @@ const loadUsersByEventType = async (

// If we fallback to event type users we still need to filter on the rrUsernamePool

users = eventType.users.reduce((userArray: NewBookingEventType["users"], user) => {
users = eventType.users.reduce((userArray: EventTypeUsers, user) => {
if (rrUsernamePoolSize === userArray.length) return userArray;

if (rrUsernamePoolSize) {
Expand All @@ -75,7 +77,7 @@ const loadUsersByEventType = async (
}

return userArray;
}, [] as NewBookingEventType["users"]);
}, [] as EventTypeUsers);

return users;
};
Expand Down

0 comments on commit 0eed490

Please sign in to comment.