diff --git a/apps/web/app/lib/survey-builder.ts b/apps/web/app/lib/survey-builder.ts index 8abe858092..de232f7647 100644 --- a/apps/web/app/lib/survey-builder.ts +++ b/apps/web/app/lib/survey-builder.ts @@ -66,7 +66,7 @@ export const buildMultipleChoiceQuestion = ({ buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, shuffleOption: shuffleOption || "none", - required: required ?? true, + required: required ?? false, logic, }; }; @@ -105,7 +105,7 @@ export const buildOpenTextQuestion = ({ headline: { default: headline }, buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, - required: required ?? true, + required: required ?? false, longAnswer, logic, charLimit: { @@ -153,7 +153,7 @@ export const buildRatingQuestion = ({ range, buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, - required: required ?? true, + required: required ?? false, isColorCodingEnabled, lowerLabel: lowerLabel ? { default: lowerLabel } : undefined, upperLabel: upperLabel ? { default: upperLabel } : undefined, @@ -194,7 +194,7 @@ export const buildNPSQuestion = ({ headline: { default: headline }, buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, - required: required ?? true, + required: required ?? false, isColorCodingEnabled, lowerLabel: lowerLabel ? { default: lowerLabel } : undefined, upperLabel: upperLabel ? { default: upperLabel } : undefined, @@ -230,7 +230,7 @@ export const buildConsentQuestion = ({ headline: { default: headline }, buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, - required: required ?? true, + required: required ?? false, label: { default: label }, logic, }; @@ -269,7 +269,7 @@ export const buildCTAQuestion = ({ buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, dismissButtonLabel: dismissButtonLabel ? { default: dismissButtonLabel } : undefined, - required: required ?? true, + required: required ?? false, buttonExternal, buttonUrl, logic, diff --git a/apps/web/modules/survey/lib/questions.tsx b/apps/web/modules/survey/lib/questions.tsx index 5f84fec23e..dfa535b77d 100644 --- a/apps/web/modules/survey/lib/questions.tsx +++ b/apps/web/modules/survey/lib/questions.tsx @@ -341,7 +341,7 @@ export const getCXQuestionNameMap = (t: TFnType) => ) as Record; export const universalQuestionPresets = { - required: true, + required: false, }; export const getQuestionDefaults = (id: string, project: any, t: TFnType) => { diff --git a/packages/surveys/src/components/questions/file-upload-question.tsx b/packages/surveys/src/components/questions/file-upload-question.tsx index bbbfc82e99..c1d10fac25 100644 --- a/packages/surveys/src/components/questions/file-upload-question.tsx +++ b/packages/surveys/src/components/questions/file-upload-question.tsx @@ -14,21 +14,21 @@ import { FileInput } from "../general/file-input"; import { Subheader } from "../general/subheader"; interface FileUploadQuestionProps { - readonly question: TSurveyFileUploadQuestion; - readonly value: string[]; - readonly onChange: (responseData: TResponseData) => void; - readonly onSubmit: (data: TResponseData, ttc: TResponseTtc) => void; - readonly onBack: () => void; - readonly onFileUpload: (file: TJsFileUploadParams["file"], config?: TUploadFileConfig) => Promise; - readonly isFirstQuestion: boolean; - readonly isLastQuestion: boolean; - readonly surveyId: string; - readonly languageCode: string; - readonly ttc: TResponseTtc; - readonly setTtc: (ttc: TResponseTtc) => void; - readonly autoFocusEnabled: boolean; - readonly currentQuestionId: TSurveyQuestionId; - readonly isBackButtonHidden: boolean; + question: TSurveyFileUploadQuestion; + value: string[]; + onChange: (responseData: TResponseData) => void; + onSubmit: (data: TResponseData, ttc: TResponseTtc) => void; + onBack: () => void; + onFileUpload: (file: TJsFileUploadParams["file"], config?: TUploadFileConfig) => Promise; + isFirstQuestion: boolean; + isLastQuestion: boolean; + surveyId: string; + languageCode: string; + ttc: TResponseTtc; + setTtc: (ttc: TResponseTtc) => void; + autoFocusEnabled: boolean; + currentQuestionId: TSurveyQuestionId; + isBackButtonHidden: boolean; } export function FileUploadQuestion({ @@ -46,7 +46,7 @@ export function FileUploadQuestion({ setTtc, currentQuestionId, isBackButtonHidden, -}: FileUploadQuestionProps) { +}: Readonly) { const [startTime, setStartTime] = useState(performance.now()); const isMediaAvailable = question.imageUrl || question.videoUrl; useTtc(question.id, ttc, setTtc, startTime, setStartTime, question.id === currentQuestionId); diff --git a/packages/surveys/src/components/questions/open-text-question.tsx b/packages/surveys/src/components/questions/open-text-question.tsx index 75285f42a5..c141390a36 100644 --- a/packages/surveys/src/components/questions/open-text-question.tsx +++ b/packages/surveys/src/components/questions/open-text-question.tsx @@ -12,19 +12,19 @@ import { type TResponseData, type TResponseTtc } from "@formbricks/types/respons import type { TSurveyOpenTextQuestion, TSurveyQuestionId } from "@formbricks/types/surveys/types"; interface OpenTextQuestionProps { - readonly question: TSurveyOpenTextQuestion; - readonly value: string; - readonly onChange: (responseData: TResponseData) => void; - readonly onSubmit: (data: TResponseData, ttc: TResponseTtc) => void; - readonly onBack: () => void; - readonly isFirstQuestion: boolean; - readonly isLastQuestion: boolean; - readonly languageCode: string; - readonly ttc: TResponseTtc; - readonly setTtc: (ttc: TResponseTtc) => void; - readonly autoFocusEnabled: boolean; - readonly currentQuestionId: TSurveyQuestionId; - readonly isBackButtonHidden: boolean; + question: TSurveyOpenTextQuestion; + value: string; + onChange: (responseData: TResponseData) => void; + onSubmit: (data: TResponseData, ttc: TResponseTtc) => void; + onBack: () => void; + isFirstQuestion: boolean; + isLastQuestion: boolean; + languageCode: string; + ttc: TResponseTtc; + setTtc: (ttc: TResponseTtc) => void; + autoFocusEnabled: boolean; + currentQuestionId: TSurveyQuestionId; + isBackButtonHidden: boolean; } export function OpenTextQuestion({ diff --git a/packages/surveys/src/components/wrappers/stacked-cards-container.tsx b/packages/surveys/src/components/wrappers/stacked-cards-container.tsx index 0afb0344f4..f3edf9ef68 100644 --- a/packages/surveys/src/components/wrappers/stacked-cards-container.tsx +++ b/packages/surveys/src/components/wrappers/stacked-cards-container.tsx @@ -11,14 +11,14 @@ import { StackedCard } from "./stacked-card"; // offset < 0 -> Question cards that are already answered // offset > 0 -> Question that aren't answered yet interface StackedCardsContainerProps { - readonly cardArrangement: TCardArrangementOptions; - readonly currentQuestionId: TSurveyQuestionId; - readonly survey: TJsEnvironmentStateSurvey; - readonly getCardContent: (questionIdxTemp: number, offset: number) => JSX.Element | undefined; - readonly styling: TProjectStyling | TSurveyStyling; - readonly setQuestionId: (questionId: TSurveyQuestionId) => void; - readonly shouldResetQuestionId?: boolean; - readonly fullSizeCards: boolean; + cardArrangement: TCardArrangementOptions; + currentQuestionId: TSurveyQuestionId; + survey: TJsEnvironmentStateSurvey; + getCardContent: (questionIdxTemp: number, offset: number) => JSX.Element | undefined; + styling: TProjectStyling | TSurveyStyling; + setQuestionId: (questionId: TSurveyQuestionId) => void; + shouldResetQuestionId?: boolean; + fullSizeCards: boolean; } export function StackedCardsContainer({ @@ -30,7 +30,7 @@ export function StackedCardsContainer({ setQuestionId, shouldResetQuestionId = true, fullSizeCards = false, -}: StackedCardsContainerProps) { +}: Readonly) { const [hovered, setHovered] = useState(false); const highlightBorderColor = survey.styling?.overwriteThemeStyling ? survey.styling?.highlightBorderColor?.light diff --git a/packages/surveys/src/components/wrappers/survey-container.tsx b/packages/surveys/src/components/wrappers/survey-container.tsx index 3c67eef957..42839173d4 100644 --- a/packages/surveys/src/components/wrappers/survey-container.tsx +++ b/packages/surveys/src/components/wrappers/survey-container.tsx @@ -3,14 +3,14 @@ import { useEffect, useRef, useState } from "preact/hooks"; import { type TPlacement } from "@formbricks/types/common"; interface SurveyContainerProps { - readonly mode: "modal" | "inline"; - readonly placement?: TPlacement; - readonly darkOverlay?: boolean; - readonly children: React.ReactNode; - readonly onClose?: () => void; - readonly clickOutside?: boolean; - readonly isOpen?: boolean; - readonly style?: React.CSSProperties; + mode: "modal" | "inline"; + placement?: TPlacement; + darkOverlay?: boolean; + children: React.ReactNode; + onClose?: () => void; + clickOutside?: boolean; + isOpen?: boolean; + style?: React.CSSProperties; } export function SurveyContainer({ @@ -22,7 +22,7 @@ export function SurveyContainer({ clickOutside, isOpen = true, style, -}: SurveyContainerProps) { +}: Readonly) { const [show, setShow] = useState(false); const modalRef = useRef(null);