From 5ceaac5e3dacb3bc7ef0ebb5a4f238d2fd52c41e Mon Sep 17 00:00:00 2001 From: kuwsh1n Date: Mon, 26 Feb 2024 00:54:28 +0300 Subject: [PATCH] add checkbox by answer --- src/assets/styles/components/myModal.module.scss | 14 ++++++++++++++ src/components/MyModal.jsx | 6 ++++++ src/pages/NewForm.jsx | 8 +++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/assets/styles/components/myModal.module.scss b/src/assets/styles/components/myModal.module.scss index 131684f..c17db0f 100644 --- a/src/assets/styles/components/myModal.module.scss +++ b/src/assets/styles/components/myModal.module.scss @@ -50,6 +50,20 @@ padding: 0 1%; } } + &__mandatory { + margin-top: 5%; + display: flex; + align-items: center; + &__title { + display: block; + font-size: 15px; + font-family: "Montserrat", sans-serif + } + &__choice { + display: block; + margin-left: 10px; + } + } &__time { margin-top: 5%; span { diff --git a/src/components/MyModal.jsx b/src/components/MyModal.jsx index 9badffb..621dc05 100644 --- a/src/components/MyModal.jsx +++ b/src/components/MyModal.jsx @@ -12,6 +12,8 @@ const MyModal = ({ listTypeAnswer, comment, datetime, + mandatory, + setMandatory, setAnswer, setComment, setDatetime, @@ -49,6 +51,10 @@ const MyModal = ({ Комментарий +
+ Обязательный вопрос + setMandatory(!mandatory)}/> +
Дедлайн выполнения setDatetime(event.target.value)}/> diff --git a/src/pages/NewForm.jsx b/src/pages/NewForm.jsx index 459535f..caf6d86 100644 --- a/src/pages/NewForm.jsx +++ b/src/pages/NewForm.jsx @@ -19,6 +19,7 @@ const NewForm = () => { const [answer, setAnswer] = useState(""); const [comment, setComment] = useState(""); const [datetime, setDatetime] = useState(""); + const [mandatory, setMandatory] = useState(false); const [file, setFile] = useState([]); const [currentTypeAnswer, setCurrentTypeAnswer] = useState(""); @@ -48,6 +49,7 @@ const NewForm = () => { setDatetime(""); setFile(""); setCurrentTypeAnswer(""); + setMandatory(false); } function editAnswerByForm(id) { @@ -57,17 +59,18 @@ const NewForm = () => { setDatetime(obj.datetime); setFile(obj.file); setCurrentTypeAnswer(obj.typeAnswer); + setMandatory(obj.mandatory) setStateModal(id); } function updateAnswerByForm() { - console.log(currentTypeAnswer) setNewForm(newForm.map(item => { if (item.id === stateModal) { item.answer = answer; item.comment = comment; item.datetime = datetime; item.file = file; + item.mandatory = mandatory; item.typeAnswer = currentTypeAnswer; } return item @@ -82,6 +85,7 @@ const NewForm = () => { typeAnswer: currentTypeAnswer, comment: comment, datetime: datetime, + mandatory: mandatory, file: file }]); cleanStates(); @@ -142,6 +146,7 @@ const NewForm = () => { currentTypeAnswer={currentTypeAnswer} answer={answer} comment={comment} + mandatory={mandatory} datetime={datetime} file={file} listTypeAnswer={listTypeAnswer} @@ -149,6 +154,7 @@ const NewForm = () => { setComment={setComment} setDatetime={setDatetime} setFile={setFile} + setMandatory={setMandatory} cleanStates={cleanStates} saveStates={saveStates} updateAnswerByForm={updateAnswerByForm}