import React, { useCallback } from "react"; import { Choice } from "../../../../../../types/Item"; import QuestionFIeld from "../QuestionFIeld/QuestionFIeld"; import Choices from "../ChoiceField/Choices"; import { FaCirclePlus } from "react-icons/fa6"; import ValidationField from "../../../../../../Components/ValidationField/ValidationField"; import MaltySelectTag from "../Tags/MaltySelectTag"; import { toast } from "react-toastify"; import SelectTagV2 from "../../../../../../Components/CustomFields/SelectTagV2"; import LaTeXInputMemo from "../../../../../../Components/LatextInput/LaTeXInputMemo"; import { Field } from "formik"; export const Question: React.FC = React.memo(({ index, data }) => { const { values, setFieldValue, ShowHint, t } = data; const handleAddChoice = useCallback( (parent_index: number, fromKeyCombination: boolean = false) => { setFieldValue(`Questions.[${parent_index}].answers`, [ ...(values?.Questions?.[parent_index]?.answers as Choice[]), { answer: null, content_image: null, content: null, isCorrect: 0, }, ]); if (fromKeyCombination) { toast.success(t("header.new_choice_have_been_added")); } }, [setFieldValue, values, t], ); return (
{values?.Questions?.[index]?.answers?.length < 5 && (

handleAddChoice(index)} size={23} />{" "} {t("header.add_new_choice")}

)}
{ShowHint && ( )}
); });