-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[site,newsletter][s]: fix hero newsletter form (broken after Brevo up…
…date)
- Loading branch information
Showing
3 changed files
with
66 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
import { HTMLProps } from "react"; | ||
|
||
const loadScript = ( | ||
props: HTMLProps<HTMLScriptElement> & { textContent?: string } | ||
): (() => void) => { | ||
const script = document.createElement("script"); | ||
Object.assign(script, props); | ||
document.head.appendChild(script); | ||
return () => document.head.removeChild(script); | ||
}; | ||
|
||
export const loadScripts = () => { | ||
const formValidationScript = loadScript({ | ||
id: "newsletter-form-validation-message", | ||
textContent: ` | ||
window.LOCALE = 'en'; | ||
window.EMAIL_INVALID_MESSAGE = "The information provided is invalid. Please review the field format and try again."; | ||
window.REQUIRED_ERROR_MESSAGE = "This field cannot be left blank. "; | ||
window.GENERIC_INVALID_MESSAGE = "The information provided is invalid. Please review the field format and try again."; | ||
window.translation = { | ||
common: { | ||
selectedList: '{quantity} list selected', | ||
selectedLists: '{quantity} lists selected' | ||
} | ||
}; | ||
var AUTOHIDE = Boolean(0); | ||
`, | ||
}); | ||
|
||
const formSubmitScript = loadScript({ | ||
id: "newsletter-submit-form", | ||
src: "https://sibforms.com/forms/end-form/build/main.js", | ||
async: true, | ||
defer: true, | ||
}); | ||
|
||
return { | ||
resetElements: () => { | ||
formSubmitScript(); | ||
formValidationScript(); | ||
}, | ||
}; | ||
}; | ||
|
4bc7ce5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
site-portaljs – ./site
site-portaljs-git-main-datopian1.vercel.app
www.portaljs.org
portaljs.org
site-portaljs-datopian1.vercel.app
docs-portaljs.vercel.app