style(forms): ujednolicenie ekranu sukcesu i usuniecie zbednych opcji
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
'use client';
|
||||
|
||||
export function getRecaptchaToken(action: string = 'submit'): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
const siteKey = process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY;
|
||||
if (typeof window === 'undefined' || !siteKey || !(window as any).grecaptcha) {
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
(window as any).grecaptcha.ready(() => {
|
||||
(window as any).grecaptcha
|
||||
.execute(siteKey, { action })
|
||||
.then((token: string) => resolve(token))
|
||||
.catch(() => resolve(null));
|
||||
});
|
||||
} catch {
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user