import React, { useState } from "react"; import { Pie } from "../charts/pies/Pie"; import { IQuestionData } from "../types"; import chartImg1 from "../icons/chartImg1.png"; type Props = { question: IQuestionData; }; export const RRadio = ({ question }: Props) => { const [dataset, setDataset] = useState([50, 30, 12, 5, 3]); const result = question.answers.reduce((acc: any, cur: any) => { acc[cur] = (acc[cur] || 0) + 1; return acc; }, {}); // console.log(result); return (
{question.content.choices.map((choice: any, index: number) => (
{choice.text} - {result[choice.text] ? result[choice.text] : 0}
))}
); };