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