import React, { useState } from "react"; import { RatingType, AnswerType } from "../types"; type Props = { element: RatingType; response: AnswerType; handleAnswer: () => void; }; export const ARatingForm = ({ element, response, 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; } }); setAnswer(name); setSelectedchoice(event.currentTarget.name); handleAnswer(); } return (
{element.content.choices.map((choice) => (
))}
); };