styles type Dropdown
This commit is contained in:
parent
2cbfb06b4a
commit
05d5d396b8
8 changed files with 74 additions and 35 deletions
|
|
@ -11,10 +11,15 @@ interface QuestionItemProps {
|
|||
}
|
||||
|
||||
const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQuestion = `Вопрос ${indexQuestion}`}) => {
|
||||
const [selectedType, setSelectedType] = useState<'single' | 'multiply'>('single');
|
||||
|
||||
const [answerOption, setAnswerOption] = useState(['']);
|
||||
const [questionType] = useState('single');
|
||||
const [textQuestion, setTextQuestion] = useState(initialTextQuestion);
|
||||
|
||||
const handleTypeChange = (type: 'single' | 'multiply') => {
|
||||
setSelectedType(type);
|
||||
}
|
||||
|
||||
const handleAddAnswer = () => {
|
||||
setAnswerOption([...answerOption, '']);
|
||||
};
|
||||
|
|
@ -33,17 +38,15 @@ const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQu
|
|||
<div className={styles.questionCard}>
|
||||
<div className={styles.questionContainer}>
|
||||
<h2>
|
||||
<textarea
|
||||
value={textQuestion}
|
||||
onChange={handleQuestionChange}
|
||||
/>
|
||||
<textarea
|
||||
value={textQuestion}
|
||||
onChange={handleQuestionChange}
|
||||
/>
|
||||
</h2>
|
||||
{answerOption.map((answerText, index) => (
|
||||
<AnswerOption
|
||||
key={index}
|
||||
src={questionType === "single" ?
|
||||
'../../../public/radio_button_checked.svg' :
|
||||
'../../../public/check_box.svg' }
|
||||
selectedType={selectedType}
|
||||
index={index + 1} // Индекс ответа
|
||||
value={answerText}
|
||||
onChange={(value) => handleAnswerChange(index, value)}
|
||||
|
|
@ -54,7 +57,7 @@ const QuestionItem: React.FC<QuestionItemProps> = ({indexQuestion, initialTextQu
|
|||
onClick={handleAddAnswer}
|
||||
/>
|
||||
</div>
|
||||
<TypeDropdown/>
|
||||
<TypeDropdown selectedType={selectedType} onTypeChange={handleTypeChange}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue