Skip to content

Commit

Permalink
fix: type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Udit-takkar committed Jun 19, 2024
1 parent 5e540f6 commit cfffc1e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
5 changes: 3 additions & 2 deletions apps/web/lib/booking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ export const getEventTypesFromDB = async (id: number) => {
}

const metadata = EventTypeMetaDataSchema.parse(eventType.metadata);
const isOrgTeamEvent = !!eventType?.team && !!eventType?.profile?.organizationId;
const { profile, ...restEventType } = eventType;
const isOrgTeamEvent = !!eventType?.team && !!profile?.organizationId;

return {
isDynamic: false,
...eventType,
...restEventType,
bookingFields: getBookingFieldsWithSystemFields({ ...eventType, isOrgTeamEvent }),
metadata,
};
Expand Down
9 changes: 5 additions & 4 deletions packages/features/bookings/lib/handleNewBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
},
});

const isOrgTeamEvent = !!eventType?.team && !!eventType?.profile?.organizationId;
const { profile, ...restEventType } = eventType;
const isOrgTeamEvent = !!eventType?.team && !!profile?.organizationId;

return {
...eventType,
...restEventType,
metadata: EventTypeMetaDataSchema.parse(eventType?.metadata || {}),
recurringEvent: parseRecurringEvent(eventType?.recurringEvent),
customInputs: customInputSchema.array().parse(eventType?.customInputs || []),
locations: (eventType?.locations ?? []) as LocationObject[],
bookingFields: getBookingFieldsWithSystemFields({ ...eventType, isOrgTeamEvent } || {}),
bookingFields: getBookingFieldsWithSystemFields({ ...restEventType, isOrgTeamEvent } || {}),
isDynamic: false,
};
};
Expand Down Expand Up @@ -1017,7 +1018,7 @@ async function handler(
? getDefaultEvent(req.body.eventTypeSlug)
: await getEventTypesFromDB(req.body.eventTypeId);

const isOrgTeamEvent = !!eventType?.team && !!eventType?.profile?.organizationId;
const isOrgTeamEvent = !!eventType?.team && !!eventType?.team?.parentId;

eventType = {
...eventType,
Expand Down
8 changes: 5 additions & 3 deletions packages/features/eventtypes/lib/bookingFieldsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ async function getEventType(eventTypeId: EventType["id"]) {
throw new Error(`EventType:${eventTypeId} not found`);
}

const isOrgTeamEvent = !!rawEventType?.teamId && !!rawEventType?.profile?.organizationId;
const { profile, ...restEventType } = rawEventType;

const isOrgTeamEvent = !!rawEventType?.teamId && !!profile?.organizationId;

const eventType = {
...rawEventType,
bookingFields: getBookingFieldsWithSystemFields({ ...rawEventType, isOrgTeamEvent }),
...restEventType,
bookingFields: getBookingFieldsWithSystemFields({ ...restEventType, isOrgTeamEvent }),
};
return eventType;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/features/instant-meeting/handleInstantMeeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const handleInstantMeetingWebhookTrigger = async (args: {

async function handler(req: NextApiRequest) {
let eventType = await getEventTypesFromDB(req.body.eventTypeId);
const isOrgTeamEvent = !!eventType?.team && !!eventType?.profile?.organizationId;
const isOrgTeamEvent = !!eventType?.team && !!eventType?.team?.parentId;
eventType = {
...eventType,
bookingFields: getBookingFieldsWithSystemFields({ ...eventType, isOrgTeamEvent }),
Expand Down
7 changes: 1 addition & 6 deletions packages/lib/event-types/getEventTypeById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ export const getEventTypeById = async ({
teamId: true,
},
},
profile: {
select: {
organizationId: true,
},
},
teamId: true,
team: {
select: {
Expand Down Expand Up @@ -396,7 +391,7 @@ export const getEventTypeById = async ({
});
}

const isOrgTeamEvent = !!eventType?.teamId && !!eventType?.profile?.organizationId;
const isOrgTeamEvent = !!eventType?.teamId && !!eventType.team?.parentId;
const eventTypeObject = Object.assign({}, eventType, {
users: eventTypeUsers,
periodStartDate: eventType.periodStartDate?.toString() ?? null,
Expand Down

0 comments on commit cfffc1e

Please sign in to comment.