diff --git a/client/src/scss/_modalForm.scss b/client/src/scss/_modalForm.scss
index f6ee8c374..4f5146991 100644
--- a/client/src/scss/_modalForm.scss
+++ b/client/src/scss/_modalForm.scss
@@ -1,7 +1,4 @@
form {
- input.form-control:invalid {
- background-color: #fdd;
- }
button.form-btn-full-width {
width: 91.2%;
}
diff --git a/client/src/views/out/home/history/Editor.js b/client/src/views/out/home/history/Editor.js
index 351814a54..f972075f7 100644
--- a/client/src/views/out/home/history/Editor.js
+++ b/client/src/views/out/home/history/Editor.js
@@ -2,6 +2,7 @@ import CIcon from '@coreui/icons-react'
import {
CButton,
CForm,
+ CFormControl,
CImage,
CInputGroup,
CInputGroupText,
@@ -19,6 +20,7 @@ import ReactTooltip from 'react-tooltip'
const Editor = ({ visible, setVisible, add, dataForm, setDataForm, refetch }) => {
const [imgPreview, setImgPreview] = useState(new Array(dataForm.people.length).fill(false))
const [pending, setPending] = useState(false)
+ const [validated, setValidated] = useState(false)
const formRef = useRef(null)
const preventDefaultAndFocus = (e) => {
e.preventDefault()
@@ -64,8 +66,9 @@ const Editor = ({ visible, setVisible, add, dataForm, setDataForm, refetch }) =>
reader.readAsDataURL(file)
}
const handleSubmit = async () => {
+ setValidated(true) // display the validation message & style
// prevent the form from submitting if the form is invalid
- if (!formRef.current.reportValidity()) return
+ if (!formRef.current.checkValidity()) return
setPending(true)
const data = new FormData()
@@ -105,6 +108,7 @@ const Editor = ({ visible, setVisible, add, dataForm, setDataForm, refetch }) =>
}
setPending(false)
setVisible(false)
+ setValidated(false)
refetch()
}
@@ -115,12 +119,12 @@ const Editor = ({ visible, setVisible, add, dataForm, setDataForm, refetch }) =>
{add ? 'Add a year' : 'Edit this year'}
-
+
-
-
-
type="button"
name="name"
onClick={(e) => handlePeopleDelete(e, index)}
+ disabled={dataForm.people.length === 1 || pending}
>
x
@@ -191,13 +196,13 @@ const Editor = ({ visible, setVisible, add, dataForm, setDataForm, refetch }) =>
onMouseLeave={() => handleLeaveImgIcon(index)}
/>
- handleChangeImage(e, index)}