Skip to content

Commit 771ae72

Browse files
docs: added url param after form submission
1 parent dec345c commit 771ae72

File tree

1 file changed

+11
-0
lines changed
  • apps/docs/src/components/HubspotForm

1 file changed

+11
-0
lines changed

apps/docs/src/components/HubspotForm/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ const HubspotForm: React.FC<HubspotFormProps> = ({
186186
},
187187
};
188188

189+
const url = new URL(window.location.href);
190+
189191
try {
190192
const response = await fetch(
191193
`https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formId}`,
@@ -209,14 +211,23 @@ const HubspotForm: React.FC<HubspotFormProps> = ({
209211
Object.keys(prev).forEach((k) => (cleared[k] = false));
210212
return cleared;
211213
});
214+
215+
url.searchParams.append('success', 'true');
216+
window.history.replaceState(null, null, url);
212217
} else {
213218
const data = await response.json();
214219
setStatus({ type: 'error', message: data.message });
215220
setIsSubmitting(false);
221+
222+
url.searchParams.append('success', 'false');
223+
window.history.replaceState(null, null, url);
216224
}
217225
} catch (error) {
218226
setStatus({ type: 'error', message: 'An unexpected error occurred. Please try again later.' });
219227
setIsSubmitting(false);
228+
229+
url.searchParams.append('success', 'false');
230+
window.history.replaceState(null, null, url);
220231
}
221232
};
222233

0 commit comments

Comments
 (0)