-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from Web-Dev-Path/bug/MailChimp-not-saving-name
Fixing Mailchimp not saving name. Refactor reCaptcha file structure.
- Loading branch information
Showing
14 changed files
with
197 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import Mailchimp from '../Mailchimp'; | ||
import ContactUsForm from '@/components/ContactUs/ContactUsForm'; | ||
|
||
const ContactUs = ({ setMsg }) => { | ||
return <Mailchimp child={<ContactUsForm setResponseMessage={setMsg} />} />; | ||
}; | ||
|
||
export default ContactUs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import MailchimpSubscribe from 'react-mailchimp-subscribe'; | ||
import { cloneElement, useRef } from 'react'; | ||
import GoogleReCAPTCHA from 'react-google-recaptcha'; | ||
|
||
const MAILCHIMP_URL = process.env.NEXT_PUBLIC_MAILCHIMP_URL; | ||
const RECAPTCHA_SITE_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY; | ||
|
||
const Mailchimp = ({ child }) => { | ||
const reCAPTCHARef = useRef(null); | ||
let childToBeRendered = cloneElement(child); | ||
|
||
const getReCaptchaToken = async () => { | ||
await reCAPTCHARef.current.reset(); | ||
const token = await reCAPTCHARef.current.executeAsync(); | ||
return token; | ||
}; | ||
|
||
return ( | ||
<MailchimpSubscribe | ||
url={MAILCHIMP_URL} | ||
render={({ subscribe, status, message }) => { | ||
childToBeRendered = { | ||
...childToBeRendered, | ||
props: { | ||
...child.props, | ||
subscribe, | ||
status, | ||
message, | ||
getReCaptchaToken, | ||
}, | ||
}; | ||
|
||
return ( | ||
<GoogleReCAPTCHA | ||
ref={reCAPTCHARef} | ||
size='invisible' | ||
sitekey={RECAPTCHA_SITE_KEY} | ||
> | ||
{childToBeRendered} | ||
</GoogleReCAPTCHA> | ||
); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default Mailchimp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Mailchimp from '../Mailchimp'; | ||
import NewsletterForm from '@/components/NewsletterSubscribe/NewsletterForm'; | ||
|
||
const NewsletterSubscribe = () => { | ||
return <Mailchimp child={<NewsletterForm />} />; | ||
}; | ||
|
||
export default NewsletterSubscribe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.