fix: prevent mobile schedule requests for non-mobile-eligible orders
Three bugs fixed: 1. Typo: order.lineItem -> order.lineItems in resetScheduleIfUnavailable The premium fee check was accessing a non-existent property, so the condition always evaluated to undefined (falsy), skipping the offerPremium validation entirely. 2. findIndex truthiness: findIndex returns -1 (truthy!) when not found and 0 (falsy!) when found at index 0. Changed to >= 0 check. 3. Unsafe default: getScheduleApiResponse had includeMobileTimeSlots defaulting to true, meaning any new caller that forgot the flag would request mobile time slots regardless of serviceability. Changed default to false. Co-authored-by: Mark Harris <mark.harris@safelite.com>
This commit is contained in:
parent
5cf8816b0b
commit
08dca0f147
2 changed files with 3 additions and 3 deletions
|
|
@ -323,7 +323,7 @@ const getScheduleApiResponse = async ({
|
|||
providerNumber,
|
||||
inshopProviderNumber,
|
||||
zipCode,
|
||||
includeMobileTimeSlots = true,
|
||||
includeMobileTimeSlots = false,
|
||||
includeInshopTimeSlots = true,
|
||||
}) => {
|
||||
const apiEndDateLimit = sumDateString(startDateString, TIME_SLOTS_CALL_DAYS_LIMIT);
|
||||
|
|
|
|||
|
|
@ -4169,9 +4169,9 @@ async function resetScheduleIfUnavailable(context, order, pageNameToLog) {
|
|||
var mobileRouteCodeFound = false;
|
||||
// if early bird fee is in supporting items then need to check the timeslot to see if offer premium is also still available
|
||||
if (
|
||||
order.lineItem?.supportingItems?.findIndex(
|
||||
order.lineItems?.supportingItems?.findIndex(
|
||||
(item) => item.partType == PREMIUM_FEE_PART_TYPE
|
||||
)
|
||||
) >= 0
|
||||
) {
|
||||
newTimeSlotsResponse.data.days?.forEach((day) => {
|
||||
day.timeSlots.forEach((ts) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue