mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-08 23:59:38 -06:00
* add vite survey package * add renderSurvey method * add all survey components * First working version of renderSurvey * integrate survey package into survey preview * add survey modal functionality to formbricks-surveys * fix build errors and add new template types * add response queue * add simple formbricks-js integration * add local state management for surveys * add local storage to multiple choice and open text questions * add local state to other question types, layout fixes * Fix modal close button, clean js package code * add new calculate progress function * fix progressbar on thankyou card * fix churn survey branching in demo product * use tsup to bundle @formbricks/js * update survey positioning in link surveys * fix preview reset button in link survey * change logic for progress bar * update progressbar logic * update spacing * add conditional autofocus / disable for iframe * add userId to link survey * integrated email verification * moved token verification and reading to server component * ran pnpm format * added question prefilling * ran pnpm format * Moved question prefilling logic to Link Survey * Refactor types * centralize survey package props, fix build errors * fix userId in link survey * fix survey closed message * add redirect on complete, fix bugs * smaller bugfixes * smaller bugfixes * fix bugs * fix build errors * remove logs --------- Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { Question } from "@/../../packages/types/questions";
|
|
import { TTemplate } from "@formbricks/types/v1/templates";
|
|
|
|
export const replaceQuestionPresetPlaceholders = (question: Question, product) => {
|
|
if (!question) return;
|
|
if (!product) return question;
|
|
const newQuestion = JSON.parse(JSON.stringify(question));
|
|
if (newQuestion.headline) {
|
|
newQuestion.headline = newQuestion.headline.replace("{{productName}}", product.name);
|
|
}
|
|
if (newQuestion.subheader) {
|
|
newQuestion.subheader = newQuestion.subheader?.replace("{{productName}}", product.name);
|
|
}
|
|
return newQuestion;
|
|
};
|
|
|
|
// replace all occurences of productName with the actual product name in the current template
|
|
export const replacePresetPlaceholders = (template: TTemplate, product: any) => {
|
|
const preset = JSON.parse(JSON.stringify(template.preset));
|
|
preset.name = preset.name.replace("{{productName}}", product.name);
|
|
preset.questions = preset.questions.map((question) => {
|
|
return replaceQuestionPresetPlaceholders(question, product);
|
|
});
|
|
return { ...template, preset };
|
|
};
|