import React, { useState } from "react"; import { RatingType, AnswersType, AnswerProps } from "../types"; interface Props extends AnswerProps { element: RatingType; } 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; answers && (answers.answer = name); setAnswer(name); setSelectedchoice(event.currentTarget.name); handleAnswer(); } return (
{element.content.choices.map((choice) => (
))}
); };