From 8611410b21baf3749b9e0c74c276ab33db0a7e2c Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Fri, 25 Apr 2025 19:04:31 +0530 Subject: [PATCH] chore: refactored templates file (#5492) Co-authored-by: Victor Santos --- .../xm-templates/lib/xm-templates.ts | 236 +- apps/web/app/lib/survey-builder.test.ts | 612 ++ apps/web/app/lib/survey-builder.ts | 414 + apps/web/app/lib/templates.ts | 7236 +++++------------ .../survey/components/template-list/index.tsx | 2 +- .../editor/components/how-to-send-card.tsx | 2 +- .../editor/components/questions-view.tsx | 2 +- .../survey/templates/lib/minimal-survey.ts | 2 +- apps/web/playwright/js.spec.ts | 2 +- apps/web/vite.config.mts | 1 + sonar-project.properties | 4 +- 11 files changed, 3013 insertions(+), 5500 deletions(-) create mode 100644 apps/web/app/lib/survey-builder.test.ts create mode 100644 apps/web/app/lib/survey-builder.ts diff --git a/apps/web/app/(app)/(onboarding)/environments/[environmentId]/xm-templates/lib/xm-templates.ts b/apps/web/app/(app)/(onboarding)/environments/[environmentId]/xm-templates/lib/xm-templates.ts index fa11c26f11..5fb64cfabc 100644 --- a/apps/web/app/(app)/(onboarding)/environments/[environmentId]/xm-templates/lib/xm-templates.ts +++ b/apps/web/app/(app)/(onboarding)/environments/[environmentId]/xm-templates/lib/xm-templates.ts @@ -1,8 +1,13 @@ -import { getDefaultEndingCard } from "@/app/lib/templates"; +import { + buildCTAQuestion, + buildNPSQuestion, + buildOpenTextQuestion, + buildRatingQuestion, + getDefaultEndingCard, +} from "@/app/lib/survey-builder"; import { createId } from "@paralleldrive/cuid2"; import { TFnType } from "@tolgee/react"; import { logger } from "@formbricks/logger"; -import { TSurveyQuestionTypeEnum } from "@formbricks/types/surveys/types"; import { TXMTemplate } from "@formbricks/types/templates"; export const getXMSurveyDefault = (t: TFnType): TXMTemplate => { @@ -26,35 +31,26 @@ const npsSurvey = (t: TFnType): TXMTemplate => { ...getXMSurveyDefault(t), name: t("templates.nps_survey_name"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.NPS, - headline: { default: t("templates.nps_survey_question_1_headline") }, + buildNPSQuestion({ + headline: t("templates.nps_survey_question_1_headline"), required: true, - lowerLabel: { default: t("templates.nps_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.nps_survey_question_1_upper_label") }, + lowerLabel: t("templates.nps_survey_question_1_lower_label"), + upperLabel: t("templates.nps_survey_question_1_upper_label"), isColorCodingEnabled: true, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.nps_survey_question_2_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.nps_survey_question_2_headline"), required: false, inputType: "text", - charLimit: { - enabled: false, - }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.nps_survey_question_3_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.nps_survey_question_3_headline"), required: false, inputType: "text", - charLimit: { - enabled: false, - }, - }, + t, + }), ], }; }; @@ -67,9 +63,8 @@ const starRatingSurvey = (t: TFnType): TXMTemplate => { ...defaultSurvey, name: t("templates.star_rating_survey_name"), questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -102,16 +97,15 @@ const starRatingSurvey = (t: TFnType): TXMTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.star_rating_survey_question_1_headline") }, + headline: t("templates.star_rating_survey_question_1_headline"), required: true, - lowerLabel: { default: t("templates.star_rating_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.star_rating_survey_question_1_upper_label") }, - isColorCodingEnabled: false, - }, - { + lowerLabel: t("templates.star_rating_survey_question_1_lower_label"), + upperLabel: t("templates.star_rating_survey_question_1_upper_label"), + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[1], - html: { default: t("templates.star_rating_survey_question_2_html") }, - type: TSurveyQuestionTypeEnum.CTA, + html: t("templates.star_rating_survey_question_2_html"), logic: [ { id: createId(), @@ -138,25 +132,23 @@ const starRatingSurvey = (t: TFnType): TXMTemplate => { ], }, ], - headline: { default: t("templates.star_rating_survey_question_2_headline") }, + headline: t("templates.star_rating_survey_question_2_headline"), required: true, buttonUrl: "https://formbricks.com/github", - buttonLabel: { default: t("templates.star_rating_survey_question_2_button_label") }, + buttonLabel: t("templates.star_rating_survey_question_2_button_label"), buttonExternal: true, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.star_rating_survey_question_3_headline") }, + headline: t("templates.star_rating_survey_question_3_headline"), required: true, - subheader: { default: t("templates.star_rating_survey_question_3_subheader") }, - buttonLabel: { default: t("templates.star_rating_survey_question_3_button_label") }, - placeholder: { default: t("templates.star_rating_survey_question_3_placeholder") }, + subheader: t("templates.star_rating_survey_question_3_subheader"), + buttonLabel: t("templates.star_rating_survey_question_3_button_label"), + placeholder: t("templates.star_rating_survey_question_3_placeholder"), inputType: "text", - charLimit: { - enabled: false, - }, - }, + t, + }), ], }; }; @@ -169,9 +161,8 @@ const csatSurvey = (t: TFnType): TXMTemplate => { ...defaultSurvey, name: t("templates.csat_survey_name"), questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -204,15 +195,14 @@ const csatSurvey = (t: TFnType): TXMTemplate => { ], range: 5, scale: "smiley", - headline: { default: t("templates.csat_survey_question_1_headline") }, + headline: t("templates.csat_survey_question_1_headline"), required: true, - lowerLabel: { default: t("templates.csat_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.csat_survey_question_1_upper_label") }, - isColorCodingEnabled: false, - }, - { + lowerLabel: t("templates.csat_survey_question_1_lower_label"), + upperLabel: t("templates.csat_survey_question_1_upper_label"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, logic: [ { id: createId(), @@ -239,25 +229,20 @@ const csatSurvey = (t: TFnType): TXMTemplate => { ], }, ], - headline: { default: t("templates.csat_survey_question_2_headline") }, + headline: t("templates.csat_survey_question_2_headline"), required: false, - placeholder: { default: t("templates.csat_survey_question_2_placeholder") }, + placeholder: t("templates.csat_survey_question_2_placeholder"), inputType: "text", - charLimit: { - enabled: false, - }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.csat_survey_question_3_headline") }, + headline: t("templates.csat_survey_question_3_headline"), required: false, - placeholder: { default: t("templates.csat_survey_question_3_placeholder") }, + placeholder: t("templates.csat_survey_question_3_placeholder"), inputType: "text", - charLimit: { - enabled: false, - }, - }, + t, + }), ], }; }; @@ -267,28 +252,22 @@ const cessSurvey = (t: TFnType): TXMTemplate => { ...getXMSurveyDefault(t), name: t("templates.cess_survey_name"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "number", - headline: { default: t("templates.cess_survey_question_1_headline") }, + headline: t("templates.cess_survey_question_1_headline"), required: true, - lowerLabel: { default: t("templates.cess_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.cess_survey_question_1_upper_label") }, - isColorCodingEnabled: false, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.cess_survey_question_2_headline") }, + lowerLabel: t("templates.cess_survey_question_1_lower_label"), + upperLabel: t("templates.cess_survey_question_1_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.cess_survey_question_2_headline"), required: true, - placeholder: { default: t("templates.cess_survey_question_2_placeholder") }, + placeholder: t("templates.cess_survey_question_2_placeholder"), inputType: "text", - charLimit: { - enabled: false, - }, - }, + t, + }), ], }; }; @@ -301,9 +280,8 @@ const smileysRatingSurvey = (t: TFnType): TXMTemplate => { ...defaultSurvey, name: t("templates.smileys_survey_name"), questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -336,16 +314,15 @@ const smileysRatingSurvey = (t: TFnType): TXMTemplate => { ], range: 5, scale: "smiley", - headline: { default: t("templates.smileys_survey_question_1_headline") }, + headline: t("templates.smileys_survey_question_1_headline"), required: true, - lowerLabel: { default: t("templates.smileys_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.smileys_survey_question_1_upper_label") }, - isColorCodingEnabled: false, - }, - { + lowerLabel: t("templates.smileys_survey_question_1_lower_label"), + upperLabel: t("templates.smileys_survey_question_1_upper_label"), + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[1], - html: { default: t("templates.smileys_survey_question_2_html") }, - type: TSurveyQuestionTypeEnum.CTA, + html: t("templates.smileys_survey_question_2_html"), logic: [ { id: createId(), @@ -372,25 +349,23 @@ const smileysRatingSurvey = (t: TFnType): TXMTemplate => { ], }, ], - headline: { default: t("templates.smileys_survey_question_2_headline") }, + headline: t("templates.smileys_survey_question_2_headline"), required: true, buttonUrl: "https://formbricks.com/github", - buttonLabel: { default: t("templates.smileys_survey_question_2_button_label") }, + buttonLabel: t("templates.smileys_survey_question_2_button_label"), buttonExternal: true, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.smileys_survey_question_3_headline") }, + headline: t("templates.smileys_survey_question_3_headline"), required: true, - subheader: { default: t("templates.smileys_survey_question_3_subheader") }, - buttonLabel: { default: t("templates.smileys_survey_question_3_button_label") }, - placeholder: { default: t("templates.smileys_survey_question_3_placeholder") }, + subheader: t("templates.smileys_survey_question_3_subheader"), + buttonLabel: t("templates.smileys_survey_question_3_button_label"), + placeholder: t("templates.smileys_survey_question_3_placeholder"), inputType: "text", - charLimit: { - enabled: false, - }, - }, + t, + }), ], }; }; @@ -400,37 +375,26 @@ const enpsSurvey = (t: TFnType): TXMTemplate => { ...getXMSurveyDefault(t), name: t("templates.enps_survey_name"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.NPS, - headline: { - default: t("templates.enps_survey_question_1_headline"), - }, + buildNPSQuestion({ + headline: t("templates.enps_survey_question_1_headline"), required: false, - lowerLabel: { default: t("templates.enps_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.enps_survey_question_1_upper_label") }, + lowerLabel: t("templates.enps_survey_question_1_lower_label"), + upperLabel: t("templates.enps_survey_question_1_upper_label"), isColorCodingEnabled: true, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.enps_survey_question_2_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.enps_survey_question_2_headline"), required: false, inputType: "text", - charLimit: { - enabled: false, - }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - headline: { default: t("templates.enps_survey_question_3_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.enps_survey_question_3_headline"), required: false, inputType: "text", - charLimit: { - enabled: false, - }, - }, + t, + }), ], }; }; diff --git a/apps/web/app/lib/survey-builder.test.ts b/apps/web/app/lib/survey-builder.test.ts new file mode 100644 index 0000000000..5a78d2e0a8 --- /dev/null +++ b/apps/web/app/lib/survey-builder.test.ts @@ -0,0 +1,612 @@ +import { describe, expect, test } from "vitest"; +import { TShuffleOption, TSurveyLogic, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys/types"; +import { TTemplateRole } from "@formbricks/types/templates"; +import { + buildCTAQuestion, + buildConsentQuestion, + buildMultipleChoiceQuestion, + buildNPSQuestion, + buildOpenTextQuestion, + buildRatingQuestion, + buildSurvey, + createChoiceJumpLogic, + createJumpLogic, + getDefaultEndingCard, + getDefaultSurveyPreset, + getDefaultWelcomeCard, + hiddenFieldsDefault, +} from "./survey-builder"; + +// Mock the TFnType from @tolgee/react +const mockT = (props: any): string => (typeof props === "string" ? props : props.key); + +describe("Survey Builder", () => { + describe("buildMultipleChoiceQuestion", () => { + test("creates a single choice question with required fields", () => { + const question = buildMultipleChoiceQuestion({ + headline: "Test Question", + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + choices: ["Option 1", "Option 2", "Option 3"], + t: mockT, + }); + + expect(question).toMatchObject({ + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + headline: { default: "Test Question" }, + choices: expect.arrayContaining([ + expect.objectContaining({ label: { default: "Option 1" } }), + expect.objectContaining({ label: { default: "Option 2" } }), + expect.objectContaining({ label: { default: "Option 3" } }), + ]), + buttonLabel: { default: "common.next" }, + backButtonLabel: { default: "common.back" }, + shuffleOption: "none", + required: true, + }); + expect(question.choices.length).toBe(3); + expect(question.id).toBeDefined(); + }); + + test("creates a multiple choice question with provided ID", () => { + const customId = "custom-id-123"; + const question = buildMultipleChoiceQuestion({ + id: customId, + headline: "Test Question", + type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, + choices: ["Option 1", "Option 2"], + t: mockT, + }); + + expect(question.id).toBe(customId); + expect(question.type).toBe(TSurveyQuestionTypeEnum.MultipleChoiceMulti); + }); + + test("handles 'other' option correctly", () => { + const choices = ["Option 1", "Option 2", "Other"]; + const question = buildMultipleChoiceQuestion({ + headline: "Test Question", + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + choices, + containsOther: true, + t: mockT, + }); + + expect(question.choices.length).toBe(3); + expect(question.choices[2].id).toBe("other"); + }); + + test("uses provided choice IDs when available", () => { + const choiceIds = ["id1", "id2", "id3"]; + const question = buildMultipleChoiceQuestion({ + headline: "Test Question", + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + choices: ["Option 1", "Option 2", "Option 3"], + choiceIds, + t: mockT, + }); + + expect(question.choices[0].id).toBe(choiceIds[0]); + expect(question.choices[1].id).toBe(choiceIds[1]); + expect(question.choices[2].id).toBe(choiceIds[2]); + }); + + test("applies all optional parameters correctly", () => { + const logic: TSurveyLogic[] = [ + { + id: "logic-1", + conditions: { + id: "cond-1", + connector: "and", + conditions: [], + }, + actions: [], + }, + ]; + + const shuffleOption: TShuffleOption = "all"; + + const question = buildMultipleChoiceQuestion({ + headline: "Test Question", + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + subheader: "This is a subheader", + choices: ["Option 1", "Option 2"], + buttonLabel: "Custom Next", + backButtonLabel: "Custom Back", + shuffleOption, + required: false, + logic, + t: mockT, + }); + + expect(question.subheader).toEqual({ default: "This is a subheader" }); + expect(question.buttonLabel).toEqual({ default: "Custom Next" }); + expect(question.backButtonLabel).toEqual({ default: "Custom Back" }); + expect(question.shuffleOption).toBe("all"); + expect(question.required).toBe(false); + expect(question.logic).toBe(logic); + }); + }); + + describe("buildOpenTextQuestion", () => { + test("creates an open text question with required fields", () => { + const question = buildOpenTextQuestion({ + headline: "Open Question", + inputType: "text", + t: mockT, + }); + + expect(question).toMatchObject({ + type: TSurveyQuestionTypeEnum.OpenText, + headline: { default: "Open Question" }, + inputType: "text", + buttonLabel: { default: "common.next" }, + backButtonLabel: { default: "common.back" }, + required: true, + charLimit: { + enabled: false, + }, + }); + expect(question.id).toBeDefined(); + }); + + test("applies all optional parameters correctly", () => { + const logic: TSurveyLogic[] = [ + { + id: "logic-1", + conditions: { + id: "cond-1", + connector: "and", + conditions: [], + }, + actions: [], + }, + ]; + + const question = buildOpenTextQuestion({ + id: "custom-id", + headline: "Open Question", + subheader: "Answer this question", + placeholder: "Type here", + buttonLabel: "Submit", + backButtonLabel: "Previous", + required: false, + longAnswer: true, + inputType: "email", + logic, + t: mockT, + }); + + expect(question.id).toBe("custom-id"); + expect(question.subheader).toEqual({ default: "Answer this question" }); + expect(question.placeholder).toEqual({ default: "Type here" }); + expect(question.buttonLabel).toEqual({ default: "Submit" }); + expect(question.backButtonLabel).toEqual({ default: "Previous" }); + expect(question.required).toBe(false); + expect(question.longAnswer).toBe(true); + expect(question.inputType).toBe("email"); + expect(question.logic).toBe(logic); + }); + }); + + describe("buildRatingQuestion", () => { + test("creates a rating question with required fields", () => { + const question = buildRatingQuestion({ + headline: "Rating Question", + scale: "number", + range: 5, + t: mockT, + }); + + expect(question).toMatchObject({ + type: TSurveyQuestionTypeEnum.Rating, + headline: { default: "Rating Question" }, + scale: "number", + range: 5, + buttonLabel: { default: "common.next" }, + backButtonLabel: { default: "common.back" }, + required: true, + isColorCodingEnabled: false, + }); + expect(question.id).toBeDefined(); + }); + + test("applies all optional parameters correctly", () => { + const logic: TSurveyLogic[] = [ + { + id: "logic-1", + conditions: { + id: "cond-1", + connector: "and", + conditions: [], + }, + actions: [], + }, + ]; + + const question = buildRatingQuestion({ + id: "custom-id", + headline: "Rating Question", + subheader: "Rate us", + scale: "star", + range: 10, + lowerLabel: "Poor", + upperLabel: "Excellent", + buttonLabel: "Submit", + backButtonLabel: "Previous", + required: false, + isColorCodingEnabled: true, + logic, + t: mockT, + }); + + expect(question.id).toBe("custom-id"); + expect(question.subheader).toEqual({ default: "Rate us" }); + expect(question.scale).toBe("star"); + expect(question.range).toBe(10); + expect(question.lowerLabel).toEqual({ default: "Poor" }); + expect(question.upperLabel).toEqual({ default: "Excellent" }); + expect(question.buttonLabel).toEqual({ default: "Submit" }); + expect(question.backButtonLabel).toEqual({ default: "Previous" }); + expect(question.required).toBe(false); + expect(question.isColorCodingEnabled).toBe(true); + expect(question.logic).toBe(logic); + }); + }); + + describe("buildNPSQuestion", () => { + test("creates an NPS question with required fields", () => { + const question = buildNPSQuestion({ + headline: "NPS Question", + t: mockT, + }); + + expect(question).toMatchObject({ + type: TSurveyQuestionTypeEnum.NPS, + headline: { default: "NPS Question" }, + buttonLabel: { default: "common.next" }, + backButtonLabel: { default: "common.back" }, + required: true, + isColorCodingEnabled: false, + }); + expect(question.id).toBeDefined(); + }); + + test("applies all optional parameters correctly", () => { + const logic: TSurveyLogic[] = [ + { + id: "logic-1", + conditions: { + id: "cond-1", + connector: "and", + conditions: [], + }, + actions: [], + }, + ]; + + const question = buildNPSQuestion({ + id: "custom-id", + headline: "NPS Question", + subheader: "How likely are you to recommend us?", + lowerLabel: "Not likely", + upperLabel: "Very likely", + buttonLabel: "Submit", + backButtonLabel: "Previous", + required: false, + isColorCodingEnabled: true, + logic, + t: mockT, + }); + + expect(question.id).toBe("custom-id"); + expect(question.subheader).toEqual({ default: "How likely are you to recommend us?" }); + expect(question.lowerLabel).toEqual({ default: "Not likely" }); + expect(question.upperLabel).toEqual({ default: "Very likely" }); + expect(question.buttonLabel).toEqual({ default: "Submit" }); + expect(question.backButtonLabel).toEqual({ default: "Previous" }); + expect(question.required).toBe(false); + expect(question.isColorCodingEnabled).toBe(true); + expect(question.logic).toBe(logic); + }); + }); + + describe("buildConsentQuestion", () => { + test("creates a consent question with required fields", () => { + const question = buildConsentQuestion({ + headline: "Consent Question", + label: "I agree to terms", + t: mockT, + }); + + expect(question).toMatchObject({ + type: TSurveyQuestionTypeEnum.Consent, + headline: { default: "Consent Question" }, + label: { default: "I agree to terms" }, + buttonLabel: { default: "common.next" }, + backButtonLabel: { default: "common.back" }, + required: true, + }); + expect(question.id).toBeDefined(); + }); + + test("applies all optional parameters correctly", () => { + const logic: TSurveyLogic[] = [ + { + id: "logic-1", + conditions: { + id: "cond-1", + connector: "and", + conditions: [], + }, + actions: [], + }, + ]; + + const question = buildConsentQuestion({ + id: "custom-id", + headline: "Consent Question", + subheader: "Please read the terms", + label: "I agree to terms", + buttonLabel: "Submit", + backButtonLabel: "Previous", + required: false, + logic, + t: mockT, + }); + + expect(question.id).toBe("custom-id"); + expect(question.subheader).toEqual({ default: "Please read the terms" }); + expect(question.label).toEqual({ default: "I agree to terms" }); + expect(question.buttonLabel).toEqual({ default: "Submit" }); + expect(question.backButtonLabel).toEqual({ default: "Previous" }); + expect(question.required).toBe(false); + expect(question.logic).toBe(logic); + }); + }); + + describe("buildCTAQuestion", () => { + test("creates a CTA question with required fields", () => { + const question = buildCTAQuestion({ + headline: "CTA Question", + buttonExternal: false, + t: mockT, + }); + + expect(question).toMatchObject({ + type: TSurveyQuestionTypeEnum.CTA, + headline: { default: "CTA Question" }, + buttonLabel: { default: "common.next" }, + backButtonLabel: { default: "common.back" }, + required: true, + buttonExternal: false, + }); + expect(question.id).toBeDefined(); + }); + + test("applies all optional parameters correctly", () => { + const logic: TSurveyLogic[] = [ + { + id: "logic-1", + conditions: { + id: "cond-1", + connector: "and", + conditions: [], + }, + actions: [], + }, + ]; + + const question = buildCTAQuestion({ + id: "custom-id", + headline: "CTA Question", + html: "

Click the button

", + buttonLabel: "Click me", + buttonExternal: true, + buttonUrl: "https://example.com", + backButtonLabel: "Previous", + required: false, + dismissButtonLabel: "No thanks", + logic, + t: mockT, + }); + + expect(question.id).toBe("custom-id"); + expect(question.html).toEqual({ default: "

Click the button

" }); + expect(question.buttonLabel).toEqual({ default: "Click me" }); + expect(question.buttonExternal).toBe(true); + expect(question.buttonUrl).toBe("https://example.com"); + expect(question.backButtonLabel).toEqual({ default: "Previous" }); + expect(question.required).toBe(false); + expect(question.dismissButtonLabel).toEqual({ default: "No thanks" }); + expect(question.logic).toBe(logic); + }); + + test("handles external button with URL", () => { + const question = buildCTAQuestion({ + headline: "CTA Question", + buttonExternal: true, + buttonUrl: "https://formbricks.com", + t: mockT, + }); + + expect(question.buttonExternal).toBe(true); + expect(question.buttonUrl).toBe("https://formbricks.com"); + }); + }); + + // Test combinations of parameters for edge cases + describe("Edge cases", () => { + test("multiple choice question with empty choices array", () => { + const question = buildMultipleChoiceQuestion({ + headline: "Test Question", + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + choices: [], + t: mockT, + }); + + expect(question.choices).toEqual([]); + }); + + test("open text question with all parameters", () => { + const question = buildOpenTextQuestion({ + id: "custom-id", + headline: "Open Question", + subheader: "Answer this question", + placeholder: "Type here", + buttonLabel: "Submit", + backButtonLabel: "Previous", + required: false, + longAnswer: true, + inputType: "email", + logic: [], + t: mockT, + }); + + expect(question).toMatchObject({ + id: "custom-id", + type: TSurveyQuestionTypeEnum.OpenText, + headline: { default: "Open Question" }, + subheader: { default: "Answer this question" }, + placeholder: { default: "Type here" }, + buttonLabel: { default: "Submit" }, + backButtonLabel: { default: "Previous" }, + required: false, + longAnswer: true, + inputType: "email", + logic: [], + }); + }); + }); +}); + +describe("Helper Functions", () => { + test("createJumpLogic returns valid jump logic", () => { + const sourceId = "q1"; + const targetId = "q2"; + const operator: "isClicked" = "isClicked"; + const logic = createJumpLogic(sourceId, targetId, operator); + + // Check structure + expect(logic).toHaveProperty("id"); + expect(logic).toHaveProperty("conditions"); + expect(logic.conditions).toHaveProperty("conditions"); + expect(Array.isArray(logic.conditions.conditions)).toBe(true); + + // Check one of the inner conditions + const condition = logic.conditions.conditions[0]; + // Need to use type checking to ensure condition is a TSingleCondition not a TConditionGroup + if (!("connector" in condition)) { + expect(condition.leftOperand.value).toBe(sourceId); + expect(condition.operator).toBe(operator); + } + + // Check actions + expect(Array.isArray(logic.actions)).toBe(true); + const action = logic.actions[0]; + if (action.objective === "jumpToQuestion") { + expect(action.target).toBe(targetId); + } + }); + + test("createChoiceJumpLogic returns valid jump logic based on choice selection", () => { + const sourceId = "q1"; + const choiceId = "choice1"; + const targetId = "q2"; + const logic = createChoiceJumpLogic(sourceId, choiceId, targetId); + + expect(logic).toHaveProperty("id"); + expect(logic.conditions).toHaveProperty("conditions"); + + const condition = logic.conditions.conditions[0]; + if (!("connector" in condition)) { + expect(condition.leftOperand.value).toBe(sourceId); + expect(condition.operator).toBe("equals"); + expect(condition.rightOperand?.value).toBe(choiceId); + } + + const action = logic.actions[0]; + if (action.objective === "jumpToQuestion") { + expect(action.target).toBe(targetId); + } + }); + + test("getDefaultWelcomeCard returns expected welcome card", () => { + const card = getDefaultWelcomeCard(mockT); + expect(card.enabled).toBe(false); + expect(card.headline).toEqual({ default: "templates.default_welcome_card_headline" }); + expect(card.html).toEqual({ default: "templates.default_welcome_card_html" }); + expect(card.buttonLabel).toEqual({ default: "templates.default_welcome_card_button_label" }); + // boolean flags + expect(card.timeToFinish).toBe(false); + expect(card.showResponseCount).toBe(false); + }); + + test("getDefaultEndingCard returns expected end screen card", () => { + // Pass empty languages array to simulate no languages + const card = getDefaultEndingCard([], mockT); + expect(card).toHaveProperty("id"); + expect(card.type).toBe("endScreen"); + expect(card.headline).toEqual({ default: "templates.default_ending_card_headline" }); + expect(card.subheader).toEqual({ default: "templates.default_ending_card_subheader" }); + expect(card.buttonLabel).toEqual({ default: "templates.default_ending_card_button_label" }); + expect(card.buttonLink).toBe("https://formbricks.com"); + }); + + test("getDefaultSurveyPreset returns expected default survey preset", () => { + const preset = getDefaultSurveyPreset(mockT); + expect(preset.name).toBe("New Survey"); + expect(preset.questions).toEqual([]); + // test welcomeCard and endings + expect(preset.welcomeCard).toHaveProperty("headline"); + expect(Array.isArray(preset.endings)).toBe(true); + expect(preset.hiddenFields).toEqual(hiddenFieldsDefault); + }); + + test("buildSurvey returns built survey with overridden preset properties", () => { + const config = { + name: "Custom Survey", + role: "productManager" as TTemplateRole, + industries: ["eCommerce"] as string[], + channels: ["link"], + description: "Test survey", + questions: [ + { + id: "q1", + type: TSurveyQuestionTypeEnum.OpenText, // changed from "OpenText" + headline: { default: "Question 1" }, + inputType: "text", + buttonLabel: { default: "Next" }, + backButtonLabel: { default: "Back" }, + required: true, + }, + ], + endings: [ + { + id: "end1", + type: "endScreen", + headline: { default: "End Screen" }, + subheader: { default: "Thanks" }, + buttonLabel: { default: "Finish" }, + buttonLink: "https://formbricks.com", + }, + ], + hiddenFields: { enabled: false, fieldIds: ["f1"] }, + }; + + const survey = buildSurvey(config as any, mockT); + expect(survey.name).toBe(config.name); + expect(survey.role).toBe(config.role); + expect(survey.industries).toEqual(config.industries); + expect(survey.channels).toEqual(config.channels); + expect(survey.description).toBe(config.description); + // preset overrides + expect(survey.preset.name).toBe(config.name); + expect(survey.preset.questions).toEqual(config.questions); + expect(survey.preset.endings).toEqual(config.endings); + expect(survey.preset.hiddenFields).toEqual(config.hiddenFields); + }); + + test("hiddenFieldsDefault has expected default configuration", () => { + expect(hiddenFieldsDefault).toEqual({ enabled: true, fieldIds: [] }); + }); +}); diff --git a/apps/web/app/lib/survey-builder.ts b/apps/web/app/lib/survey-builder.ts new file mode 100644 index 0000000000..8abe858092 --- /dev/null +++ b/apps/web/app/lib/survey-builder.ts @@ -0,0 +1,414 @@ +import { createI18nString, extractLanguageCodes } from "@/lib/i18n/utils"; +import { createId } from "@paralleldrive/cuid2"; +import { TFnType } from "@tolgee/react"; +import { + TShuffleOption, + TSurveyCTAQuestion, + TSurveyConsentQuestion, + TSurveyEndScreenCard, + TSurveyEnding, + TSurveyHiddenFields, + TSurveyLanguage, + TSurveyLogic, + TSurveyMultipleChoiceQuestion, + TSurveyNPSQuestion, + TSurveyOpenTextQuestion, + TSurveyOpenTextQuestionInputType, + TSurveyQuestion, + TSurveyQuestionTypeEnum, + TSurveyRatingQuestion, + TSurveyWelcomeCard, +} from "@formbricks/types/surveys/types"; +import { TTemplate, TTemplateRole } from "@formbricks/types/templates"; + +const defaultButtonLabel = "common.next"; +const defaultBackButtonLabel = "common.back"; + +export const buildMultipleChoiceQuestion = ({ + id, + headline, + type, + subheader, + choices, + choiceIds, + buttonLabel, + backButtonLabel, + shuffleOption, + required, + logic, + containsOther = false, + t, +}: { + id?: string; + headline: string; + type: TSurveyQuestionTypeEnum.MultipleChoiceMulti | TSurveyQuestionTypeEnum.MultipleChoiceSingle; + subheader?: string; + choices: string[]; + choiceIds?: string[]; + buttonLabel?: string; + backButtonLabel?: string; + shuffleOption?: TShuffleOption; + required?: boolean; + logic?: TSurveyLogic[]; + containsOther?: boolean; + t: TFnType; +}): TSurveyMultipleChoiceQuestion => { + return { + id: id ?? createId(), + type, + subheader: subheader ? { default: subheader } : undefined, + headline: { default: headline }, + choices: choices.map((choice, index) => { + const isLastIndex = index === choices.length - 1; + const id = containsOther && isLastIndex ? "other" : choiceIds ? choiceIds[index] : createId(); + return { id, label: { default: choice } }; + }), + buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, + backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, + shuffleOption: shuffleOption || "none", + required: required ?? true, + logic, + }; +}; + +export const buildOpenTextQuestion = ({ + id, + headline, + subheader, + placeholder, + inputType, + buttonLabel, + backButtonLabel, + required, + logic, + longAnswer, + t, +}: { + id?: string; + headline: string; + subheader?: string; + placeholder?: string; + buttonLabel?: string; + backButtonLabel?: string; + required?: boolean; + logic?: TSurveyLogic[]; + inputType: TSurveyOpenTextQuestionInputType; + longAnswer?: boolean; + t: TFnType; +}): TSurveyOpenTextQuestion => { + return { + id: id ?? createId(), + type: TSurveyQuestionTypeEnum.OpenText, + inputType, + subheader: subheader ? { default: subheader } : undefined, + placeholder: placeholder ? { default: placeholder } : undefined, + headline: { default: headline }, + buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, + backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, + required: required ?? true, + longAnswer, + logic, + charLimit: { + enabled: false, + }, + }; +}; + +export const buildRatingQuestion = ({ + id, + headline, + subheader, + scale, + range, + lowerLabel, + upperLabel, + buttonLabel, + backButtonLabel, + required, + logic, + isColorCodingEnabled = false, + t, +}: { + id?: string; + headline: string; + scale: TSurveyRatingQuestion["scale"]; + range: TSurveyRatingQuestion["range"]; + lowerLabel?: string; + upperLabel?: string; + subheader?: string; + placeholder?: string; + buttonLabel?: string; + backButtonLabel?: string; + required?: boolean; + logic?: TSurveyLogic[]; + isColorCodingEnabled?: boolean; + t: TFnType; +}): TSurveyRatingQuestion => { + return { + id: id ?? createId(), + type: TSurveyQuestionTypeEnum.Rating, + subheader: subheader ? { default: subheader } : undefined, + headline: { default: headline }, + scale, + range, + buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, + backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, + required: required ?? true, + isColorCodingEnabled, + lowerLabel: lowerLabel ? { default: lowerLabel } : undefined, + upperLabel: upperLabel ? { default: upperLabel } : undefined, + logic, + }; +}; + +export const buildNPSQuestion = ({ + id, + headline, + subheader, + lowerLabel, + upperLabel, + buttonLabel, + backButtonLabel, + required, + logic, + isColorCodingEnabled = false, + t, +}: { + id?: string; + headline: string; + lowerLabel?: string; + upperLabel?: string; + subheader?: string; + placeholder?: string; + buttonLabel?: string; + backButtonLabel?: string; + required?: boolean; + logic?: TSurveyLogic[]; + isColorCodingEnabled?: boolean; + t: TFnType; +}): TSurveyNPSQuestion => { + return { + id: id ?? createId(), + type: TSurveyQuestionTypeEnum.NPS, + subheader: subheader ? { default: subheader } : undefined, + headline: { default: headline }, + buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, + backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, + required: required ?? true, + isColorCodingEnabled, + lowerLabel: lowerLabel ? { default: lowerLabel } : undefined, + upperLabel: upperLabel ? { default: upperLabel } : undefined, + logic, + }; +}; + +export const buildConsentQuestion = ({ + id, + headline, + subheader, + label, + buttonLabel, + backButtonLabel, + required, + logic, + t, +}: { + id?: string; + headline: string; + subheader?: string; + buttonLabel?: string; + backButtonLabel?: string; + required?: boolean; + logic?: TSurveyLogic[]; + label: string; + t: TFnType; +}): TSurveyConsentQuestion => { + return { + id: id ?? createId(), + type: TSurveyQuestionTypeEnum.Consent, + subheader: subheader ? { default: subheader } : undefined, + headline: { default: headline }, + buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, + backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, + required: required ?? true, + label: { default: label }, + logic, + }; +}; + +export const buildCTAQuestion = ({ + id, + headline, + html, + buttonLabel, + buttonExternal, + backButtonLabel, + required, + logic, + dismissButtonLabel, + buttonUrl, + t, +}: { + id?: string; + headline: string; + buttonExternal: boolean; + html?: string; + buttonLabel?: string; + backButtonLabel?: string; + required?: boolean; + logic?: TSurveyLogic[]; + dismissButtonLabel?: string; + buttonUrl?: string; + t: TFnType; +}): TSurveyCTAQuestion => { + return { + id: id ?? createId(), + type: TSurveyQuestionTypeEnum.CTA, + html: html ? { default: html } : undefined, + headline: { default: headline }, + buttonLabel: { default: buttonLabel || t(defaultButtonLabel) }, + backButtonLabel: { default: backButtonLabel || t(defaultBackButtonLabel) }, + dismissButtonLabel: dismissButtonLabel ? { default: dismissButtonLabel } : undefined, + required: required ?? true, + buttonExternal, + buttonUrl, + logic, + }; +}; + +// Helper function to create standard jump logic based on operator +export const createJumpLogic = ( + sourceQuestionId: string, + targetId: string, + operator: "isSkipped" | "isSubmitted" | "isClicked" +): TSurveyLogic => ({ + id: createId(), + conditions: { + id: createId(), + connector: "and", + conditions: [ + { + id: createId(), + leftOperand: { + value: sourceQuestionId, + type: "question", + }, + operator: operator, + }, + ], + }, + actions: [ + { + id: createId(), + objective: "jumpToQuestion", + target: targetId, + }, + ], +}); + +// Helper function to create jump logic based on choice selection +export const createChoiceJumpLogic = ( + sourceQuestionId: string, + choiceId: string, + targetId: string +): TSurveyLogic => ({ + id: createId(), + conditions: { + id: createId(), + connector: "and", + conditions: [ + { + id: createId(), + leftOperand: { + value: sourceQuestionId, + type: "question", + }, + operator: "equals", + rightOperand: { + type: "static", + value: choiceId, + }, + }, + ], + }, + actions: [ + { + id: createId(), + objective: "jumpToQuestion", + target: targetId, + }, + ], +}); + +export const getDefaultEndingCard = (languages: TSurveyLanguage[], t: TFnType): TSurveyEndScreenCard => { + const languageCodes = extractLanguageCodes(languages); + return { + id: createId(), + type: "endScreen", + headline: createI18nString(t("templates.default_ending_card_headline"), languageCodes), + subheader: createI18nString(t("templates.default_ending_card_subheader"), languageCodes), + buttonLabel: createI18nString(t("templates.default_ending_card_button_label"), languageCodes), + buttonLink: "https://formbricks.com", + }; +}; + +export const hiddenFieldsDefault: TSurveyHiddenFields = { + enabled: true, + fieldIds: [], +}; + +export const getDefaultWelcomeCard = (t: TFnType): TSurveyWelcomeCard => { + return { + enabled: false, + headline: { default: t("templates.default_welcome_card_headline") }, + html: { default: t("templates.default_welcome_card_html") }, + buttonLabel: { default: t("templates.default_welcome_card_button_label") }, + timeToFinish: false, + showResponseCount: false, + }; +}; + +export const getDefaultSurveyPreset = (t: TFnType): TTemplate["preset"] => { + return { + name: "New Survey", + welcomeCard: getDefaultWelcomeCard(t), + endings: [getDefaultEndingCard([], t)], + hiddenFields: hiddenFieldsDefault, + questions: [], + }; +}; + +/** + * Generic builder for survey. + * @param config - The configuration for survey settings and questions. + * @param t - The translation function. + */ +export const buildSurvey = ( + config: { + name: string; + role: TTemplateRole; + industries: ("eCommerce" | "saas" | "other")[]; + channels: ("link" | "app" | "website")[]; + description: string; + questions: TSurveyQuestion[]; + endings?: TSurveyEnding[]; + hiddenFields?: TSurveyHiddenFields; + }, + t: TFnType +): TTemplate => { + const localSurvey = getDefaultSurveyPreset(t); + return { + name: config.name, + role: config.role, + industries: config.industries, + channels: config.channels, + description: config.description, + preset: { + ...localSurvey, + name: config.name, + questions: config.questions, + endings: config.endings ?? localSurvey.endings, + hiddenFields: config.hiddenFields ?? hiddenFieldsDefault, + }, + }; +}; diff --git a/apps/web/app/lib/templates.ts b/apps/web/app/lib/templates.ts index eda74dfb64..c377bc4041 100644 --- a/apps/web/app/lib/templates.ts +++ b/apps/web/app/lib/templates.ts @@ -1,1288 +1,523 @@ -import { createI18nString, extractLanguageCodes } from "@/lib/i18n/utils"; +import { + buildCTAQuestion, + buildConsentQuestion, + buildMultipleChoiceQuestion, + buildNPSQuestion, + buildOpenTextQuestion, + buildRatingQuestion, + buildSurvey, + createChoiceJumpLogic, + createJumpLogic, + getDefaultEndingCard, + getDefaultSurveyPreset, + hiddenFieldsDefault, +} from "@/app/lib/survey-builder"; import { createId } from "@paralleldrive/cuid2"; import { TFnType } from "@tolgee/react"; -import { - TSurvey, - TSurveyEndScreenCard, - TSurveyHiddenFields, - TSurveyLanguage, - TSurveyOpenTextQuestion, - TSurveyQuestionTypeEnum, - TSurveyWelcomeCard, -} from "@formbricks/types/surveys/types"; +import { TSurvey, TSurveyOpenTextQuestion, TSurveyQuestionTypeEnum } from "@formbricks/types/surveys/types"; import { TTemplate } from "@formbricks/types/templates"; -export const getDefaultEndingCard = (languages: TSurveyLanguage[], t: TFnType): TSurveyEndScreenCard => { - const languageCodes = extractLanguageCodes(languages); - return { - id: createId(), - type: "endScreen", - headline: createI18nString(t("templates.default_ending_card_headline"), languageCodes), - subheader: createI18nString(t("templates.default_ending_card_subheader"), languageCodes), - buttonLabel: createI18nString(t("templates.default_ending_card_button_label"), languageCodes), - buttonLink: "https://formbricks.com", - }; -}; - -const hiddenFieldsDefault: TSurveyHiddenFields = { - enabled: true, - fieldIds: [], -}; - -export const getDefaultWelcomeCard = (t: TFnType): TSurveyWelcomeCard => { - return { - enabled: false, - headline: { default: t("templates.default_welcome_card_headline") }, - html: { default: t("templates.default_welcome_card_html") }, - buttonLabel: { default: t("templates.default_welcome_card_button_label") }, - timeToFinish: false, - showResponseCount: false, - }; -}; - -export const getDefaultSurveyPreset = (t: TFnType): TTemplate["preset"] => { - return { - name: "New Survey", - welcomeCard: getDefaultWelcomeCard(t), - endings: [getDefaultEndingCard([], t)], - hiddenFields: hiddenFieldsDefault, - questions: [], - }; -}; - const cartAbandonmentSurvey = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.card_abandonment_survey"), - role: "productManager", - industries: ["eCommerce"], - channels: ["app", "website", "link"], - description: t("templates.card_abandonment_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.card_abandonment_survey"), + role: "productManager", + industries: ["eCommerce"], + channels: ["app", "website", "link"], + description: t("templates.card_abandonment_survey_description"), + endings: localSurvey.endings, questions: [ - { + buildCTAQuestion({ id: reusableQuestionIds[0], - html: { - default: t("templates.card_abandonment_survey_question_1_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.card_abandonment_survey_question_1_headline") }, + html: t("templates.card_abandonment_survey_question_1_html"), + logic: [createJumpLogic(reusableQuestionIds[0], localSurvey.endings[0].id, "isSkipped")], + headline: t("templates.card_abandonment_survey_question_1_headline"), required: false, - buttonLabel: { default: t("templates.card_abandonment_survey_question_1_button_label") }, + buttonLabel: t("templates.card_abandonment_survey_question_1_button_label"), buttonExternal: false, - dismissButtonLabel: { - default: t("templates.card_abandonment_survey_question_1_dismiss_button_label"), - }, - }, - { - id: createId(), + dismissButtonLabel: t("templates.card_abandonment_survey_question_1_dismiss_button_label"), + t, + }), + buildMultipleChoiceQuestion({ + headline: t("templates.card_abandonment_survey_question_2_headline"), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.card_abandonment_survey_question_2_headline") }, - subheader: { default: t("templates.card_abandonment_survey_question_2_subheader") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - required: true, - shuffleOption: "none", + subheader: t("templates.card_abandonment_survey_question_2_subheader"), choices: [ - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_2_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_2_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_2_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.card_abandonment_survey_question_2_choice_6") }, - }, + t("templates.card_abandonment_survey_question_2_choice_1"), + t("templates.card_abandonment_survey_question_2_choice_2"), + t("templates.card_abandonment_survey_question_2_choice_3"), + t("templates.card_abandonment_survey_question_2_choice_4"), + t("templates.card_abandonment_survey_question_2_choice_5"), + t("templates.card_abandonment_survey_question_2_choice_6"), ], - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.card_abandonment_survey_question_3_headline"), - }, + containsOther: true, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.card_abandonment_survey_question_3_headline"), required: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, inputType: "text", - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { default: t("templates.card_abandonment_survey_question_4_headline") }, + t, + }), + buildRatingQuestion({ + headline: t("templates.card_abandonment_survey_question_4_headline"), required: true, scale: "number", range: 5, - lowerLabel: { default: t("templates.card_abandonment_survey_question_4_lower_label") }, - upperLabel: { default: t("templates.card_abandonment_survey_question_4_upper_label") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - isColorCodingEnabled: false, - }, - { - id: createId(), + lowerLabel: t("templates.card_abandonment_survey_question_4_lower_label"), + upperLabel: t("templates.card_abandonment_survey_question_4_upper_label"), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, - headline: { - default: t("templates.card_abandonment_survey_question_5_headline"), - }, - subheader: { default: t("templates.card_abandonment_survey_question_5_subheader") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, + headline: t("templates.card_abandonment_survey_question_5_headline"), + subheader: t("templates.card_abandonment_survey_question_5_subheader"), + required: true, choices: [ - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_5_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_5_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_5_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_5_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.card_abandonment_survey_question_5_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.card_abandonment_survey_question_5_choice_6") }, - }, + t("templates.card_abandonment_survey_question_5_choice_1"), + t("templates.card_abandonment_survey_question_5_choice_2"), + t("templates.card_abandonment_survey_question_5_choice_3"), + t("templates.card_abandonment_survey_question_5_choice_4"), + t("templates.card_abandonment_survey_question_5_choice_5"), + t("templates.card_abandonment_survey_question_5_choice_6"), ], - }, - { + containsOther: true, + t, + }), + buildConsentQuestion({ id: reusableQuestionIds[1], - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - ], - type: TSurveyQuestionTypeEnum.Consent, - headline: { default: t("templates.card_abandonment_survey_question_6_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], reusableQuestionIds[2], "isSkipped")], + headline: t("templates.card_abandonment_survey_question_6_headline"), required: false, - label: { default: t("templates.card_abandonment_survey_question_6_label") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.card_abandonment_survey_question_7_headline") }, + label: t("templates.card_abandonment_survey_question_6_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.card_abandonment_survey_question_7_headline"), required: true, inputType: "email", longAnswer: false, - placeholder: { default: "example@email.com" }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + placeholder: "example@email.com", + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.card_abandonment_survey_question_8_headline") }, + headline: t("templates.card_abandonment_survey_question_8_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const siteAbandonmentSurvey = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.site_abandonment_survey"), - role: "productManager", - industries: ["eCommerce"], - channels: ["app", "website"], - description: t("templates.site_abandonment_survey_description"), - preset: { - ...localSurvey, + + return buildSurvey( + { name: t("templates.site_abandonment_survey"), + role: "productManager", + industries: ["eCommerce"], + channels: ["app", "website"], + description: t("templates.site_abandonment_survey_description"), + endings: localSurvey.endings, questions: [ - { + buildCTAQuestion({ id: reusableQuestionIds[0], - html: { - default: t("templates.site_abandonment_survey_question_1_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.site_abandonment_survey_question_2_headline") }, + html: t("templates.site_abandonment_survey_question_1_html"), + logic: [createJumpLogic(reusableQuestionIds[0], localSurvey.endings[0].id, "isSkipped")], + headline: t("templates.site_abandonment_survey_question_2_headline"), required: false, - buttonLabel: { default: t("templates.site_abandonment_survey_question_2_button_label") }, - backButtonLabel: { default: t("templates.back") }, + buttonLabel: t("templates.site_abandonment_survey_question_2_button_label"), buttonExternal: false, - dismissButtonLabel: { - default: t("templates.site_abandonment_survey_question_2_dismiss_button_label"), - }, - }, - { - id: createId(), + dismissButtonLabel: t("templates.site_abandonment_survey_question_2_dismiss_button_label"), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.site_abandonment_survey_question_3_headline") }, - subheader: { default: t("templates.site_abandonment_survey_question_3_subheader") }, + headline: t("templates.site_abandonment_survey_question_3_headline"), + subheader: t("templates.site_abandonment_survey_question_3_subheader"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_3_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_3_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_3_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_3_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_3_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.site_abandonment_survey_question_3_choice_6") }, - }, + t("templates.site_abandonment_survey_question_3_choice_1"), + t("templates.site_abandonment_survey_question_3_choice_2"), + t("templates.site_abandonment_survey_question_3_choice_3"), + t("templates.site_abandonment_survey_question_3_choice_4"), + t("templates.site_abandonment_survey_question_3_choice_5"), + t("templates.site_abandonment_survey_question_3_choice_6"), ], - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.site_abandonment_survey_question_4_headline"), - }, + containsOther: true, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.site_abandonment_survey_question_4_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { default: t("templates.site_abandonment_survey_question_5_headline") }, + t, + }), + buildRatingQuestion({ + headline: t("templates.site_abandonment_survey_question_5_headline"), required: true, scale: "number", range: 5, - lowerLabel: { default: t("templates.site_abandonment_survey_question_5_lower_label") }, - upperLabel: { default: t("templates.site_abandonment_survey_question_5_upper_label") }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + lowerLabel: t("templates.site_abandonment_survey_question_5_lower_label"), + upperLabel: t("templates.site_abandonment_survey_question_5_upper_label"), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, - headline: { - default: t("templates.site_abandonment_survey_question_6_headline"), - }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - subheader: { default: t("templates.site_abandonment_survey_question_6_subheader") }, + headline: t("templates.site_abandonment_survey_question_6_headline"), + subheader: t("templates.site_abandonment_survey_question_6_subheader"), required: true, choices: [ - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_6_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_6_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_6_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_6_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.site_abandonment_survey_question_6_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.site_abandonment_survey_question_6_choice_6") }, - }, + t("templates.site_abandonment_survey_question_6_choice_1"), + t("templates.site_abandonment_survey_question_6_choice_2"), + t("templates.site_abandonment_survey_question_6_choice_3"), + t("templates.site_abandonment_survey_question_6_choice_4"), + t("templates.site_abandonment_survey_question_6_choice_5"), ], - }, - { + t, + }), + buildConsentQuestion({ id: reusableQuestionIds[1], - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - ], - type: TSurveyQuestionTypeEnum.Consent, - headline: { default: t("templates.site_abandonment_survey_question_7_headline") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, + logic: [createJumpLogic(reusableQuestionIds[1], reusableQuestionIds[2], "isSkipped")], + headline: t("templates.site_abandonment_survey_question_7_headline"), required: false, - label: { default: t("templates.site_abandonment_survey_question_7_label") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.site_abandonment_survey_question_8_headline") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, + label: t("templates.site_abandonment_survey_question_7_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.site_abandonment_survey_question_8_headline"), required: true, inputType: "email", longAnswer: false, - placeholder: { default: "example@email.com" }, - }, - { + placeholder: "example@email.com", + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.site_abandonment_survey_question_9_headline") }, - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, + headline: t("templates.site_abandonment_survey_question_9_headline"), required: false, inputType: "text", - }, + t, + }), ], }, - }; + t + ); }; const productMarketFitSuperhuman = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.product_market_fit_superhuman"), - role: "productManager", - industries: ["saas"], - channels: ["app", "link"], - description: t("templates.product_market_fit_superhuman_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.product_market_fit_superhuman"), + role: "productManager", + industries: ["saas"], + channels: ["app", "link"], + description: t("templates.product_market_fit_superhuman_description"), + endings: localSurvey.endings, questions: [ - { + buildCTAQuestion({ id: reusableQuestionIds[0], - html: { - default: t("templates.product_market_fit_superhuman_question_1_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.product_market_fit_superhuman_question_1_headline") }, + html: t("templates.product_market_fit_superhuman_question_1_html"), + logic: [createJumpLogic(reusableQuestionIds[0], localSurvey.endings[0].id, "isSkipped")], + headline: t("templates.product_market_fit_superhuman_question_1_headline"), required: false, - buttonLabel: { - default: t("templates.product_market_fit_superhuman_question_1_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, + buttonLabel: t("templates.product_market_fit_superhuman_question_1_button_label"), buttonExternal: false, - dismissButtonLabel: { - default: t("templates.product_market_fit_superhuman_question_1_dismiss_button_label"), - }, - }, - { - id: createId(), + dismissButtonLabel: t("templates.product_market_fit_superhuman_question_1_dismiss_button_label"), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.product_market_fit_superhuman_question_2_headline") }, - subheader: { default: t("templates.product_market_fit_superhuman_question_2_subheader") }, + headline: t("templates.product_market_fit_superhuman_question_2_headline"), + subheader: t("templates.product_market_fit_superhuman_question_2_subheader"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_2_choice_3") }, - }, + t("templates.product_market_fit_superhuman_question_2_choice_1"), + t("templates.product_market_fit_superhuman_question_2_choice_2"), + t("templates.product_market_fit_superhuman_question_2_choice_3"), ], - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.product_market_fit_superhuman_question_3_headline") }, - subheader: { default: t("templates.product_market_fit_superhuman_question_3_subheader") }, + headline: "templates.product_market_fit_superhuman_question_3_headline", + subheader: t("templates.product_market_fit_superhuman_question_3_subheader"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_3_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_3_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_3_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_3_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_superhuman_question_3_choice_5") }, - }, + t("templates.product_market_fit_superhuman_question_3_choice_1"), + t("templates.product_market_fit_superhuman_question_3_choice_2"), + t("templates.product_market_fit_superhuman_question_3_choice_3"), + t("templates.product_market_fit_superhuman_question_3_choice_4"), + t("templates.product_market_fit_superhuman_question_3_choice_5"), ], - }, - { + t, + }), + buildOpenTextQuestion({ id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.product_market_fit_superhuman_question_4_headline") }, + headline: t("templates.product_market_fit_superhuman_question_4_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, inputType: "text", - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.product_market_fit_superhuman_question_5_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.product_market_fit_superhuman_question_5_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, inputType: "text", - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.product_market_fit_superhuman_question_6_headline") }, - subheader: { default: t("templates.product_market_fit_superhuman_question_6_subheader") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.product_market_fit_superhuman_question_6_headline"), + subheader: t("templates.product_market_fit_superhuman_question_6_subheader"), required: true, - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, inputType: "text", - }, + t, + }), ], }, - }; + t + ); }; const onboardingSegmentation = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.onboarding_segmentation"), - role: "productManager", - industries: ["saas"], - channels: ["app", "link"], - description: t("templates.onboarding_segmentation_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.onboarding_segmentation"), + role: "productManager", + industries: ["saas"], + channels: ["app", "link"], + description: t("templates.onboarding_segmentation_description"), questions: [ - { - id: createId(), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.onboarding_segmentation_question_1_headline") }, - subheader: { default: t("templates.onboarding_segmentation_question_1_subheader") }, + headline: t("templates.onboarding_segmentation_question_1_headline"), + subheader: t("templates.onboarding_segmentation_question_1_subheader"), required: true, shuffleOption: "none", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, choices: [ - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_1_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_1_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_1_choice_5") }, - }, + t("templates.onboarding_segmentation_question_1_choice_1"), + t("templates.onboarding_segmentation_question_1_choice_2"), + t("templates.onboarding_segmentation_question_1_choice_3"), + t("templates.onboarding_segmentation_question_1_choice_4"), + t("templates.onboarding_segmentation_question_1_choice_5"), ], - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.onboarding_segmentation_question_2_headline") }, - subheader: { default: t("templates.onboarding_segmentation_question_2_subheader") }, + headline: t("templates.onboarding_segmentation_question_2_headline"), + subheader: t("templates.onboarding_segmentation_question_2_subheader"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_2_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_2_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_2_choice_5") }, - }, + t("templates.onboarding_segmentation_question_2_choice_1"), + t("templates.onboarding_segmentation_question_2_choice_2"), + t("templates.onboarding_segmentation_question_2_choice_3"), + t("templates.onboarding_segmentation_question_2_choice_4"), + t("templates.onboarding_segmentation_question_2_choice_5"), ], - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.onboarding_segmentation_question_3_headline") }, - subheader: { default: t("templates.onboarding_segmentation_question_3_subheader") }, + headline: t("templates.onboarding_segmentation_question_3_headline"), + subheader: t("templates.onboarding_segmentation_question_3_subheader"), required: true, - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, + buttonLabel: t("templates.finish"), shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_3_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_3_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_3_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_3_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.onboarding_segmentation_question_3_choice_5") }, - }, + t("templates.onboarding_segmentation_question_3_choice_1"), + t("templates.onboarding_segmentation_question_3_choice_2"), + t("templates.onboarding_segmentation_question_3_choice_3"), + t("templates.onboarding_segmentation_question_3_choice_4"), + t("templates.onboarding_segmentation_question_3_choice_5"), ], - }, + t, + }), ], }, - }; + t + ); }; const churnSurvey = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId(), createId(), createId()]; const reusableOptionIds = [createId(), createId(), createId(), createId(), createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.churn_survey"), - role: "sales", - industries: ["saas", "eCommerce", "other"], - channels: ["app", "link"], - description: t("templates.churn_survey_description"), - preset: { - ...localSurvey, - name: "Churn Survey", + return buildSurvey( + { + name: t("templates.churn_survey"), + role: "sales", + industries: ["saas", "eCommerce", "other"], + channels: ["app", "link"], + description: t("templates.churn_survey_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[0], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[1], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[2], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[3], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[4], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[4], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[0], reusableQuestionIds[1]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[2], reusableQuestionIds[3]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[3], reusableQuestionIds[4]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[4], localSurvey.endings[0].id), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.churn_survey_question_1_choice_1") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.churn_survey_question_1_choice_2") }, - }, - { - id: reusableOptionIds[2], - label: { default: t("templates.churn_survey_question_1_choice_3") }, - }, - { - id: reusableOptionIds[3], - label: { default: t("templates.churn_survey_question_1_choice_4") }, - }, - { - id: reusableOptionIds[4], - label: { default: t("templates.churn_survey_question_1_choice_5") }, - }, + t("templates.churn_survey_question_1_choice_1"), + t("templates.churn_survey_question_1_choice_2"), + t("templates.churn_survey_question_1_choice_3"), + t("templates.churn_survey_question_1_choice_4"), + t("templates.churn_survey_question_1_choice_5"), ], - headline: { default: t("templates.churn_survey_question_1_headline") }, + choiceIds: [ + reusableOptionIds[0], + reusableOptionIds[1], + reusableOptionIds[2], + reusableOptionIds[3], + reusableOptionIds[4], + ], + headline: t("templates.churn_survey_question_1_headline"), required: true, - subheader: { default: t("templates.churn_survey_question_1_subheader") }, - }, - { + subheader: t("templates.churn_survey_question_1_subheader"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.churn_survey_question_2_headline") }, - backButtonLabel: { default: t("templates.back") }, + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.churn_survey_question_2_headline"), required: true, - buttonLabel: { default: t("templates.churn_survey_question_2_button_label") }, + buttonLabel: t("templates.churn_survey_question_2_button_label"), inputType: "text", - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[2], - html: { - default: t("templates.churn_survey_question_3_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "isClicked", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.churn_survey_question_3_headline") }, + html: t("templates.churn_survey_question_3_html"), + logic: [createJumpLogic(reusableQuestionIds[2], localSurvey.endings[0].id, "isClicked")], + headline: t("templates.churn_survey_question_3_headline"), required: true, buttonUrl: "https://formbricks.com", - buttonLabel: { default: t("templates.churn_survey_question_3_button_label") }, + buttonLabel: t("templates.churn_survey_question_3_button_label"), buttonExternal: true, - backButtonLabel: { default: t("templates.back") }, - dismissButtonLabel: { default: t("templates.churn_survey_question_3_dismiss_button_label") }, - }, - { + dismissButtonLabel: t("templates.churn_survey_question_3_dismiss_button_label"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[3], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.churn_survey_question_4_headline") }, + logic: [createJumpLogic(reusableQuestionIds[3], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.churn_survey_question_4_headline"), required: true, inputType: "text", - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[4], - html: { - default: t("templates.churn_survey_question_5_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isClicked", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.churn_survey_question_5_headline") }, + html: t("templates.churn_survey_question_5_html"), + logic: [createJumpLogic(reusableQuestionIds[4], localSurvey.endings[0].id, "isClicked")], + headline: t("templates.churn_survey_question_5_headline"), required: true, buttonUrl: "mailto:ceo@company.com", - buttonLabel: { default: t("templates.churn_survey_question_5_button_label") }, + buttonLabel: t("templates.churn_survey_question_5_button_label"), buttonExternal: true, - dismissButtonLabel: { default: t("templates.churn_survey_question_5_dismiss_button_label") }, - backButtonLabel: { default: t("templates.back") }, - }, + dismissButtonLabel: t("templates.churn_survey_question_5_dismiss_button_label"), + t, + }), ], }, - }; + t + ); }; const earnedAdvocacyScore = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId(), createId()]; const reusableOptionIds = [createId(), createId(), createId(), createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.earned_advocacy_score_name"), - role: "customerSuccess", - industries: ["saas", "eCommerce", "other"], - channels: ["app", "link"], - description: t("templates.earned_advocacy_score_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.earned_advocacy_score_name"), + role: "customerSuccess", + industries: ["saas", "eCommerce", "other"], + channels: ["app", "link"], + description: t("templates.earned_advocacy_score_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[2]), ], shuffleOption: "none", choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.earned_advocacy_score_question_1_choice_1") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.earned_advocacy_score_question_1_choice_2") }, - }, + t("templates.earned_advocacy_score_question_1_choice_1"), + t("templates.earned_advocacy_score_question_1_choice_2"), ], - headline: { default: t("templates.earned_advocacy_score_question_1_headline") }, + choiceIds: [reusableOptionIds[0], reusableOptionIds[1]], + headline: t("templates.earned_advocacy_score_question_1_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - ], - headline: { default: t("templates.earned_advocacy_score_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], reusableQuestionIds[3], "isSubmitted")], + headline: t("templates.earned_advocacy_score_question_2_headline"), required: true, - placeholder: { default: t("templates.earned_advocacy_score_question_2_placeholder") }, + placeholder: t("templates.earned_advocacy_score_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.earned_advocacy_score_question_3_headline") }, + headline: t("templates.earned_advocacy_score_question_3_headline"), required: true, - placeholder: { default: t("templates.earned_advocacy_score_question_3_placeholder") }, + placeholder: t("templates.earned_advocacy_score_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[3], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[3], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[3], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[3], reusableOptionIds[3], localSurvey.endings[0].id), ], shuffleOption: "none", choices: [ - { - id: reusableOptionIds[2], - label: { default: t("templates.earned_advocacy_score_question_4_choice_1") }, - }, - { - id: reusableOptionIds[3], - label: { default: t("templates.earned_advocacy_score_question_4_choice_2") }, - }, + t("templates.earned_advocacy_score_question_4_choice_1"), + t("templates.earned_advocacy_score_question_4_choice_2"), ], - headline: { default: t("templates.earned_advocacy_score_question_4_headline") }, + choiceIds: [reusableOptionIds[2], reusableOptionIds[3]], + headline: t("templates.earned_advocacy_score_question_4_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.earned_advocacy_score_question_5_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.earned_advocacy_score_question_5_headline"), required: true, - placeholder: { default: t("templates.earned_advocacy_score_question_5_placeholder") }, + placeholder: t("templates.earned_advocacy_score_question_5_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const improveTrialConversion = (t: TFnType): TTemplate => { @@ -1297,432 +532,119 @@ const improveTrialConversion = (t: TFnType): TTemplate => { createId(), ]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.improve_trial_conversion_name"), - role: "sales", - industries: ["saas"], - channels: ["link", "app"], - description: t("templates.improve_trial_conversion_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.improve_trial_conversion_name"), + role: "sales", + industries: ["saas"], + channels: ["link", "app"], + description: t("templates.improve_trial_conversion_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[0], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[1], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[2], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[3], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[4], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[4], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[0], reusableQuestionIds[1]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[2], reusableQuestionIds[3]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[3], reusableQuestionIds[4]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[4], localSurvey.endings[0].id), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.improve_trial_conversion_question_1_choice_1") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.improve_trial_conversion_question_1_choice_2") }, - }, - { - id: reusableOptionIds[2], - label: { default: t("templates.improve_trial_conversion_question_1_choice_3") }, - }, - { - id: reusableOptionIds[3], - label: { default: t("templates.improve_trial_conversion_question_1_choice_4") }, - }, - { - id: reusableOptionIds[4], - label: { default: t("templates.improve_trial_conversion_question_1_choice_5") }, - }, + t("templates.improve_trial_conversion_question_1_choice_1"), + t("templates.improve_trial_conversion_question_1_choice_2"), + t("templates.improve_trial_conversion_question_1_choice_3"), + t("templates.improve_trial_conversion_question_1_choice_4"), + t("templates.improve_trial_conversion_question_1_choice_5"), ], - headline: { default: t("templates.improve_trial_conversion_question_1_headline") }, + choiceIds: [ + reusableOptionIds[0], + reusableOptionIds[1], + reusableOptionIds[2], + reusableOptionIds[3], + reusableOptionIds[4], + ], + headline: t("templates.improve_trial_conversion_question_1_headline"), required: true, - subheader: { default: t("templates.improve_trial_conversion_question_1_subheader") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + subheader: t("templates.improve_trial_conversion_question_1_subheader"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, - ], - headline: { default: t("templates.improve_trial_conversion_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], reusableQuestionIds[5], "isSubmitted")], + headline: t("templates.improve_trial_conversion_question_2_headline"), required: true, - buttonLabel: { default: t("templates.improve_trial_conversion_question_2_button_label") }, + buttonLabel: t("templates.improve_trial_conversion_question_2_button_label"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, - ], - headline: { default: t("templates.improve_trial_conversion_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[2], reusableQuestionIds[5], "isSubmitted")], + headline: t("templates.improve_trial_conversion_question_2_headline"), required: true, - buttonLabel: { default: t("templates.improve_trial_conversion_question_2_button_label") }, + buttonLabel: t("templates.improve_trial_conversion_question_2_button_label"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[3], - html: { - default: t("templates.improve_trial_conversion_question_4_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[3], - type: "question", - }, - operator: "isClicked", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.improve_trial_conversion_question_4_headline") }, + html: t("templates.improve_trial_conversion_question_4_html"), + logic: [createJumpLogic(reusableQuestionIds[3], localSurvey.endings[0].id, "isClicked")], + headline: t("templates.improve_trial_conversion_question_4_headline"), required: true, buttonUrl: "https://formbricks.com/github", - buttonLabel: { default: t("templates.improve_trial_conversion_question_4_button_label") }, + buttonLabel: t("templates.improve_trial_conversion_question_4_button_label"), buttonExternal: true, - dismissButtonLabel: { - default: t("templates.improve_trial_conversion_question_4_dismiss_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, - }, - { + dismissButtonLabel: t("templates.improve_trial_conversion_question_4_dismiss_button_label"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, - ], - headline: { default: t("templates.improve_trial_conversion_question_5_headline") }, + logic: [createJumpLogic(reusableQuestionIds[4], reusableQuestionIds[5], "isSubmitted")], + headline: t("templates.improve_trial_conversion_question_5_headline"), required: true, - subheader: { default: t("templates.improve_trial_conversion_question_5_subheader") }, - buttonLabel: { default: t("templates.improve_trial_conversion_question_5_button_label") }, + subheader: t("templates.improve_trial_conversion_question_5_subheader"), + buttonLabel: t("templates.improve_trial_conversion_question_5_button_label"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[5], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[5], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[5], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createJumpLogic(reusableQuestionIds[5], localSurvey.endings[0].id, "isSubmitted"), + createJumpLogic(reusableQuestionIds[5], localSurvey.endings[0].id, "isSkipped"), ], - headline: { default: t("templates.improve_trial_conversion_question_6_headline") }, + headline: t("templates.improve_trial_conversion_question_6_headline"), required: false, - subheader: { default: t("templates.improve_trial_conversion_question_6_subheader") }, + subheader: t("templates.improve_trial_conversion_question_6_subheader"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const reviewPrompt = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.review_prompt_name"), - role: "marketing", - industries: ["saas", "eCommerce", "other"], - channels: ["link", "app"], - description: t("templates.review_prompt_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.review_prompt_name"), + role: "marketing", + industries: ["saas", "eCommerce", "other"], + channels: ["link", "app"], + description: t("templates.review_prompt_description"), + endings: localSurvey.endings, questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -1755,1206 +677,596 @@ const reviewPrompt = (t: TFnType): TTemplate => { ], range: 5, scale: "star", - headline: { default: t("templates.review_prompt_question_1_headline") }, + headline: t("templates.review_prompt_question_1_headline"), required: true, - lowerLabel: { default: t("templates.review_prompt_question_1_lower_label") }, - upperLabel: { default: t("templates.review_prompt_question_1_upper_label") }, + lowerLabel: t("templates.review_prompt_question_1_lower_label"), + upperLabel: t("templates.review_prompt_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[1], - html: { default: t("templates.review_prompt_question_2_html") }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isClicked", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.review_prompt_question_2_headline") }, + html: t("templates.review_prompt_question_2_html"), + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isClicked")], + headline: t("templates.review_prompt_question_2_headline"), required: true, buttonUrl: "https://formbricks.com/github", - buttonLabel: { default: t("templates.review_prompt_question_2_button_label") }, + buttonLabel: t("templates.review_prompt_question_2_button_label"), buttonExternal: true, - backButtonLabel: { default: t("templates.back") }, - }, - { + backButtonLabel: t("templates.back"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.review_prompt_question_3_headline") }, + headline: t("templates.review_prompt_question_3_headline"), required: true, - subheader: { default: t("templates.review_prompt_question_3_subheader") }, - buttonLabel: { default: t("templates.review_prompt_question_3_button_label") }, - placeholder: { default: t("templates.review_prompt_question_3_placeholder") }, + subheader: t("templates.review_prompt_question_3_subheader"), + buttonLabel: t("templates.review_prompt_question_3_button_label"), + placeholder: t("templates.review_prompt_question_3_placeholder"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const interviewPrompt = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.interview_prompt_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.interview_prompt_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.interview_prompt_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.interview_prompt_description"), questions: [ - { + buildCTAQuestion({ id: createId(), - type: TSurveyQuestionTypeEnum.CTA, - headline: { default: t("templates.interview_prompt_question_1_headline") }, - html: { default: t("templates.interview_prompt_question_1_html") }, - buttonLabel: { default: t("templates.interview_prompt_question_1_button_label") }, + headline: t("templates.interview_prompt_question_1_headline"), + html: t("templates.interview_prompt_question_1_html"), + buttonLabel: t("templates.interview_prompt_question_1_button_label"), buttonUrl: "https://cal.com/johannes", buttonExternal: true, required: false, - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const improveActivationRate = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId(), createId(), createId(), createId()]; const reusableOptionIds = [createId(), createId(), createId(), createId(), createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.improve_activation_rate_name"), - role: "productManager", - industries: ["saas"], - channels: ["link"], - description: t("templates.improve_activation_rate_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.improve_activation_rate_name"), + role: "productManager", + industries: ["saas"], + channels: ["link"], + description: t("templates.improve_activation_rate_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[2], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[3], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[4], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[4], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[2], reusableQuestionIds[3]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[3], reusableQuestionIds[4]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[4], reusableQuestionIds[5]), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.improve_activation_rate_question_1_choice_1") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.improve_activation_rate_question_1_choice_2") }, - }, - { - id: reusableOptionIds[2], - label: { default: t("templates.improve_activation_rate_question_1_choice_3") }, - }, - { - id: reusableOptionIds[3], - label: { default: t("templates.improve_activation_rate_question_1_choice_4") }, - }, - { - id: reusableOptionIds[4], - label: { default: t("templates.improve_activation_rate_question_1_choice_5") }, - }, + t("templates.improve_activation_rate_question_1_choice_1"), + t("templates.improve_activation_rate_question_1_choice_2"), + t("templates.improve_activation_rate_question_1_choice_3"), + t("templates.improve_activation_rate_question_1_choice_4"), + t("templates.improve_activation_rate_question_1_choice_5"), ], - headline: { - default: t("templates.improve_activation_rate_question_1_headline"), - }, + choiceIds: [ + reusableOptionIds[0], + reusableOptionIds[1], + reusableOptionIds[2], + reusableOptionIds[3], + reusableOptionIds[4], + ], + headline: t("templates.improve_activation_rate_question_1_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.improve_activation_rate_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.improve_activation_rate_question_2_headline"), required: true, - placeholder: { default: t("templates.improve_activation_rate_question_2_placeholder") }, + placeholder: t("templates.improve_activation_rate_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.improve_activation_rate_question_3_headline") }, + logic: [createJumpLogic(reusableQuestionIds[2], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.improve_activation_rate_question_3_headline"), required: true, - placeholder: { default: t("templates.improve_activation_rate_question_3_placeholder") }, + placeholder: t("templates.improve_activation_rate_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[3], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.improve_activation_rate_question_4_headline") }, + logic: [createJumpLogic(reusableQuestionIds[3], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.improve_activation_rate_question_4_headline"), required: true, - placeholder: { default: t("templates.improve_activation_rate_question_4_placeholder") }, + placeholder: t("templates.improve_activation_rate_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.improve_activation_rate_question_5_headline") }, + logic: [createJumpLogic(reusableQuestionIds[4], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.improve_activation_rate_question_5_headline"), required: true, - placeholder: { default: t("templates.improve_activation_rate_question_5_placeholder") }, + placeholder: t("templates.improve_activation_rate_question_5_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[5], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [], - headline: { default: t("templates.improve_activation_rate_question_6_headline") }, + headline: t("templates.improve_activation_rate_question_6_headline"), required: false, - subheader: { default: t("templates.improve_activation_rate_question_6_subheader") }, - placeholder: { default: t("templates.improve_activation_rate_question_6_placeholder") }, + subheader: t("templates.improve_activation_rate_question_6_subheader"), + placeholder: t("templates.improve_activation_rate_question_6_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const employeeSatisfaction = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.employee_satisfaction_name"), - role: "peopleManager", - industries: ["saas", "eCommerce", "other"], - channels: ["app", "link"], - description: t("templates.employee_satisfaction_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.employee_satisfaction_name"), + role: "peopleManager", + industries: ["saas", "eCommerce", "other"], + channels: ["app", "link"], + description: t("templates.employee_satisfaction_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "star", - headline: { default: t("templates.employee_satisfaction_question_1_headline") }, + headline: t("templates.employee_satisfaction_question_1_headline"), required: true, - lowerLabel: { default: t("templates.employee_satisfaction_question_1_lower_label") }, - upperLabel: { default: t("templates.employee_satisfaction_question_1_upper_label") }, + lowerLabel: t("templates.employee_satisfaction_question_1_lower_label"), + upperLabel: t("templates.employee_satisfaction_question_1_upper_label"), isColorCodingEnabled: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_2_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_2_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_2_choice_5") }, - }, + t("templates.employee_satisfaction_question_2_choice_1"), + t("templates.employee_satisfaction_question_2_choice_2"), + t("templates.employee_satisfaction_question_2_choice_3"), + t("templates.employee_satisfaction_question_2_choice_4"), + t("templates.employee_satisfaction_question_2_choice_5"), ], - headline: { default: t("templates.employee_satisfaction_question_2_headline") }, + headline: t("templates.employee_satisfaction_question_2_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.employee_satisfaction_question_3_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.employee_satisfaction_question_3_headline"), required: false, - placeholder: { default: t("templates.employee_satisfaction_question_3_placeholder") }, + placeholder: t("templates.employee_satisfaction_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "number", - headline: { default: t("templates.employee_satisfaction_question_5_headline") }, + headline: t("templates.employee_satisfaction_question_5_headline"), required: true, - lowerLabel: { default: t("templates.employee_satisfaction_question_5_lower_label") }, - upperLabel: { default: t("templates.employee_satisfaction_question_5_upper_label") }, + lowerLabel: t("templates.employee_satisfaction_question_5_lower_label"), + upperLabel: t("templates.employee_satisfaction_question_5_upper_label"), isColorCodingEnabled: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.employee_satisfaction_question_6_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.employee_satisfaction_question_6_headline"), required: false, - placeholder: { default: t("templates.employee_satisfaction_question_6_placeholder") }, + placeholder: t("templates.employee_satisfaction_question_6_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_7_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_7_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_7_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_7_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.employee_satisfaction_question_7_choice_5") }, - }, + t("templates.employee_satisfaction_question_7_choice_1"), + t("templates.employee_satisfaction_question_7_choice_2"), + t("templates.employee_satisfaction_question_7_choice_3"), + t("templates.employee_satisfaction_question_7_choice_4"), + t("templates.employee_satisfaction_question_7_choice_5"), ], - headline: { default: t("templates.employee_satisfaction_question_7_headline") }, + headline: t("templates.employee_satisfaction_question_7_headline"), required: true, - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const uncoverStrengthsAndWeaknesses = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.uncover_strengths_and_weaknesses_name"), - role: "productManager", - industries: ["saas", "other"], - channels: ["app", "link"], - description: t("templates.uncover_strengths_and_weaknesses_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.uncover_strengths_and_weaknesses_name"), + role: "productManager", + industries: ["saas", "other"], + channels: ["app", "link"], + description: t("templates.uncover_strengths_and_weaknesses_description"), questions: [ - { + buildMultipleChoiceQuestion({ + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + shuffleOption: "none", + choices: [ + t("templates.uncover_strengths_and_weaknesses_question_1_choice_1"), + t("templates.uncover_strengths_and_weaknesses_question_1_choice_2"), + t("templates.uncover_strengths_and_weaknesses_question_1_choice_3"), + t("templates.uncover_strengths_and_weaknesses_question_1_choice_4"), + t("templates.uncover_strengths_and_weaknesses_question_1_choice_5"), + ], + headline: t("templates.uncover_strengths_and_weaknesses_question_1_headline"), + required: true, + containsOther: true, + t, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_1_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_1_choice_4") }, - }, - { - id: "other", - label: { default: t("templates.uncover_strengths_and_weaknesses_question_1_choice_5") }, - }, + t("templates.uncover_strengths_and_weaknesses_question_2_choice_1"), + t("templates.uncover_strengths_and_weaknesses_question_2_choice_2"), + t("templates.uncover_strengths_and_weaknesses_question_2_choice_3"), + t("templates.uncover_strengths_and_weaknesses_question_2_choice_4"), ], - headline: { default: t("templates.uncover_strengths_and_weaknesses_question_1_headline") }, + headline: t("templates.uncover_strengths_and_weaknesses_question_2_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - shuffleOption: "none", - choices: [ - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.uncover_strengths_and_weaknesses_question_2_choice_3") }, - }, - { - id: "other", - label: { default: t("templates.uncover_strengths_and_weaknesses_question_2_choice_4") }, - }, - ], - headline: { default: t("templates.uncover_strengths_and_weaknesses_question_2_headline") }, - required: true, - subheader: { default: t("templates.uncover_strengths_and_weaknesses_question_2_subheader") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.uncover_strengths_and_weaknesses_question_3_headline") }, + subheader: t("templates.uncover_strengths_and_weaknesses_question_2_subheader"), + containsOther: true, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.uncover_strengths_and_weaknesses_question_3_headline"), required: false, - subheader: { default: t("templates.uncover_strengths_and_weaknesses_question_3_subheader") }, + subheader: t("templates.uncover_strengths_and_weaknesses_question_3_subheader"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const productMarketFitShort = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.product_market_fit_short_name"), - role: "productManager", - industries: ["saas"], - channels: ["app", "link"], - description: t("templates.product_market_fit_short_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.product_market_fit_short_name"), + role: "productManager", + industries: ["saas"], + channels: ["app", "link"], + description: t("templates.product_market_fit_short_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.product_market_fit_short_question_1_headline") }, - subheader: { default: t("templates.product_market_fit_short_question_1_subheader") }, + headline: t("templates.product_market_fit_short_question_1_headline"), + subheader: t("templates.product_market_fit_short_question_1_subheader"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.product_market_fit_short_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_short_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.product_market_fit_short_question_1_choice_3") }, - }, + t("templates.product_market_fit_short_question_1_choice_1"), + t("templates.product_market_fit_short_question_1_choice_2"), + t("templates.product_market_fit_short_question_1_choice_3"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.product_market_fit_short_question_2_headline") }, - subheader: { default: t("templates.product_market_fit_short_question_2_subheader") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.product_market_fit_short_question_2_headline"), + subheader: t("templates.product_market_fit_short_question_2_subheader"), required: true, inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const marketAttribution = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.market_attribution_name"), - role: "marketing", - industries: ["saas", "eCommerce"], - channels: ["website", "app", "link"], - description: t("templates.market_attribution_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.market_attribution_name"), + role: "marketing", + industries: ["saas", "eCommerce"], + channels: ["website", "app", "link"], + description: t("templates.market_attribution_description"), questions: [ - { - id: createId(), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.market_attribution_question_1_headline") }, - subheader: { default: t("templates.market_attribution_question_1_subheader") }, + headline: t("templates.market_attribution_question_1_headline"), + subheader: t("templates.market_attribution_question_1_subheader"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.market_attribution_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.market_attribution_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.market_attribution_question_1_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.market_attribution_question_1_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.market_attribution_question_1_choice_5") }, - }, + t("templates.market_attribution_question_1_choice_1"), + t("templates.market_attribution_question_1_choice_2"), + t("templates.market_attribution_question_1_choice_3"), + t("templates.market_attribution_question_1_choice_4"), + t("templates.market_attribution_question_1_choice_5"), ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const changingSubscriptionExperience = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.changing_subscription_experience_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.changing_subscription_experience_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.changing_subscription_experience_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.changing_subscription_experience_description"), questions: [ - { - id: createId(), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.changing_subscription_experience_question_1_headline") }, + headline: t("templates.changing_subscription_experience_question_1_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_1_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_1_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_1_choice_5") }, - }, + t("templates.changing_subscription_experience_question_1_choice_1"), + t("templates.changing_subscription_experience_question_1_choice_2"), + t("templates.changing_subscription_experience_question_1_choice_3"), + t("templates.changing_subscription_experience_question_1_choice_4"), + t("templates.changing_subscription_experience_question_1_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + buttonLabel: t("templates.next"), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.changing_subscription_experience_question_2_headline") }, + headline: t("templates.changing_subscription_experience_question_2_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.changing_subscription_experience_question_2_choice_3") }, - }, + t("templates.changing_subscription_experience_question_2_choice_1"), + t("templates.changing_subscription_experience_question_2_choice_2"), + t("templates.changing_subscription_experience_question_2_choice_3"), ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const identifyCustomerGoals = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.identify_customer_goals_name"), - role: "productManager", - industries: ["saas", "other"], - channels: ["app", "website"], - description: t("templates.identify_customer_goals_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.identify_customer_goals_name"), + role: "productManager", + industries: ["saas", "other"], + channels: ["app", "website"], + description: t("templates.identify_customer_goals_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: "What's your primary goal for using $[projectName]?" }, + headline: "What's your primary goal for using $[projectName]?", required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: "Understand my user base deeply" }, - }, - { - id: createId(), - label: { default: "Identify upselling opportunities" }, - }, - { - id: createId(), - label: { default: "Build the best possible product" }, - }, - { - id: createId(), - label: { default: "Rule the world to make everyone breakfast brussels sprouts." }, - }, + "Understand my user base deeply", + "Identify upselling opportunities", + "Build the best possible product", + "Rule the world to make everyone breakfast brussels sprouts.", ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const featureChaser = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.feature_chaser_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.feature_chaser_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.feature_chaser_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.feature_chaser_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "number", - headline: { default: t("templates.feature_chaser_question_1_headline") }, + headline: t("templates.feature_chaser_question_1_headline"), required: true, - lowerLabel: { default: t("templates.feature_chaser_question_1_lower_label") }, - upperLabel: { default: t("templates.feature_chaser_question_1_upper_label") }, + lowerLabel: t("templates.feature_chaser_question_1_lower_label"), + upperLabel: t("templates.feature_chaser_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", choices: [ - { id: createId(), label: { default: t("templates.feature_chaser_question_2_choice_1") } }, - { id: createId(), label: { default: t("templates.feature_chaser_question_2_choice_2") } }, - { id: createId(), label: { default: t("templates.feature_chaser_question_2_choice_3") } }, - { id: createId(), label: { default: t("templates.feature_chaser_question_2_choice_4") } }, + t("templates.feature_chaser_question_2_choice_1"), + t("templates.feature_chaser_question_2_choice_2"), + t("templates.feature_chaser_question_2_choice_3"), + t("templates.feature_chaser_question_2_choice_4"), ], - headline: { default: t("templates.feature_chaser_question_2_headline") }, + headline: t("templates.feature_chaser_question_2_headline"), required: true, - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const fakeDoorFollowUp = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.fake_door_follow_up_name"), - role: "productManager", - industries: ["saas", "eCommerce"], - channels: ["app", "website"], - description: t("templates.fake_door_follow_up_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.fake_door_follow_up_name"), + role: "productManager", + industries: ["saas", "eCommerce"], + channels: ["app", "website"], + description: t("templates.fake_door_follow_up_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { default: t("templates.fake_door_follow_up_question_1_headline") }, + buildRatingQuestion({ + headline: t("templates.fake_door_follow_up_question_1_headline"), required: true, - lowerLabel: { default: t("templates.fake_door_follow_up_question_1_lower_label") }, - upperLabel: { default: t("templates.fake_door_follow_up_question_1_upper_label") }, + lowerLabel: t("templates.fake_door_follow_up_question_1_lower_label"), + upperLabel: t("templates.fake_door_follow_up_question_1_upper_label"), range: 5, scale: "number", isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + buttonLabel: t("templates.next"), + t, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, - headline: { default: t("templates.fake_door_follow_up_question_2_headline") }, + headline: t("templates.fake_door_follow_up_question_2_headline"), required: false, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.fake_door_follow_up_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.fake_door_follow_up_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.fake_door_follow_up_question_2_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.fake_door_follow_up_question_2_choice_4") }, - }, + t("templates.fake_door_follow_up_question_2_choice_1"), + t("templates.fake_door_follow_up_question_2_choice_2"), + t("templates.fake_door_follow_up_question_2_choice_3"), + t("templates.fake_door_follow_up_question_2_choice_4"), ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const feedbackBox = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId(), createId()]; const reusableOptionIds = [createId(), createId()]; const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.feedback_box_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.feedback_box_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.feedback_box_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.feedback_box_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[0], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[1], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[0], reusableQuestionIds[1]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[3]), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.feedback_box_question_1_choice_1") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.feedback_box_question_1_choice_2") }, - }, + t("templates.feedback_box_question_1_choice_1"), + t("templates.feedback_box_question_1_choice_2"), ], - headline: { default: t("templates.feedback_box_question_1_headline") }, + headline: t("templates.feedback_box_question_1_headline"), required: true, - subheader: { default: t("templates.feedback_box_question_1_subheader") }, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + subheader: t("templates.feedback_box_question_1_subheader"), + buttonLabel: t("templates.next"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - ], - headline: { default: t("templates.feedback_box_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], reusableQuestionIds[2], "isSubmitted")], + headline: t("templates.feedback_box_question_2_headline"), required: true, - subheader: { default: t("templates.feedback_box_question_2_subheader") }, + subheader: t("templates.feedback_box_question_2_subheader"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[2], - html: { - default: t("templates.feedback_box_question_3_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, + html: t("templates.feedback_box_question_3_html"), logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "isClicked", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createJumpLogic(reusableQuestionIds[2], localSurvey.endings[0].id, "isClicked"), + createJumpLogic(reusableQuestionIds[2], localSurvey.endings[0].id, "isSkipped"), ], - headline: { default: t("templates.feedback_box_question_3_headline") }, + headline: t("templates.feedback_box_question_3_headline"), required: false, - buttonLabel: { default: t("templates.feedback_box_question_3_button_label") }, + buttonLabel: t("templates.feedback_box_question_3_button_label"), buttonExternal: false, - dismissButtonLabel: { default: t("templates.feedback_box_question_3_dismiss_button_label") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + dismissButtonLabel: t("templates.feedback_box_question_3_dismiss_button_label"), + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.feedback_box_question_4_headline") }, + headline: t("templates.feedback_box_question_4_headline"), required: true, - subheader: { default: t("templates.feedback_box_question_4_subheader") }, - buttonLabel: { default: t("templates.feedback_box_question_4_button_label") }, - placeholder: { default: t("templates.feedback_box_question_4_placeholder") }, + subheader: t("templates.feedback_box_question_4_subheader"), + buttonLabel: t("templates.feedback_box_question_4_button_label"), + placeholder: t("templates.feedback_box_question_4_placeholder"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const integrationSetupSurvey = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.integration_setup_survey_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.integration_setup_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.integration_setup_survey_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.integration_setup_survey_description"), questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -2987,195 +1299,138 @@ const integrationSetupSurvey = (t: TFnType): TTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.integration_setup_survey_question_1_headline") }, + headline: t("templates.integration_setup_survey_question_1_headline"), required: true, - lowerLabel: { default: t("templates.integration_setup_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.integration_setup_survey_question_1_upper_label") }, + lowerLabel: t("templates.integration_setup_survey_question_1_lower_label"), + upperLabel: t("templates.integration_setup_survey_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.integration_setup_survey_question_2_headline") }, + headline: t("templates.integration_setup_survey_question_2_headline"), required: false, - placeholder: { default: t("templates.integration_setup_survey_question_2_placeholder") }, + placeholder: t("templates.integration_setup_survey_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.integration_setup_survey_question_3_headline") }, + headline: t("templates.integration_setup_survey_question_3_headline"), required: false, - subheader: { default: t("templates.integration_setup_survey_question_3_subheader") }, + subheader: t("templates.integration_setup_survey_question_3_subheader"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const newIntegrationSurvey = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.new_integration_survey_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.new_integration_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.new_integration_survey_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.new_integration_survey_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.new_integration_survey_question_1_headline") }, + headline: t("templates.new_integration_survey_question_1_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.new_integration_survey_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.new_integration_survey_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.new_integration_survey_question_1_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.new_integration_survey_question_1_choice_4") }, - }, - { - id: "other", - label: { default: t("templates.new_integration_survey_question_1_choice_5") }, - }, + t("templates.new_integration_survey_question_1_choice_1"), + t("templates.new_integration_survey_question_1_choice_2"), + t("templates.new_integration_survey_question_1_choice_3"), + t("templates.new_integration_survey_question_1_choice_4"), + t("templates.new_integration_survey_question_1_choice_5"), ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + containsOther: true, + t, + }), ], }, - }; + t + ); }; const docsFeedback = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.docs_feedback_name"), - role: "productManager", - industries: ["saas"], - channels: ["app", "website", "link"], - description: t("templates.docs_feedback_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.docs_feedback_name"), + role: "productManager", + industries: ["saas"], + channels: ["app", "website", "link"], + description: t("templates.docs_feedback_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.docs_feedback_question_1_headline") }, + headline: t("templates.docs_feedback_question_1_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.docs_feedback_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.docs_feedback_question_1_choice_2") }, - }, + t("templates.docs_feedback_question_1_choice_1"), + t("templates.docs_feedback_question_1_choice_2"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.docs_feedback_question_2_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.docs_feedback_question_2_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.docs_feedback_question_3_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.docs_feedback_question_3_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const nps = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.nps_name"), - role: "customerSuccess", - industries: ["saas", "eCommerce", "other"], - channels: ["app", "link", "website"], - description: t("templates.nps_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.nps_name"), + role: "customerSuccess", + industries: ["saas", "eCommerce", "other"], + channels: ["app", "link", "website"], + description: t("templates.nps_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.NPS, - headline: { default: t("templates.nps_question_1_headline") }, + buildNPSQuestion({ + headline: t("templates.nps_question_1_headline"), required: false, - lowerLabel: { default: t("templates.nps_question_1_lower_label") }, - upperLabel: { default: t("templates.nps_question_1_upper_label") }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.nps_question_2_headline") }, + lowerLabel: t("templates.nps_question_1_lower_label"), + upperLabel: t("templates.nps_question_1_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.nps_question_2_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const customerSatisfactionScore = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [ createId(), createId(), @@ -3188,188 +1443,166 @@ const customerSatisfactionScore = (t: TFnType): TTemplate => { createId(), createId(), ]; - return { - name: t("templates.csat_name"), - role: "customerSuccess", - industries: ["saas", "eCommerce", "other"], - channels: ["app", "link", "website"], - description: t("templates.csat_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.csat_name"), + role: "customerSuccess", + industries: ["saas", "eCommerce", "other"], + channels: ["app", "link", "website"], + description: t("templates.csat_description"), questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, range: 10, scale: "number", - headline: { - default: t("templates.csat_question_1_headline"), - }, + headline: t("templates.csat_question_1_headline"), required: true, - lowerLabel: { default: t("templates.csat_question_1_lower_label") }, - upperLabel: { default: t("templates.csat_question_1_upper_label") }, + lowerLabel: t("templates.csat_question_1_lower_label"), + upperLabel: t("templates.csat_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[1], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_2_headline") }, - subheader: { default: t("templates.csat_question_2_subheader") }, + headline: t("templates.csat_question_2_headline"), + subheader: t("templates.csat_question_2_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_2_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_2_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_2_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_2_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_2_choice_5") } }, + t("templates.csat_question_2_choice_1"), + t("templates.csat_question_2_choice_2"), + t("templates.csat_question_2_choice_3"), + t("templates.csat_question_2_choice_4"), + t("templates.csat_question_2_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[2], type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, - headline: { - default: t("templates.csat_question_3_headline"), - }, - subheader: { default: t("templates.csat_question_3_subheader") }, + headline: t("templates.csat_question_3_headline"), + subheader: t("templates.csat_question_3_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_3_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_5") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_6") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_7") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_8") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_9") } }, - { id: createId(), label: { default: t("templates.csat_question_3_choice_10") } }, + t("templates.csat_question_3_choice_1"), + t("templates.csat_question_3_choice_2"), + t("templates.csat_question_3_choice_3"), + t("templates.csat_question_3_choice_4"), + t("templates.csat_question_3_choice_5"), + t("templates.csat_question_3_choice_6"), + t("templates.csat_question_3_choice_7"), + t("templates.csat_question_3_choice_8"), + t("templates.csat_question_3_choice_9"), + t("templates.csat_question_3_choice_10"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[3], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_4_headline") }, - subheader: { default: t("templates.csat_question_4_subheader") }, + headline: t("templates.csat_question_4_headline"), + subheader: t("templates.csat_question_4_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_4_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_4_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_4_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_4_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_4_choice_5") } }, + t("templates.csat_question_4_choice_1"), + t("templates.csat_question_4_choice_2"), + t("templates.csat_question_4_choice_3"), + t("templates.csat_question_4_choice_4"), + t("templates.csat_question_4_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[4], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_5_headline") }, - subheader: { default: t("templates.csat_question_5_subheader") }, + headline: t("templates.csat_question_5_headline"), + subheader: t("templates.csat_question_5_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_5_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_5_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_5_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_5_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_5_choice_5") } }, + t("templates.csat_question_5_choice_1"), + t("templates.csat_question_5_choice_2"), + t("templates.csat_question_5_choice_3"), + t("templates.csat_question_5_choice_4"), + t("templates.csat_question_5_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[5], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_6_headline") }, - subheader: { default: t("templates.csat_question_6_subheader") }, + headline: t("templates.csat_question_6_headline"), + subheader: t("templates.csat_question_6_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_6_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_6_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_6_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_6_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_6_choice_5") } }, + t("templates.csat_question_6_choice_1"), + t("templates.csat_question_6_choice_2"), + t("templates.csat_question_6_choice_3"), + t("templates.csat_question_6_choice_4"), + t("templates.csat_question_6_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[6], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_7_headline") }, - subheader: { default: t("templates.csat_question_7_subheader") }, + headline: t("templates.csat_question_7_headline"), + subheader: t("templates.csat_question_7_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_7_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_7_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_7_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_7_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_7_choice_5") } }, - { id: createId(), label: { default: t("templates.csat_question_7_choice_6") } }, + t("templates.csat_question_7_choice_1"), + t("templates.csat_question_7_choice_2"), + t("templates.csat_question_7_choice_3"), + t("templates.csat_question_7_choice_4"), + t("templates.csat_question_7_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[7], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_8_headline") }, - subheader: { default: t("templates.csat_question_8_subheader") }, + headline: t("templates.csat_question_8_headline"), + subheader: t("templates.csat_question_8_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_8_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_8_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_8_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_8_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_8_choice_5") } }, - { id: createId(), label: { default: t("templates.csat_question_8_choice_6") } }, + t("templates.csat_question_8_choice_1"), + t("templates.csat_question_8_choice_2"), + t("templates.csat_question_8_choice_3"), + t("templates.csat_question_8_choice_4"), + t("templates.csat_question_8_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[8], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.csat_question_9_headline") }, - subheader: { default: t("templates.csat_question_9_subheader") }, + headline: t("templates.csat_question_9_headline"), + subheader: t("templates.csat_question_9_subheader"), required: true, choices: [ - { id: createId(), label: { default: t("templates.csat_question_9_choice_1") } }, - { id: createId(), label: { default: t("templates.csat_question_9_choice_2") } }, - { id: createId(), label: { default: t("templates.csat_question_9_choice_3") } }, - { id: createId(), label: { default: t("templates.csat_question_9_choice_4") } }, - { id: createId(), label: { default: t("templates.csat_question_9_choice_5") } }, + t("templates.csat_question_9_choice_1"), + t("templates.csat_question_9_choice_2"), + t("templates.csat_question_9_choice_3"), + t("templates.csat_question_9_choice_4"), + t("templates.csat_question_9_choice_5"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[9], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.csat_question_10_headline") }, + headline: t("templates.csat_question_10_headline"), required: false, - placeholder: { default: t("templates.csat_question_10_placeholder") }, + placeholder: t("templates.csat_question_10_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const collectFeedback = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [ createId(), createId(), @@ -3379,19 +1612,16 @@ const collectFeedback = (t: TFnType): TTemplate => { createId(), createId(), ]; - return { - name: t("templates.collect_feedback_name"), - role: "productManager", - industries: ["other", "eCommerce"], - channels: ["website", "link"], - description: t("templates.collect_feedback_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.collect_feedback_name"), + role: "productManager", + industries: ["other", "eCommerce"], + channels: ["website", "link"], + description: t("templates.collect_feedback_description"), questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -3424,21 +1654,16 @@ const collectFeedback = (t: TFnType): TTemplate => { ], range: 5, scale: "star", - headline: { default: t("templates.collect_feedback_question_1_headline") }, - subheader: { default: t("templates.collect_feedback_question_1_subheader") }, + headline: t("templates.collect_feedback_question_1_headline"), + subheader: t("templates.collect_feedback_question_1_subheader"), required: true, - lowerLabel: { default: t("templates.collect_feedback_question_1_lower_label") }, - upperLabel: { default: t("templates.collect_feedback_question_1_upper_label") }, + lowerLabel: t("templates.collect_feedback_question_1_lower_label"), + upperLabel: t("templates.collect_feedback_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [ { id: createId(), @@ -3465,669 +1690,452 @@ const collectFeedback = (t: TFnType): TTemplate => { ], }, ], - headline: { default: t("templates.collect_feedback_question_2_headline") }, + headline: t("templates.collect_feedback_question_2_headline"), required: true, longAnswer: true, - placeholder: { default: t("templates.collect_feedback_question_2_placeholder") }, + placeholder: t("templates.collect_feedback_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.collect_feedback_question_3_headline") }, + headline: t("templates.collect_feedback_question_3_headline"), required: true, longAnswer: true, - placeholder: { default: t("templates.collect_feedback_question_3_placeholder") }, + placeholder: t("templates.collect_feedback_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildRatingQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.Rating, range: 5, scale: "smiley", - headline: { default: t("templates.collect_feedback_question_4_headline") }, + headline: t("templates.collect_feedback_question_4_headline"), required: true, - lowerLabel: { default: t("templates.collect_feedback_question_4_lower_label") }, - upperLabel: { default: t("templates.collect_feedback_question_4_upper_label") }, + lowerLabel: t("templates.collect_feedback_question_4_lower_label"), + upperLabel: t("templates.collect_feedback_question_4_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.collect_feedback_question_5_headline") }, + headline: t("templates.collect_feedback_question_5_headline"), required: false, longAnswer: true, - placeholder: { default: t("templates.collect_feedback_question_5_placeholder") }, + placeholder: t("templates.collect_feedback_question_5_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[5], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, choices: [ - { id: createId(), label: { default: t("templates.collect_feedback_question_6_choice_1") } }, - { id: createId(), label: { default: t("templates.collect_feedback_question_6_choice_2") } }, - { id: createId(), label: { default: t("templates.collect_feedback_question_6_choice_3") } }, - { id: createId(), label: { default: t("templates.collect_feedback_question_6_choice_4") } }, - { id: "other", label: { default: t("templates.collect_feedback_question_6_choice_5") } }, + t("templates.collect_feedback_question_6_choice_1"), + t("templates.collect_feedback_question_6_choice_2"), + t("templates.collect_feedback_question_6_choice_3"), + t("templates.collect_feedback_question_6_choice_4"), + t("templates.collect_feedback_question_6_choice_5"), ], - headline: { default: t("templates.collect_feedback_question_6_headline") }, + headline: t("templates.collect_feedback_question_6_headline"), required: true, shuffleOption: "none", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + containsOther: true, + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[6], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.collect_feedback_question_7_headline") }, + headline: t("templates.collect_feedback_question_7_headline"), required: false, inputType: "email", longAnswer: false, - placeholder: { default: t("templates.collect_feedback_question_7_placeholder") }, - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + placeholder: t("templates.collect_feedback_question_7_placeholder"), + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const identifyUpsellOpportunities = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.identify_upsell_opportunities_name"), - role: "sales", - industries: ["saas"], - channels: ["app", "link"], - description: t("templates.identify_upsell_opportunities_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.identify_upsell_opportunities_name"), + role: "sales", + industries: ["saas"], + channels: ["app", "link"], + description: t("templates.identify_upsell_opportunities_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.identify_upsell_opportunities_question_1_headline") }, + headline: t("templates.identify_upsell_opportunities_question_1_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.identify_upsell_opportunities_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.identify_upsell_opportunities_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.identify_upsell_opportunities_question_1_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.identify_upsell_opportunities_question_1_choice_4") }, - }, + t("templates.identify_upsell_opportunities_question_1_choice_1"), + t("templates.identify_upsell_opportunities_question_1_choice_2"), + t("templates.identify_upsell_opportunities_question_1_choice_3"), + t("templates.identify_upsell_opportunities_question_1_choice_4"), ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const prioritizeFeatures = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.prioritize_features_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.prioritize_features_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.prioritize_features_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.prioritize_features_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, logic: [], shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.prioritize_features_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.prioritize_features_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.prioritize_features_question_1_choice_3") }, - }, - { id: "other", label: { default: t("templates.prioritize_features_question_1_choice_4") } }, + t("templates.prioritize_features_question_1_choice_1"), + t("templates.prioritize_features_question_1_choice_2"), + t("templates.prioritize_features_question_1_choice_3"), + t("templates.prioritize_features_question_1_choice_4"), ], - headline: { default: t("templates.prioritize_features_question_1_headline") }, + headline: t("templates.prioritize_features_question_1_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + containsOther: true, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, logic: [], shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.prioritize_features_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.prioritize_features_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.prioritize_features_question_2_choice_3") }, - }, + t("templates.prioritize_features_question_2_choice_1"), + t("templates.prioritize_features_question_2_choice_2"), + t("templates.prioritize_features_question_2_choice_3"), ], - headline: { default: t("templates.prioritize_features_question_2_headline") }, + headline: t("templates.prioritize_features_question_2_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.prioritize_features_question_3_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.prioritize_features_question_3_headline"), required: true, - placeholder: { default: t("templates.prioritize_features_question_3_placeholder") }, + placeholder: t("templates.prioritize_features_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const gaugeFeatureSatisfaction = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.gauge_feature_satisfaction_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.gauge_feature_satisfaction_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.gauge_feature_satisfaction_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.gauge_feature_satisfaction_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { default: t("templates.gauge_feature_satisfaction_question_1_headline") }, + buildRatingQuestion({ + headline: t("templates.gauge_feature_satisfaction_question_1_headline"), required: true, - lowerLabel: { default: t("templates.gauge_feature_satisfaction_question_1_lower_label") }, - upperLabel: { default: t("templates.gauge_feature_satisfaction_question_1_upper_label") }, + lowerLabel: t("templates.gauge_feature_satisfaction_question_1_lower_label"), + upperLabel: t("templates.gauge_feature_satisfaction_question_1_upper_label"), scale: "number", range: 5, isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.gauge_feature_satisfaction_question_2_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.gauge_feature_satisfaction_question_2_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], endings: [getDefaultEndingCard([], t)], hiddenFields: hiddenFieldsDefault, }, - }; + t + ); }; const marketSiteClarity = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.market_site_clarity_name"), - role: "marketing", - industries: ["saas", "eCommerce", "other"], - channels: ["website"], - description: t("templates.market_site_clarity_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.market_site_clarity_name"), + role: "marketing", + industries: ["saas", "eCommerce", "other"], + channels: ["website"], + description: t("templates.market_site_clarity_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.market_site_clarity_question_1_headline") }, + headline: t("templates.market_site_clarity_question_1_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.market_site_clarity_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.market_site_clarity_question_1_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.market_site_clarity_question_1_choice_3") }, - }, + t("templates.market_site_clarity_question_1_choice_1"), + t("templates.market_site_clarity_question_1_choice_2"), + t("templates.market_site_clarity_question_1_choice_3"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.market_site_clarity_question_2_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.market_site_clarity_question_2_headline"), required: false, inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.CTA, - headline: { default: t("templates.market_site_clarity_question_3_headline") }, + t, + }), + buildCTAQuestion({ + headline: t("templates.market_site_clarity_question_3_headline"), required: false, - buttonLabel: { default: t("templates.market_site_clarity_question_3_button_label") }, + buttonLabel: t("templates.market_site_clarity_question_3_button_label"), buttonUrl: "https://app.formbricks.com/auth/signup", buttonExternal: true, - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const customerEffortScore = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.customer_effort_score_name"), - role: "productManager", - industries: ["saas"], - channels: ["app"], - description: t("templates.customer_effort_score_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.customer_effort_score_name"), + role: "productManager", + industries: ["saas"], + channels: ["app"], + description: t("templates.customer_effort_score_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "number", - headline: { default: t("templates.customer_effort_score_question_1_headline") }, + headline: t("templates.customer_effort_score_question_1_headline"), required: true, - lowerLabel: { default: t("templates.customer_effort_score_question_1_lower_label") }, - upperLabel: { default: t("templates.customer_effort_score_question_1_upper_label") }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.customer_effort_score_question_2_headline") }, + lowerLabel: t("templates.customer_effort_score_question_1_lower_label"), + upperLabel: t("templates.customer_effort_score_question_1_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.customer_effort_score_question_2_headline"), required: true, - placeholder: { default: t("templates.customer_effort_score_question_2_placeholder") }, + placeholder: t("templates.customer_effort_score_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const careerDevelopmentSurvey = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.career_development_survey_name"), - role: "productManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.career_development_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.career_development_survey_name"), + role: "productManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.career_development_survey_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "number", - headline: { - default: t("templates.career_development_survey_question_1_headline"), - }, - lowerLabel: { default: t("templates.career_development_survey_question_1_lower_label") }, - upperLabel: { default: t("templates.career_development_survey_question_1_upper_label") }, + headline: t("templates.career_development_survey_question_1_headline"), + lowerLabel: t("templates.career_development_survey_question_1_lower_label"), + upperLabel: t("templates.career_development_survey_question_1_upper_label"), required: true, - isColorCodingEnabled: false, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "number", - headline: { - default: t("templates.career_development_survey_question_2_headline"), - }, - lowerLabel: { default: t("templates.career_development_survey_question_2_lower_label") }, - upperLabel: { default: t("templates.career_development_survey_question_2_upper_label") }, + headline: t("templates.career_development_survey_question_2_headline"), + lowerLabel: t("templates.career_development_survey_question_2_lower_label"), + upperLabel: t("templates.career_development_survey_question_2_upper_label"), required: true, - isColorCodingEnabled: false, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "number", - headline: { - default: t("templates.career_development_survey_question_3_headline"), - }, - lowerLabel: { default: t("templates.career_development_survey_question_3_lower_label") }, - upperLabel: { default: t("templates.career_development_survey_question_3_upper_label") }, + headline: t("templates.career_development_survey_question_3_headline"), + lowerLabel: t("templates.career_development_survey_question_3_lower_label"), + upperLabel: t("templates.career_development_survey_question_3_upper_label"), required: true, - isColorCodingEnabled: false, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "number", - headline: { - default: t("templates.career_development_survey_question_4_headline"), - }, - lowerLabel: { default: t("templates.career_development_survey_question_4_lower_label") }, - upperLabel: { default: t("templates.career_development_survey_question_4_upper_label") }, + headline: t("templates.career_development_survey_question_4_headline"), + lowerLabel: t("templates.career_development_survey_question_4_lower_label"), + upperLabel: t("templates.career_development_survey_question_4_upper_label"), required: true, - isColorCodingEnabled: false, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.career_development_survey_question_5_headline") }, - subheader: { default: t("templates.career_development_survey_question_5_subheader") }, + headline: t("templates.career_development_survey_question_5_headline"), + subheader: t("templates.career_development_survey_question_5_subheader"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.career_development_survey_question_5_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_5_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_5_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_5_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_5_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.career_development_survey_question_5_choice_6") }, - }, + t("templates.career_development_survey_question_5_choice_1"), + t("templates.career_development_survey_question_5_choice_2"), + t("templates.career_development_survey_question_5_choice_3"), + t("templates.career_development_survey_question_5_choice_4"), + t("templates.career_development_survey_question_5_choice_5"), + t("templates.career_development_survey_question_5_choice_6"), ], - }, - { + containsOther: true, + t, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { default: t("templates.career_development_survey_question_6_headline") }, - subheader: { default: t("templates.career_development_survey_question_6_subheader") }, + headline: t("templates.career_development_survey_question_6_headline"), + subheader: t("templates.career_development_survey_question_6_subheader"), required: true, shuffleOption: "exceptLast", choices: [ - { - id: createId(), - label: { default: t("templates.career_development_survey_question_6_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_6_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_6_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_6_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.career_development_survey_question_6_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.career_development_survey_question_6_choice_6") }, - }, + t("templates.career_development_survey_question_6_choice_1"), + t("templates.career_development_survey_question_6_choice_2"), + t("templates.career_development_survey_question_6_choice_3"), + t("templates.career_development_survey_question_6_choice_4"), + t("templates.career_development_survey_question_6_choice_5"), + t("templates.career_development_survey_question_6_choice_6"), ], - }, + containsOther: true, + t, + }), ], }, - }; + t + ); }; const professionalDevelopmentSurvey = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.professional_development_survey_name"), - role: "productManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.professional_development_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.professional_development_survey_name"), + role: "productManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.professional_development_survey_description"), questions: [ - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { - default: t("templates.professional_development_survey_question_1_headline"), - }, + headline: t("templates.professional_development_survey_question_1_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_1_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_1_choice_2") }, - }, + t("templates.professional_development_survey_question_1_choice_1"), + t("templates.professional_development_survey_question_1_choice_1"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), - { + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, - headline: { - default: t("templates.professional_development_survey_question_2_headline"), - }, - subheader: { default: t("templates.professional_development_survey_question_2_subheader") }, + headline: t("templates.professional_development_survey_question_2_headline"), + subheader: t("templates.professional_development_survey_question_2_subheader"), required: true, shuffleOption: "exceptLast", choices: [ - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_2_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_2_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_2_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_2_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_2_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.professional_development_survey_question_2_choice_6") }, - }, + t("templates.professional_development_survey_question_2_choice_1"), + t("templates.professional_development_survey_question_2_choice_2"), + t("templates.professional_development_survey_question_2_choice_3"), + t("templates.professional_development_survey_question_2_choice_4"), + t("templates.professional_development_survey_question_2_choice_5"), + t("templates.professional_development_survey_question_2_choice_6"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + containsOther: true, + t, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, - headline: { - default: t("templates.professional_development_survey_question_3_headline"), - }, + headline: t("templates.professional_development_survey_question_3_headline"), required: true, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_3_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_3_choice_2") }, - }, + t("templates.professional_development_survey_question_3_choice_1"), + t("templates.professional_development_survey_question_3_choice_2"), ], - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "number", - headline: { - default: t("templates.professional_development_survey_question_4_headline"), - }, - lowerLabel: { - default: t("templates.professional_development_survey_question_4_lower_label"), - }, - upperLabel: { - default: t("templates.professional_development_survey_question_4_upper_label"), - }, + headline: t("templates.professional_development_survey_question_4_headline"), + lowerLabel: t("templates.professional_development_survey_question_4_lower_label"), + upperLabel: t("templates.professional_development_survey_question_4_upper_label"), required: true, isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: createId(), type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, - headline: { - default: t("templates.professional_development_survey_question_5_headline"), - }, + headline: t("templates.professional_development_survey_question_5_headline"), required: true, shuffleOption: "exceptLast", choices: [ - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_5_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_5_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_5_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_5_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.professional_development_survey_question_5_choice_5") }, - }, - { - id: "other", - label: { default: t("templates.professional_development_survey_question_5_choice_6") }, - }, + t("templates.professional_development_survey_question_5_choice_1"), + t("templates.professional_development_survey_question_5_choice_2"), + t("templates.professional_development_survey_question_5_choice_3"), + t("templates.professional_development_survey_question_5_choice_4"), + t("templates.professional_development_survey_question_5_choice_5"), + t("templates.professional_development_survey_question_5_choice_6"), ], - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + containsOther: true, + t, + }), ], }, - }; + t + ); }; const rateCheckoutExperience = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.rate_checkout_experience_name"), - role: "productManager", - industries: ["eCommerce"], - channels: ["website", "app"], - description: t("templates.rate_checkout_experience_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.rate_checkout_experience_name"), + role: "productManager", + industries: ["eCommerce"], + channels: ["website", "app"], + description: t("templates.rate_checkout_experience_description"), + endings: localSurvey.endings, questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -4160,87 +2168,51 @@ const rateCheckoutExperience = (t: TFnType): TTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.rate_checkout_experience_question_1_headline") }, + headline: t("templates.rate_checkout_experience_question_1_headline"), required: true, - lowerLabel: { default: t("templates.rate_checkout_experience_question_1_lower_label") }, - upperLabel: { default: t("templates.rate_checkout_experience_question_1_upper_label") }, + lowerLabel: t("templates.rate_checkout_experience_question_1_lower_label"), + upperLabel: t("templates.rate_checkout_experience_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.rate_checkout_experience_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.rate_checkout_experience_question_2_headline"), required: true, - placeholder: { default: t("templates.rate_checkout_experience_question_2_placeholder") }, + placeholder: t("templates.rate_checkout_experience_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.rate_checkout_experience_question_3_headline") }, + headline: t("templates.rate_checkout_experience_question_3_headline"), required: true, - placeholder: { default: t("templates.rate_checkout_experience_question_3_placeholder") }, + placeholder: t("templates.rate_checkout_experience_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const measureSearchExperience = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.measure_search_experience_name"), - role: "productManager", - industries: ["saas", "eCommerce"], - channels: ["app", "website"], - description: t("templates.measure_search_experience_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.measure_search_experience_name"), + role: "productManager", + industries: ["saas", "eCommerce"], + channels: ["app", "website"], + description: t("templates.measure_search_experience_description"), + endings: localSurvey.endings, questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -4273,87 +2245,51 @@ const measureSearchExperience = (t: TFnType): TTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.measure_search_experience_question_1_headline") }, + headline: t("templates.measure_search_experience_question_1_headline"), required: true, - lowerLabel: { default: t("templates.measure_search_experience_question_1_lower_label") }, - upperLabel: { default: t("templates.measure_search_experience_question_1_upper_label") }, + lowerLabel: t("templates.measure_search_experience_question_1_lower_label"), + upperLabel: t("templates.measure_search_experience_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.measure_search_experience_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.measure_search_experience_question_2_headline"), required: true, - placeholder: { default: t("templates.measure_search_experience_question_2_placeholder") }, + placeholder: t("templates.measure_search_experience_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.measure_search_experience_question_3_headline") }, + headline: t("templates.measure_search_experience_question_3_headline"), required: true, - placeholder: { default: t("templates.measure_search_experience_question_3_placeholder") }, + placeholder: t("templates.measure_search_experience_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const evaluateContentQuality = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.evaluate_content_quality_name"), - role: "marketing", - industries: ["other"], - channels: ["website"], - description: t("templates.evaluate_content_quality_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.evaluate_content_quality_name"), + role: "marketing", + industries: ["other"], + channels: ["website"], + description: t("templates.evaluate_content_quality_description"), + endings: localSurvey.endings, questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -4386,197 +2322,70 @@ const evaluateContentQuality = (t: TFnType): TTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.evaluate_content_quality_question_1_headline") }, + headline: t("templates.evaluate_content_quality_question_1_headline"), required: true, - lowerLabel: { default: t("templates.evaluate_content_quality_question_1_lower_label") }, - upperLabel: { default: t("templates.evaluate_content_quality_question_1_upper_label") }, + lowerLabel: t("templates.evaluate_content_quality_question_1_lower_label"), + upperLabel: t("templates.evaluate_content_quality_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.evaluate_content_quality_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.evaluate_content_quality_question_2_headline"), required: true, - placeholder: { default: t("templates.evaluate_content_quality_question_2_placeholder") }, + placeholder: t("templates.evaluate_content_quality_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.evaluate_content_quality_question_3_headline") }, + headline: t("templates.evaluate_content_quality_question_3_headline"), required: true, - placeholder: { default: t("templates.evaluate_content_quality_question_3_placeholder") }, + placeholder: t("templates.evaluate_content_quality_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const measureTaskAccomplishment = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId(), createId(), createId()]; const reusableOptionIds = [createId(), createId(), createId()]; - return { - name: t("templates.measure_task_accomplishment_name"), - role: "productManager", - industries: ["saas"], - channels: ["app", "website"], - description: t("templates.measure_task_accomplishment_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.measure_task_accomplishment_name"), + role: "productManager", + industries: ["saas"], + channels: ["app", "website"], + description: t("templates.measure_task_accomplishment_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[0], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[1], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[2], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[4], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[3]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[0], reusableQuestionIds[1]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[2], reusableQuestionIds[4]), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.measure_task_accomplishment_question_1_option_1_label") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.measure_task_accomplishment_question_1_option_2_label") }, - }, - { - id: reusableOptionIds[2], - label: { default: t("templates.measure_task_accomplishment_question_1_option_3_label") }, - }, + t("templates.measure_task_accomplishment_question_1_option_1_label"), + t("templates.measure_task_accomplishment_question_1_option_2_label"), + t("templates.measure_task_accomplishment_question_1_option_3_label"), ], - headline: { default: t("templates.measure_task_accomplishment_question_1_headline") }, + headline: t("templates.measure_task_accomplishment_question_1_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildRatingQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -4609,20 +2418,15 @@ const measureTaskAccomplishment = (t: TFnType): TTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.measure_task_accomplishment_question_2_headline") }, + headline: t("templates.measure_task_accomplishment_question_2_headline"), required: false, - lowerLabel: { default: t("templates.measure_task_accomplishment_question_2_lower_label") }, - upperLabel: { default: t("templates.measure_task_accomplishment_question_2_upper_label") }, + lowerLabel: t("templates.measure_task_accomplishment_question_2_lower_label"), + upperLabel: t("templates.measure_task_accomplishment_question_2_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [ { id: createId(), @@ -4657,19 +2461,14 @@ const measureTaskAccomplishment = (t: TFnType): TTemplate => { ], }, ], - headline: { default: t("templates.measure_task_accomplishment_question_3_headline") }, + headline: t("templates.measure_task_accomplishment_question_3_headline"), required: false, - placeholder: { default: t("templates.measure_task_accomplishment_question_3_placeholder") }, + placeholder: t("templates.measure_task_accomplishment_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [ { id: createId(), @@ -4704,28 +2503,25 @@ const measureTaskAccomplishment = (t: TFnType): TTemplate => { ], }, ], - headline: { default: t("templates.measure_task_accomplishment_question_4_headline") }, + headline: t("templates.measure_task_accomplishment_question_4_headline"), required: false, - buttonLabel: { default: t("templates.measure_task_accomplishment_question_4_button_label") }, + buttonLabel: t("templates.measure_task_accomplishment_question_4_button_label"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.measure_task_accomplishment_question_5_headline") }, + headline: t("templates.measure_task_accomplishment_question_5_headline"), required: true, - buttonLabel: { default: t("templates.measure_task_accomplishment_question_5_button_label") }, - placeholder: { default: t("templates.measure_task_accomplishment_question_5_placeholder") }, + buttonLabel: t("templates.measure_task_accomplishment_question_5_button_label"), + placeholder: t("templates.measure_task_accomplishment_question_5_placeholder"), inputType: "text", - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const identifySignUpBarriers = (t: TFnType): TTemplate => { @@ -4743,60 +2539,28 @@ const identifySignUpBarriers = (t: TFnType): TTemplate => { ]; const reusableOptionIds = [createId(), createId(), createId(), createId(), createId()]; - return { - name: t("templates.identify_sign_up_barriers_name"), - role: "marketing", - industries: ["saas", "eCommerce", "other"], - channels: ["website"], - description: t("templates.identify_sign_up_barriers_description"), - preset: { - ...localSurvey, - name: t("templates.identify_sign_up_barriers_with_project_name"), + return buildSurvey( + { + name: t("templates.identify_sign_up_barriers_name"), + role: "marketing", + industries: ["saas", "eCommerce", "other"], + channels: ["website"], + description: t("templates.identify_sign_up_barriers_description"), + endings: localSurvey.endings, questions: [ - { + buildCTAQuestion({ id: reusableQuestionIds[0], - html: { - default: t("templates.identify_sign_up_barriers_question_1_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.identify_sign_up_barriers_question_1_headline") }, + html: t("templates.identify_sign_up_barriers_question_1_html"), + logic: [createJumpLogic(reusableQuestionIds[0], localSurvey.endings[0].id, "isSkipped")], + headline: t("templates.identify_sign_up_barriers_question_1_headline"), required: false, - buttonLabel: { default: t("templates.identify_sign_up_barriers_question_1_button_label") }, + buttonLabel: t("templates.identify_sign_up_barriers_question_1_button_label"), buttonExternal: false, - dismissButtonLabel: { - default: t("templates.identify_sign_up_barriers_question_1_dismiss_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, - }, - { + dismissButtonLabel: t("templates.identify_sign_up_barriers_question_1_dismiss_button_label"), + t, + }), + buildRatingQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.Rating, logic: [ { id: createId(), @@ -4829,674 +2593,208 @@ const identifySignUpBarriers = (t: TFnType): TTemplate => { ], range: 5, scale: "number", - headline: { default: t("templates.identify_sign_up_barriers_question_2_headline") }, + headline: t("templates.identify_sign_up_barriers_question_2_headline"), required: true, - lowerLabel: { default: t("templates.identify_sign_up_barriers_question_2_lower_label") }, - upperLabel: { default: t("templates.identify_sign_up_barriers_question_2_upper_label") }, + lowerLabel: t("templates.identify_sign_up_barriers_question_2_lower_label"), + upperLabel: t("templates.identify_sign_up_barriers_question_2_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildMultipleChoiceQuestion({ id: reusableQuestionIds[2], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[0], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[4], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[2], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[3], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[6], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[4], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[7], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[2], reusableOptionIds[0], reusableQuestionIds[3]), + createChoiceJumpLogic(reusableQuestionIds[2], reusableOptionIds[1], reusableQuestionIds[4]), + createChoiceJumpLogic(reusableQuestionIds[2], reusableOptionIds[2], reusableQuestionIds[5]), + createChoiceJumpLogic(reusableQuestionIds[2], reusableOptionIds[3], reusableQuestionIds[6]), + createChoiceJumpLogic(reusableQuestionIds[2], reusableOptionIds[4], reusableQuestionIds[7]), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.identify_sign_up_barriers_question_3_choice_1_label") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.identify_sign_up_barriers_question_3_choice_2_label") }, - }, - { - id: reusableOptionIds[2], - label: { default: t("templates.identify_sign_up_barriers_question_3_choice_3_label") }, - }, - { - id: reusableOptionIds[3], - label: { default: t("templates.identify_sign_up_barriers_question_3_choice_4_label") }, - }, - { - id: reusableOptionIds[4], - label: { default: t("templates.identify_sign_up_barriers_question_3_choice_5_label") }, - }, + t("templates.identify_sign_up_barriers_question_3_choice_1_label"), + t("templates.identify_sign_up_barriers_question_3_choice_2_label"), + t("templates.identify_sign_up_barriers_question_3_choice_3_label"), + t("templates.identify_sign_up_barriers_question_3_choice_4_label"), + t("templates.identify_sign_up_barriers_question_3_choice_5_label"), ], - headline: { default: t("templates.identify_sign_up_barriers_question_3_headline") }, + choiceIds: [ + reusableOptionIds[0], + reusableOptionIds[1], + reusableOptionIds[2], + reusableOptionIds[3], + reusableOptionIds[4], + ], + headline: t("templates.identify_sign_up_barriers_question_3_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[3], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[8], - }, - ], - }, - ], - headline: { default: t("templates.identify_sign_up_barriers_question_4_headline") }, + logic: [createJumpLogic(reusableQuestionIds[3], reusableQuestionIds[8], "isSubmitted")], + headline: t("templates.identify_sign_up_barriers_question_4_headline"), required: true, - placeholder: { default: t("templates.identify_sign_up_barriers_question_4_placeholder") }, + placeholder: t("templates.identify_sign_up_barriers_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[8], - }, - ], - }, - ], - headline: { default: t("templates.identify_sign_up_barriers_question_5_headline") }, + logic: [createJumpLogic(reusableQuestionIds[4], reusableQuestionIds[8], "isSubmitted")], + headline: t("templates.identify_sign_up_barriers_question_5_headline"), required: true, - placeholder: { default: t("templates.identify_sign_up_barriers_question_5_placeholder") }, + placeholder: t("templates.identify_sign_up_barriers_question_5_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[5], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[5], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[8], - }, - ], - }, - ], - headline: { default: t("templates.identify_sign_up_barriers_question_6_headline") }, + logic: [createJumpLogic(reusableQuestionIds[5], reusableQuestionIds[8], "isSubmitted")], + headline: t("templates.identify_sign_up_barriers_question_6_headline"), required: true, - placeholder: { default: t("templates.identify_sign_up_barriers_question_6_placeholder") }, + placeholder: t("templates.identify_sign_up_barriers_question_6_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[6], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[6], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[8], - }, - ], - }, - ], - headline: { default: t("templates.identify_sign_up_barriers_question_7_headline") }, + logic: [createJumpLogic(reusableQuestionIds[6], reusableQuestionIds[8], "isSubmitted")], + headline: t("templates.identify_sign_up_barriers_question_7_headline"), required: true, - placeholder: { default: t("templates.identify_sign_up_barriers_question_7_placeholder") }, + placeholder: t("templates.identify_sign_up_barriers_question_7_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[7], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.identify_sign_up_barriers_question_8_headline") }, + headline: t("templates.identify_sign_up_barriers_question_8_headline"), required: true, - placeholder: { default: t("templates.identify_sign_up_barriers_question_8_placeholder") }, + placeholder: t("templates.identify_sign_up_barriers_question_8_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[8], - html: { - default: t("templates.identify_sign_up_barriers_question_9_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - headline: { default: t("templates.identify_sign_up_barriers_question_9_headline") }, + html: t("templates.identify_sign_up_barriers_question_9_html"), + headline: t("templates.identify_sign_up_barriers_question_9_headline"), required: false, buttonUrl: "https://app.formbricks.com/auth/signup", - buttonLabel: { default: t("templates.identify_sign_up_barriers_question_9_button_label") }, + buttonLabel: t("templates.identify_sign_up_barriers_question_9_button_label"), buttonExternal: true, - dismissButtonLabel: { - default: t("templates.identify_sign_up_barriers_question_9_dismiss_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, - }, + dismissButtonLabel: t("templates.identify_sign_up_barriers_question_9_dismiss_button_label"), + t, + }), ], }, - }; + t + ); }; const buildProductRoadmap = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.build_product_roadmap_name"), - role: "productManager", - industries: ["saas"], - channels: ["app", "link"], - description: t("templates.build_product_roadmap_description"), - preset: { - ...localSurvey, - name: t("templates.build_product_roadmap_name_with_project_name"), + return buildSurvey( + { + name: t("templates.build_product_roadmap_name"), + role: "productManager", + industries: ["saas"], + channels: ["app", "link"], + description: t("templates.build_product_roadmap_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "number", - headline: { - default: t("templates.build_product_roadmap_question_1_headline"), - }, + headline: t("templates.build_product_roadmap_question_1_headline"), required: true, - lowerLabel: { default: t("templates.build_product_roadmap_question_1_lower_label") }, - upperLabel: { default: t("templates.build_product_roadmap_question_1_upper_label") }, + lowerLabel: t("templates.build_product_roadmap_question_1_lower_label"), + upperLabel: t("templates.build_product_roadmap_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.build_product_roadmap_question_2_headline"), - }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.build_product_roadmap_question_2_headline"), required: true, - placeholder: { default: t("templates.build_product_roadmap_question_2_placeholder") }, + placeholder: t("templates.build_product_roadmap_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const understandPurchaseIntention = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.understand_purchase_intention_name"), - role: "sales", - industries: ["eCommerce"], - channels: ["website", "link", "app"], - description: t("templates.understand_purchase_intention_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.understand_purchase_intention_name"), + role: "sales", + industries: ["eCommerce"], + channels: ["website", "link", "app"], + description: t("templates.understand_purchase_intention_description"), + endings: localSurvey.endings, questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "isLessThanOrEqual", - rightOperand: { - type: "static", - value: 2, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[1], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: 3, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: 4, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: 5, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], "2", reusableQuestionIds[1]), + createChoiceJumpLogic(reusableQuestionIds[0], "3", reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[0], "4", reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[0], "5", localSurvey.endings[0].id), ], range: 5, scale: "number", - headline: { default: t("templates.understand_purchase_intention_question_1_headline") }, + headline: t("templates.understand_purchase_intention_question_1_headline"), required: true, - lowerLabel: { default: t("templates.understand_purchase_intention_question_1_lower_label") }, - upperLabel: { default: t("templates.understand_purchase_intention_question_1_upper_label") }, + lowerLabel: t("templates.understand_purchase_intention_question_1_lower_label"), + upperLabel: t("templates.understand_purchase_intention_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "or", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted"), + createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSkipped"), ], - headline: { default: t("templates.understand_purchase_intention_question_2_headline") }, + headline: t("templates.understand_purchase_intention_question_2_headline"), required: false, - placeholder: { default: t("templates.understand_purchase_intention_question_2_placeholder") }, + placeholder: t("templates.understand_purchase_intention_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.understand_purchase_intention_question_3_headline") }, + headline: t("templates.understand_purchase_intention_question_3_headline"), required: true, - placeholder: { default: t("templates.understand_purchase_intention_question_3_placeholder") }, + placeholder: t("templates.understand_purchase_intention_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const improveNewsletterContent = (t: TFnType): TTemplate => { const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [createId(), createId(), createId()]; - return { - name: t("templates.improve_newsletter_content_name"), - role: "marketing", - industries: ["eCommerce", "saas", "other"], - channels: ["link"], - description: t("templates.improve_newsletter_content_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.improve_newsletter_content_name"), + role: "marketing", + industries: ["eCommerce", "saas", "other"], + channels: ["link"], + description: t("templates.improve_newsletter_content_description"), + endings: localSurvey.endings, questions: [ - { + buildRatingQuestion({ id: reusableQuestionIds[0], - type: TSurveyQuestionTypeEnum.Rating, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: 5, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], "5", reusableQuestionIds[2]), { id: createId(), conditions: { @@ -5528,84 +2826,43 @@ const improveNewsletterContent = (t: TFnType): TTemplate => { ], range: 5, scale: "smiley", - headline: { default: t("templates.improve_newsletter_content_question_1_headline") }, + headline: t("templates.improve_newsletter_content_question_1_headline"), required: true, - lowerLabel: { default: t("templates.improve_newsletter_content_question_1_lower_label") }, - upperLabel: { default: t("templates.improve_newsletter_content_question_1_upper_label") }, + lowerLabel: t("templates.improve_newsletter_content_question_1_lower_label"), + upperLabel: t("templates.improve_newsletter_content_question_1_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "or", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSkipped", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, + createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted"), + createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSkipped"), ], - headline: { default: t("templates.improve_newsletter_content_question_2_headline") }, + headline: t("templates.improve_newsletter_content_question_2_headline"), required: false, - placeholder: { default: t("templates.improve_newsletter_content_question_2_placeholder") }, + placeholder: t("templates.improve_newsletter_content_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[2], - html: { - default: t("templates.improve_newsletter_content_question_3_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - headline: { default: t("templates.improve_newsletter_content_question_3_headline") }, + html: t("templates.improve_newsletter_content_question_3_html"), + headline: t("templates.improve_newsletter_content_question_3_headline"), required: false, buttonUrl: "https://formbricks.com", - buttonLabel: { default: t("templates.improve_newsletter_content_question_3_button_label") }, + buttonLabel: t("templates.improve_newsletter_content_question_3_button_label"), buttonExternal: true, - dismissButtonLabel: { - default: t("templates.improve_newsletter_content_question_3_dismiss_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, - }, + dismissButtonLabel: t("templates.improve_newsletter_content_question_3_dismiss_button_label"), + t, + }), ], }, - }; + t + ); }; const evaluateAProductIdea = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); const reusableQuestionIds = [ createId(), createId(), @@ -5616,272 +2873,102 @@ const evaluateAProductIdea = (t: TFnType): TTemplate => { createId(), createId(), ]; - return { - name: t("templates.evaluate_a_product_idea_name"), - role: "productManager", - industries: ["saas", "other"], - channels: ["link", "app"], - description: t("templates.evaluate_a_product_idea_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.evaluate_a_product_idea_name"), + role: "productManager", + industries: ["saas", "other"], + channels: ["link", "app"], + description: t("templates.evaluate_a_product_idea_description"), questions: [ - { + buildCTAQuestion({ id: reusableQuestionIds[0], - html: { - default: t("templates.evaluate_a_product_idea_question_1_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - headline: { - default: t("templates.evaluate_a_product_idea_question_1_headline"), - }, + html: t("templates.evaluate_a_product_idea_question_1_html"), + headline: t("templates.evaluate_a_product_idea_question_1_headline"), required: true, - buttonLabel: { default: t("templates.evaluate_a_product_idea_question_1_button_label") }, + buttonLabel: t("templates.evaluate_a_product_idea_question_1_button_label"), buttonExternal: false, - dismissButtonLabel: { - default: t("templates.evaluate_a_product_idea_question_1_dismiss_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, - }, - { + dismissButtonLabel: t("templates.evaluate_a_product_idea_question_1_dismiss_button_label"), + t, + }), + buildRatingQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.Rating, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isLessThanOrEqual", - rightOperand: { - type: "static", - value: 3, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isGreaterThanOrEqual", - rightOperand: { - type: "static", - value: 4, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[1], "3", reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[1], "4", reusableQuestionIds[3]), ], range: 5, scale: "number", - headline: { default: t("templates.evaluate_a_product_idea_question_2_headline") }, + headline: t("templates.evaluate_a_product_idea_question_2_headline"), required: true, - lowerLabel: { default: t("templates.evaluate_a_product_idea_question_2_lower_label") }, - upperLabel: { default: t("templates.evaluate_a_product_idea_question_2_upper_label") }, + lowerLabel: t("templates.evaluate_a_product_idea_question_2_lower_label"), + upperLabel: t("templates.evaluate_a_product_idea_question_2_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.evaluate_a_product_idea_question_3_headline") }, + headline: t("templates.evaluate_a_product_idea_question_3_headline"), required: true, - placeholder: { default: t("templates.evaluate_a_product_idea_question_3_placeholder") }, + placeholder: t("templates.evaluate_a_product_idea_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildCTAQuestion({ id: reusableQuestionIds[3], - html: { - default: t("templates.evaluate_a_product_idea_question_4_html"), - }, - type: TSurveyQuestionTypeEnum.CTA, - headline: { default: t("templates.evaluate_a_product_idea_question_4_headline") }, + html: t("templates.evaluate_a_product_idea_question_4_html"), + headline: t("templates.evaluate_a_product_idea_question_4_headline"), required: true, - buttonLabel: { default: t("templates.evaluate_a_product_idea_question_4_button_label") }, + buttonLabel: t("templates.evaluate_a_product_idea_question_4_button_label"), buttonExternal: false, - dismissButtonLabel: { - default: t("templates.evaluate_a_product_idea_question_4_dismiss_button_label"), - }, - backButtonLabel: { default: t("templates.back") }, - }, - { + dismissButtonLabel: t("templates.evaluate_a_product_idea_question_4_dismiss_button_label"), + t, + }), + buildRatingQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.Rating, logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isLessThanOrEqual", - rightOperand: { - type: "static", - value: 3, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isGreaterThanOrEqual", - rightOperand: { - type: "static", - value: 4, - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[6], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[4], "3", reusableQuestionIds[5]), + createChoiceJumpLogic(reusableQuestionIds[4], "4", reusableQuestionIds[6]), ], range: 5, scale: "number", - headline: { default: t("templates.evaluate_a_product_idea_question_5_headline") }, + headline: t("templates.evaluate_a_product_idea_question_5_headline"), required: true, - lowerLabel: { default: t("templates.evaluate_a_product_idea_question_5_lower_label") }, - upperLabel: { default: t("templates.evaluate_a_product_idea_question_5_upper_label") }, + lowerLabel: t("templates.evaluate_a_product_idea_question_5_lower_label"), + upperLabel: t("templates.evaluate_a_product_idea_question_5_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[5], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[5], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[7], - }, - ], - }, - ], - headline: { default: t("templates.evaluate_a_product_idea_question_6_headline") }, + logic: [createJumpLogic(reusableQuestionIds[5], reusableQuestionIds[7], "isSubmitted")], + headline: t("templates.evaluate_a_product_idea_question_6_headline"), required: true, - placeholder: { default: t("templates.evaluate_a_product_idea_question_6_placeholder") }, + placeholder: t("templates.evaluate_a_product_idea_question_6_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[6], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.evaluate_a_product_idea_question_7_headline") }, + headline: t("templates.evaluate_a_product_idea_question_7_headline"), required: true, - placeholder: { default: t("templates.evaluate_a_product_idea_question_7_placeholder") }, + placeholder: t("templates.evaluate_a_product_idea_question_7_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[7], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.evaluate_a_product_idea_question_8_headline") }, + headline: t("templates.evaluate_a_product_idea_question_8_headline"), required: false, - placeholder: { default: t("templates.evaluate_a_product_idea_question_8_placeholder") }, + placeholder: t("templates.evaluate_a_product_idea_question_8_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const understandLowEngagement = (t: TFnType): TTemplate => { @@ -5889,994 +2976,445 @@ const understandLowEngagement = (t: TFnType): TTemplate => { const reusableQuestionIds = [createId(), createId(), createId(), createId(), createId(), createId()]; const reusableOptionIds = [createId(), createId(), createId(), createId()]; - return { - name: t("templates.understand_low_engagement_name"), - role: "productManager", - industries: ["saas"], - channels: ["link"], - description: t("templates.understand_low_engagement_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.understand_low_engagement_name"), + role: "productManager", + industries: ["saas"], + channels: ["link"], + description: t("templates.understand_low_engagement_description"), + endings: localSurvey.endings, questions: [ - { + buildMultipleChoiceQuestion({ id: reusableQuestionIds[0], type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[0], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[1], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[1], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[2], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[2], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[3], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: reusableOptionIds[3], - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[4], - }, - ], - }, - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[0], - type: "question", - }, - operator: "equals", - rightOperand: { - type: "static", - value: "other", - }, - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: reusableQuestionIds[5], - }, - ], - }, + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[0], reusableQuestionIds[1]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[1], reusableQuestionIds[2]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[2], reusableQuestionIds[3]), + createChoiceJumpLogic(reusableQuestionIds[0], reusableOptionIds[3], reusableQuestionIds[4]), + createChoiceJumpLogic(reusableQuestionIds[0], "other", reusableQuestionIds[5]), ], choices: [ - { - id: reusableOptionIds[0], - label: { default: t("templates.understand_low_engagement_question_1_choice_1") }, - }, - { - id: reusableOptionIds[1], - label: { default: t("templates.understand_low_engagement_question_1_choice_2") }, - }, - { - id: reusableOptionIds[2], - label: { default: t("templates.understand_low_engagement_question_1_choice_3") }, - }, - { - id: reusableOptionIds[3], - label: { default: t("templates.understand_low_engagement_question_1_choice_4") }, - }, - { - id: "other", - label: { default: t("templates.understand_low_engagement_question_1_choice_5") }, - }, + t("templates.understand_low_engagement_question_1_choice_1"), + t("templates.understand_low_engagement_question_1_choice_2"), + t("templates.understand_low_engagement_question_1_choice_3"), + t("templates.understand_low_engagement_question_1_choice_4"), + t("templates.understand_low_engagement_question_1_choice_5"), ], - headline: { default: t("templates.understand_low_engagement_question_1_headline") }, + headline: t("templates.understand_low_engagement_question_1_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + containsOther: true, + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[1], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[1], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.understand_low_engagement_question_2_headline") }, + logic: [createJumpLogic(reusableQuestionIds[1], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.understand_low_engagement_question_2_headline"), required: true, - placeholder: { default: t("templates.understand_low_engagement_question_2_placeholder") }, + placeholder: t("templates.understand_low_engagement_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[2], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[2], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.understand_low_engagement_question_3_headline") }, + logic: [createJumpLogic(reusableQuestionIds[2], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.understand_low_engagement_question_3_headline"), required: true, - placeholder: { default: t("templates.understand_low_engagement_question_3_placeholder") }, + placeholder: t("templates.understand_low_engagement_question_3_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[3], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[3], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.understand_low_engagement_question_4_headline") }, + logic: [createJumpLogic(reusableQuestionIds[3], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.understand_low_engagement_question_4_headline"), required: true, - placeholder: { default: t("templates.understand_low_engagement_question_4_placeholder") }, + placeholder: t("templates.understand_low_engagement_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[4], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - logic: [ - { - id: createId(), - conditions: { - id: createId(), - connector: "and", - conditions: [ - { - id: createId(), - leftOperand: { - value: reusableQuestionIds[4], - type: "question", - }, - operator: "isSubmitted", - }, - ], - }, - actions: [ - { - id: createId(), - objective: "jumpToQuestion", - target: localSurvey.endings[0].id, - }, - ], - }, - ], - headline: { default: t("templates.understand_low_engagement_question_5_headline") }, + logic: [createJumpLogic(reusableQuestionIds[4], localSurvey.endings[0].id, "isSubmitted")], + headline: t("templates.understand_low_engagement_question_5_headline"), required: true, - placeholder: { default: t("templates.understand_low_engagement_question_5_placeholder") }, + placeholder: t("templates.understand_low_engagement_question_5_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { + t, + }), + buildOpenTextQuestion({ id: reusableQuestionIds[5], - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, logic: [], - headline: { default: t("templates.understand_low_engagement_question_6_headline") }, + headline: t("templates.understand_low_engagement_question_6_headline"), required: false, - placeholder: { default: t("templates.understand_low_engagement_question_6_placeholder") }, + placeholder: t("templates.understand_low_engagement_question_6_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const employeeWellBeing = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.employee_well_being_name"), - role: "peopleManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.employee_well_being_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.employee_well_being_name"), + role: "peopleManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.employee_well_being_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { default: t("templates.employee_well_being_question_1_headline") }, + buildRatingQuestion({ + headline: t("templates.employee_well_being_question_1_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.employee_well_being_question_1_lower_label"), - }, - upperLabel: { - default: t("templates.employee_well_being_question_1_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.employee_well_being_question_2_headline"), - }, + lowerLabel: t("templates.employee_well_being_question_1_lower_label"), + upperLabel: t("templates.employee_well_being_question_1_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.employee_well_being_question_2_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.employee_well_being_question_2_lower_label"), - }, - upperLabel: { - default: t("templates.employee_well_being_question_2_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { default: t("templates.employee_well_being_question_3_headline") }, + lowerLabel: t("templates.employee_well_being_question_2_lower_label"), + upperLabel: t("templates.employee_well_being_question_2_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.employee_well_being_question_3_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.employee_well_being_question_3_lower_label"), - }, - upperLabel: { - default: t("templates.employee_well_being_question_3_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.employee_well_being_question_4_headline") }, + lowerLabel: t("templates.employee_well_being_question_3_lower_label"), + upperLabel: t("templates.employee_well_being_question_3_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.employee_well_being_question_4_headline"), required: false, - placeholder: { default: t("templates.employee_well_being_question_4_placeholder") }, + placeholder: t("templates.employee_well_being_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const longTermRetentionCheckIn = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.long_term_retention_check_in_name"), - role: "peopleManager", - industries: ["saas", "other"], - channels: ["app", "link"], - description: t("templates.long_term_retention_check_in_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.long_term_retention_check_in_name"), + role: "peopleManager", + industries: ["saas", "other"], + channels: ["app", "link"], + description: t("templates.long_term_retention_check_in_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + buildRatingQuestion({ range: 5, scale: "star", - headline: { default: t("templates.long_term_retention_check_in_question_1_headline") }, + headline: t("templates.long_term_retention_check_in_question_1_headline"), required: true, - lowerLabel: { default: t("templates.long_term_retention_check_in_question_1_lower_label") }, - upperLabel: { default: t("templates.long_term_retention_check_in_question_1_upper_label") }, + lowerLabel: t("templates.long_term_retention_check_in_question_1_lower_label"), + upperLabel: t("templates.long_term_retention_check_in_question_1_upper_label"), isColorCodingEnabled: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.long_term_retention_check_in_question_2_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.long_term_retention_check_in_question_2_headline"), required: false, - placeholder: { default: t("templates.long_term_retention_check_in_question_2_placeholder") }, + placeholder: t("templates.long_term_retention_check_in_question_2_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_3_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_3_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_3_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_3_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_3_choice_5") }, - }, + t("templates.long_term_retention_check_in_question_3_choice_1"), + t("templates.long_term_retention_check_in_question_3_choice_2"), + t("templates.long_term_retention_check_in_question_3_choice_3"), + t("templates.long_term_retention_check_in_question_3_choice_4"), + t("templates.long_term_retention_check_in_question_3_choice_5"), ], - headline: { - default: t("templates.long_term_retention_check_in_question_3_headline"), - }, + headline: t("templates.long_term_retention_check_in_question_3_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "number", - headline: { default: t("templates.long_term_retention_check_in_question_4_headline") }, + headline: t("templates.long_term_retention_check_in_question_4_headline"), required: true, - lowerLabel: { default: t("templates.long_term_retention_check_in_question_4_lower_label") }, - upperLabel: { default: t("templates.long_term_retention_check_in_question_4_upper_label") }, + lowerLabel: t("templates.long_term_retention_check_in_question_4_lower_label"), + upperLabel: t("templates.long_term_retention_check_in_question_4_upper_label"), isColorCodingEnabled: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.long_term_retention_check_in_question_5_headline"), - }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.long_term_retention_check_in_question_5_headline"), required: false, - placeholder: { default: t("templates.long_term_retention_check_in_question_5_placeholder") }, + placeholder: t("templates.long_term_retention_check_in_question_5_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.NPS, - headline: { default: t("templates.long_term_retention_check_in_question_6_headline") }, + t, + }), + buildNPSQuestion({ + headline: t("templates.long_term_retention_check_in_question_6_headline"), required: false, - lowerLabel: { default: t("templates.long_term_retention_check_in_question_6_lower_label") }, - upperLabel: { default: t("templates.long_term_retention_check_in_question_6_upper_label") }, + lowerLabel: t("templates.long_term_retention_check_in_question_6_lower_label"), + upperLabel: t("templates.long_term_retention_check_in_question_6_upper_label"), isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), + t, + }), + buildMultipleChoiceQuestion({ type: TSurveyQuestionTypeEnum.MultipleChoiceMulti, shuffleOption: "none", choices: [ - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_7_choice_1") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_7_choice_2") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_7_choice_3") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_7_choice_4") }, - }, - { - id: createId(), - label: { default: t("templates.long_term_retention_check_in_question_7_choice_5") }, - }, + t("templates.long_term_retention_check_in_question_7_choice_1"), + t("templates.long_term_retention_check_in_question_7_choice_2"), + t("templates.long_term_retention_check_in_question_7_choice_3"), + t("templates.long_term_retention_check_in_question_7_choice_4"), + t("templates.long_term_retention_check_in_question_7_choice_5"), ], - headline: { default: t("templates.long_term_retention_check_in_question_7_headline") }, + headline: t("templates.long_term_retention_check_in_question_7_headline"), required: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.long_term_retention_check_in_question_8_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.long_term_retention_check_in_question_8_headline"), required: false, - placeholder: { default: t("templates.long_term_retention_check_in_question_8_placeholder") }, + placeholder: t("templates.long_term_retention_check_in_question_8_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, + t, + }), + buildRatingQuestion({ range: 5, scale: "smiley", - headline: { default: t("templates.long_term_retention_check_in_question_9_headline") }, + headline: t("templates.long_term_retention_check_in_question_9_headline"), required: true, - lowerLabel: { default: t("templates.long_term_retention_check_in_question_9_lower_label") }, - upperLabel: { default: t("templates.long_term_retention_check_in_question_9_upper_label") }, + lowerLabel: t("templates.long_term_retention_check_in_question_9_lower_label"), + upperLabel: t("templates.long_term_retention_check_in_question_9_upper_label"), isColorCodingEnabled: true, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { default: t("templates.long_term_retention_check_in_question_10_headline") }, + t, + }), + buildOpenTextQuestion({ + headline: t("templates.long_term_retention_check_in_question_10_headline"), required: false, - placeholder: { default: t("templates.long_term_retention_check_in_question_10_placeholder") }, + placeholder: t("templates.long_term_retention_check_in_question_10_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const professionalDevelopmentGrowth = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.professional_development_growth_survey_name"), - role: "peopleManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.professional_development_growth_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.professional_development_growth_survey_name"), + role: "peopleManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.professional_development_growth_survey_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.professional_development_growth_survey_question_1_headline"), - }, + buildRatingQuestion({ + headline: t("templates.professional_development_growth_survey_question_1_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.professional_development_growth_survey_question_1_lower_label"), - }, - upperLabel: { - default: t("templates.professional_development_growth_survey_question_1_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.professional_development_growth_survey_question_2_headline"), - }, + lowerLabel: t("templates.professional_development_growth_survey_question_1_lower_label"), + upperLabel: t("templates.professional_development_growth_survey_question_1_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.professional_development_growth_survey_question_2_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.professional_development_growth_survey_question_2_lower_label"), - }, - upperLabel: { - default: t("templates.professional_development_growth_survey_question_2_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.professional_development_growth_survey_question_3_headline"), - }, + lowerLabel: t("templates.professional_development_growth_survey_question_2_lower_label"), + upperLabel: t("templates.professional_development_growth_survey_question_2_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.professional_development_growth_survey_question_3_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.professional_development_growth_survey_question_3_lower_label"), - }, - upperLabel: { - default: t("templates.professional_development_growth_survey_question_3_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.professional_development_growth_survey_question_4_headline"), - }, + lowerLabel: t("templates.professional_development_growth_survey_question_3_lower_label"), + upperLabel: t("templates.professional_development_growth_survey_question_3_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.professional_development_growth_survey_question_4_headline"), required: false, - placeholder: { - default: t("templates.professional_development_growth_survey_question_4_placeholder"), - }, + placeholder: t("templates.professional_development_growth_survey_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const recognitionAndReward = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.recognition_and_reward_survey_name"), - role: "peopleManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.recognition_and_reward_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.recognition_and_reward_survey_name"), + role: "peopleManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.recognition_and_reward_survey_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.recognition_and_reward_survey_question_1_headline"), - }, + buildRatingQuestion({ + headline: t("templates.recognition_and_reward_survey_question_1_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.recognition_and_reward_survey_question_1_lower_label"), - }, - upperLabel: { - default: t("templates.recognition_and_reward_survey_question_1_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.recognition_and_reward_survey_question_2_headline"), - }, + lowerLabel: t("templates.recognition_and_reward_survey_question_1_lower_label"), + upperLabel: t("templates.recognition_and_reward_survey_question_1_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.recognition_and_reward_survey_question_2_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.recognition_and_reward_survey_question_2_lower_label"), - }, - upperLabel: { - default: t("templates.recognition_and_reward_survey_question_2_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.recognition_and_reward_survey_question_3_headline"), - }, + lowerLabel: t("templates.recognition_and_reward_survey_question_2_lower_label"), + upperLabel: t("templates.recognition_and_reward_survey_question_2_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.recognition_and_reward_survey_question_3_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.recognition_and_reward_survey_question_3_lower_label"), - }, - upperLabel: { - default: t("templates.recognition_and_reward_survey_question_3_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.recognition_and_reward_survey_question_4_headline"), - }, + lowerLabel: t("templates.recognition_and_reward_survey_question_3_lower_label"), + upperLabel: t("templates.recognition_and_reward_survey_question_3_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.recognition_and_reward_survey_question_4_headline"), required: false, - placeholder: { - default: t("templates.recognition_and_reward_survey_question_4_placeholder"), - }, + placeholder: t("templates.recognition_and_reward_survey_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + t, + }), ], }, - }; + t + ); }; const alignmentAndEngagement = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.alignment_and_engagement_survey_name"), - role: "peopleManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.alignment_and_engagement_survey_description"), - preset: { - ...localSurvey, - name: "Alignment and Engagement with Company Vision", + return buildSurvey( + { + name: t("templates.alignment_and_engagement_survey_name"), + role: "peopleManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.alignment_and_engagement_survey_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.alignment_and_engagement_survey_question_1_headline"), - }, + buildRatingQuestion({ + headline: t("templates.alignment_and_engagement_survey_question_1_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.alignment_and_engagement_survey_question_1_lower_label"), - }, - upperLabel: { - default: t("templates.alignment_and_engagement_survey_question_1_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.alignment_and_engagement_survey_question_2_headline"), - }, + lowerLabel: t("templates.alignment_and_engagement_survey_question_1_lower_label"), + upperLabel: t("templates.alignment_and_engagement_survey_question_1_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.alignment_and_engagement_survey_question_2_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.alignment_and_engagement_survey_question_2_lower_label"), - }, - upperLabel: { - default: t("templates.alignment_and_engagement_survey_question_2_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.alignment_and_engagement_survey_question_3_headline"), - }, + lowerLabel: t("templates.alignment_and_engagement_survey_question_2_lower_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.alignment_and_engagement_survey_question_3_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.alignment_and_engagement_survey_question_3_lower_label"), - }, - upperLabel: { - default: t("templates.alignment_and_engagement_survey_question_3_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.alignment_and_engagement_survey_question_4_headline"), - }, + lowerLabel: t("templates.alignment_and_engagement_survey_question_3_lower_label"), + upperLabel: t("templates.alignment_and_engagement_survey_question_3_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.alignment_and_engagement_survey_question_4_headline"), required: false, - placeholder: { - default: t("templates.alignment_and_engagement_survey_question_4_placeholder"), - }, + placeholder: t("templates.alignment_and_engagement_survey_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; const supportiveWorkCulture = (t: TFnType): TTemplate => { - const localSurvey = getDefaultSurveyPreset(t); - return { - name: t("templates.supportive_work_culture_survey_name"), - role: "peopleManager", - industries: ["saas", "eCommerce", "other"], - channels: ["link"], - description: t("templates.supportive_work_culture_survey_description"), - preset: { - ...localSurvey, + return buildSurvey( + { name: t("templates.supportive_work_culture_survey_name"), + role: "peopleManager", + industries: ["saas", "eCommerce", "other"], + channels: ["link"], + description: t("templates.supportive_work_culture_survey_description"), questions: [ - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.supportive_work_culture_survey_question_1_headline"), - }, + buildRatingQuestion({ + headline: t("templates.supportive_work_culture_survey_question_1_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.supportive_work_culture_survey_question_1_lower_label"), - }, - upperLabel: { - default: t("templates.supportive_work_culture_survey_question_1_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.supportive_work_culture_survey_question_2_headline"), - }, + lowerLabel: t("templates.supportive_work_culture_survey_question_1_lower_label"), + upperLabel: t("templates.supportive_work_culture_survey_question_1_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.supportive_work_culture_survey_question_2_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.supportive_work_culture_survey_question_2_lower_label"), - }, - upperLabel: { - default: t("templates.supportive_work_culture_survey_question_2_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.Rating, - headline: { - default: t("templates.supportive_work_culture_survey_question_3_headline"), - }, + lowerLabel: t("templates.supportive_work_culture_survey_question_2_lower_label"), + upperLabel: t("templates.supportive_work_culture_survey_question_2_upper_label"), + t, + }), + buildRatingQuestion({ + headline: t("templates.supportive_work_culture_survey_question_3_headline"), required: true, scale: "number", range: 10, - lowerLabel: { - default: t("templates.supportive_work_culture_survey_question_3_lower_label"), - }, - upperLabel: { - default: t("templates.supportive_work_culture_survey_question_3_upper_label"), - }, - isColorCodingEnabled: false, - buttonLabel: { default: t("templates.next") }, - backButtonLabel: { default: t("templates.back") }, - }, - { - id: createId(), - type: TSurveyQuestionTypeEnum.OpenText, - charLimit: { - enabled: false, - }, - headline: { - default: t("templates.supportive_work_culture_survey_question_4_headline"), - }, + lowerLabel: t("templates.supportive_work_culture_survey_question_3_lower_label"), + upperLabel: t("templates.supportive_work_culture_survey_question_3_upper_label"), + t, + }), + buildOpenTextQuestion({ + headline: t("templates.supportive_work_culture_survey_question_4_headline"), required: false, - placeholder: { - default: t("templates.supportive_work_culture_survey_question_4_placeholder"), - }, + placeholder: t("templates.supportive_work_culture_survey_question_4_placeholder"), inputType: "text", - buttonLabel: { default: t("templates.finish") }, - backButtonLabel: { default: t("templates.back") }, - }, + buttonLabel: t("templates.finish"), + t, + }), ], }, - }; + t + ); }; export const templates = (t: TFnType): TTemplate[] => [ @@ -6980,51 +3518,35 @@ export const previewSurvey = (projectName: string, t: TFnType) => { segment: null, questions: [ { - id: "lbdxozwikh838yc6a8vbwuju", - type: "rating", - range: 5, - scale: "star", + ...buildRatingQuestion({ + id: "lbdxozwikh838yc6a8vbwuju", + range: 5, + scale: "star", + headline: t("templates.preview_survey_question_1_headline", { projectName }), + required: true, + subheader: t("templates.preview_survey_question_1_subheader"), + lowerLabel: t("templates.preview_survey_question_1_lower_label"), + upperLabel: t("templates.preview_survey_question_1_upper_label"), + t, + }), isDraft: true, - headline: { - default: t("templates.preview_survey_question_1_headline", { projectName }), - }, - required: true, - subheader: { - default: t("templates.preview_survey_question_1_subheader"), - }, - lowerLabel: { - default: t("templates.preview_survey_question_1_lower_label"), - }, - upperLabel: { - default: t("templates.preview_survey_question_1_upper_label"), - }, }, { - id: "rjpu42ps6dzirsn9ds6eydgt", - type: "multipleChoiceSingle", - choices: [ - { - id: "x6wty2s72v7vd538aadpurqx", - label: { - default: t("templates.preview_survey_question_2_choice_1_label"), - }, - }, - { - id: "fbcj4530t2n357ymjp2h28d6", - label: { - default: t("templates.preview_survey_question_2_choice_2_label"), - }, - }, - ], + ...buildMultipleChoiceQuestion({ + id: "rjpu42ps6dzirsn9ds6eydgt", + type: TSurveyQuestionTypeEnum.MultipleChoiceSingle, + choiceIds: ["x6wty2s72v7vd538aadpurqx", "fbcj4530t2n357ymjp2h28d6"], + choices: [ + t("templates.preview_survey_question_2_choice_1_label"), + t("templates.preview_survey_question_2_choice_2_label"), + ], + headline: t("templates.preview_survey_question_2_headline"), + backButtonLabel: t("templates.preview_survey_question_2_back_button_label"), + required: true, + shuffleOption: "none", + t, + }), isDraft: true, - headline: { - default: t("templates.preview_survey_question_2_headline"), - }, - backButtonLabel: { - default: t("templates.preview_survey_question_2_back_button_label"), - }, - required: true, - shuffleOption: "none", }, ], endings: [ diff --git a/apps/web/modules/survey/components/template-list/index.tsx b/apps/web/modules/survey/components/template-list/index.tsx index 4cfcc63c9d..0d7c99f2cb 100644 --- a/apps/web/modules/survey/components/template-list/index.tsx +++ b/apps/web/modules/survey/components/template-list/index.tsx @@ -105,7 +105,7 @@ export const TemplateList = ({ }; return ( -
+
{showFilters && !templateSearch && ( { await page.locator("#questionCard-4").getByLabel("textarea").fill("Much higher response rates!"); await page.locator("#questionCard-4").getByRole("button", { name: "Next" }).click(); await page.locator("#questionCard-5").getByLabel("textarea").fill("Make this end to end test pass!"); - await page.getByRole("button", { name: "Finish" }).click(); + await page.locator("#questionCard-5").getByRole("button", { name: "Next" }).click(); await page.getByTestId("loading-spinner").waitFor({ state: "hidden" }); await page.waitForLoadState("networkidle"); diff --git a/apps/web/vite.config.mts b/apps/web/vite.config.mts index 5abfa0b2e9..6219e31279 100644 --- a/apps/web/vite.config.mts +++ b/apps/web/vite.config.mts @@ -89,6 +89,7 @@ export default defineConfig({ "modules/account/**/*.ts", "modules/analysis/**/*.tsx", "modules/analysis/**/*.ts", + "app/lib/survey-builder.ts", "modules/survey/editor/components/end-screen-form.tsx", "lib/utils/billing.ts", "lib/crypto.ts", diff --git a/sonar-project.properties b/sonar-project.properties index edd7cd982e..fdeea7dd59 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -21,5 +21,5 @@ sonar.scm.exclusions.disabled=false sonar.sourceEncoding=UTF-8 # Coverage -sonar.coverage.exclusions=**/*.test.*,**/*.spec.*,**/*.mdx,**/*.config.mts,**/*.config.ts,**/constants.ts,**/route.ts,**/types/**,**/*.stories.*,**/mocks/**,**/__mocks__/**,**/openapi.ts,**/openapi-document.ts,**/instrumentation.ts,scripts/merge-client-endpoints.ts,**/playwright/**,**/Dockerfile,**/*.config.cjs,**/*.css -sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/*.mdx,**/*.config.mts,**/*.config.ts,**/constants.ts,**/route.ts,**/types/**,**/*.stories.*,**/mocks/**,**/__mocks__/**,**/openapi.ts,**/openapi-document.ts,**/instrumentation.ts,scripts/merge-client-endpoints.ts,**/playwright/**,**/Dockerfile,**/*.config.cjs,**/*.css +sonar.coverage.exclusions=**/*.test.*,**/*.spec.*,**/*.mdx,**/*.config.mts,**/*.config.ts,**/constants.ts,**/route.ts,**/types/**,**/*.stories.*,**/mocks/**,**/__mocks__/**,**/openapi.ts,**/openapi-document.ts,**/instrumentation.ts,scripts/merge-client-endpoints.ts,**/playwright/**,**/Dockerfile,**/*.config.cjs,**/*.css,**/templates.ts +sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/*.mdx,**/*.config.mts,**/*.config.ts,**/constants.ts,**/route.ts,**/types/**,**/*.stories.*,**/mocks/**,**/__mocks__/**,**/openapi.ts,**/openapi-document.ts,**/instrumentation.ts,scripts/merge-client-endpoints.ts,**/playwright/**,**/Dockerfile,**/*.config.cjs,**/*.css,**/templates.ts