From 6559eeea6bac26fc84a6a0692affc8453a5056c2 Mon Sep 17 00:00:00 2001 From: DavidAtSafelite Date: Sun, 7 May 2023 11:52:56 -0400 Subject: [PATCH] Modifications to complete SSR-290 --- .../service-package-question.vue | 83 ++++- .../service-packages/service-packages.vue | 47 +-- src/store/index.js | 329 +++++++++--------- 3 files changed, 242 insertions(+), 217 deletions(-) diff --git a/src/layouts/service-packages/service-package-question/service-package-question.vue b/src/layouts/service-packages/service-package-question/service-package-question.vue index c9011df2..53a6cd7b 100644 --- a/src/layouts/service-packages/service-package-question/service-package-question.vue +++ b/src/layouts/service-packages/service-package-question/service-package-question.vue @@ -22,6 +22,9 @@ TIER_TWO: 'TierTwo', TIER_THREE: 'TierThree', }; + + const store = useMainStore(); + export default { name: 'servicePackageQuestion', emits: ['vapsItemsSelected'], @@ -39,6 +42,11 @@ }; }, watch: { + availableLineItems() { + if (this.allGlassPartsAndItemsHavePrices(store.order.lineItems)) { + this.selectDefaultPackage(); + } + }, selectedPackageName(newValue) { const VapsProductsInSelectedPackage = this.getVapsLineItemsForSelectedPackage(newValue); this.$emit('vapsItemsSelected', VapsProductsInSelectedPackage); @@ -54,7 +62,7 @@ }, servicePackageAnswers() { if (!this.cmsWidgetName) return []; - let cmsAnswersContent = [ + const cmsAnswersContent = [ { Name: 'TierOne', cmsWidgetName: 'EconomyServicePackage' @@ -72,10 +80,6 @@ if (this.getCmsContent(cmsAnswersContent[0].cmsWidgetName, 'HeaderText') == '') { return {}; } - - if (!this.shouldDisplayTierTwoPackage) { - cmsAnswersContent = cmsAnswersContent.filter((answer) => answer.Name != packageNames.TIER_TWO); - } const modifiedAnswers = cmsAnswersContent.map((answer) => ({ value: answer.Name, buttonLabel: this.getHeaderTextFromCms(answer.cmsWidgetName), @@ -92,9 +96,13 @@ }, frontWipersApplicableForTierTwo() { const store = useMainStore(); - const frontWipersAreAvailable = this.lineItemsContainsPartType(partTypeStrings.FRONT_WIPER); + const frontWipersAreAvailable = this.lineItemsContainsPartType( + partTypeStrings.FRONT_WIPER + ); const isRepair = store.order.damage.isRepair; - const glassToReplaceContainsWindshield = this.glassToReplaceContainsGlassLocation(glassLocations.WINDSHIELD); + const glassToReplaceContainsWindshield = this.glassToReplaceContainsGlassLocation( + glassLocations.WINDSHIELD + ); if (frontWipersAreAvailable) { if (isRepair) { return true; @@ -162,7 +170,7 @@ }, getPackagePriceString(packageName) { const formattedPriceFloat = parseFloat(this.getPackagePrice(packageName)).toFixed(2); - return '+$' + formattedPriceFloat; + return '$' + formattedPriceFloat; }, getPackagePrice(packageName) { let priceFloat = 0; @@ -178,9 +186,11 @@ const priceFrontWipers = this.frontWipersApplicableForTierTwo; const priceRearWipers = this.rearWiperApplicableForTierTwo; this.nullSafeAvailableLineItems.forEach((item) => { - if ((priceFrontWipers && - item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER) || - (priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER)) { + if ( + (priceFrontWipers && + item.partType.toUpperCase() === partTypeStrings.FRONT_WIPER) || + (priceRearWipers && item.partType.toUpperCase() === partTypeStrings.REAR_WIPER) + ) { vapsPrice += this.getTotalLineItemPrice(item); } }); @@ -205,6 +215,26 @@ }); return vapsPrice; }, + selectDefaultPackage() { + const vapsFromStore = store.order.lineItems.vaps; + let lowestTierForPackage = packageNames.TIER_ONE; + if (vapsFromStore?.length > 0) { + vapsFromStore.every((vapsItem) => { + let lowestTierForThisItem = this.getLowestTierForThisItem(vapsItem); + if (lowestTierForThisItem === packageNames.TIER_THREE) { + lowestTierForPackage = packageNames.TIER_THREE; + return false; + } else if (lowestTierForThisItem === packageNames.TIER_TWO) { + lowestTierForPackage = packageNames.TIER_TWO; + return true; + } else { + return true; + } + }); + } + this.selectedPackageName = lowestTierForPackage; + }, + getLowestTierForThisItem(vapsItem) { let lowestTierForThisItem = null; switch (vapsItem.partType) { @@ -282,6 +312,37 @@ return null; } }, + allGlassPartsAndItemsHavePrices() { + if (this.pricedGlassParts) { + for (let i = 0; i < this.pricedGlassParts.length; i++) { + if (this.priceIsNullOrZero(this.pricedGlassParts[i])) { + return false; + } + } + } + if (this.supportingItems) { + for (let i = 0; i < this.supportingItems.length; i++) { + if (this.priceIsNullOrZero(this.supportingItems[i])) { + return false; + } + } + } + if (this.selectedVaps) { + for (let i = 0; i < this.selectedVaps.length; i++) { + if (this.priceIsNullOrZero(this.selectedVaps[i])) { + return false; + } + } + } + return true; + }, + priceIsNullOrZero(lineItem) { + return ( + (lineItem.kitPrice == null || lineItem.kitPrice == 0) && + (lineItem.laborAmount == null || lineItem.laborAmount == 0) && + (lineItem.sellingPrice == null || lineItem.sellingPrice == 0) + ); + }, getLineItemsContainingPartType(partType) { const partTypeMatches = this.nullSafeAvailableLineItems.filter( (lineItem) => lineItem.partType.toUpperCase() === partType diff --git a/src/layouts/service-packages/service-packages.vue b/src/layouts/service-packages/service-packages.vue index 0dde5b0d..b990f2d0 100644 --- a/src/layouts/service-packages/service-packages.vue +++ b/src/layouts/service-packages/service-packages.vue @@ -7,7 +7,7 @@ justification="left" issContainingPage="service-packages" class="my-5"/> -
+
+ style="margin-bottom: 6rem;" + class="mt-2 mx-6" /> @@ -134,7 +134,7 @@ this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, forwardButtonAction() { - if (!this.allGlassPartsAndItemsHavePrices()) { + if (!this.$ref.servicePackage.allGlassPartsAndItemsHavePrices()) { console.error('One or more items have no price assigned!'); } if (this.pricedGlassParts.length > 0) { @@ -145,37 +145,6 @@ store.saveVaps(this.selectedVaps); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); - }, - allGlassPartsAndItemsHavePrices() { - if (this.pricedGlassParts) { - for (let i = 0; i < this.pricedGlassParts.length; i++) { - if (this.priceIsNullOrZero(this.pricedGlassParts[i])) { - return false; - } - } - } - if (this.supportingItems) { - for (let i = 0; i < this.supportingItems.length; i++) { - if (this.priceIsNullOrZero(this.supportingItems[i])) { - return false; - } - } - } - if (this.selectedVaps) { - for (let i = 0; i < this.selectedVaps.length; i++) { - if (this.priceIsNullOrZero(this.selectedVaps[i])) { - return false; - } - } - } - return true; - }, - priceIsNullOrZero(lineItem) { - return ( - (lineItem.kitPrice == null || lineItem.kitPrice == 0) && - (lineItem.laborAmount == null || lineItem.laborAmount == 0) && - (lineItem.sellingPrice == null || lineItem.sellingPrice == 0) - ); } }, components: { @@ -189,10 +158,4 @@ contentGroupModal } }; - - \ No newline at end of file + \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 39aeb76f..5b635e59 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,11 +1,11 @@ -import { defineStore } from "pinia"; -import { endpoints } from "@/constants/endpoints.js"; -import { getDateForSavedSessionTimeout } from "@/helpers/session-helper"; -import globalMethods from "@/global-methods"; -import { experimentTriggers } from "@/constants/experiments"; -import { applicationConfig } from "@/constants/application-config"; -import { issPageValues } from "@/router/router-constants/issPage-values"; -import { damageLocationsSelected } from "@/constants/damage-locations-selected"; +import { defineStore } from 'pinia'; +import { endpoints } from '@/constants/endpoints.js'; +import { getDateForSavedSessionTimeout } from '@/helpers/session-helper'; +import globalMethods from '@/global-methods'; +import { experimentTriggers } from '@/constants/experiments'; +import { applicationConfig } from '@/constants/application-config'; +import { issPageValues } from '@/router/router-constants/issPage-values'; +import { damageLocationsSelected } from '@/constants/damage-locations-selected'; const storeId = 'main'; @@ -47,7 +47,7 @@ const getDefaultState = () => { damageCause: null, damageState: null, damageCity: null, - isDamageGlassOnly: null, + isDamageGlassOnly: null }, customer: { address: { @@ -96,9 +96,9 @@ const getDefaultState = () => { triggeredSiteEntry: false }, issConfig: { - clientName: "Generic Insurance", // this is the default and will be overriden by the client's name - clientDisplayName: "Generic Insurance", // this is the default and will be overridden by the client's name or client display name. - styleSheet: "", + clientName: 'Generic Insurance', // this is the default and will be overriden by the client's name + clientDisplayName: 'Generic Insurance', // this is the default and will be overridden by the client's name or client display name. + styleSheet: '', accountNumber: 0, isCoverageEnabled: false, // Indicates if we should be calling coverage on this flow. isAuthenticated: false, // Indicates if user is authenticated or not. @@ -144,10 +144,10 @@ export const useMainStore = defineStore({ streetAddress: registration.address, city: registration.city, state: registration.state, - zipCode: registration.zipCode, + zipCode: registration.zipCode }, firstName: registration.firstName, - lastName: registration.lastName, + lastName: registration.lastName } } else { @@ -157,10 +157,10 @@ export const useMainStore = defineStore({ streetAddress: address.streetAddress, city: address.city, state: address.state, - zipCode: address.zipCode, + zipCode: address.zipCode }, firstName: state.order.customer.firstName, - lastName: state.order.customer.lastName, + lastName: state.order.customer.lastName } } }, @@ -182,41 +182,41 @@ export const useMainStore = defineStore({ issSelectedMultiGlass: state.order.damage.glassToReplace?.length > 1, issSelectedWindshieldGlass: getNonFalseValuesOfPropertyInArrayOfObjects( state.order.damage.glassToReplace, - "glassLocation" + 'glassLocation' ).includes(damageLocationsSelected.WINDSHIELD), issSelectedBackGlass: getNonFalseValuesOfPropertyInArrayOfObjects( state.order.damage.glassToReplace, - "glassLocation" + 'glassLocation' ).includes(damageLocationsSelected.REAR), issSelectedDriverSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects( state.order.damage.glassToReplace, - "glassLocation" + 'glassLocation' ).includes(damageLocationsSelected.DRIVER), issSelectedPassengerSideGlass: getNonFalseValuesOfPropertyInArrayOfObjects( state.order.damage.glassToReplace, - "glassLocation" + 'glassLocation' ).includes(damageLocationsSelected.PASSENGER), issOrderPartNumbers: [ ...getNonFalseValuesOfPropertyInArrayOfObjects( state.order.lineItems.glassParts, - "partNumber" + 'partNumber' ), ...getNonFalseValuesOfPropertyInArrayOfObjects( state.order.lineItems.otherParts, - "partNumber" - ), + 'partNumber' + ) ], issOrderPartTypes: [ ...getNonFalseValuesOfPropertyInArrayOfObjects( state.order.lineItems.glassParts, - "recalibrationType" + 'recalibrationType' ), ...getNonFalseValuesOfPropertyInArrayOfObjects( state.order.lineItems.otherParts, - "recalibrationType" - ), - ], + 'recalibrationType' + ) + ] }; }, experimentSettings: (state) => { @@ -248,7 +248,7 @@ export const useMainStore = defineStore({ endpoint: endpoints.GetRouteInfo.url(applicationConfig.APPLICATION_ABBREVIATION), payload: { pageName: pageName - }, + } }); }, getHomepageName() { @@ -365,7 +365,8 @@ export const useMainStore = defineStore({ // PartsOrQuestions API Actions async getPartsOrQuestions() { - this.resetGlassPartsState(); + this.resetPartsAndDependencies(); + const vehicle = this.vehicle; const damage = this.damage; const order = this.order; @@ -460,8 +461,8 @@ export const useMainStore = defineStore({ }, async getWipers() { const carId = this.order.vehicle.carId; - ///WARNING - ///TODO: this is temp test code until serviceLocation is complete. + //WARNING + //TODO: this is temp test code until serviceLocation is complete. //const serviceZipCode = this.order.serviceLocation.zipCode; const serviceZipCode = '44902'; return globalMethods @@ -502,7 +503,7 @@ export const useMainStore = defineStore({ endpoint: endpoints.GetSupportingItems.url, payload: { carId: carId, - serviceType: isRepair ? 'Repair' : 'Replace', + damageType: isRepair ? 'Repair' : 'Replace', parentAccountNumber: applicationConfig.CASH_PARENT_ACCOUNT_NUMBER, parts: glassPartsArray, numberOfRepairChips: isRepair ? numberOfChips : 0 @@ -517,21 +518,21 @@ export const useMainStore = defineStore({ getLineItemQueryStringForPricing(availableLineItems); const vehicle = this.order.vehicle; - ///WARNING - ///TODO: this is temp test code until serviceLocation is complete. - /// and ctu is available. Also, EON may need to be implemented. - zipCodeToUse = "44902"; - ctuToUse = "01820"; - let queryString = + //WARNING + //TODO: this is temp test code until serviceLocation is complete. + // and ctu is available. Also, EON may need to be implemented. + zipCodeToUse = '44902'; + ctuToUse = '01820'; + const queryString = `ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}` + - `&CTU=${ctuToUse}` + - `&CarId=${vehicle.carId}` + - `&Make=${vehicle.make}` + - `&Model=${vehicle.model}` + - `&Year=${vehicle.year}` + - `&EON=0` + - `&ZipCode=${zipCodeToUse}` + - `${availableLineItemsFormattedForRequest}`; + `&CTU=${ctuToUse}` + + `&CarId=${vehicle.carId}` + + `&Make=${vehicle.make}` + + `&Model=${vehicle.model}` + + `&Year=${vehicle.year}` + + `&EON=0` + + `&ZipCode=${zipCodeToUse}` + + `${availableLineItemsFormattedForRequest}`; const response = await globalMethods @@ -543,7 +544,7 @@ export const useMainStore = defineStore({ return []; }); - availableLineItems = addPricesToLineItems(availableLineItems, response.data.lineItems) + availableLineItems = addPricesToLineItems(availableLineItems, response.data.lineItems); return availableLineItems; }, @@ -554,7 +555,7 @@ export const useMainStore = defineStore({ const encodedLineItems = encodeURIComponent(JSON.stringify(lineItemsToSend)); return globalMethods.callHttpClient({ method: endpoints.GetServiceabilityDetails.method, - endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}`, + endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}` }); }, @@ -563,8 +564,8 @@ export const useMainStore = defineStore({ method: endpoints.LookupVehicleByVin.method, endpoint: endpoints.LookupVehicleByVin.url, payload: { - vin, - }, + vin + } }); }, @@ -606,7 +607,7 @@ export const useMainStore = defineStore({ if (isDamageChanging) { //Reset dependent state when changing - this.resetGlassPartsState(); + this.resetPartsAndDependencies(); // Save new values this.updateIsRepair(isWindshieldRepair); @@ -665,6 +666,8 @@ export const useMainStore = defineStore({ this.order.vehicle.imageUrl = vehicle.imageUrl; this.order.vehicle.imageVifNumber = vehicle.imageVifNumber; this.order.vehicle.imageColor = vehicle.imageVifColor; + + this.resetDamagePartsAndDependencies(); }, updateVehicleVin(vin) { @@ -699,7 +702,9 @@ export const useMainStore = defineStore({ resetSupportingItemsState() { this.order.lineItems.supportingItems = null; }, - + resetVapsState() { + this.order.lineItems.vaps = null; + }, resetDamageState() { this.order.damage.isRepair = null; this.order.damage.numberOfChips = null; @@ -719,8 +724,7 @@ export const useMainStore = defineStore({ previouslySelectedPartNumbers !== currentlySelectedPartNumbers; if (haveSelectedVehiclePartsChanged) { - this.updateGlassParts(null); - this.resetSupportingItemsState(); + this.resetPartsAndDependencies(); this.updateMoldingQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null); this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null}); @@ -728,12 +732,11 @@ export const useMainStore = defineStore({ } }, - resetISSConfigState() - { - this.issConfig.clientName = "Generic Insurance"; - this.issConfig.clientDisplayName = "Generic Insurance"; + resetISSConfigState() { + this.issConfig.clientName = 'Generic Insurance'; + this.issConfig.clientDisplayName = 'Generic Insurance'; this.issConfig.accountNumber = 0; - this.issConfig.styleSheet = ""; + this.issConfig.styleSheet = ''; this.issConfig.isCoverageEnabled = false; this.issConfig.isAuthenticated = false; this.issConfig.enableTPAFlow = false; @@ -743,35 +746,36 @@ export const useMainStore = defineStore({ }, updateVehicleYear(year) { - if(this.order.vehicle.year != year) + if(this.order.vehicle.year !== year) { this.resetVehicleState(); - this.resetDamageState(); + this.resetDamagePartsAndDependencies(); + this.order.vehicle.year = year; } }, updateVehicleMake(make) { - if(this.order.vehicle.make != make) + if(this.order.vehicle.make !== make) { const year = this.order.vehicle.year; this.resetVehicleState(); - this.resetDamageState(); - + this.resetDamagePartsAndDependencies(); + this.order.vehicle.year = year; this.order.vehicle.make = make; } }, updateVehicleModel(model) { - if(this.order.vehicle.model != model) + if(this.order.vehicle.model !== model) { const year = this.order.vehicle.year; const make = this.order.vehicle.make; this.resetVehicleState(); - this.resetDamageState(); + this.resetDamagePartsAndDependencies(); this.order.vehicle.year = year; this.order.vehicle.make = make; @@ -781,14 +785,14 @@ export const useMainStore = defineStore({ updateVehicleStyle(style) { - if(this.order.vehicle.style != style) + if(this.order.vehicle.style !== style) { const year = this.order.vehicle.year; const make = this.order.vehicle.make; const model = this.order.vehicle.model; this.resetVehicleState(); - this.resetDamageState(); + this.resetDamagePartsAndDependencies(); this.order.vehicle.year = year; this.order.vehicle.make = make; @@ -853,11 +857,11 @@ export const useMainStore = defineStore({ // if part question answers have changed, reset subsequent question answers const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue( this.order.damage.partQuestionAnswers, - "result" + 'result' ); const sortedPartQuestionAnswersArray = sortArrayOfObjectsByPropertyValue( partQuestionAnswersArray, - "result" + 'result' ); const havePartQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedPartQuestionAnswersArray.length || @@ -876,15 +880,18 @@ export const useMainStore = defineStore({ //Save new values this.updatePartQuestionAnswers(partQuestionAnswersArray); + + this.resetSupportingItemsState(); + this.resetVapsState(); }, saveMoldingQuestionAnswers(moldingQuestionAnswersArray) { const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue( this.order.damage.moldingQuestionAnswers, - "result" + 'result' ); const sortedMoldingQuestionAnswersArray = sortArrayOfObjectsByPropertyValue( moldingQuestionAnswersArray, - "result" + 'result' ); const haveMoldingQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedMoldingQuestionAnswersArray.length || @@ -893,8 +900,7 @@ export const useMainStore = defineStore({ ); if (haveMoldingQuestionAnswersChanged) { - this.updateGlassParts(null); - this.updateSupportingItems(null); + this.resetPartsAndDependencies(); this.updateCapabilityQuestionAnswers(null); this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, @@ -909,11 +915,11 @@ export const useMainStore = defineStore({ saveCapabilityQuestionAnswers(capabilityQuestionAnswersArray) { const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue( this.order.damage.capabilityQuestionAnswers, - "result" + 'result' ); const sortedCapabilityQuestionAnswersArray = sortArrayOfObjectsByPropertyValue( capabilityQuestionAnswersArray, - "result" + 'result' ); const haveCapabilityQuestionAnswersChanged = sortedPreviousResultsArray?.length !== sortedCapabilityQuestionAnswersArray.length || @@ -986,21 +992,20 @@ export const useMainStore = defineStore({ } }); }, - logPageView({ userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId, experimentsForUser }) - { - var payload = { - userId: userId, - sessionKey: sessionKey, - sessionId: sessionId, - pageName: pageName, - applicationName: applicationConfig.APPLICATION_NAME, - action: action, - event: event, - shouldUseSessionId: shouldUseSessionId, - experimentsForUser: experimentsForUser, - } + logPageView({ userId, sessionKey, pageName, sessionId, action, event, shouldUseSessionId, experimentsForUser }) { + const payload = { + userId: userId, + sessionKey: sessionKey, + sessionId: sessionId, + pageName: pageName, + applicationName: applicationConfig.APPLICATION_NAME, + action: action, + event: event, + shouldUseSessionId: shouldUseSessionId, + experimentsForUser: experimentsForUser + }; - return globalMethods.callHttpClient({ + return globalMethods.callHttpClient({ method: endpoints.LogPageView.method, endpoint: endpoints.LogPageView.url, payload: payload, @@ -1010,27 +1015,27 @@ export const useMainStore = defineStore({ return response; }, (error) => { - console.log("Analytics Service Error: " + error.data); + console.log('Analytics Service Error: ' + error.data); } ); }, logCustomEvent({ userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId, experimentsForUser}) { - if ( pageName == null || pageName.length == 0 ) - pageName = "none"; + if ( pageName == null || pageName.length === 0 ) + pageName = 'none'; - var payload = { - userId: userId, - sessionKey: sessionKey, - sessionId: sessionId, - pageName: pageName, - applicationName: applicationConfig.APPLICATION_NAME, - category: category, - action: action, - label: label, - value: value, - shouldUseSessionId: shouldUseSessionId, - experimentsForUser: experimentsForUser + const payload = { + userId: userId, + sessionKey: sessionKey, + sessionId: sessionId, + pageName: pageName, + applicationName: applicationConfig.APPLICATION_NAME, + category: category, + action: action, + label: label, + value: value, + shouldUseSessionId: shouldUseSessionId, + experimentsForUser: experimentsForUser }; return globalMethods.callHttpClient({ @@ -1043,23 +1048,23 @@ export const useMainStore = defineStore({ return response; }, (error) => { - console.log("Analytics Service Error: " + error.data); + console.log('Analytics Service Error: ' + error.data); } ); }, initializeSession({ userId, sessionId, userAgent, referrer }) { - var payload = { - applicationName: applicationConfig.APPLICATION_NAME, - userId: userId, - deviceId: userId, - sessionId: sessionId, - userAgent: userAgent, - operatorId: "WEB", - userName: "SafeliteISS", - referrer: referrer - }; + const payload = { + applicationName: applicationConfig.APPLICATION_NAME, + userId: userId, + deviceId: userId, + sessionId: sessionId, + userAgent: userAgent, + operatorId: 'WEB', + userName: 'SafeliteISS', + referrer: referrer + }; - return globalMethods.callHttpClient({ + return globalMethods.callHttpClient({ method: endpoints.InitializeSession.method, endpoint: endpoints.InitializeSession.url, payload: payload, @@ -1069,7 +1074,7 @@ export const useMainStore = defineStore({ return response; }, (error) => { - console.log("Analytics Service Error: " + error.data); + console.log('Analytics Service Error: ' + error.data); } ); }, @@ -1094,16 +1099,16 @@ export const useMainStore = defineStore({ }, async runExperimentsForTrigger({ userId, triggerEvent, triggerValue }) { - if (triggerEvent == experimentTriggers.SITE_ENTRY) { + if (triggerEvent === experimentTriggers.SITE_ENTRY) { this.updateTriggeredSiteEntry(true); } - var payload = { - applicationName: applicationConfig.APPLICATION_NAME, - userId: userId, - triggerEvent: triggerEvent, - triggerValue: triggerValue, - experimentOrder: this.experimentOrder + const payload = { + applicationName: applicationConfig.APPLICATION_NAME, + userId: userId, + triggerEvent: triggerEvent, + triggerValue: triggerValue, + experimentOrder: this.experimentOrder }; const response = await globalMethods.callHttpClient({ @@ -1148,8 +1153,7 @@ export const useMainStore = defineStore({ this.resetRegistrationAndDependencies(); if (!isSelectedGlassAvailableForVehicle) { - this.resetDamageAndDependencies(); - this.resetPartsAndDependencies(); + this.resetDamageState(); } //Save new values @@ -1164,8 +1168,7 @@ export const useMainStore = defineStore({ this.resetRegistrationAndDependencies(); if (!isSelectedGlassAvailableForVehicle) { - this.resetDamageAndDependencies(); - this.resetPartsAndDependencies(); + this.resetDamageState(); } //Save new values @@ -1174,42 +1177,40 @@ export const useMainStore = defineStore({ }, saveRegistrationLicensePlateLookup({ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo }) { //Reset dependent state when changing - if - ( - registrationInfo?.licensePlate !== this.order.vehicle.registration?.licensePlate || - registrationInfo?.state !== this.order.vehicle.registration?.state - ) + if (registrationInfo?.licensePlate !== this.order.vehicle.registration?.licensePlate || + registrationInfo?.state !== this.order.vehicle.registration?.state) { this.resetRegistrationAndDependencies(); if (!isSelectedGlassAvailableForVehicle) { - this.resetDamageAndDependencies(); - this.resetPartsAndDependencies(); + this.resetDamageState(); } //Save new values this.updateVehicle(vehicleInfo); - } + } - this.updateRegistration(registrationInfo); - }, + this.updateRegistration(registrationInfo); + }, resetRegistrationAndDependencies() { this.resetRegistrationState(); this.resetGlassPartsState(); - this.updateSupportingItems(null); + this.resetSupportingItemsState(); + this.resetVapsState(); }, - resetDamageAndDependencies() { + resetDamagePartsAndDependencies() { this.resetDamageState(); this.resetGlassPartsState(); - this.updateSupportingItems(null); - this.updateVaps(null); + this.resetSupportingItemsState(); + this.resetVapsState(); }, resetPartsAndDependencies() { this.resetGlassPartsState(); - this.updateSupportingItems(null); + this.resetSupportingItemsState(); + this.resetVapsState(); } }, persist: true @@ -1219,16 +1220,16 @@ export const useMainStore = defineStore({ // Private Functions function getHasRecalibrationPart(state) { - var hasRequiresRecalibration = - getNonFalseValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - "requiresRecalibration" - )?.length > 0; - var hasRecalibrationType = - getNonFalseValuesOfPropertyInArrayOfObjects( - state.order.lineItems.glassParts, - "recalibrationType" - )?.length > 0; + const hasRequiresRecalibration = + getNonFalseValuesOfPropertyInArrayOfObjects( + state.order.lineItems.glassParts, + 'requiresRecalibration' + )?.length > 0; + const hasRecalibrationType = + getNonFalseValuesOfPropertyInArrayOfObjects( + state.order.lineItems.glassParts, + 'recalibrationType' + )?.length > 0; if (hasRequiresRecalibration) { if (hasRecalibrationType) { @@ -1236,8 +1237,8 @@ function getHasRecalibrationPart(state) { return ( getNonFalseValuesOfPropertyInArrayOfObjects( state.order.lineItems.glassParts, - "recalibrationType" - )[0].toLowerCase() != "unknown" + 'recalibrationType' + )[0].toLowerCase() !== 'unknown' ); } else { // Has 'requiresRecalibration' but no 'recalibrationType' at all @@ -1311,9 +1312,9 @@ function getAllPartNumbers(partsOrQuestions) { .map((glass) => glass.parts) .flat() .map((part) => part.partNumber) - .filter((partNumber) => !partNumber.toUpperCase().includes("FEE")) + .filter((partNumber) => !partNumber.toUpperCase().includes('FEE')) .sort() - .join(",") + .join(',') : []; } @@ -1321,14 +1322,14 @@ function addPricesToLineItems(lineItems, pricingLineItems) { lineItems.forEach((lineItem) => { const lineItemIndex = pricingLineItems.findIndex( (pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber - ) + ); if (lineItem.childParts) { - addPricesToLineItems(lineItem.childParts, pricingLineItems) + addPricesToLineItems(lineItem.childParts, pricingLineItems); } - const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0] - lineItem.laborAmount = pricedLineItem.laborAmount - lineItem.sellingPrice = pricedLineItem.sellingPrice - lineItem.kitPrice = pricedLineItem.kitPrice + const pricedLineItem = pricingLineItems.splice(lineItemIndex, 1)[0]; + lineItem.laborAmount = pricedLineItem.laborAmount; + lineItem.sellingPrice = pricedLineItem.sellingPrice; + lineItem.kitPrice = pricedLineItem.kitPrice; }); return lineItems; }