File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
apps/docs/src/components/HubspotForm Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments