Merge pull request #2531 from Safelite/nation/CASH-715

CASH-715 policy vehicle change
This commit is contained in:
CarlNation 2025-05-19 10:30:50 -04:00 committed by GitHub
commit 352a3d4dc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3621,25 +3621,25 @@ export function mapTaxedLineItemsToStoreFormat(availableLineItems, storeLineItem
export function getArrayOfAllLineItemsAndChildParts(lineItems) { export function getArrayOfAllLineItemsAndChildParts(lineItems) {
let consolidatedLineItemsArray = []; let consolidatedLineItemsArray = [];
if (lineItems.glassParts != null) if (lineItems?.glassParts != null)
consolidatedLineItemsArray = [ consolidatedLineItemsArray = [
...consolidatedLineItemsArray, ...consolidatedLineItemsArray,
...getFlattenedArrayOfLineItemsWithChildParts(lineItems.glassParts), ...getFlattenedArrayOfLineItemsWithChildParts(lineItems.glassParts),
]; ];
if (lineItems.supportingItems != null) if (lineItems?.supportingItems != null)
consolidatedLineItemsArray = [ consolidatedLineItemsArray = [
...consolidatedLineItemsArray, ...consolidatedLineItemsArray,
...getFlattenedArrayOfLineItemsWithChildParts(lineItems.supportingItems), ...getFlattenedArrayOfLineItemsWithChildParts(lineItems.supportingItems),
]; ];
if (lineItems.vaps != null) if (lineItems?.vaps != null)
consolidatedLineItemsArray = [ consolidatedLineItemsArray = [
...consolidatedLineItemsArray, ...consolidatedLineItemsArray,
...getFlattenedArrayOfLineItemsWithChildParts(lineItems.vaps), ...getFlattenedArrayOfLineItemsWithChildParts(lineItems.vaps),
]; ];
if (lineItems.promos != null) if (lineItems?.promos != null)
consolidatedLineItemsArray = [ consolidatedLineItemsArray = [
...consolidatedLineItemsArray, ...consolidatedLineItemsArray,
...getFlattenedArrayOfLineItemsWithChildParts(lineItems.promos), ...getFlattenedArrayOfLineItemsWithChildParts(lineItems.promos),
@ -3789,7 +3789,15 @@ function supportingItemsEqual(supportingItemsA, supportingItemsB) {
// if so, make sure it's not in the past. if in the past, clear schedule info in store. // if so, make sure it's not in the past. if in the past, clear schedule info in store.
// if date not in past, then call schedule service to verify appointment is still available. // if date not in past, then call schedule service to verify appointment is still available.
async function resetScheduleIfUnavailable(context, order, pageNameToLog) { async function resetScheduleIfUnavailable(context, order, pageNameToLog) {
if (!order.schedule?.date) { // lineItems empty can happen when a customer goes all the way through scheduling as cash but then
// switches to insurance AND also switches vehicles during policy lookup. If you call shop-time-slots
// without parts, you get 500 errors so skip the call.
const lineItems = getArrayOfAllLineItemsAndChildParts(order.lineItems);
if (!order.schedule?.date || lineItems.length === 0) {
console.log(new Date() + " no schedule date or lineItems. skip resetSchedule logic.");
console.log(new Date() + " schedule.schedule.date" + JSON.stringify(order.schedule));
console.log(new Date() + " lineItems" + JSON.stringify(order.lineItems));
return; return;
} }