@@ -1254,16 +1262,26 @@ className={`w-element`} />
+className={`w-element crww4sf c1ukwrqd c1o3gzl4 cx93287 c1nuvu2f c1lll4jc ci596ri`}>
+\n async function onRecaptcha(token) {\n const waitForJobCompletion = (UUID) => {\n return new Promise(async (resolve, reject) => {\n try {\n const endpoint = \`${WINDMILL_BASE_URL}/w/bside-hosted-websites/jobs_u/completed/get_result_maybe/\${UUID}\`;\n const checkResponse = await fetch(endpoint, {\n method: 'GET',\n headers: {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Bearer ${BREVO_JWT_TOKEN}\"\n }\n });\n \n const checkData = await checkResponse.json();\n \n if (checkData.completed) {\n document.getElementById('contact.responseMessage').innerText = 'Message sent successfully!';\n console.log('Success'); \n document.getElementById('contact.form').reset(); // Clear the form\n resolve(checkData);\n } else {\n // If not completed, wait for a second then try again\n setTimeout(async () => {\n const result = await waitForJobCompletion(UUID);\n resolve(result);\n }, 1000);\n }\n } catch (error) {\n document.getElementById('contact.responseMessage').innerText = 'Error sending message.';\n console.error('Error:', error);\n reject(error);\n }\n });\n }\n \n const triggerJob = async () => {\n const webhookUrl = \"${WINDMILL_BASE_URL}/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form\"; \n\nconst name = document.getElementById('contact.name').value;\n const subject = document.getElementById('contact.subject').value;\n const email = document.getElementById('contact.email').value;\n const message = document.getElementById('contact.message').value;\n \n const formData = {\n auth: ${BREVO_API_ACCESS_KEY_LITERAL},\n body: {\n subject,\n sender: {\n name: \"${PROJECT_NAME} Website Correspondance\",\n email: \"site-contact@${OWNER_CONTACT_DOMAIN}\"\n },\n to: [{\n name: 'No Reply | ${PROJECT_NAME}',\n email: \"info@${OWNER_CONTACT_DOMAIN}\"\n }],\n textContent: \`\${name} (\${email}) has sent the following message:\\n\\n\${message}\`,\n subject,\n replyTo: {\n name,\n email\n }\n }\n };\n \n return await fetch(webhookUrl, {\n method: 'POST',\n headers: {\n \"Content-Type\": \"application/json\",\n \"Authorization\": \"Bearer ${BREVO_JWT_TOKEN}\"\n },\n body: JSON.stringify(formData) // Send data as JSON\n })\n }\n \n if (!token.length > 0) {\n throw new Error(\"reCaptcha Token Response missing\")\n }\n\n try {\n const response = await fetch(\`https://recaptchaenterprise.googleapis.com/v1/projects/bside-hosted-webistes/assessments?key=${RECAPTCHA_API_KEY}\`, {\n method: 'POST',\n body: JSON.stringify({\n \"event\": {\n token,\n siteKey: "${RECAPTCHA_KEY}",\n }\n })\n })\n\n \n const data = await response.json()\n\n if ('tokenProperties' in data && data.tokenProperties?.valid) {\n if (document.getElementById('contact.form').reportValidity()) {\n const jobTriggerResponse = await triggerJob();\n const UUID = await jobTriggerResponse.text();\n const jobCompletionData = await waitForJobCompletion(UUID);\n \n return jobCompletionData;\n }\n }\n \n } catch (error) {\n console.log(error)\n throw new Error(\"reCaptcha Token Response score failed to verify\") \n }\n }\n`}
+executeScriptOnCanvas={false}
+clientOnly={false}
+className={`w-html-embed`} />
+className={`w-element crww4sf c99w2b6 cx93287 ckqrydf c1ed0fez cjesh6`} />