mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 02:10:33 -05:00
fix response questions in wrong order FOR-558
This commit is contained in:
@@ -24,14 +24,17 @@ export default function ResponseTimeline({ environmentId, surveyId }) {
|
||||
|
||||
// Replace question IDs with question headlines in response data
|
||||
const updatedResponses = responses.map((response) => {
|
||||
const updatedData: Array<{ question: string; answer: string }> = []; // Specify the type of updatedData
|
||||
for (const [questionId, answer] of Object.entries(response.data)) {
|
||||
const questionHeadline = questionIdToHeadline[questionId];
|
||||
if (questionHeadline) {
|
||||
updatedData.push({ question: questionHeadline, answer: answer as string });
|
||||
const updatedResponse: Array<{ question: string; answer: string }> = []; // Specify the type of updatedData
|
||||
// iterate over survey questions and build the updated response
|
||||
for (const question of survey.questions) {
|
||||
const questionId = question.id;
|
||||
const questionHeadline = question.headline;
|
||||
const answer = response.data[questionId];
|
||||
if (answer) {
|
||||
updatedResponse.push({ question: questionHeadline, answer: answer as string });
|
||||
}
|
||||
}
|
||||
return { ...response, data: updatedData };
|
||||
return { ...response, responses: updatedResponse };
|
||||
});
|
||||
|
||||
return updatedResponses;
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
import { PersonAvatar } from "@formbricks/ui";
|
||||
import { timeSince } from "@formbricks/lib/time";
|
||||
import Link from "next/link";
|
||||
import { PersonAvatar } from "@formbricks/ui";
|
||||
import { CheckCircleIcon } from "@heroicons/react/24/solid";
|
||||
import Link from "next/link";
|
||||
|
||||
interface OpenTextSummaryProps {
|
||||
data: any;
|
||||
data: {
|
||||
id: string;
|
||||
personId: string;
|
||||
value: string;
|
||||
updatedAt: string;
|
||||
finished: boolean;
|
||||
responses: {
|
||||
id: string;
|
||||
question: string;
|
||||
answer: string;
|
||||
}[];
|
||||
};
|
||||
environmentId: string;
|
||||
}
|
||||
|
||||
@@ -42,7 +53,7 @@ export default function SingleResponse({ data, environmentId }: OpenTextSummaryP
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-6 rounded-b-lg bg-white p-6">
|
||||
{data.data.map((response) => {
|
||||
{data.responses.map((response) => {
|
||||
return (
|
||||
<div key={response.id}>
|
||||
<p className="text-sm text-slate-500">{response.question}</p>
|
||||
|
||||
Reference in New Issue
Block a user