Repository navigation
fix(ui): show HubSpot submission errors inline (blocked email, invali… - #164
Open
maccomaccomaccomacco wants to merge 1 commit into
Open
maccomaccomaccomacco wants to merge 1 commit into
maccomaccomaccomacco wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When HubSpot rejects a submission (e.g. a free email provider, which the Sales form blocks), the site shows a generic "Form submission failed. Please try again" plus a "review the highlighted fields" banner with nothing highlighted. Users have no way to know what to fix.
What changes
lib/hubspot.ts: 4xx responses from the HubSpot submissions API now throwHubSpotSubmissionErrorcarrying HubSpot's error list (errorType+ message). 5xx and network errors are unchanged.api/hubspot/submit/route.ts: on a HubSpot rejection, responds 400 witherrors: [{ code, message, field }]; the field is derived from the error type (email errors) or from HubSpot's message. Server errors still return 500 with the generic message.HubSpotSsrForm.tsx: field-level errors are shown inline under the field with a readable message per code (BLOCKED_EMAIL,INVALID_EMAIL,REQUIRED_FIELD, fallback). The "review the highlighted fields" banner now only shows when a field is actually highlighted. Errors with no matching field fall back to the existing alert, but with the precise reason.locales/en.json: newforms.errors.*strings.No change to the success flow or to HubSpot.
How to test
On the preview, submit
/contact-saleswith a gmail.com address: expect "Please use your work email address. Free email providers are not accepted." under Work Email, no red banner, no generic alert. Submit with a work email: unchanged success flow (no lead is created by the gmail test, HubSpot rejects it).