feat(calcom): add custom cal.com field

Closes: #2654
This commit is contained in:
Alexander Schaber
2024-06-23 16:20:40 +02:00
parent 6c6061a123
commit 01210dba3f
6 changed files with 17 additions and 1 deletions

View File

@@ -90,6 +90,15 @@ export const CalQuestionForm = ({
onChange={(e) => updateQuestion(questionIdx, { calUserName: e.target.value })}
/>
</div>
<Label htmlFor="calHost">Your self-hosted Cal.com instance</Label>
<div className="mt-2">
<Input
id="calHost"
name="calHost"
value={question.calHost}
onChange={(e) => updateQuestion(questionIdx, { calHost: e.target.value })}
/>
</div>
</div>
</div>
</form>

View File

@@ -185,6 +185,7 @@ export const questionTypes: TQuestion[] = [
preset: {
headline: { default: "Schedule a call with me" },
calUserName: "rick/get-rick-rolled",
calHost: "cal.com",
} as Partial<TSurveyCalQuestion>,
},
{

View File

@@ -228,6 +228,7 @@ export const mockCalQuestion: TSurveyCalQuestion = {
default: "Skip",
},
calUserName: "rick/get-rick-rolled",
calHost: "cal.com",
id: "o3bnux6p42u9ew9d02l14r26",
type: TSurveyQuestionTypeEnum.Cal,
isDraft: true,

View File

@@ -44,7 +44,10 @@ export const CalEmbed = ({ question, onSuccessfulBooking }: CalEmbedProps) => {
useEffect(() => {
// remove any existing cal-inline elements
document.querySelectorAll("cal-inline").forEach((el) => el.remove());
cal("inline", { elementOrSelector: "#fb-cal-embed", calLink: question.calUserName });
cal("inline", {
elementOrSelector: "#fb-cal-embed",
calLink: `https://${question.calHost}/${question.calUserName}`,
});
}, [cal, question.calUserName]);
return (

View File

@@ -136,6 +136,7 @@ export type TLegacySurveyFileUploadQuestion = z.infer<typeof ZLegacySurveyFileUp
export const ZLegacySurveyCalQuestion = ZLegacySurveyQuestionBase.extend({
type: z.literal(TSurveyQuestionTypeEnum.Cal),
calUserName: z.string(),
calHost: z.string().optional(),
logic: z.array(ZSurveyCalLogic).optional(),
});

View File

@@ -383,6 +383,7 @@ export type TSurveyFileUploadQuestion = z.infer<typeof ZSurveyFileUploadQuestion
export const ZSurveyCalQuestion = ZSurveyQuestionBase.extend({
type: z.literal(TSurveyQuestionTypeEnum.Cal),
calUserName: z.string(),
calHost: z.string().optional(),
logic: z.array(ZSurveyCalLogic).optional(),
});