Skip to content

Feat: Add SubscriptionList#80

Merged
mariana-caetano merged 7 commits into
mainfrom
feat/subscription-list
Jun 22, 2026
Merged

Feat: Add SubscriptionList#80
mariana-caetano merged 7 commits into
mainfrom
feat/subscription-list

Conversation

@mariana-caetano

@mariana-caetano mariana-caetano commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Description

To test locally:

  1. Clone the repository.
  2. Run in the terminal yarn install.
  3. Change the branch to feat/subscription-list: git checkout feat/subscription-list.
  4. Run Storybook: yarn storybook.
  5. Go to http://localhost:6006/ and navigate to SubscriptionList in the left sidebar.
Screenshot_255

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: ['release-no', 'release-auto', 'release-patch', 'release-minor', 'release-major']

@mariana-caetano mariana-caetano self-assigned this Mar 31, 2026
@mariana-caetano mariana-caetano added the release-auto Automatic version bump label Mar 31, 2026
const emailEncoded = encodeURIComponent(email)
const url = baseURL + emailEncoded + urlEnd

fetch(url, { method: 'POST' })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should improve error handling.

For fetch(), 4xx and 5xx responses are not errors. They represent an error on the part of the API, but they don't trigger the .catch() (98). This means that if there is any error in zapier, or one of the services it uses, and fetch() returns 500, the user will get a success message, when in fact the email won't be registered to the subscription list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, @PedroAntunesCosta. I updated the Zapier fetch flow to use async/await and to show the success message only when response.ok is true. If the API returns a 4xx or 5xx status code, the user now sees the generic error message (subscription_list.error) instead of the success message.

The change is in this commit. Let me know what you think of this change.

return
}

const isValid = await checkEmail(email)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error treatment here is innacurate. checkEmail(email) can return false for reasons other than invalid emails:

  • The RapidAPI request fails.
  • The RapidAPI response is otherwise unusable.
  • NEXT_PUBLIC_NEWSLETTER_API_KEY is missing - (E.g., I tested the component with storybook and entered my VTEX email. I got the 'invalid email' error message and this was probably the reason.) This is probably not an issue in production once the environment is correctly configured.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, Pedro! The checkEmail now returns 'valid' | 'invalid' | 'error' instead of a boolean:

  • invalid: shows the invalid email message (only when RapidAPI returns block: true).
  • error: shows the generic error message (RapidAPI failure, unusable response, missing API key, etc.)
    It also checks response.ok before parsing the RapidAPI response.

To test in Storybook, NEXT_PUBLIC_NEWSLETTER_API_KEY needs to be set before running yarn storybook. Without it, the expected behavior is the generic error message: not “invalid email”.

I'll also follow up with Bruno to confirm that NEXT_PUBLIC_NEWSLETTER_API_KEY is configured on Netlify environments.

mariana-caetano and others added 2 commits June 22, 2026 10:28
Co-authored-by: Cursor <cursoragent@cursor.com>
Distinguish invalid emails from API failures and check Zapier response.ok before showing success.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mariana-caetano

Copy link
Copy Markdown
Contributor Author

@PedroAntunesCosta só mais uma dúvida em relação à variável de ambiente. Não tenho acesso ao netlify.
Para que a validação de e-mail funcione em produção, precisamos da variável de ambiente NEXT_PUBLIC_NEWSLETTER_API_KEY configurada no Netlify. Pode me confirmar:

  • Se a variável já existe nos projetos devportal e no helpcenter do Netlify?
  • Se o nome está exatamente como NEXT_PUBLIC_NEWSLETTER_API_KEY?
  • Se após configurar/alterar, podemos fazer redeploy?
    Obrigada!

@PedroAntunesCosta PedroAntunesCosta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@mariana-caetano mariana-caetano merged commit 3d81f59 into main Jun 22, 2026
1 check passed
@mariana-caetano mariana-caetano deleted the feat/subscription-list branch June 22, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-auto Automatic version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants