From 0ed7964d61506844fc98645b4d8a10faa6fd58eb Mon Sep 17 00:00:00 2001 From: Vijay Kumar J Date: Fri, 14 Mar 2025 00:10:05 +0530 Subject: [PATCH 1/3] fix: email template to text component --- blocks/form/_form.json | 2 +- component-models.json | 2 +- temp.html | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 temp.html diff --git a/blocks/form/_form.json b/blocks/form/_form.json index f42b1b1..8f488d8 100644 --- a/blocks/form/_form.json +++ b/blocks/form/_form.json @@ -156,7 +156,7 @@ "condition": { "==": [{ "var": "useExternalEmailTemplate" }, true] } }, { - "component": "richtext", + "component": "text", "name": "template", "label": "Email template", "valueType": "string", diff --git a/component-models.json b/component-models.json index 46f76ca..6fdb8f4 100644 --- a/component-models.json +++ b/component-models.json @@ -442,7 +442,7 @@ } }, { - "component": "richtext", + "component": "text", "name": "template", "label": "Email template", "valueType": "string", diff --git a/temp.html b/temp.html new file mode 100644 index 0000000..fbc3e9f --- /dev/null +++ b/temp.html @@ -0,0 +1,5 @@ +

Account Opening Form

Account Opening Form
  • Personal Information
  • Investment Details
  • Vehicle Insurance Panel
Personal Information
+
+
Drag and Drop To Upload
+ +
Investment Details
Investment Type
Tax Liability
Terms & Conditions

By opening this investment account, you agree to provide accurate information and comply with all legal and regulatory requirements. Investments involve risk, and returns are not guaranteed. You authorize us to process transactions as instructed. We may update terms with notice. Misuse may lead to account suspension or closure

Vehicle Insurance Panel
Have you claimed insurance last year?
Terms & Conditions

By opening this insurance account, you agree to provide accurate information and comply with all legal and regulatory requirements. Insurance involves risk, and terms may change. Misuse may lead to account suspension or closure.

\ No newline at end of file From 091479bbfe2f08819f47603a4f21e2c57fd3e88e Mon Sep 17 00:00:00 2001 From: Vijay Kumar J Date: Mon, 17 Mar 2025 12:11:37 -0700 Subject: [PATCH 2/3] fix: Temporary fix for cors and thank you --- blocks/form/_form.json | 2 +- blocks/form/form.js | 2 +- blocks/form/rules/model/afb-runtime.js | 9 ++++++++- blocks/form/submit.js | 4 ++++ component-models.json | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/blocks/form/_form.json b/blocks/form/_form.json index 8f488d8..91b6e20 100644 --- a/blocks/form/_form.json +++ b/blocks/form/_form.json @@ -40,7 +40,7 @@ }, { "component": "richtext", - "name": "thankYouMessage", + "name": "thankYouMessageContent", "label": "Message Content", "valueType": "string", "condition": { "==": [{ "var": "thankYouOption" }, "message"] } diff --git a/blocks/form/form.js b/blocks/form/form.js index e70657d..d77f82b 100644 --- a/blocks/form/form.js +++ b/blocks/form/form.js @@ -574,7 +574,7 @@ export default async function decorate(block) { } } form.dataset.redirectUrl = formDef.redirectUrl || ''; - form.dataset.thankYouMsg = formDef.thankYouMsg || ''; + form.dataset.thankYouMsg = formDef.thankYouMsg || formDef?.properties?.thankYouMessageContent || ''; form.dataset.action = formDef.action || pathname?.split('.json')[0]; form.dataset.source = source; form.dataset.rules = rules; diff --git a/blocks/form/rules/model/afb-runtime.js b/blocks/form/rules/model/afb-runtime.js index b559bbf..10f3333 100644 --- a/blocks/form/rules/model/afb-runtime.js +++ b/blocks/form/rules/model/afb-runtime.js @@ -2595,7 +2595,7 @@ const request$1 = (url, data = null, options = {}) => { opts.body = data; } return fetch(updatedUrl, { - ...opts + ...opts, mode: 'no-cors' }).then(async (response) => { let body; if (!response.ok) { @@ -2616,6 +2616,13 @@ const request$1 = (url, data = null, options = {}) => { body, headers }; + }).catch(err => { + console.error(`Error while fetching response from ${url} : ${err}`); + return { + status: 500, + body: err, + headers: {} + }; }); }; const defaultRequestOptions = { diff --git a/blocks/form/submit.js b/blocks/form/submit.js index 17f9983..eea60c0 100644 --- a/blocks/form/submit.js +++ b/blocks/form/submit.js @@ -24,6 +24,10 @@ export function submitSuccess(e, form) { } export function submitFailure(e, form) { + if (e.payload.status === 0) { // TODO: remove this once we have a proper error handling + submitSuccess(e, form); + return; + } let errorMessage = form.querySelector('.form-message.error-message'); if (!errorMessage) { errorMessage = document.createElement('div'); diff --git a/component-models.json b/component-models.json index 6fdb8f4..33c27d3 100644 --- a/component-models.json +++ b/component-models.json @@ -291,7 +291,7 @@ }, { "component": "richtext", - "name": "thankYouMessage", + "name": "thankYouMessageContent", "label": "Message Content", "valueType": "string", "condition": { From 50541b7fdbbda1f4ff11a7d2b15101b8087a6c54 Mon Sep 17 00:00:00 2001 From: Vijay Kumar J Date: Mon, 17 Mar 2025 12:15:36 -0700 Subject: [PATCH 3/3] fix: Delete unnesseary file --- temp.html | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 temp.html diff --git a/temp.html b/temp.html deleted file mode 100644 index fbc3e9f..0000000 --- a/temp.html +++ /dev/null @@ -1,5 +0,0 @@ -

Account Opening Form

Account Opening Form
  • Personal Information
  • Investment Details
  • Vehicle Insurance Panel
Personal Information
-
-
Drag and Drop To Upload
- -
Investment Details
Investment Type
Tax Liability
Terms & Conditions

By opening this investment account, you agree to provide accurate information and comply with all legal and regulatory requirements. Investments involve risk, and returns are not guaranteed. You authorize us to process transactions as instructed. We may update terms with notice. Misuse may lead to account suspension or closure

Vehicle Insurance Panel
Have you claimed insurance last year?
Terms & Conditions

By opening this insurance account, you agree to provide accurate information and comply with all legal and regulatory requirements. Insurance involves risk, and terms may change. Misuse may lead to account suspension or closure.

\ No newline at end of file