import React, { useState } from "react"; import { IRating, AnswerProps } from "../types"; interface Props extends AnswerProps { element: IRating; } export const ARatingForm = ({ element, answerQuestion }: Props) => { const [selectedchoice, setSelectedchoice] = useState(""); const [answer, setAnswer] = useState(""); function buttonClick(event: React.MouseEvent) { event.preventDefault(); const { name } = event.currentTarget; answerQuestion.answer = name; setAnswer(name); setSelectedchoice(event.currentTarget.name); if (answerQuestion.answer) { answerQuestion.requiredCheck = true; } else { answerQuestion.requiredCheck = false; } console.log(answerQuestion); } return (
{element.content.choices.map((choice) => (
))}
); };