api requests
This commit is contained in:
parent
fe74490440
commit
5a1cc7c43c
22 changed files with 665 additions and 133 deletions
|
|
@ -7,16 +7,18 @@ import Delete from '../../assets/deleteQuestion.svg?react';
|
|||
|
||||
|
||||
interface QuestionItemProps {
|
||||
indexQuestion: number;
|
||||
questionId: number;
|
||||
initialTextQuestion?: string;
|
||||
valueQuestion: string;
|
||||
onChangeQuestion: (valueQuestion: string) => void;
|
||||
onDeleteQuestion: (index: number) => void;
|
||||
onDeleteQuestion: (index: number) => Promise<void>;
|
||||
selectedType: 'single' | 'multiply'; // Уточняем тип
|
||||
setSelectedType: (type: 'single' | 'multiply') => void; // Уточняем тип
|
||||
}
|
||||
|
||||
const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQuestion = `Вопрос ${indexQuestion}`,
|
||||
valueQuestion, onChangeQuestion, onDeleteQuestion}) => {
|
||||
const [selectedType, setSelectedType] = useState<'single' | 'multiply'>('single');
|
||||
const QuestionItem: React.FC<QuestionItemProps> = ({questionId, initialTextQuestion = `Вопрос ${questionId}`,
|
||||
valueQuestion, onChangeQuestion, onDeleteQuestion, setSelectedType, selectedType}) => {
|
||||
// const [selectedType, setSelectedType] = useState<'single' | 'multiply'>('single');
|
||||
const [answerOption, setAnswerOption] = useState(['']);
|
||||
const [textQuestion, setTextQuestion] = useState(initialTextQuestion);
|
||||
const [isEditingQuestion, setIsEditingQuestion] = useState(false);
|
||||
|
|
@ -86,8 +88,12 @@ const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQu
|
|||
setTextQuestion(valueQuestion);
|
||||
}, [valueQuestion]);
|
||||
|
||||
const handleDeleteQuestion = () => {
|
||||
onDeleteQuestion(indexQuestion);
|
||||
const handleDeleteQuestion = async () => {
|
||||
try {
|
||||
await onDeleteQuestion(questionId);
|
||||
} catch (error) {
|
||||
console.error('Ошибка при удалении вопроса:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleSelect = (index: number) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue