Skip to content

Commit

Permalink
feat: corrected verificationBody empty string function
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Aug 2, 2024
1 parent 39bfdd1 commit 5e614b0
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,26 @@ export const getDataModelVersion = () => {
/**
* the issuance table does not allow the verificationBody to be null. by requirement this field is nullable.
* this function defines null or undefined verificationBody for all issuances that exist in a staged record
* @param stagedRecord from the staging table
* @param stagedItem from the staging table
*/
export const updateNilVerificationBodyAsEmptyString = (stagedRecord) => {
export const updateNilVerificationBodyAsEmptyString = (stagedItem) => {
try {
if (stagedRecord?.data && stagedRecord?.table === 'Projects') {
const data = JSON.parse(stagedRecord.data);
data?.issuances?.forEach((issuance) => {
if (!issuance?.validationBody) {
issuance.validationBody = '';
if (stagedItem?.data) {
const data = JSON.parse(stagedItem.data);
data?.forEach((changeRecord) => {
if (stagedItem?.table === 'Projects') {
changeRecord?.issuances?.forEach((issuance) => {
if (!issuance?.verificationBody) {
issuance.verificationBody = '';
}
});
} else if (stagedItem?.table === 'Units') {
if (data?.issuance && !data.issuance?.verificationBody) {
data.issuance.verificationBody = '';
}
}
});
stagedRecord.data = JSON.stringify(data);
} else if (stagedRecord?.data && stagedRecord?.table === 'Units') {
const data = JSON.parse(stagedRecord.data);
if (data?.issuance && !data.issuance?.validationBody) {
data.issuance.validationBody = '';
}
stagedRecord.data = JSON.stringify(data);
stagedItem.data = JSON.stringify(data);
}
} catch {
return;
Expand Down

0 comments on commit 5e614b0

Please sign in to comment.