diff --git a/apps/core/client/queries/get-recaptcha-settings.ts b/apps/core/client/queries/get-recaptcha-settings.ts index 40804faef..c9b7f8ba7 100644 --- a/apps/core/client/queries/get-recaptcha-settings.ts +++ b/apps/core/client/queries/get-recaptcha-settings.ts @@ -6,6 +6,7 @@ const GET_RECAPTCHA_SETTINGS_QUERY = /* GraphQL */ ` site { settings { reCaptcha { + isEnabledOnStorefront siteKey } } diff --git a/apps/core/components/forms/contact-us.tsx b/apps/core/components/forms/contact-us.tsx index 79985c24b..14bd8c49a 100644 --- a/apps/core/components/forms/contact-us.tsx +++ b/apps/core/components/forms/contact-us.tsx @@ -27,13 +27,11 @@ interface ContactUsProps { fields: string[]; pageEntityId: number; reCaptchaSettings?: { + isEnabledOnStorefront: boolean; siteKey: string; }; } -// TODO: replace mocked var when enabled field will be added to GraphQL api -const IS_RECAPTCHA_ENABLED = true; - const fieldNameMapping = { fullname: 'Full name', companyname: 'Company name', @@ -89,8 +87,7 @@ export const ContactUs = ({ fields, pageEntityId, reCaptchaSettings }: ContactUs }; const onSubmit = async (formData: FormData) => { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (IS_RECAPTCHA_ENABLED && !reCaptchaToken) { + if (reCaptchaSettings?.isEnabledOnStorefront && !reCaptchaToken) { return setReCaptchaValid(false); } @@ -202,23 +199,20 @@ export const ContactUs = ({ fields, pageEntityId, reCaptchaSettings }: ContactUs - { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - IS_RECAPTCHA_ENABLED && ( - - - {!isReCaptchaValid && ( - - Pass ReCAPTCHA check - - )} - - ) - } + {reCaptchaSettings?.isEnabledOnStorefront && ( + + + {!isReCaptchaValid && ( + + Pass ReCAPTCHA check + + )} + + )}