-- update to use data variables
This commit is contained in:
parent
518ff044fd
commit
3058682c9b
@ -1,10 +1,10 @@
|
||||
{
|
||||
"build": {
|
||||
"id": "3a43926a-2e6a-4920-abed-f92de16a8c1e",
|
||||
"id": "0fa6d084-a975-4ebd-8c09-aebcb05c2326",
|
||||
"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": 5355,
|
||||
"createdAt": "2026-01-05T00:35:32.408+00:00",
|
||||
"updatedAt": "2026-01-05T00:35:32.408+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": [],
|
||||
|
||||
2
app/__generated__/$.tsx
generated
2
app/__generated__/$.tsx
generated
@ -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-05T00:35:32.408Z";
|
||||
|
||||
export const siteName = "Inasa Healthcare";
|
||||
|
||||
|
||||
2
app/__generated__/$resources.sitemap.xml.ts
generated
2
app/__generated__/$resources.sitemap.xml.ts
generated
@ -2,7 +2,7 @@
|
||||
export const sitemap = [
|
||||
{
|
||||
"path": "/",
|
||||
"lastModified": "2026-01-04"
|
||||
"lastModified": "2026-01-05"
|
||||
}
|
||||
];
|
||||
|
||||
2
app/__generated__/[about]._index.tsx
generated
2
app/__generated__/[about]._index.tsx
generated
@ -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-05T00:35:32.408Z";
|
||||
|
||||
export const siteName = "Inasa Healthcare";
|
||||
|
||||
|
||||
9
app/__generated__/[contact]._index.tsx
generated
9
app/__generated__/[contact]._index.tsx
generated
@ -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-05T00:35:32.408Z";
|
||||
|
||||
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>
|
||||
|
||||
2
app/__generated__/[insurance]._index.tsx
generated
2
app/__generated__/[insurance]._index.tsx
generated
@ -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-05T00:35:32.408Z";
|
||||
|
||||
export const siteName = "Inasa Healthcare";
|
||||
|
||||
|
||||
2
app/__generated__/[services]._index.tsx
generated
2
app/__generated__/[services]._index.tsx
generated
@ -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-05T00:35:32.408Z";
|
||||
|
||||
export const siteName = "Inasa Healthcare";
|
||||
|
||||
|
||||
9
app/__generated__/_index.tsx
generated
9
app/__generated__/_index.tsx
generated
@ -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-05T00:35:32.408Z";
|
||||
|
||||
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>
|
||||
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user