import { FC, useState, } from "react"; import { ItemsSelectionView } from "./ItemsSelectionView/ItemsSelectionView"; import { ItemDetailsView } from "./ItemDetailsView/ItemDetailsView"; import { Box } from "@mui/material"; import { QuestionKeys, SelectedQuestions, TagKeys } from "../types"; type Items = { id: string; title: string; subTitle?: string; }; type Props = { questionsItems: Items[] | []; selectedQuestions: SelectedQuestions; handleAddQuestion: (scope: QuestionKeys | TagKeys, id: string, type: "question" | "tag") => void; handlePrevStep: () => void; handleNextStep: () => void; }; export const AmoQuestions: FC = ({ questionsItems, selectedQuestions, handleAddQuestion, handlePrevStep, handleNextStep, }) => { const [isSelection, setIsSelection] = useState(false); const [activeScope, setActiveScope] = useState(null); const [selectedQuestion, setSelectedQuestion] = useState(null); const handleAdd = () => { if (activeScope === null || selectedQuestion === null) return handleAddQuestion(activeScope, selectedQuestion, "question") } return ( {isSelection && activeScope !== null ? ( // Здесь выбираем элемент в табличку { setActiveScope(null); setIsSelection(false); }} onLargeBtnClick={() => { handleAdd(); setActiveScope(null); setIsSelection(false); }} /> ) : ( // Табличка )} ); };