From 1aa93ac548bfc60c4b3234f032b1b5db782827ef Mon Sep 17 00:00:00 2001 From: david ornelas Date: Wed, 3 Jul 2024 13:39:36 -0700 Subject: [PATCH 1/3] fix(app-rfi): fix false error display on studentstatus N --- .../src/core/utils/submission-helpers.js | 3 +- shared/utils/deep-cloner.js | 31 +++++++++++++++++++ shared/utils/index.js | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 shared/utils/deep-cloner.js diff --git a/packages/app-rfi/src/core/utils/submission-helpers.js b/packages/app-rfi/src/core/utils/submission-helpers.js index 4c605fa261..572ad25d9f 100644 --- a/packages/app-rfi/src/core/utils/submission-helpers.js +++ b/packages/app-rfi/src/core/utils/submission-helpers.js @@ -1,6 +1,7 @@ // @ts-check import { KEY } from "./constants"; import { pushDataLayerEventToGa, setClientId } from "./google-analytics"; +import { deepCloner } from "../../../../../shared/utils"; /** * In order to make a field not required, we set the default or blank value @@ -97,7 +98,7 @@ function submissionSetHiddenFields(payload, test) { export const rfiSubmit = (value, submissionUrl, test, callback = a => ({})) => { // MARSHALL FIELDS FOR THE PAYLOAD - let payload = value; + let payload = deepCloner(value); payload = submissionFormFieldPrep(payload); payload = submissionSetHiddenFields(payload, test); payload = removeUnansweredFields(payload); diff --git a/shared/utils/deep-cloner.js b/shared/utils/deep-cloner.js new file mode 100644 index 0000000000..d087906fb0 --- /dev/null +++ b/shared/utils/deep-cloner.js @@ -0,0 +1,31 @@ +function deepCloner(obj) { + // Check if the object is null or not an object, return it if so + if (obj === null || typeof obj !== 'object') { + return obj; + } + + // Handle Date + if (obj instanceof Date) { + return new Date(obj.getTime()); + } + + // Handle Array + if (Array.isArray(obj)) { + const arrCopy = []; + for (let i = 0; i < obj.length; i++) { + arrCopy[i] = deepClone(obj[i]); + } + return arrCopy; + } + + // Handle Object + const objCopy = {}; + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + objCopy[key] = deepClone(obj[key]); + } + } + return objCopy; +}; + +export { deepCloner }; diff --git a/shared/utils/index.js b/shared/utils/index.js index 3850f85914..9be2d9f750 100644 --- a/shared/utils/index.js +++ b/shared/utils/index.js @@ -18,3 +18,4 @@ export * from "./id-generator"; export * from "./numbers"; export * from "./script-utils"; export * from "./timers"; +export * from "./deep-cloner"; From e20c43bba05049e18186cc143f3b121d5653baa8 Mon Sep 17 00:00:00 2001 From: david ornelas Date: Wed, 3 Jul 2024 14:24:32 -0700 Subject: [PATCH 2/3] fix(app-rfi): fixed deep clone function --- shared/utils/deep-cloner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/utils/deep-cloner.js b/shared/utils/deep-cloner.js index d087906fb0..0ec63eb86f 100644 --- a/shared/utils/deep-cloner.js +++ b/shared/utils/deep-cloner.js @@ -22,7 +22,7 @@ function deepCloner(obj) { const objCopy = {}; for (const key in obj) { if (obj.hasOwnProperty(key)) { - objCopy[key] = deepClone(obj[key]); + objCopy[key] = deepCloner(obj[key]); } } return objCopy; From 01584a0bd745b776c60d48f86ab48e1c3a77c520 Mon Sep 17 00:00:00 2001 From: david ornelas Date: Wed, 3 Jul 2024 14:29:15 -0700 Subject: [PATCH 3/3] fix(app-rfi): added correct class to select --- packages/app-rfi/src/components/controls/RfiSelect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app-rfi/src/components/controls/RfiSelect.js b/packages/app-rfi/src/components/controls/RfiSelect.js index 9d031f58d7..5074d0b364 100644 --- a/packages/app-rfi/src/components/controls/RfiSelect.js +++ b/packages/app-rfi/src/components/controls/RfiSelect.js @@ -44,7 +44,7 @@ const RfiSelect = ({