Dynamic group booking follow-up (#2430)
This commit is contained in:
parent
01eee52849
commit
eceba51020
7 changed files with 26 additions and 9 deletions
|
@ -116,6 +116,7 @@ const BookingPage = ({
|
||||||
name: attendees[0].name,
|
name: attendees[0].name,
|
||||||
email: attendees[0].email,
|
email: attendees[0].email,
|
||||||
location,
|
location,
|
||||||
|
eventName: profile.eventName || "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,12 @@ import { GetServerSidePropsContext } from "next";
|
||||||
import { JSONObject } from "superjson/dist/types";
|
import { JSONObject } from "superjson/dist/types";
|
||||||
|
|
||||||
import { getLocationLabels } from "@calcom/app-store/utils";
|
import { getLocationLabels } from "@calcom/app-store/utils";
|
||||||
import { getDefaultEvent, getGroupName, getUsernameList } from "@calcom/lib/defaultEvents";
|
import {
|
||||||
|
getDefaultEvent,
|
||||||
|
getDynamicEventName,
|
||||||
|
getGroupName,
|
||||||
|
getUsernameList,
|
||||||
|
} from "@calcom/lib/defaultEvents";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
|
|
||||||
import { asStringOrThrow } from "@lib/asStringOrNull";
|
import { asStringOrThrow } from "@lib/asStringOrNull";
|
||||||
|
@ -187,6 +192,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
})
|
})
|
||||||
? false
|
? false
|
||||||
: true,
|
: true,
|
||||||
|
eventName: getDynamicEventName(dynamicNames, eventTypeSlug),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
name: user.name || user.username,
|
name: user.name || user.username,
|
||||||
|
@ -195,6 +201,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
theme: user.theme,
|
theme: user.theme,
|
||||||
brandColor: user.brandColor,
|
brandColor: user.brandColor,
|
||||||
darkBrandColor: user.darkBrandColor,
|
darkBrandColor: user.darkBrandColor,
|
||||||
|
eventName: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const t = await getTranslation(context.locale ?? "en", "common");
|
const t = await getTranslation(context.locale ?? "en", "common");
|
||||||
|
|
|
@ -112,7 +112,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
|
|
||||||
const evt: CalendarEvent = {
|
const evt: CalendarEvent = {
|
||||||
title: bookingToDelete?.title,
|
title: bookingToDelete?.title,
|
||||||
type: bookingToDelete?.eventType?.title as string,
|
type: (bookingToDelete?.eventType?.title as string) || bookingToDelete?.title,
|
||||||
description: bookingToDelete?.description || "",
|
description: bookingToDelete?.description || "",
|
||||||
startTime: bookingToDelete?.startTime ? dayjs(bookingToDelete.startTime).format() : "",
|
startTime: bookingToDelete?.startTime ? dayjs(bookingToDelete.startTime).format() : "",
|
||||||
endTime: bookingToDelete?.endTime ? dayjs(bookingToDelete.endTime).format() : "",
|
endTime: bookingToDelete?.endTime ? dayjs(bookingToDelete.endTime).format() : "",
|
||||||
|
@ -128,7 +128,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
destinationCalendar: bookingToDelete?.destinationCalendar || bookingToDelete?.user.destinationCalendar,
|
destinationCalendar: bookingToDelete?.destinationCalendar || bookingToDelete?.user.destinationCalendar,
|
||||||
cancellationReason: cancellationReason,
|
cancellationReason: cancellationReason,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hook up the webhook logic here
|
// Hook up the webhook logic here
|
||||||
const eventTrigger: WebhookTriggerEvents = "BOOKING_CANCELLED";
|
const eventTrigger: WebhookTriggerEvents = "BOOKING_CANCELLED";
|
||||||
// Send Webhook call if hooked to BOOKING.CANCELLED
|
// Send Webhook call if hooked to BOOKING.CANCELLED
|
||||||
|
|
|
@ -145,7 +145,7 @@ export default function Success(props: inferSSRProps<typeof getServerSideProps>)
|
||||||
const eventNameObject = {
|
const eventNameObject = {
|
||||||
attendeeName,
|
attendeeName,
|
||||||
eventType: props.eventType.title,
|
eventType: props.eventType.title,
|
||||||
eventName: props.eventType.eventName,
|
eventName: (props.dynamicEventName as string) || props.eventType.eventName,
|
||||||
host: props.profile.name || "Nameless",
|
host: props.profile.name || "Nameless",
|
||||||
t,
|
t,
|
||||||
};
|
};
|
||||||
|
@ -456,6 +456,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
const ssr = await ssrInit(context);
|
const ssr = await ssrInit(context);
|
||||||
const typeId = parseInt(asStringOrNull(context.query.type) ?? "");
|
const typeId = parseInt(asStringOrNull(context.query.type) ?? "");
|
||||||
const typeSlug = asStringOrNull(context.query.eventSlug) ?? "15min";
|
const typeSlug = asStringOrNull(context.query.eventSlug) ?? "15min";
|
||||||
|
const dynamicEventName = asStringOrNull(context.query.eventName) ?? "";
|
||||||
|
|
||||||
if (isNaN(typeId)) {
|
if (isNaN(typeId)) {
|
||||||
return {
|
return {
|
||||||
|
@ -498,6 +499,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (!typeId) eventType["eventName"] = getDynamicEventName(users, typeSlug);
|
||||||
|
|
||||||
const profile = {
|
const profile = {
|
||||||
name: eventType.team?.name || eventType.users[0]?.name || null,
|
name: eventType.team?.name || eventType.users[0]?.name || null,
|
||||||
email: eventType.team ? null : eventType.users[0].email || null,
|
email: eventType.team ? null : eventType.users[0].email || null,
|
||||||
|
@ -512,6 +515,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
profile,
|
profile,
|
||||||
eventType,
|
eventType,
|
||||||
trpcState: ssr.dehydrate(),
|
trpcState: ssr.dehydrate(),
|
||||||
|
dynamicEventName,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
theme: null /* Teams don't have a theme, and `BookingPage` uses it */,
|
theme: null /* Teams don't have a theme, and `BookingPage` uses it */,
|
||||||
brandColor: null /* Teams don't have a brandColor, and `BookingPage` uses it */,
|
brandColor: null /* Teams don't have a brandColor, and `BookingPage` uses it */,
|
||||||
darkBrandColor: null /* Teams don't have a darkBrandColor, and `BookingPage` uses it */,
|
darkBrandColor: null /* Teams don't have a darkBrandColor, and `BookingPage` uses it */,
|
||||||
|
eventName: null,
|
||||||
},
|
},
|
||||||
eventType: eventTypeObject,
|
eventType: eventTypeObject,
|
||||||
booking,
|
booking,
|
||||||
|
|
|
@ -151,7 +151,7 @@
|
||||||
"unconfirmed": "Unconfirmed",
|
"unconfirmed": "Unconfirmed",
|
||||||
"guests": "Guests",
|
"guests": "Guests",
|
||||||
"guest": "Guest",
|
"guest": "Guest",
|
||||||
"web_conferencing_details_to_follow": "Web conferencing details to follow.",
|
"web_conferencing_details_to_follow": "Web conferencing details to follow in the confirmation email.",
|
||||||
"the_username": "The username",
|
"the_username": "The username",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
"is_still_available": "is still available.",
|
"is_still_available": "is still available.",
|
||||||
|
|
|
@ -83,7 +83,7 @@ const commons = {
|
||||||
|
|
||||||
const min15Event = {
|
const min15Event = {
|
||||||
length: 15,
|
length: 15,
|
||||||
slug: "15min",
|
slug: "15",
|
||||||
title: "15min",
|
title: "15min",
|
||||||
eventName: "Dynamic Collective 15min Event",
|
eventName: "Dynamic Collective 15min Event",
|
||||||
description: "Dynamic Collective 15min Event",
|
description: "Dynamic Collective 15min Event",
|
||||||
|
@ -91,7 +91,7 @@ const min15Event = {
|
||||||
};
|
};
|
||||||
const min30Event = {
|
const min30Event = {
|
||||||
length: 30,
|
length: 30,
|
||||||
slug: "30min",
|
slug: "30",
|
||||||
title: "30min",
|
title: "30min",
|
||||||
eventName: "Dynamic Collective 30min Event",
|
eventName: "Dynamic Collective 30min Event",
|
||||||
description: "Dynamic Collective 30min Event",
|
description: "Dynamic Collective 30min Event",
|
||||||
|
@ -99,7 +99,7 @@ const min30Event = {
|
||||||
};
|
};
|
||||||
const min60Event = {
|
const min60Event = {
|
||||||
length: 60,
|
length: 60,
|
||||||
slug: "60min",
|
slug: "60",
|
||||||
title: "60min",
|
title: "60min",
|
||||||
eventName: "Dynamic Collective 60min Event",
|
eventName: "Dynamic Collective 60min Event",
|
||||||
description: "Dynamic Collective 60min Event",
|
description: "Dynamic Collective 60min Event",
|
||||||
|
@ -109,7 +109,12 @@ const min60Event = {
|
||||||
const defaultEvents = [min15Event, min30Event, min60Event];
|
const defaultEvents = [min15Event, min30Event, min60Event];
|
||||||
|
|
||||||
export const getDynamicEventDescription = (dynamicUsernames: string[], slug: string): string => {
|
export const getDynamicEventDescription = (dynamicUsernames: string[], slug: string): string => {
|
||||||
return `Book a ${slug} event with ${dynamicUsernames.join(", ")}`;
|
return `Book a ${slug} min event with ${dynamicUsernames.join(", ")}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDynamicEventName = (dynamicNames: string[], slug: string): string => {
|
||||||
|
const lastUser = dynamicNames.pop();
|
||||||
|
return `Dynamic Collective ${slug} min event with ${dynamicNames.join(", ")} & ${lastUser}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDefaultEvent = (slug: string) => {
|
export const getDefaultEvent = (slug: string) => {
|
||||||
|
|
Loading…
Reference in a new issue