feat: add instant meeting expiry input (#15555)
* feat: add instant meeting expiry input * fix: type err * chore: remove type * chore: update label * chore: update column name
This commit is contained in:
1 parent
a28eb63d61
commit
d25595b546
15 files changed
+116
-61
No files matched your search
@@ -204,11 +204,6 @@ export const useBookings = ({ event, hashedLink, bookingForm, metadata, teamMemb
|
||||
});
|
||||
},
|
||||
onError: (err, _, ctx) => {
|
||||
// TODO:
|
||||
// const vercelId = ctx?.meta?.headers?.get("x-vercel-id");
|
||||
// if (vercelId) {
|
||||
// setResponseVercelIdHeader(vercelId);
|
||||
// }
|
||||
bookerFormErrorRef && bookerFormErrorRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
},
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ export type FormValues = {
|
||||
eventName: string;
|
||||
slug: string;
|
||||
isInstantEvent: boolean;
|
||||
instantMeetingExpiryTimeOffsetInSeconds: number;
|
||||
length: number;
|
||||
offsetStart: number;
|
||||
description: string;
|
||||
|
||||
@@ -194,12 +194,26 @@ async function handler(req: NextApiRequest) {
|
||||
const newBooking = await prisma.booking.create(createBookingObj);
|
||||
|
||||
// Create Instant Meeting Token
|
||||
|
||||
const token = randomBytes(32).toString("hex");
|
||||
|
||||
const eventTypeWithExpiryTimeOffset = await prisma.eventType.findUniqueOrThrow({
|
||||
where: {
|
||||
id: req.body.eventTypeId,
|
||||
},
|
||||
select: {
|
||||
instantMeetingExpiryTimeOffsetInSeconds: true,
|
||||
},
|
||||
});
|
||||
|
||||
const instantMeetingExpiryTimeOffsetInSeconds =
|
||||
eventTypeWithExpiryTimeOffset?.instantMeetingExpiryTimeOffsetInSeconds ?? 90;
|
||||
|
||||
const instantMeetingToken = await prisma.instantMeetingToken.create({
|
||||
data: {
|
||||
token,
|
||||
// 90 Seconds
|
||||
expires: new Date(new Date().getTime() + 1000 * 90),
|
||||
// current time + offset Seconds
|
||||
expires: new Date(new Date().getTime() + 1000 * instantMeetingExpiryTimeOffsetInSeconds),
|
||||
team: {
|
||||
connect: {
|
||||
id: eventType.team.id,
|
||||
|
||||
Reference in new issue
Block a user