Merge pull request #772 from Safelite/feature/digital/SSR-1375

SSR-1375 Cleanup validateZip api calls
This commit is contained in:
Josh Dassinger 2024-06-27 09:29:25 -05:00 committed by GitHub
commit d4c1e5b2d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 27 deletions

View file

@ -24,21 +24,12 @@ jest.mock('@/helpers/cms-content-helper', () => ({
/** @ignore */
function setupMocks({
isZipValid = true,
isZipServiceable = true,
lookupVinByPlateResponse,
partsOrQuestions = [],
carId = 'C0000',
vinLookupResponseError = null,
route = null
}) {
useMainStore().validateZip = jest.fn().mockImplementation(() => Promise.resolve({
data: {
isValid: isZipValid,
isServiceable: isZipServiceable
}
}));
useMainStore().lookupVinByPlate = jest.fn().mockImplementation(() => Promise.resolve({
data: lookupVinByPlateResponse || {
vin: 'TEST_VIN',

View file

@ -1040,22 +1040,15 @@ export const useMainStore = defineStore({
},
async getInsurancePriceOrderItems(availableLineItems) {
const zipCodeToUse = this.order.serviceLocation.zipCode;
if (!this.order.serviceLocation.zipCodeCtu) {
const zipInfo = await this.validateZip({ zip: zipCodeToUse });
this.order.serviceLocation.zipCodeCtu = zipInfo.zipCodeCtu;
}
const ctuToUse = this.order.serviceLocation.zipCodeCtu;
const deductibleToUse = this.order.currentDeductible ?? 0;
const { serviceLocation, currentDeductible } = this.order;
const lineItemsQueryString = getLineItemQueryString(availableLineItems, 'lineItems');
let queryString =
`ParentAccountNumber=${this.order.parentAccountNumber}`
+ `&BillToAccountNumber=${this.billToAccountNumber}`
+ `&CTU=${ctuToUse}`
+ `&Deductible=${deductibleToUse}`
+ `&ZipCode=${zipCodeToUse}`
+ `&CTU=${serviceLocation.zipCodeCtu}`
+ `&Deductible=${currentDeductible ?? 0}`
+ `&ZipCode=${serviceLocation.zipCode}`
+ `${lineItemsQueryString}`;
const lineItemServerData = this.order.lineItems?.serverData;
@ -1085,12 +1078,6 @@ export const useMainStore = defineStore({
},
async getITACPriceOrderItems(availableLineItems) {
const zipCodeToUse = this.order.serviceLocation.zipCode;
if (!this.order.serviceLocation.zipCodeCtu) {
const zipInfo = await this.validateZip({ zip: zipCodeToUse });
this.order.serviceLocation.zipCodeCtu = zipInfo.zipCodeCtu;
}
const { policy, vehicle, contactInfo, serviceLocation, insuranceCoverage } = this.order;
const response = await globalMethods
@ -1104,7 +1091,7 @@ export const useMainStore = defineStore({
ReferralDate: `${this.order.referralDate}Z`,
lineItems: availableLineItems,
ServerData: this.order.lineItems.serverData,
ServiceZipCode: zipCodeToUse,
ServiceZipCode: serviceLocation.zipCode,
Customer: {
PhoneNumber: contactInfo.servicePhone,
State: policy.damageState,