From 935c30e57f57c5433d6d6d8f497d8c50459a09cc Mon Sep 17 00:00:00 2001 From: jimmys-box <89916651+jimmys-box@users.noreply.github.com> Date: Thu, 17 Mar 2022 16:20:05 +0100 Subject: [PATCH] debug: --- components/form/CandidateField.jsx | 36 ++++++++++++++--------------- components/form/CandidatesField.jsx | 5 ++-- components/form/ConfirmModal.jsx | 10 ++++---- pages/new/index.js | 8 +++++-- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/components/form/CandidateField.jsx b/components/form/CandidateField.jsx index 91a3832..4f7e52a 100644 --- a/components/form/CandidateField.jsx +++ b/components/form/CandidateField.jsx @@ -8,7 +8,7 @@ import { Input, InputGroup, InputGroupAddon, - Button, Modal, ModalHeader, ModalBody, ModalFooter + Button, Modal, ModalHeader, ModalBody, Form } from "reactstrap"; import {useTranslation} from "react-i18next"; import { @@ -37,9 +37,20 @@ const CandidateField = ({avatar, label, description, candIndex, onDelete, onAdd, const [plusIcon, setPlusIcon] = useState("none"); const addCandidate = () => { + if (label != "") { toggle(); onAdd(); + setSelectedState(!selected); + } + else {} + } + if (label != "") { + const type = "button"; } + else { + const type = "submit"; + } + useEffect(() => { setClassName("candidateButton " + (selected ? "candidateAdded" : "")) }, [selected]); @@ -67,14 +78,8 @@ const CandidateField = ({avatar, label, description, candIndex, onDelete, onAdd, const uploadToClient = (event) => { if (event.target.files && event.target.files[0]) { const i = event.target.files[0]; - setImage(i); setCreateObjectURL(URL.createObjectURL(i)); - - - - - } }; @@ -101,17 +106,9 @@ const CandidateField = ({avatar, label, description, candIndex, onDelete, onAdd, - - - - - - - - - - + +
Ajouter un participant
@@ -159,11 +156,14 @@ const CandidateField = ({avatar, label, description, candIndex, onDelete, onAdd, - + +
diff --git a/components/form/CandidatesField.jsx b/components/form/CandidatesField.jsx index 1fdefea..8e96b13 100644 --- a/components/form/CandidatesField.jsx +++ b/components/form/CandidatesField.jsx @@ -46,7 +46,7 @@ const CandidatesField = ({onChange}) => { useEffect(() => { addCandidate(); - addCandidate(); + }, []) @@ -78,10 +78,11 @@ const CandidatesField = ({onChange}) => { if (index + 1 === candidates.length) { addCandidate(); } - else { + else { candidates[index + 1].fieldRef.current.focus(); } } + } const onSortEnd = ({oldIndex, newIndex}) => { diff --git a/components/form/ConfirmModal.jsx b/components/form/ConfirmModal.jsx index 9a77763..7f3ecc2 100644 --- a/components/form/ConfirmModal.jsx +++ b/components/form/ConfirmModal.jsx @@ -13,16 +13,16 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; const ConfirmModal = ({ tabIndex, title, candidates, grades, isTimeLimited, start, finish, emails, restrictResult, className, confirmCallback }) => { const [visibled, setVisibility] = useState(false); const { t } = useTranslation(); - const toggleConfirm = () => setVisibility(!visibled) + const toggle = () => setVisibility(!visibled) return (
-