diff --git a/src/components/footer/index.tsx b/src/components/footer/index.tsx index 5e7c6c8..998e394 100644 --- a/src/components/footer/index.tsx +++ b/src/components/footer/index.tsx @@ -1,108 +1,83 @@ -import React, { useState } from 'react' - +import React from 'react' import { Section } from '../shared' import { SolidButton } from '../shared/styledComponents' import { StyledHeading, StyledDesc, InputStyled, StyledAnchor } from './style' -const Footer = () => { - const [email, setEmail] = useState('') - const [emailError, setEmailError] = useState('') - - const handleEmailChange = (e: React.ChangeEvent) => { - const value = e.target.value - setEmail(value) - - if ( - value && - (value.toLowerCase().includes('@gmail.com') || - value.toLowerCase().includes('@googlemail.com')) - ) { - setEmailError('Gmail addresses are not allowed.') - } else { - setEmailError('') - } - } - - const handleSubmit = (e: React.FormEvent) => { - if (emailError) { - e.preventDefault() - } - } - - return ( -
-
-
- Data Controller - - Data Controller is a product of 4GL Apps, a brand of Bowe IO Ltd, - which is a UK company with a focus on SAS Software,{' '} - Apps, and - Services. - -
-
- Newsletter -
-
- - {emailError && ( -
- {emailError} -
- )} -
-
- -
-
- -
- Subscribe -
-
-
- Other Resources - - Visit our educational and fun SASĀ® software quiz{' '} - Sasensei{' '} - and test your knowledge of SAS topics. - -
-
-
- ) +const anchorStyles = { + color: '#888' } +const Footer = () => ( +
+
+
+ Data Controller + + Data Controller is a product of 4GL Apps, a brand of Bowe IO Ltd, + which is a UK company with a focus on SAS Software,{' '} + + Apps + + , and Services. + +
+
+ Newsletter +
+
+ +
+
+ +
+
+ +
+ Subscribe +
+
+
+ Other Resources + + Visit our educational and fun SASĀ® software quiz{' '} + + Sasensei + {' '} + and test your knowledge of SAS topics. + +
+
+
+) + export default Footer diff --git a/src/pages/contact.tsx b/src/pages/contact.tsx index 7dede26..0a2139b 100644 --- a/src/pages/contact.tsx +++ b/src/pages/contact.tsx @@ -37,10 +37,28 @@ const Contact: React.FC> = ({ data, location }) => { const [name, setName] = useState() const [email, setEmail] = useState() + const [emailError, setEmailError] = useState(false) const [subject, setSubject] = useState() const [message, setMessage] = useState() const [notification, setNotification] = useState() + const handleEmailChange = (e: React.ChangeEvent) => { + const value = e.target.value + setEmail(value) + + if ( + value && + (value.toLowerCase().includes('@gmail.com') || + value.toLowerCase().includes('@googlemail.com')) + ) { + setEmailError(true) + setNotification('Gmail addresses are not allowed.') + } else { + setEmailError(false) + setNotification(undefined) + } + } + const getBorderStyle = (value: string | undefined) => value === undefined ? {} : value ? {} : { border: '1px solid red' } @@ -66,6 +84,11 @@ const Contact: React.FC> = ({ data, location }) => { onSubmit={async (evt) => { evt.preventDefault() + // Prevent sending if emailError is set + if (emailError) { + return + } + if (name && email && subject && message) { const res = await nostrController .sendDM( @@ -121,10 +144,7 @@ Message: ${message}` name="email" rules="required|email" aria-describedby="emailHelp" - onChange={(evt) => { - setEmail(evt.target.value) - setNotification(undefined) - }} + onChange={handleEmailChange} style={getBorderStyle(email)} />