import React, { useState } from "react"; import { RatingType, AnswersType } from "../types"; type Props = { element: RatingType; answers: AnswersType | undefined; handleAnswer: () => void; }; export const ARatingForm = ({ element, answers, handleAnswer }: Props) => { const [selectedchoice, setSelectedchoice] = useState(""); const [answer, setAnswer] = useState(""); function buttonClick(event: React.MouseEvent) { event.preventDefault(); const { name } = event.currentTarget; // response.answers.map((a) => { // if (a.questionId === element._id) { // a.answer = name; // } // }); answers && (answers.answer = name); setAnswer(name); setSelectedchoice(event.currentTarget.name); handleAnswer(); } return (
{element.content.choices.map((choice) => (
))}
); };