added callback function to captcha controller

This commit is contained in:
Miodec 2022-09-22 12:57:02 +02:00
parent 6fd6cdf55b
commit 6ab9a44ed2

View file

@ -2,13 +2,18 @@ const siteKey = "6Lc-V8McAAAAAJ7s6LGNe7MBZnRiwbsbiWts87aj";
const captchas: Record<string, number> = {};
export function render(element: HTMLElement, id: string): void {
export function render(
element: HTMLElement,
id: string,
callback?: (data: any) => void
): void {
if (captchas[id] !== undefined && captchas[id] !== null) {
return;
}
const widgetId = grecaptcha.render(element, {
sitekey: siteKey,
callback,
});
captchas[id] = widgetId;