Files
formbricks/packages/lib/responses.ts
Anshuman Pandey 892776c493 refactor: moves team settings to server components (#693)
* feat: moves edit team name to server components

* feat: server components for membership roles

* feat: adds server actions and services

* fix: fixes invite server action

* feat: adds packages for jwt and email

* feat: server actions

* feat: moves edit memberships logic to server components

* feat: moves delete team logic to server components

* fix: fixes team loading states

* rename getAllMembershipsByUserId -> getMembershipsByUserId

* remove cache from mutating functions

* remove cache from updateInvite

* refactoring

* fix build error

---------

Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
2023-09-18 17:32:42 +09:00

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;
};