Skip to content

Commit

Permalink
Merge pull request #1312 from ASU/fix-rfi-submit-errors
Browse files Browse the repository at this point in the history
fix(app-rfi): fix false error display on studentstatus
  • Loading branch information
mlsamuelson authored Jul 3, 2024
2 parents d31ae2b + 01584a0 commit 62f4675
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/app-rfi/src/components/controls/RfiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const RfiSelect = ({
<Field
as="select"
id={id}
className="form-control"
className="form-select"
required={required}
disabled={disabled}
autoFocus={autoFocus}
Expand Down
3 changes: 2 additions & 1 deletion packages/app-rfi/src/core/utils/submission-helpers.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions shared/utils/deep-cloner.js
Original file line number Diff line number Diff line change
@@ -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] = deepCloner(obj[key]);
}
}
return objCopy;
};

export { deepCloner };
1 change: 1 addition & 0 deletions shared/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from "./id-generator";
export * from "./numbers";
export * from "./script-utils";
export * from "./timers";
export * from "./deep-cloner";

0 comments on commit 62f4675

Please sign in to comment.