mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-25 15:59:06 -06:00
* Fix new Session event not triggered every time a new session is created * make syncWithBackend method private
21 lines
629 B
TypeScript
21 lines
629 B
TypeScript
import { Question } from "@formbricks/types/questions";
|
|
import { TResponse } from "@formbricks/types/v1/responses";
|
|
|
|
export const getQuestionResponseMapping = (
|
|
survey: { questions: Question[] },
|
|
response: TResponse
|
|
): { question: string; answer: string }[] => {
|
|
const questionResponseMapping: { question: string; answer: string }[] = [];
|
|
|
|
for (const question of survey.questions) {
|
|
const answer = response.data[question.id];
|
|
|
|
questionResponseMapping.push({
|
|
question: question.headline,
|
|
answer: typeof answer !== "undefined" ? answer.toString() : "",
|
|
});
|
|
}
|
|
|
|
return questionResponseMapping;
|
|
};
|