mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-21 21:50:39 -06:00
Compare commits
5 Commits
docs/custo
...
aschaber-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4327319d75 | ||
|
|
dc4f146983 | ||
|
|
0ed6401df7 | ||
|
|
e856006e04 | ||
|
|
01210dba3f |
@@ -1,8 +1,10 @@
|
||||
import { PlusIcon } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { createI18nString, extractLanguageCodes } from "@formbricks/lib/i18n/utils";
|
||||
import { TAttributeClass } from "@formbricks/types/attributeClasses";
|
||||
import { TSurvey, TSurveyCalQuestion } from "@formbricks/types/surveys";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import { Checkbox } from "@formbricks/ui/Checkbox";
|
||||
import { Input } from "@formbricks/ui/Input";
|
||||
import { Label } from "@formbricks/ui/Label";
|
||||
import { QuestionFormInput } from "@formbricks/ui/QuestionFormInput";
|
||||
@@ -30,6 +32,15 @@ export const CalQuestionForm = ({
|
||||
attributeClasses,
|
||||
}: CalQuestionFormProps): JSX.Element => {
|
||||
const surveyLanguageCodes = extractLanguageCodes(localSurvey.languages);
|
||||
const [isCalHostEnabled, setIsCalHostEnabled] = useState(!!question.calHost);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isCalHostEnabled) {
|
||||
updateQuestion(questionIdx, { calHost: undefined });
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isCalHostEnabled]);
|
||||
|
||||
return (
|
||||
<form>
|
||||
@@ -80,15 +91,41 @@ export const CalQuestionForm = ({
|
||||
Add Description
|
||||
</Button>
|
||||
)}
|
||||
<div className="mt-3">
|
||||
<Label htmlFor="calUserName">Add your Cal.com username or username/event</Label>
|
||||
<div className="mt-2">
|
||||
<Input
|
||||
id="calUserName"
|
||||
name="calUserName"
|
||||
value={question.calUserName}
|
||||
onChange={(e) => updateQuestion(questionIdx, { calUserName: e.target.value })}
|
||||
/>
|
||||
<div className="mt-3 flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-3">
|
||||
<Label htmlFor="calUserName">Add your Cal.com username or username/event</Label>
|
||||
<div>
|
||||
<Input
|
||||
id="calUserName"
|
||||
name="calUserName"
|
||||
value={question.calUserName}
|
||||
onChange={(e) => updateQuestion(questionIdx, { calUserName: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="calHost"
|
||||
checked={isCalHostEnabled}
|
||||
onCheckedChange={(checked: boolean) => setIsCalHostEnabled(checked)}
|
||||
/>
|
||||
<Label htmlFor="calHost">Do you have a self-hosted Cal.com instance?</Label>
|
||||
</div>
|
||||
|
||||
{isCalHostEnabled && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label htmlFor="calHost">Enter the hostname of your self-hosted Cal.com instance</Label>
|
||||
<Input
|
||||
id="calHost"
|
||||
name="calHost"
|
||||
placeholder="cal.com"
|
||||
value={question.calHost}
|
||||
onChange={(e) => updateQuestion(questionIdx, { calHost: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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>,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -44,8 +44,12 @@ 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, question.calUserName]);
|
||||
cal("init", { calOrigin: question.calHost ? `https://${question.calHost}` : "https://cal.com" });
|
||||
cal("inline", {
|
||||
elementOrSelector: "#fb-cal-embed",
|
||||
calLink: question.calUserName,
|
||||
});
|
||||
}, [cal, question.calHost, question.calUserName]);
|
||||
|
||||
return (
|
||||
<div className="fb-relative fb-mt-4 fb-overflow-auto">
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
|
||||
@@ -385,6 +385,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(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user