Files
formbricks/apps/web/lib/questions.ts
Moritz Rengert a0baa25864 Feature Thank You Card (#222)
add thankyou card to surveys.

---------

Co-authored-by: Johannes <johannes@formbricks.com>
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-04-12 12:35:04 +02:00

49 lines
1.2 KiB
TypeScript

import { Bars3BottomLeftIcon, 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: Bars3BottomLeftIcon,
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;
};