Merge pull request 'SECURITY-1: Update to use data variables within webstudio' (#6) from security-audit into dev

Reviewed-on: #6
This commit is contained in:
oonyeje 2026-01-12 08:30:15 +00:00
commit 183f93ba4e
8 changed files with 78 additions and 42 deletions

View File

@ -1,10 +1,10 @@
{
"build": {
"id": "3a43926a-2e6a-4920-abed-f92de16a8c1e",
"id": "36ee14fe-0c68-48a1-be4a-6aa499bfd0ef",
"projectId": "363652e3-9846-4534-acdf-9b2b3c66eec0",
"version": 5219,
"createdAt": "2026-01-04T01:53:12.23+00:00",
"updatedAt": "2026-01-04T01:53:12.23+00:00",
"version": 5364,
"createdAt": "2026-01-12T08:23:59.138+00:00",
"updatedAt": "2026-01-12T08:23:59.138+00:00",
"pages": {
"meta": {
"siteName": "Inasa Healthcare",
@ -34353,8 +34353,8 @@
"id": "_qqplrsPXiYHnbqOoG1hr",
"instanceId": "FWErf923dUrcCtRUj8GsR",
"name": "code",
"type": "string",
"value": "<script>\n document.getElementById('contact.form').addEventListener('submit', async function(event) {\n const waitForJobCompletion = (UUID) => {\n return new Promise(async (resolve, reject) => {\n try {\n const endpoint = `https://windmill.bsidesolutions.net/api/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 VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I\"\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}/${CONTACT_FORM_WEBHOOK_URL_PATH}`; \n\n const webhookUrl = `https://windmill.bsidesolutions.net/api/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form`; \n const 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: \"$res:u/oonyeje/brevo_access_key\",\n body: {\n subject,\n sender: {\n name: \"Inasa Healthcare Website Correspondance\",\n email: \"site-contact@inasahealthcare.com\"\n },\n to: [{\n name: 'No Reply | Inasa Healthcare',\n email: \"info@inasahealthcare.com\"\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 VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I\"\n },\n body: JSON.stringify(formData) // Send data as JSON\n })\n }\n \n event.preventDefault(); // Prevent default form submission\n const jobTriggerResponse = await triggerJob();\n const UUID = await jobTriggerResponse.text();\n const jobCompletionData = await waitForJobCompletion(UUID);\n return jobCompletionData;\n });\n</script>\n"
"type": "expression",
"value": "`\\n<script>\\n document.getElementById('contact.form').addEventListener('submit', async function(event) {\\n const waitForJobCompletion = (UUID) => {\\n return new Promise(async (resolve, reject) => {\\n try {\\n const endpoint = \\`${$ws$dataSource$OoGpzflLwGU599Of6XYyx}/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 ${$ws$dataSource$tY64kzTEDE4QeLJeMYjs5}\\\"\\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 = \\\"${$ws$dataSource$OoGpzflLwGU599Of6XYyx}/${$ws$dataSource$DQMy1uq8RqjZWPsiXfW7d}\\\"; \\n\\n // const webhookUrl = \"https://windmill.bsidesolutions.net/api/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form\"; \\n const 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: \\\"${$ws$dataSource$Dczntj_56W3g4wZnKmj8I}\\\",\\n body: {\\n subject,\\n sender: {\\n name: \\\"Inasa Healthcare Website Correspondance\\\",\\n email: \\\"site-contact@${$ws$dataSource$Q8IuHMpgxoh8_RHrPMmfT}\\\"\\n },\\n to: [{\\n name: 'No Reply | Inasa Healthcare',\\n email: \\\"info@${$ws$dataSource$Q8IuHMpgxoh8_RHrPMmfT}\\\"\\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 ${$ws$dataSource$tY64kzTEDE4QeLJeMYjs5}\\\"\\n },\\n body: JSON.stringify(formData) // Send data as JSON\\n })\\n }\\n \\n event.preventDefault(); // Prevent default form submission\\n const jobTriggerResponse = await triggerJob();\\n const UUID = await jobTriggerResponse.text();\\n const jobCompletionData = await waitForJobCompletion(UUID);\\n return jobCompletionData;\\n });\\n</script>\\n`"
}
],
[
@ -35798,7 +35798,7 @@
"name": "WINDMILL_BASE_URL",
"value": {
"type": "string",
"value": "https://windmill.bsidesolutions.net/api/"
"value": "https://windmill.bsidesolutions.net/api"
}
}
],
@ -35808,10 +35808,10 @@
"type": "variable",
"id": "Q8IuHMpgxoh8_RHrPMmfT",
"scopeInstanceId": ":root",
"name": "OWNER_CONTACT_EMAIL",
"name": "OWNER_CONTACT_DOMAIN",
"value": {
"type": "string",
"value": "bsidesolution@gmail.com"
"value": "inasahealthcare.com"
}
}
],
@ -35840,6 +35840,32 @@
"value": "https://windmill.bsidesolutions.net/api/"
}
}
],
[
"tY64kzTEDE4QeLJeMYjs5",
{
"type": "variable",
"id": "tY64kzTEDE4QeLJeMYjs5",
"scopeInstanceId": ":root",
"name": "BREVO_JWT_TOKEN",
"value": {
"type": "string",
"value": "VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I"
}
}
],
[
"Dczntj_56W3g4wZnKmj8I",
{
"type": "variable",
"id": "Dczntj_56W3g4wZnKmj8I",
"scopeInstanceId": ":root",
"name": "BREVO_API_ACCESS_KEY_LITERAL",
"value": {
"type": "string",
"value": "$res:u/oonyeje/brevo_access_key"
}
}
]
],
"resources": [],
@ -42483,7 +42509,7 @@
"children": [
{
"type": "text",
"value": "Coordinated Care, Clear Boundaries"
"value": "Compassionate Care, Every Time"
}
]
}
@ -42532,7 +42558,7 @@
},
{
"type": "text",
"value": "we respect the importance of specialized care. Medical care and mental health care are provided independently, allowing focused treatment while maintaining the option for coordinated support when appropriate and with patient consent. We are committed to: Evidence-based treatment, Cultural sensitivity and inclusivity, Confidentiality and ethical practice, Patient education and shared decision-making."
"value": "medical care and mental health care are provided independently, allowing focused treatment while maintaining the option for coordinated support when appropriate with patient consent. We are committed to: Evidence-based treatment, Cultural sensitivity and inclusivity, Confidentiality and ethical practice, Patient education and shared decision-making."
}
]
}
@ -42637,7 +42663,7 @@
"children": [
{
"type": "id",
"value": "UpAWvSyTkV8ub27YboMR0"
"value": "o_0DU0YbNmyQumTWbkIw5"
},
{
"type": "text",
@ -42690,21 +42716,6 @@
]
}
],
[
"UpAWvSyTkV8ub27YboMR0",
{
"type": "instance",
"id": "UpAWvSyTkV8ub27YboMR0",
"component": "ws:element",
"tag": "b",
"children": [
{
"type": "text",
"value": "Separate, specialized medical and mental health services"
}
]
}
],
[
"dhgnZFmKZKFvvAddOMQT8",
{
@ -43631,7 +43642,22 @@
"children": [
{
"type": "text",
"value": "Schedule an In Office or Virtual Visit Today "
"value": "Schedule an In Office Visit Today "
}
]
}
],
[
"o_0DU0YbNmyQumTWbkIw5",
{
"type": "instance",
"id": "o_0DU0YbNmyQumTWbkIw5",
"component": "ws:element",
"tag": "b",
"children": [
{
"type": "text",
"value": "Separate medical and mental health services"
}
]
}

View File

@ -10,7 +10,7 @@ import { Fragment as Fragment_1, Slot as Slot, HtmlEmbed as HtmlEmbed, Image as
export const projectId = "363652e3-9846-4534-acdf-9b2b3c66eec0";
export const lastPublished = "2026-01-04T01:53:12.230Z";
export const lastPublished = "2026-01-12T08:23:59.138Z";
export const siteName = "Inasa Healthcare";

View File

@ -2,7 +2,7 @@
export const sitemap = [
{
"path": "/",
"lastModified": "2026-01-04"
"lastModified": "2026-01-12"
}
];

View File

@ -10,7 +10,7 @@ import { Link as Link, Body as Body } from "@webstudio-is/sdk-components-react-r
export const projectId = "363652e3-9846-4534-acdf-9b2b3c66eec0";
export const lastPublished = "2026-01-04T01:53:12.230Z";
export const lastPublished = "2026-01-12T08:23:59.138Z";
export const siteName = "Inasa Healthcare";
@ -233,7 +233,7 @@ className={`w-element c11b4pmf c1jkytp4 c98g4tl c4r4hj8`}>
className={`w-element chkwo5d`}>
<h2
className={`w-element c4r4hj8 c1m5mmlf cjnxebo`}>
{"Coordinated Care, Clear Boundaries"}
{"Compassionate Care, Every Time"}
</h2>
</div>
<div
@ -248,7 +248,7 @@ className={`w-element cd5fk7w cjnxebo c1o3gzl4 c4r4hj8 c18k0d33`}>
className={`w-element`}>
{"At INASA HEALTHCARE LLC, "}
</b>
{"we respect the importance of specialized care. Medical care and mental health care are provided independently, allowing focused treatment while maintaining the option for coordinated support when appropriate and with patient consent. We are committed to: Evidence-based treatment, Cultural sensitivity and inclusivity, Confidentiality and ethical practice, Patient education and shared decision-making."}
{"medical care and mental health care are provided independently, allowing focused treatment while maintaining the option for coordinated support when appropriate with patient consent. We are committed to: Evidence-based treatment, Cultural sensitivity and inclusivity, Confidentiality and ethical practice, Patient education and shared decision-making."}
</p>
</div>
</div>
@ -270,7 +270,7 @@ className={`w-element cd5fk7w crww4sf c3g7ft6 c15fz3od c1nuvu2f c8m2yga`}>
className={`w-element cd5fk7w cn4g1iq c1o3gzl4 c4r4hj8 c18k0d33`}>
<b
className={`w-element`}>
{"Separate, specialized medical and mental health services"}
{"Separate medical and mental health services"}
</b>
{""}
<br />

View File

@ -10,7 +10,7 @@ import { Link as Link, Body as Body, RemixForm as RemixForm } from "@webstudio-i
export const projectId = "363652e3-9846-4534-acdf-9b2b3c66eec0";
export const lastPublished = "2026-01-04T01:53:12.230Z";
export const lastPublished = "2026-01-12T08:23:59.138Z";
export const siteName = "Inasa Healthcare";
@ -29,6 +29,11 @@ import { Link as Link, Body as Body, RemixForm as RemixForm } from "@webstudio-i
const Page = (_props: { system: any; }) => {
let [WINDMILL_BASE_URL, set$WINDMILL_BASE_URL] = useVariableState<any>("https://windmill.bsidesolutions.net/api")
let [BREVO_JWT_TOKEN, set$BREVO_JWT_TOKEN] = useVariableState<any>("VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I")
let [CONTACT_FORM_WEBHOOK_URL_PATH, set$CONTACT_FORM_WEBHOOK_URL_PATH] = useVariableState<any>("w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form")
let [BREVO_API_ACCESS_KEY_LITERAL, set$BREVO_API_ACCESS_KEY_LITERAL] = useVariableState<any>("$res:u/oonyeje/brevo_access_key")
let [OWNER_CONTACT_DOMAIN, set$OWNER_CONTACT_DOMAIN] = useVariableState<any>("inasahealthcare.com")
return <Body
className={`w-element cdh6bof`}>
<Slot>
@ -353,7 +358,7 @@ className={`w-element cd5fk7w cv9zpwk`} />
</div>
<HtmlEmbed
executeScriptOnCanvas={true}
code={"<script>\n document.getElementById('contact.form').addEventListener('submit', async function(event) {\n const waitForJobCompletion = (UUID) => {\n return new Promise(async (resolve, reject) => {\n try {\n const endpoint = `https://windmill.bsidesolutions.net/api/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 VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I\"\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}/${CONTACT_FORM_WEBHOOK_URL_PATH}`; \n\n const webhookUrl = `https://windmill.bsidesolutions.net/api/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form`; \n const 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: \"$res:u/oonyeje/brevo_access_key\",\n body: {\n subject,\n sender: {\n name: \"Inasa Healthcare Website Correspondance\",\n email: \"site-contact@inasahealthcare.com\"\n },\n to: [{\n name: 'No Reply | Inasa Healthcare',\n email: \"info@inasahealthcare.com\"\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 VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I\"\n },\n body: JSON.stringify(formData) // Send data as JSON\n })\n }\n \n event.preventDefault(); // Prevent default form submission\n const jobTriggerResponse = await triggerJob();\n const UUID = await jobTriggerResponse.text();\n const jobCompletionData = await waitForJobCompletion(UUID);\n return jobCompletionData;\n });\n</script>\n"}
code={`\n<script>\n document.getElementById('contact.form').addEventListener('submit', async function(event) {\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}/${CONTACT_FORM_WEBHOOK_URL_PATH}\"; \n\n // const webhookUrl = "https://windmill.bsidesolutions.net/api/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form"; \n const 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: \"Inasa Healthcare Website Correspondance\",\n email: \"site-contact@${OWNER_CONTACT_DOMAIN}\"\n },\n to: [{\n name: 'No Reply | Inasa Healthcare',\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 event.preventDefault(); // Prevent default form submission\n const jobTriggerResponse = await triggerJob();\n const UUID = await jobTriggerResponse.text();\n const jobCompletionData = await waitForJobCompletion(UUID);\n return jobCompletionData;\n });\n</script>\n`}
className={`w-html-embed`} />
</div>
</section>

View File

@ -11,7 +11,7 @@ import { Dialog as Dialog, DialogTrigger as DialogTrigger, DialogOverlay as Dial
export const projectId = "363652e3-9846-4534-acdf-9b2b3c66eec0";
export const lastPublished = "2026-01-04T01:53:12.230Z";
export const lastPublished = "2026-01-12T08:23:59.138Z";
export const siteName = "Inasa Healthcare";

View File

@ -11,7 +11,7 @@ import { Body as Body, Link as Link } from "@webstudio-is/sdk-components-react-r
export const projectId = "363652e3-9846-4534-acdf-9b2b3c66eec0";
export const lastPublished = "2026-01-04T01:53:12.230Z";
export const lastPublished = "2026-01-12T08:23:59.138Z";
export const siteName = "Inasa Healthcare";
@ -766,7 +766,7 @@ className={`w-element c1bjdpvj c8i7g5u c1036zsb c1vub16f crww4sf c3g7ft6 c1o3gzl
<Link
href={"https://d2oe0ra32qx05a.cloudfront.net/?practiceKey=k_1_112536"}
className={`w-element c1uqshd c1co9a8n c1h1x3hd ccis0ah c3hg53i c4r4hj8`}>
{"Schedule an In Office or Virtual Visit Today "}
{"Schedule an In Office Visit Today "}
</Link>
</div>
</DialogContent>

View File

@ -11,7 +11,7 @@ import { Dialog as Dialog, DialogTrigger as DialogTrigger, DialogOverlay as Dial
export const projectId = "363652e3-9846-4534-acdf-9b2b3c66eec0";
export const lastPublished = "2026-01-04T01:53:12.230Z";
export const lastPublished = "2026-01-12T08:23:59.138Z";
export const siteName = "Inasa Healthcare";
@ -51,6 +51,11 @@ import { Dialog as Dialog, DialogTrigger as DialogTrigger, DialogOverlay as Dial
const Page = (_props: { system: any; }) => {
let [WINDMILL_BASE_URL, set$WINDMILL_BASE_URL] = useVariableState<any>("https://windmill.bsidesolutions.net/api")
let [BREVO_JWT_TOKEN, set$BREVO_JWT_TOKEN] = useVariableState<any>("VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I")
let [CONTACT_FORM_WEBHOOK_URL_PATH, set$CONTACT_FORM_WEBHOOK_URL_PATH] = useVariableState<any>("w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form")
let [BREVO_API_ACCESS_KEY_LITERAL, set$BREVO_API_ACCESS_KEY_LITERAL] = useVariableState<any>("$res:u/oonyeje/brevo_access_key")
let [OWNER_CONTACT_DOMAIN, set$OWNER_CONTACT_DOMAIN] = useVariableState<any>("inasahealthcare.com")
return <Body
className={`w-element cfm4hf3 ck6slji cdh6bof`}>
<Slot>
@ -921,7 +926,7 @@ className={`w-element c1bjdpvj c8i7g5u c1036zsb c1vub16f crww4sf c3g7ft6 c1o3gzl
<Link
href={"https://d2oe0ra32qx05a.cloudfront.net/?practiceKey=k_1_112536"}
className={`w-element c1uqshd c1co9a8n c1h1x3hd ccis0ah c3hg53i c4r4hj8`}>
{"Schedule an In Office or Virtual Visit Today "}
{"Schedule an In Office Visit Today "}
</Link>
</div>
</DialogContent>
@ -1304,7 +1309,7 @@ className={`w-element cd5fk7w cv9zpwk`} />
</div>
<HtmlEmbed
executeScriptOnCanvas={true}
code={"<script>\n document.getElementById('contact.form').addEventListener('submit', async function(event) {\n const waitForJobCompletion = (UUID) => {\n return new Promise(async (resolve, reject) => {\n try {\n const endpoint = `https://windmill.bsidesolutions.net/api/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 VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I\"\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}/${CONTACT_FORM_WEBHOOK_URL_PATH}`; \n\n const webhookUrl = `https://windmill.bsidesolutions.net/api/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form`; \n const 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: \"$res:u/oonyeje/brevo_access_key\",\n body: {\n subject,\n sender: {\n name: \"Inasa Healthcare Website Correspondance\",\n email: \"site-contact@inasahealthcare.com\"\n },\n to: [{\n name: 'No Reply | Inasa Healthcare',\n email: \"info@inasahealthcare.com\"\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 VTU7hlcLX0LDE2tyEYIQ1XSe4hVPU10I\"\n },\n body: JSON.stringify(formData) // Send data as JSON\n })\n }\n \n event.preventDefault(); // Prevent default form submission\n const jobTriggerResponse = await triggerJob();\n const UUID = await jobTriggerResponse.text();\n const jobCompletionData = await waitForJobCompletion(UUID);\n return jobCompletionData;\n });\n</script>\n"}
code={`\n<script>\n document.getElementById('contact.form').addEventListener('submit', async function(event) {\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}/${CONTACT_FORM_WEBHOOK_URL_PATH}\"; \n\n // const webhookUrl = "https://windmill.bsidesolutions.net/api/w/bside-hosted-websites/jobs/run/p/f/email_automations/send_a_transactional_email_for_website_contact_form"; \n const 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: \"Inasa Healthcare Website Correspondance\",\n email: \"site-contact@${OWNER_CONTACT_DOMAIN}\"\n },\n to: [{\n name: 'No Reply | Inasa Healthcare',\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 event.preventDefault(); // Prevent default form submission\n const jobTriggerResponse = await triggerJob();\n const UUID = await jobTriggerResponse.text();\n const jobCompletionData = await waitForJobCompletion(UUID);\n return jobCompletionData;\n });\n</script>\n`}
className={`w-html-embed`} />
</div>
</section>