Web-Dev-Path / web-dev-path

The Web Dev Path platform. Progressive Web App (PWA). Next.js rules!
https://webdevpath.co
GNU General Public License v3.0
33 stars 11 forks source link

[Bug] Name is not saving on mailchimp when the subscription checkbox is checked on the contact form #187

Closed cherylli closed 1 year ago

cherylli commented 1 year ago

What do we need to build or fix? Name is not saving on mailchimp when the subscription checkbox is checked on the contact form image image

Technical details This is probably because Name and other details except the email are not passed into FormData in components/ContactUsForm/index.js

This is what we have in the subscribe function now

if (data.Subscribe) {
    subscribe({ EMAIL: data.Email });
}

which is why only the email is added

Approach suggestions I suggest adding a name field to the subscribe function, which would look like

if (data.Subscribe) {
    subscribe({ 
       EMAIL: data.Email 
       NAME: data.Name
    });
}

Here is the link to the package we are using for reference, https://www.npmjs.com/package/react-mailchimp-subscribe

It might be best to create your own MailChimp account to test that the function is working before submitting the pull request

Deadline Please keep in mind that once you assign this task to yourself, you'll need to complete it in 10 days.

Acceptance criteria

mariana-caldas commented 1 year ago

Hey, team! Just a note that we see the same problem on the MailChimp list when subscribing from the Newsletter sections, so we need to test the fix both on the contact form and on the newsletter sections, please. Thanks!

Screen Shot 2023-08-11 at 5 32 06 PM
tonykieling commented 1 year ago

Working on branch bug/MailChimp-not-saving-name:

* details in a temp file /temp-notes.txt

Next step: assess and refactor \ and \ regarding the way they use \.

tonykieling commented 1 year ago

Three tasks: 1. refactor /api/contact.js and /api/register.jsI- Both APIs are checking reCaptcha (code repetition) and one of them is sending email.  G- Having a function to check reCaptcha and one to send email - avoids repetition.  N- Changing these 2 API files and also changing the components that call them in order to call the new API and have a naming normalization (they need to use the same variable names to call the API).

2. refactor \, \ and \ in order to have the same component structure.I- Right now there is code repetition and the components are implementing MailchimpSubscribe in different ways.  G- Having one \ that receives a child, making the component utilize the same variable names and data structure - the child will be a component that implements its own form and abstracts and uses \.  N- Changing file structure to have a dir for each component + form code to be adherent to the change.

3. create \ (need to investigate a bit more)I- There are two implementation of react-google-recaptcha lib causing duplicate code.  G- Having one component with logic centralized.  N- Create the component and call it when needed.

* I- Issue, G- Goal, N- Need * working to keep the same logic and messages btw FE and BE * working also based on the discussion with Mariana and Cheryl via Slack

tonykieling commented 1 year ago

Task #1

tonykieling commented 1 year ago

Task #2

* The way both components above handle messages is a bit different - see /components/ContacUs/index.js. * \ is attaching its props to the child when rendering both \ and . This way the child components can access and use resources.

mariana-caldas commented 1 year ago

That's great you're describing what you are doing on the issue, @tonykieling ! I like your ideas to solve the problem while refactoring the codebase. That's fantastic! Thanks! 🥷 Another way of doing that is to just submit a DRAFT PR as mentioned here: https://github.com/Web-Dev-Path/web-dev-path/wiki/Creating-a-Pull-Request#about-draft-pull-requests

tonykieling commented 1 year ago

Task #3

* This way has fewer props to be exchanged among components and it is easier to manage reCAPTCHA because it is centralized. Though, it mixes Mailchimp and reCAPTCHA implementations.