Merge pull request #1852 from Safelite/feature/CSR-2076
CSR-2076 | Fix line item IDs mismatch
This commit is contained in:
commit
ee6250d40f
1 changed files with 26 additions and 1 deletions
|
|
@ -2172,7 +2172,8 @@ export const actions = {
|
|||
},
|
||||
|
||||
saveSupportingItems(context, supportingItems) {
|
||||
if (!deepEqual(supportingItems, context.state.order.lineItems.supportingItems)) {
|
||||
syncLineItemIds(supportingItems, context.state.order.lineItems.supportingItems);
|
||||
if (!supportingItemsEqual(supportingItems, context.state.order.lineItems.supportingItems)) {
|
||||
context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
addGuidToLineItemsIfNotAlreadyThere(supportingItems);
|
||||
|
|
@ -2969,6 +2970,7 @@ function syncLineItemIds(lineItemsWithoutIds, lineItemsWithIds) {
|
|||
}
|
||||
});
|
||||
if (matchedLineItemIndex > -1) {
|
||||
// Remove the matched line item
|
||||
clonedLineItemsWithIds.splice(matchedLineItemIndex, 1);
|
||||
}
|
||||
});
|
||||
|
|
@ -2985,6 +2987,29 @@ function providersEqual(providerA, providerB) {
|
|||
//TODO: Change back to deepEqual once zipCodeCtu is added to saveSession.
|
||||
}
|
||||
|
||||
function supportingItemsEqual(supportingItemsA, supportingItemsB) {
|
||||
if (typeof supportingItemsA !== typeof supportingItemsB) {
|
||||
return false;
|
||||
}
|
||||
if (supportingItemsA === null || supportingItemsB === null) {
|
||||
return supportingItemsA === supportingItemsB;
|
||||
}
|
||||
if (supportingItemsA.length != supportingItemsB.length) {
|
||||
return false;
|
||||
}
|
||||
const sortedA = supportingItemsA.slice().sort();
|
||||
const sortedB = supportingItemsB.slice().sort();
|
||||
for (let i = 0; i < sortedA.length; i++) {
|
||||
if (
|
||||
sortedA[i].partNumber != sortedB[i].partNumber ||
|
||||
sortedA[i].partType != sortedB[i].partType
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// This function will verify schedule info is still valid.
|
||||
// check to see if we have an appointment date on the order object.
|
||||
// if so, make sure it's not in the past. if in the past, clear schedule info in store.
|
||||
|
|
|
|||
Loading…
Reference in a new issue