IO-1286 Retry Supplement Importing fix.
This commit is contained in:
@@ -187,7 +187,9 @@ export function JobsAvailableContainer({
|
||||
|
||||
setJobModalVisible(false);
|
||||
setInsertLoading(true);
|
||||
const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk);
|
||||
|
||||
const estData = estDataRaw.data.available_jobs_by_pk;
|
||||
|
||||
if (!(estData && estData.est_data)) {
|
||||
//We don't have the right data. Error!
|
||||
setInsertLoading(false);
|
||||
@@ -196,7 +198,7 @@ export function JobsAvailableContainer({
|
||||
});
|
||||
} else {
|
||||
//create upsert job
|
||||
let supp = _.cloneDeep(estData.est_data);
|
||||
let supp = replaceEmpty({ ...estData.est_data });
|
||||
|
||||
delete supp.owner;
|
||||
delete supp.vehicle;
|
||||
@@ -208,7 +210,7 @@ export function JobsAvailableContainer({
|
||||
let suppDelta = await GetSupplementDelta(
|
||||
client,
|
||||
selectedJob,
|
||||
estData.est_data.joblines.data
|
||||
supp.joblines.data
|
||||
);
|
||||
|
||||
delete supp.joblines;
|
||||
@@ -380,10 +382,10 @@ export default connect(
|
||||
)(JobsAvailableContainer);
|
||||
|
||||
function replaceEmpty(someObj, replaceValue = null) {
|
||||
const replacer = (key, value) => (value === "" ? replaceValue : value);
|
||||
const replacer = (key, value) =>
|
||||
value === "" ? replaceValue || null : value;
|
||||
//^ because you seem to want to replace (strings) "null" or "undefined" too
|
||||
console.log(someObj);
|
||||
const temp = JSON.stringify(someObj, replacer);
|
||||
console.log(`temp`, temp);
|
||||
console.log("Parsed", JSON.parse(temp));
|
||||
return JSON.parse(temp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user