feat: improve Intercom app (#19687)
* fix: don't POST to cal.com/[user]/[type] * fix: return html with cal calendar embed * fix: intercom app team events types * feat: improve Intercom UX integration * Merge branch 'main' of https://github.com/calcom/cal.com
This commit is contained in:
1 parent
a3ce957f00
commit
df598bf281
9 files changed
+352
-141
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import type { NewCanvas, TextComponent, SpacerComponent } from "../lib";
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { sheet_values } = req.body;
|
||||
|
||||
if (!sheet_values) {
|
||||
return res.status(400).json({ error: "Invalid input data" });
|
||||
}
|
||||
|
||||
const { booking, eventType, organizer } = sheet_values;
|
||||
|
||||
// Prepare date and time information
|
||||
const startTime = new Date(booking.startTime);
|
||||
const options = {
|
||||
weekday: "long" as const,
|
||||
year: "numeric" as const,
|
||||
month: "long" as const,
|
||||
day: "numeric" as const,
|
||||
hour: "numeric" as const,
|
||||
minute: "numeric" as const,
|
||||
timeZone: organizer.timeZone,
|
||||
timeZoneName: "short" as const,
|
||||
};
|
||||
const formattedDate = startTime.toLocaleDateString("en-US", options);
|
||||
|
||||
// Create text components for the recap
|
||||
const confirmedText: TextComponent = {
|
||||
type: "text",
|
||||
text: `Confirmed: ${eventType.title}`,
|
||||
style: "header",
|
||||
align: "left",
|
||||
};
|
||||
|
||||
const detailsText: TextComponent = {
|
||||
type: "text",
|
||||
text: `You are scheduled with ${organizer.name} on ${formattedDate}`,
|
||||
style: "paragraph",
|
||||
align: "left",
|
||||
};
|
||||
|
||||
const spacer: SpacerComponent = {
|
||||
type: "spacer",
|
||||
size: "m",
|
||||
};
|
||||
|
||||
// Build the canvas data
|
||||
const canvasData: NewCanvas = {
|
||||
canvas: {
|
||||
content: {
|
||||
components: [confirmedText, spacer, detailsText],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return res.status(200).json(canvasData);
|
||||
}
|
||||
Reference in new issue
Block a user