fix/error-while-confirm-booking (#4834)

* Add try/catch on workflows while confirming a booking

* Revert "added ?tabName=setup to event-type detail link to give it active status (#4830)"

This reverts commit 11c44db609.

Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
alannnc
2022-10-04 14:46:17 -05:00
committed by GitHub
co-authored by Omar López
parent 8e369d3fb5
commit f01058e073
4 changed files with 44 additions and 26 deletions
@@ -44,6 +44,11 @@ function BookingListItem(booking: BookingItemProps) {
const mutation = trpc.useMutation(["viewer.bookings.confirm"], {
onSuccess: () => {
setRejectionDialogIsOpen(false);
showToast(t("booking_confirmation_success"), "success");
utils.invalidateQueries("viewer.bookings");
},
onError: () => {
showToast(t("booking_confirmation_failed"), "error");
utils.invalidateQueries("viewer.bookings");
},
});
+1 -1
View File
@@ -52,7 +52,7 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou
const { t } = useLocale();
return (
<Link href={`/event-types/${type.id}?tabName=setup`}>
<Link href={`/event-types/${type.id}`}>
<a
className="flex-grow truncate text-sm"
title={`${type.title} ${type.description ? `– ${type.description}` : ""}`}>
@@ -1275,5 +1275,7 @@
"ignore_special_characters": "Ignore special characters in your Additional Input label. Use only letters and numbers",
"retry": "Retry",
"fetching_calendars_error": "There was a problem fetching your calendars. Please <1>try again</1> or reach out to customer support.",
"calendar_connection_fail": "Calendar connection failed"
"calendar_connection_fail": "Calendar connection failed",
"booking_confirmation_success": "Booking confirmation succeeded",
"booking_confirmation_fail": "Booking confirmation failed"
}
@@ -461,37 +461,48 @@ export const bookingsRouter = createProtectedRouter()
}
//Workflows - set reminders for confirmed events
for (const updatedBooking of updatedBookings) {
if (updatedBooking.eventType?.workflows) {
const evtOfBooking = evt;
evtOfBooking.startTime = updatedBooking.startTime.toISOString();
evtOfBooking.endTime = updatedBooking.endTime.toISOString();
evtOfBooking.uid = updatedBooking.uid;
await scheduleWorkflowReminders(
updatedBooking.eventType.workflows,
updatedBooking.smsReminderNumber,
evtOfBooking,
false,
false
);
try {
for (const updatedBooking of updatedBookings) {
if (updatedBooking.eventType?.workflows) {
const evtOfBooking = evt;
evtOfBooking.startTime = updatedBooking.startTime.toISOString();
evtOfBooking.endTime = updatedBooking.endTime.toISOString();
evtOfBooking.uid = updatedBooking.uid;
await scheduleWorkflowReminders(
updatedBooking.eventType.workflows,
updatedBooking.smsReminderNumber,
evtOfBooking,
false,
false
);
}
}
} catch (error) {
// Silently fail
console.error(error);
}
// schedule job for zapier trigger 'when meeting ends'
const subscriberOptionsMeetingEnded = {
userId: booking.userId || 0,
eventTypeId: booking.eventTypeId || 0,
triggerEvent: WebhookTriggerEvents.MEETING_ENDED,
};
try {
// schedule job for zapier trigger 'when meeting ends'
const subscriberOptionsMeetingEnded = {
userId: booking.userId || 0,
eventTypeId: booking.eventTypeId || 0,
triggerEvent: WebhookTriggerEvents.MEETING_ENDED,
};
const subscribersMeetingEnded = await getWebhooks(subscriberOptionsMeetingEnded);
const subscribersMeetingEnded = await getWebhooks(subscriberOptionsMeetingEnded);
subscribersMeetingEnded.forEach((subscriber) => {
updatedBookings.forEach((booking) => {
scheduleTrigger(booking, subscriber.subscriberUrl, subscriber);
subscribersMeetingEnded.forEach((subscriber) => {
updatedBookings.forEach((booking) => {
scheduleTrigger(booking, subscriber.subscriberUrl, subscriber);
});
});
});
} catch (error) {
// Silently fail
console.error(error);
}
} else {
evt.rejectionReason = rejectionReason;
if (recurringEventId) {