1+ // eslint-disable-next-line no-unused-vars
12import React , { useState , useEffect } from 'react' ;
3+ import { useLocation } from 'react-router-dom' ;
4+ import { useDispatch } from 'react-redux' ;
5+ // import { set } from 'lodash';
26import styles from './SubscribePage.module.css' ; // Import the CSS module
37import {
48 removeNonHgnUserEmailSubscription ,
59 addNonHgnUserEmailSubscription ,
610} from '../../../actions/sendEmails' ;
7- import { useLocation } from 'react-router-dom' ;
8- import { useDispatch } from 'react-redux' ;
911import ConfirmationMessage from './ConfirmationMessage' ;
10- import { set } from 'lodash' ;
1112
12- const SubscribePage = ( ) => {
13+ function SubscribePage ( ) {
1314 const dispatch = useDispatch ( ) ;
1415 const query = new URLSearchParams ( useLocation ( ) . search ) ;
1516 const [ email , setEmail ] = useState ( '' ) ;
1617 const [ error , setError ] = useState ( '' ) ;
1718 const [ confirmationMessage , setConfirmationMessage ] = useState ( '' ) ;
1819 const [ confirmationStatus , setConfirmationStatus ] = useState ( false ) ;
1920 useEffect ( ( ) => {
20- const email = query . get ( 'email' ) ;
21- if ( email ) {
21+ const queryemail = query . get ( 'email' ) ;
22+ if ( queryemail ) {
2223 removeNonHgnUserEmailSubscription ( email ) . then ( result => {
2324 if ( result . success ) {
2425 // Handle success
@@ -33,8 +34,8 @@ const SubscribePage = () => {
3334 }
3435 } , [ query ] ) ;
3536
36- const validateEmail = email => {
37- return / \S + @ \S + \. \S + / . test ( email ) ;
37+ const validateEmail = emailval => {
38+ return / \S + @ \S + \. \S + / . test ( emailval ) ;
3839 } ;
3940
4041 const confirmationMessageCallback = ( ) => {
@@ -45,7 +46,7 @@ const SubscribePage = () => {
4546 event . preventDefault ( ) ;
4647 if ( validateEmail ( email ) ) {
4748 dispatch ( addNonHgnUserEmailSubscription ( email ) ) ;
48- console . log ( 'Email valid, submit to the server:' , email ) ;
49+ // console.log('Email valid, submit to the server:', email);
4950 setEmail ( '' ) ;
5051 setError ( '' ) ;
5152 } else {
@@ -55,13 +56,11 @@ const SubscribePage = () => {
5556
5657 if ( confirmationMessage ) {
5758 return (
58- < >
59- < ConfirmationMessage
60- message = { confirmationMessage }
61- isSuccess = { confirmationStatus }
62- confirmationMessageCallback = { confirmationMessageCallback }
63- />
64- </ >
59+ < ConfirmationMessage
60+ message = { confirmationMessage }
61+ isSuccess = { confirmationStatus }
62+ confirmationMessageCallback = { confirmationMessageCallback }
63+ />
6564 ) ;
6665 }
6766
@@ -70,9 +69,9 @@ const SubscribePage = () => {
7069 < h1 className = { styles . header } > Subscribe for Weekly Updates</ h1 >
7170 { /* ... */ }
7271 < p className = { styles . description } >
73- Join our mailing list for updates. We' ll send a confirmation to ensure you' re the owner of
74- the email provided. Once confirmed, we promise only a single email per week. Don't forget to
75- check your spam folder if you didn' t receive the confirmation!
72+ Join our mailing list for updates. We' ll send a confirmation to ensure you' re the
73+ owner of the email provided. Once confirmed, we promise only a single email per week.
74+ Don't forget to check your spam folder if you didn' t receive the confirmation!
7675 </ p >
7776 < p className = { styles . note } >
7877 Want to opt out later? No problem, every email has an unsubscribe link at the bottom.
@@ -92,6 +91,6 @@ const SubscribePage = () => {
9291 { /* ... */ }
9392 </ div >
9493 ) ;
95- } ;
94+ }
9695
9796export default SubscribePage ;
0 commit comments