mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-05 10:36:06 -06:00
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Bars4Icon, ListBulletIcon } from "@heroicons/react/24/solid";
|
|
import { createId } from "@paralleldrive/cuid2";
|
|
|
|
export type QuestionType = {
|
|
id: string;
|
|
label: string;
|
|
description: string;
|
|
icon: any;
|
|
defaults: any;
|
|
};
|
|
|
|
export const questionTypes: QuestionType[] = [
|
|
{
|
|
id: "openText",
|
|
label: "Open text",
|
|
description: "A single line of text",
|
|
icon: Bars4Icon,
|
|
defaults: {
|
|
placeholder: "Type your answer here...",
|
|
},
|
|
},
|
|
{
|
|
id: "multipleChoiceSingle",
|
|
label: "Multiple Choice Single-Select",
|
|
description: "A single choice from a list of options (radio buttons)",
|
|
icon: ListBulletIcon,
|
|
defaults: {
|
|
choices: [
|
|
{ id: createId(), label: "" },
|
|
{ id: createId(), label: "" },
|
|
],
|
|
},
|
|
},
|
|
];
|
|
|
|
export const universalQuestionDefaults = {
|
|
required: true,
|
|
};
|
|
|
|
export const getQuestionDefaults = (id: string) => {
|
|
const questionType = questionTypes.find((questionType) => questionType.id === id);
|
|
return questionType?.defaults;
|
|
};
|
|
|
|
export const getQuestionTypeName = (id: string) => {
|
|
const questionType = questionTypes.find((questionType) => questionType.id === id);
|
|
return questionType?.label;
|
|
};
|