mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-06 22:02:04 -05:00
fix: subheader validation (#2303)
This commit is contained in:
committed by
GitHub
parent
90f978bcd6
commit
26b8c4c7d5
+10
-9
@@ -60,17 +60,18 @@ const validationRules = {
|
||||
},
|
||||
// Assuming headline is of type TI18nString
|
||||
defaultValidation: (question: TSurveyQuestion, languages: TSurveyLanguage[]) => {
|
||||
// headline and subheader are default for every question
|
||||
const isHeadlineValid = isLabelValidForAllLanguages(question.headline, languages);
|
||||
let isValid = isHeadlineValid;
|
||||
const isSubheaderValid =
|
||||
question.subheader &&
|
||||
getLocalizedValue(question.subheader, "default").trim() !== "" &&
|
||||
languages.length > 1
|
||||
? isLabelValidForAllLanguages(question.subheader, languages)
|
||||
: true;
|
||||
let isValid = isHeadlineValid && isSubheaderValid;
|
||||
const defaultLanguageCode = "default";
|
||||
const fieldsToValidate = [
|
||||
"subheader",
|
||||
"html",
|
||||
"buttonLabel",
|
||||
"upperLabel",
|
||||
"backButtonLabel",
|
||||
"lowerLabel",
|
||||
];
|
||||
//question specific fields
|
||||
const fieldsToValidate = ["html", "buttonLabel", "upperLabel", "backButtonLabel", "lowerLabel"];
|
||||
|
||||
for (const field of fieldsToValidate) {
|
||||
if (question[field] && typeof question[field][defaultLanguageCode] !== "undefined") {
|
||||
|
||||
@@ -587,7 +587,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "What would have made {{productName}} easier to use?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
buttonLabel: { default: "Send" },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -612,7 +611,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "What features are you missing?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
inputType: "text",
|
||||
},
|
||||
{
|
||||
@@ -656,7 +654,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "Have you actively recommended {{productName}} to others?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -686,7 +683,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "Have you actively discouraged others from choosing {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -826,7 +822,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "star",
|
||||
headline: { default: "How do you like {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not good" },
|
||||
upperLabel: { default: "Very satisfied" },
|
||||
},
|
||||
@@ -927,7 +922,6 @@ export const templates: TTemplate[] = [
|
||||
default: "What's the main reason why you haven't finished setting up {{productName}}?",
|
||||
},
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -935,7 +929,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "What made you think {{productName}} wouldn't be useful?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -945,7 +938,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "What was difficult about setting up or using {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -955,7 +947,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "What features or functionality were missing?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -965,7 +956,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "How could we make it easier for you to get started?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -1006,7 +996,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "What do you value most about {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -1262,7 +1251,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "Which aspect is most important?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
],
|
||||
thankYouCard: thankYouCardDefault,
|
||||
@@ -1404,7 +1392,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How easy was it to set this integration up?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not easy" },
|
||||
upperLabel: { default: "Very easy" },
|
||||
},
|
||||
@@ -1566,7 +1553,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "smiley",
|
||||
headline: { default: "How satisfied are you with your {{productName}} experience?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not satisfied" },
|
||||
upperLabel: { default: "Very satisfied" },
|
||||
},
|
||||
@@ -1744,7 +1730,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "Which of these features would be MOST valuable to you?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -1758,7 +1743,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "Which of these features would be LEAST valuable to you?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: createId(),
|
||||
@@ -1874,7 +1858,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "{{productName}} makes it easy for me to [ADD GOAL]" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Disagree strongly" },
|
||||
upperLabel: { default: "Agree strongly" },
|
||||
},
|
||||
@@ -1910,7 +1893,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How easy or difficult was it to complete the checkout?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Very difficult" },
|
||||
upperLabel: { default: "Very easy" },
|
||||
},
|
||||
@@ -1954,7 +1936,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How relevant are these search results?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not at all relevant" },
|
||||
upperLabel: { default: "Very relevant" },
|
||||
},
|
||||
@@ -1998,7 +1979,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How well did this article address what you were hoping to learn?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not at all well" },
|
||||
upperLabel: { default: "Extremely well" },
|
||||
},
|
||||
@@ -2132,7 +2112,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How likely are you to sign up for {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not at all likely" },
|
||||
upperLabel: { default: "Very likely" },
|
||||
},
|
||||
@@ -2164,7 +2143,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "What is holding you back from trying {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: "atiw0j1oykb77zr0b7q4tixu",
|
||||
@@ -2249,7 +2227,6 @@ export const templates: TTemplate[] = [
|
||||
default: "How satisfied are you with the features and functionality of {{productName}}?",
|
||||
},
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not at all satisfied" },
|
||||
upperLabel: { default: "Extremely satisfied" },
|
||||
},
|
||||
@@ -2260,7 +2237,6 @@ export const templates: TTemplate[] = [
|
||||
default: "What's ONE change we could make to improve your {{productName}} experience most?",
|
||||
},
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -2292,7 +2268,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How likely are you to subscribe to {{productName}} today?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not at all likely" },
|
||||
upperLabel: { default: "Extremely likely" },
|
||||
},
|
||||
@@ -2341,7 +2316,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "smiley",
|
||||
headline: { default: "How would you rate this weeks newsletter?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Meh" },
|
||||
upperLabel: { default: "Great" },
|
||||
},
|
||||
@@ -2413,7 +2387,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "Thanks! How difficult or easy is it for you to [PROBLEM AREA] today?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Very difficult" },
|
||||
upperLabel: { default: "Very easy" },
|
||||
},
|
||||
@@ -2422,7 +2395,6 @@ export const templates: TTemplate[] = [
|
||||
type: TSurveyQuestionType.OpenText,
|
||||
headline: { default: "What's most difficult for you when it comes to [PROBLEM AREA]?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -2450,7 +2422,6 @@ export const templates: TTemplate[] = [
|
||||
scale: "number",
|
||||
headline: { default: "How valuable would this feature be to you?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
lowerLabel: { default: "Not valuable" },
|
||||
upperLabel: { default: "Very valuable" },
|
||||
},
|
||||
@@ -2526,7 +2497,6 @@ export const templates: TTemplate[] = [
|
||||
],
|
||||
headline: { default: "What's the main reason you haven't been back to {{productName}} recently?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
},
|
||||
{
|
||||
id: "r0zvi3vburf4hm7qewimzjux",
|
||||
@@ -2534,7 +2504,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "What's difficult about using {{productName}}?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -2544,7 +2513,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "Got it. Which alternative are you using instead?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -2554,7 +2522,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "Got it. How could we make it easier for you to get started?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -2564,7 +2531,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [{ condition: "submitted", destination: "end" }],
|
||||
headline: { default: "Got it. What features or functionality were missing?" },
|
||||
required: true,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
@@ -2574,7 +2540,6 @@ export const templates: TTemplate[] = [
|
||||
logic: [],
|
||||
headline: { default: "Please add more details:" },
|
||||
required: false,
|
||||
subheader: { default: "" },
|
||||
placeholder: { default: "Type your answer here..." },
|
||||
inputType: "text",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user