Skip to content

feat(core): allow customer subscription to Newsletter#2784

Merged
jorgemoya merged 1 commit intocanaryfrom
catalyst-1588-add-subscribe-newsletter
Dec 19, 2025
Merged

feat(core): allow customer subscription to Newsletter#2784
jorgemoya merged 1 commit intocanaryfrom
catalyst-1588-add-subscribe-newsletter

Conversation

@jorgemoya
Copy link
Copy Markdown
Contributor

@jorgemoya jorgemoya commented Dec 17, 2025

What/Why?

Implement functional newsletter subscription feature with BigCommerce GraphQL API integration.

What Changed

  • Replaced the mock implementation in subscribe.ts with a real BigCommerce GraphQL API call using the SubscribeToNewsletterMutation.
  • Added comprehensive error handling for invalid emails, already-subscribed users, and unexpected errors.
  • Improved form error handling in InlineEmailForm to use form.errors instead of field-level errors for better error display.
  • Added comprehensive E2E tests and test fixtures for subscription functionality.

Testing

End to end tests and locally.

Kapture.2025-12-19.at.14.05.16.mp4

Migration

Replace the subscribe action in core/components/subscribe/_actions/subscribe.ts with the latest changes to include:

  • BigCommerce GraphQL mutation for newsletter subscription
  • Error handling for invalid emails, already-subscribed users, and unexpected errors
  • Proper error messages returned via Conform's submission.reply()

Update inline-email-form to fix issue of not showing server-side error messages from form actions.

core/vibes/soul/primitives/inline-email-form/index.tsx

  1. Add import for FieldError component:
import { FieldError } from '@/vibes/soul/form/field-error';
  1. Remove the field errors extraction:
// Remove: const { errors = [] } = fields.email;
  1. Update border styling to check both form and field errors:
// Changed from:
errors.length ? 'border-error' : 'border-black',

// Changed to:
form.errors?.length || fields.email.errors?.length
  ? 'border-error focus-within:border-error'
  : 'border-black focus-within:border-primary',
  1. Update error rendering to display both field-level and form-level errors:
// Changed from:
{errors.map((error, index) => (
  <FormStatus key={index} type="error">
    {error}
  </FormStatus>
))}

// Changed to:
{fields.email.errors?.map((error) => (
  <FieldError key={error}>{error}</FieldError>
))}
{form.errors?.map((error, index) => (
  <FormStatus key={index} type="error">
    {error}
  </FormStatus>
))}

This change ensures that server-side error messages returned from form actions (like formErrors from Conform's submission.reply()) are now properly displayed to users.

Add the following translation keys to your locale files (e.g., messages/en.json):

{
  "Components": {
    "Subscribe": {
      "title": "Sign up for our newsletter",
      "placeholder": "Enter your email",
      "description": "Stay up to date with the latest news and offers from our store.",
      "success": "You have been subscribed to our newsletter.",
      "Errors": {
        "subcriberAlreadyExists": "You are already subscribed to our newsletter.",
        "invalidEmail": "Please enter a valid email address.",
        "somethingWentWrong": "Something went wrong. Please try again later."
      }
    }
  }
}

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 17, 2025

🦋 Changeset detected

Latest commit: 631cb47

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
catalyst Ready Ready Preview, Comment Dec 19, 2025 8:26pm
catalyst-b2b Ready Ready Preview, Comment Dec 19, 2025 8:26pm
catalyst-canary Ready Ready Preview, Comment Dec 19, 2025 8:26pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
catalyst-uplift-vertex Ignored Ignored Dec 19, 2025 8:26pm

@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 5a9bdae to 3dbf6ff Compare December 17, 2025 19:39
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 3dbf6ff to af40fbf Compare December 17, 2025 22:52
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from af40fbf to b7c4528 Compare December 18, 2025 17:33
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from b7c4528 to 5e02654 Compare December 18, 2025 17:51
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 5e02654 to 41daacf Compare December 19, 2025 18:11
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 41daacf to 49f88d7 Compare December 19, 2025 18:17
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 49f88d7 to 43decbb Compare December 19, 2025 18:37
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 43decbb to d3d5b75 Compare December 19, 2025 18:41
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from d3d5b75 to f07025a Compare December 19, 2025 18:50
@jorgemoya jorgemoya marked this pull request as ready for review December 19, 2025 18:50
@jorgemoya jorgemoya requested a review from a team December 19, 2025 18:50
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from f07025a to 78534bd Compare December 19, 2025 20:14
@jorgemoya jorgemoya force-pushed the catalyst-1588-add-subscribe-newsletter branch from 78534bd to 631cb47 Compare December 19, 2025 20:15
@jorgemoya jorgemoya added this pull request to the merge queue Dec 19, 2025
Merged via the queue into canary with commit 7c626a7 Dec 19, 2025
9 checks passed
@jorgemoya jorgemoya deleted the catalyst-1588-add-subscribe-newsletter branch December 19, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants