mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-22 19:39:01 -05:00
21 lines
638 B
TypeScript
21 lines
638 B
TypeScript
import { TResponse } from "@formbricks/types/responses";
|
|
import { TSurveyQuestion } from "@formbricks/types/surveys";
|
|
|
|
export const getQuestionResponseMapping = (
|
|
survey: { questions: TSurveyQuestion[] },
|
|
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;
|
|
};
|