diff --git a/src/helpers/validate.js b/src/helpers/validate.js
index 0b65264..71ef152 100644
--- a/src/helpers/validate.js
+++ b/src/helpers/validate.js
@@ -1,36 +1,52 @@
/* eslint-disable-next-line max-len */
// ----------------------------------Journal Validation------------------------------
-export const JournalValidation = (title, url, issn, rating, policyTitle,
-firstYear, lastYear, policyType, domain, date) =>{
- if(title.length<3 || url.length < 5 || issn.length<1 || rating.length<1 ||
- date.length<1 || policyTitle.length<1 || firstYear.length<1 || lastYear.length<1 ||
- policyType.length<1 || domain.length<1 || !date){
-
- return false
-
- }
-
- return true;
-
-}
+export const JournalValidation = (
+ title,
+ url,
+ issn,
+ rating,
+ policyTitle,
+ firstYear,
+ lastYear,
+ policyType,
+ domain,
+ date,
+) => {
+ if (
+ title.length < 3 ||
+ url.length < 5 ||
+ issn.length < 1 ||
+ rating.length < 1 ||
+ date.length < 1 ||
+ policyTitle.length < 1 ||
+ firstYear.length < 1 ||
+ lastYear.length < 1 ||
+ policyType.length < 1 ||
+ domain.length < 1 ||
+ !date
+ ) {
+ return false;
+ }
+
+ return true;
+};
// ----------------------------------Signup Validation------------------------------
-export const SignupValidation = ({username,email,password}) => {
- if(username<1||email<1||password<1)
- {
- return false;
- }
- return true;
-}
+export const SignupValidation = ({ username, email }) => {
+ if (username < 1 || email < 1) {
+ return false;
+ }
+
+ return true;
+};
// ----------------------------------Login Validation------------------------------
-export const LoginValidation = ({email,password}) => {
- if(email<1||password<1)
- {
- return false;
- }
- return true;
-}
\ No newline at end of file
+export const LoginValidation = ({ email, password }) => {
+ if (email < 1 || password < 1) {
+ return false;
+ }
+ return true;
+};
diff --git a/src/pages/Contact.js b/src/pages/Contact.js
index 70f7638..3c48994 100644
--- a/src/pages/Contact.js
+++ b/src/pages/Contact.js
@@ -4,90 +4,82 @@ import { Container, Row, Col, Form, Button } from 'react-bootstrap';
import { ImTwitter, ImMail, ImGithub } from 'react-icons/im';
import { FaGitter } from 'react-icons/fa';
-function Contact(){
- let formIsValid = false
+function Contact() {
+ let formIsValid = false;
const [email, setEmailAttr] = useState({
value: '',
- focused: false
- })
+ focused: false,
+ });
const [subject, setSubjectAttr] = useState({
value: '',
- focused: false
- })
+ focused: false,
+ });
const [message, setMessageAttr] = useState({
value: '',
- focused: false
- })
+ focused: false,
+ });
+ const setEmailVal = (e) => setEmailAttr((prev) => ({ ...prev, value: e.target.value }));
+ const setSubjectVal = (e) => setSubjectAttr((prev) => ({ ...prev, value: e.target.value }));
+ const setMsgVal = (e) => setMessageAttr((prev) => ({ ...prev, value: e.target.value }));
- const setEmailVal = e => setEmailAttr(prev => ({ ...prev, value: e.target.value }))
- const setSubjectVal = e => setSubjectAttr(prev => ({ ...prev, value: e.target.value }))
- const setMsgVal = e => setMessageAttr(prev => ({ ...prev, value: e.target.value }))
+ const setEmailFocus = () => setEmailAttr((prev) => ({ ...prev, focused: true }));
+ const setSubjectFocus = () => setSubjectAttr((prev) => ({ ...prev, focused: true }));
+ const setMsgFocus = () => setMessageAttr((prev) => ({ ...prev, focused: true }));
- const setEmailFocus = () => setEmailAttr(prev => ({ ...prev, focused: true }))
- const setSubjectFocus = () => setSubjectAttr(prev => ({ ...prev, focused: true }))
- const setMsgFocus = () => setMessageAttr(prev => ({ ...prev, focused: true }))
+ const emailIsValid = !!email.value;
+ const subjectIsValid = !!subject.value;
+ const messageIsValid = !!message.value;
- const emailIsValid = !!email.value
- const subjectIsValid = !!subject.value
- const messageIsValid = !!message.value
+ const emailIsInvalid = email.focused && !emailIsValid;
+ const subjectIsInvalid = subject.focused && !subjectIsValid;
+ const messageIsInvalid = message.focused && !messageIsValid;
- const emailIsInvalid = email.focused && !emailIsValid
- const subjectIsInvalid = subject.focused && !subjectIsValid
- const messageIsInvalid = message.focused && !messageIsValid
-
- formIsValid = emailIsValid && subjectIsValid && messageIsValid
+ formIsValid = emailIsValid && subjectIsValid && messageIsValid;
const formSubmitHandler = (e) => {
- e.preventDefault()
+ e.preventDefault();
if (!formIsValid) {
- console.log("INVALID FORM")
- return
+ // console.log('INVALID FORM');
+ return;
}
- console.log("PERFORM NETWORK REQUEST HERE")
- setEmailAttr({value:'',focused:false})
- setSubjectAttr({value:'',focused:false})
- setMessageAttr({value:'',focused:false})
-
- }
+ // console.log('PERFORM NETWORK REQUEST HERE');
+ setEmailAttr({ value: '', focused: false });
+ setSubjectAttr({ value: '', focused: false });
+ setMessageAttr({ value: '', focused: false });
+ };
return (
Ideas? Comments? Critiques? Want to help out? Here’s how to get in contact:
Email cannot be empty. Subject cannot be empty. Message cannot be empty.Contact Us
+ Contact Us