feat: Prerender booking link and reuse with headless router (#20720)

* mvp done

* wip

* fix ts errors and other code improvements

* fix ts errors

* ensure mobile layout support

* Make skeleton responsive on screen resize

* refactor

* Add test for EmbedElement

* make skeleton closer to pixel perfect

* Address PR feedback

* Router-preloading
## What does this PR do?

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. -->

- Fixes #XXXX (GitHub issue number)
- Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)

## Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change **(video / image - any one)**.

#### Video Demo (if applicable):

- Show screen recordings of the issue or feature.
- Demonstrate how to reproduce the issue, the behavior before and after the change.

#### Image Demo (if applicable):

- Add side-by-side screenshots of the original and updated change.
- Highlight any significant change(s).

## Mandatory Tasks (DO NOT REMOVE)

- [ ] I have self-reviewed the code (A decent size PR without self-review might be rejected).
- [ ] I have updated the developer docs in /docs if this PR makes changes that would require a [documentation change](https://cal.com/docs). If N/A, write N/A here and check the checkbox.
- [ ] I confirm automated tests are in place that prove my fix is effective or that my feature works.

## How should this be tested?

<!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. Write details that help to start the tests -->

- Are there environment variables that should be set?
- What are the minimal test data to have?
- What is expected (happy path) to have (input and output)?
- Any other important info that could help to test that PR

## Checklist

<!-- Remove bullet points below that don't apply to you -->

- I haven't read the [contributing guide](https://github.com/calcom/cal.com/blob/main/CONTRIBUTING.md)
- My code doesn't follow the style guidelines of this project
- I haven't commented my code, particularly in hard-to-understand areas
- I haven't checked if my changes generate no new warnings

* wip\

* wip

* fix mrge.io feedback

* wip

* Add README and lifecycle

* Add README and lifecycle

* Update routing form-seed and some other fixes

* remove linkFailed fix from the branch

* self-review

* self-review-2

* self-review-3

* Handle soft connect\

* Update README and fix a bug with query parmas

* Add one more case in routing-html playground

---------

Co-authored-by: Benny Joo <[email protected]>
Co-authored-by: amrit <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-05-08 19:59:26 +01:00
1 parent 3ee6a7ecde
commit 6e9ec113fe
26 files changed
+3048 -211

No files matched your search

+36 -13
View File
@@ -194,6 +194,15 @@ async function main() {
});
}
const insightsTeamMembers = await prisma.membership.findMany({
where: {
teamId: insightsTeam.id,
},
include: {
user: true,
},
});
// Create event types for the team
let teamEvents = await prisma.eventType.findMany({
where: {
@@ -207,6 +216,7 @@ async function main() {
length: true,
teamId: true,
userId: true,
assignAllTeamMembers: true,
},
});
@@ -242,6 +252,7 @@ async function main() {
},
],
});
teamEvents = await prisma.eventType.findMany({
where: {
teamId: insightsTeam.id,
@@ -254,20 +265,32 @@ async function main() {
length: true,
teamId: true,
userId: true,
assignAllTeamMembers: true,
},
});
// After creating or fetching teamEvents and insightsTeamMembers
// Create Host records for all team members for each event with assignAllTeamMembers true
const assignAllTeamMembersEvents = teamEvents.filter((event) => (event as any).assignAllTeamMembers);
if (assignAllTeamMembersEvents.length > 0 && insightsTeamMembers.length > 0) {
const hostRecords = assignAllTeamMembersEvents.flatMap((event) =>
insightsTeamMembers.map((member) => ({
userId: member.user.id,
eventTypeId: event.id,
isFixed: false,
}))
);
if (hostRecords.length > 0) {
await prisma.host.createMany({
data: hostRecords,
skipDuplicates: true,
});
}
}
}
const javascriptEventId = teamEvents.find((event) => event.slug === "team-javascript")?.id;
const salesEventId = teamEvents.find((event) => event.slug === "team-sales")?.id;
const insightsMembers = await prisma.membership.findMany({
where: {
teamId: insightsTeam.id,
},
include: {
user: true,
},
});
// Create bookings for the team events
const baseBooking = {
@@ -276,7 +299,7 @@ async function main() {
description: "Team Meeting Should be changed in shuffle",
startTime: dayjs().toISOString(),
endTime: dayjs().toISOString(),
userId: insightsMembers[0].user.id, // Use first org member as default
userId: insightsTeamMembers[0].user.id, // Use first org member as default
};
// Create past bookings -2y, -1y, -0y
@@ -287,7 +310,7 @@ async function main() {
{ ...baseBooking },
dayjs().get("y") - 2,
teamEvents,
insightsMembers.map((m) => m.user.id)
insightsTeamMembers.map((m) => m.user.id)
)
),
],
@@ -300,7 +323,7 @@ async function main() {
{ ...baseBooking },
dayjs().get("y") - 1,
teamEvents,
insightsMembers.map((m) => m.user.id)
insightsTeamMembers.map((m) => m.user.id)
)
),
],
@@ -313,7 +336,7 @@ async function main() {
{ ...baseBooking },
dayjs().get("y"),
teamEvents,
insightsMembers.map((m) => m.user.id)
insightsTeamMembers.map((m) => m.user.id)
)
),
],
@@ -331,7 +354,7 @@ async function main() {
}
const seededForm = await seedRoutingForms(
insightsTeam.id,
owner?.user.id ?? insightsMembers[0].user.id,
owner?.user.id ?? insightsTeamMembers[0].user.id,
attributes
);
+41 -9
View File
@@ -469,7 +469,7 @@ export async function seedRoutingForms(
},
});
if (form) {
console.log(`Skipping Routing Form - Form Seed, "Seeded Form - Pro" already exists`);
console.log(`Skipping Routing Form - Form Seed, ${seededForm.name} already exists`);
return;
}
@@ -477,6 +477,16 @@ export async function seedRoutingForms(
throw new Error("No attributes found - Please call seedAttributes first");
}
const formFieldSkillsOptions = attributeRaw[2].options.map((opt) => ({
id: opt.id,
label: opt.value,
}));
const formFieldLocationOptions = attributeRaw[1].options.map((opt) => ({
id: opt.id,
label: opt.value,
}));
await prisma.app_RoutingForms_Form.create({
data: {
id: seededForm.id,
@@ -491,6 +501,21 @@ export async function seedRoutingForms(
queryValue: {
id: "aaba9988-cdef-4012-b456-719300f53ef8",
type: "group",
children1: {
"b98b98a8-0123-4456-b89a-b19300f55277": {
type: "rule",
properties: {
field: seededForm.formFieldSkills.id,
value: [
formFieldSkillsOptions.filter((opt) => opt.label === "JavaScript").map((opt) => opt.id),
],
operator: "multiselect_equals",
valueSrc: ["value"],
valueType: ["multiselect"],
valueError: [null],
},
},
},
},
attributesQueryValue: {
id: "ab99bbb9-89ab-4cde-b012-319300f53ef8",
@@ -522,6 +547,19 @@ export async function seedRoutingForms(
queryValue: {
id: "aaba9948-cdef-4012-b456-719300f53ef8",
type: "group",
children1: {
"c98b98a8-1123-4456-e89a-a19300f55277": {
type: "rule",
properties: {
field: seededForm.formFieldSkills.id,
value: [formFieldSkillsOptions.filter((opt) => opt.label === "Sales").map((opt) => opt.id)],
operator: "multiselect_equals",
valueSrc: ["value"],
valueType: ["multiselect"],
valueError: [null],
},
},
},
},
attributesQueryValue: {
id: "ab988888-89ab-4cde-b012-319300f53ef8",
@@ -559,20 +597,14 @@ export async function seedRoutingForms(
id: seededForm.formFieldLocation.id,
type: "select",
label: "Location",
options: attributeRaw[1].options.map((opt) => ({
id: opt.id,
label: opt.value,
})),
options: formFieldLocationOptions,
required: true,
},
{
id: seededForm.formFieldSkills.id,
type: "multiselect",
label: "skills",
options: attributeRaw[2].options.map((opt) => ({
id: opt.id,
label: opt.value,
})),
options: formFieldSkillsOptions,
required: true,
},
{