import React from "react"; import { IQuestionData } from "../types"; import chartImg2 from "../icons/chartImg2.png"; type Props = { question: IQuestionData; }; export const RRating = ({ question }: Props) => { const result = question.answers.reduce((acc: any, cur: any) => { acc[cur] = (acc[cur] || 0) + 1; return acc; }, {}); console.log(result); return (
{question.content.minRateDescription}
{question.content.choices.map((choice: any, index: number) => (
{choice.text} - {result[choice.text] ? result[choice.text] : 0}
))}
{question.content.maxRateDescription}
); };