Untitled
unknown
plain_text
a year ago
2.2 kB
42
Indexable
import React, { useState } from 'react'; import { Textarea, Textbox, Card, Label, Button, Group } from '@d-lift/uxcomponents'; const Questionnaire = () => { const [questions, setQuestions] = useState([{ question: '', description: '' }]); const handleAddQuestion = () => { setQuestions([...questions, { question: '', description: '' }]); }; const handleInputChange = (index, event) => { const { name, value } = event.target; const newQuestions = [...questions]; newQuestions[index][name] = value; setQuestions(newQuestions); }; const handleSubmit = (event) => { event.preventDefault(); console.log('Submitted data', questions); }; return ( <Card> {questions.map((q, index) => ( <div key={index}> <Label className="bold-font">Question {index + 1} :</Label> <Textbox name="question" model="RFIRequest.question" onChange={(e) => handleInputChange(index, e)}></Textbox> <Label className="bold-font" labelKey="request_desc"> {' '} </Label> <Textarea id="noresize" maxLength="100" model="textarea" rows="5" wrap="hard" model="RFIRequest.questionDesc" onChange={(e) => handleInputChange(index, e)}></Textarea> </div> ))} <Group> <Button id="addQues-btn" className="green-button" onClick={handleAddQuestion} labelKey="addQues_btn"></Button> <Button id="submit-btn" className="green-button" onClick={handleSubmit} labelKey="submit_btn"></Button> </Group> </Card> ); }; export default Questionnaire;
Editor is loading...
Leave a Comment