Partial
This commit is contained in:
parent
7e9f7d83c0
commit
152a799caa
4 changed files with 217 additions and 59 deletions
|
|
@ -1,190 +1,204 @@
|
||||||
|
const baseContentUrl = '/content/api/v1/content';
|
||||||
|
const baseLocationUrl = '/location/api/v1/location';
|
||||||
|
const baseScheduleUrl = '/schedule/api/v1/schedule';
|
||||||
|
const basePartsUrl = '/parts/api/v1/parts';
|
||||||
|
const baseVehicleUrl = '/vehicle/api/v1/vehicle';
|
||||||
|
const basePriceUrl = '/price/api/v1/price';
|
||||||
|
const baseAnalyticsUrl = '/analytics/api/v1/analytics';
|
||||||
|
const baseExperimentsUrl = '/experiments/api/v1/experiments';
|
||||||
|
const baseClientAuthUrl = '/clientauth/api/v1/clientauth';
|
||||||
|
const baseOrderUrl = '/order/api/v1/order';
|
||||||
|
const baseCoverageUrl = '/coverage/api/v1/coverage';
|
||||||
|
const baseAccountUrl = '/account/api/v1/account/';
|
||||||
|
|
||||||
const endpoints = Object.freeze({
|
const endpoints = Object.freeze({
|
||||||
GetRouteInfo: {
|
GetRouteInfo: {
|
||||||
url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/RouteInfo`,
|
url: (applicationAbbreviation) => `${baseContentUrl}/${applicationAbbreviation}/RouteInfo`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetHomepageInfo: {
|
GetHomepageInfo: {
|
||||||
url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/HomepageInfo`,
|
url: (applicationAbbreviation) => `${baseContentUrl}/${applicationAbbreviation}/HomepageInfo`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetPageData: {
|
GetPageData: {
|
||||||
url: (applicationAbbreviation, pageName) => `/content/api/v1/content/${applicationAbbreviation}/${pageName}`,
|
url: (applicationAbbreviation, pageName) => `${baseContentUrl}/${applicationAbbreviation}/${pageName}`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetAlertReasons: {
|
GetAlertReasons: {
|
||||||
url: '/location/api/v1/location/alert-reasons',
|
url: `${baseLocationUrl}/alert-reasons`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetShopTimeSlots: {
|
GetShopTimeSlots: {
|
||||||
url: '/schedule/api/v1/schedule/shop-time-slots',
|
url: `${baseScheduleUrl}/shop-time-slots`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetMobileTimeSlots: {
|
GetMobileTimeSlots: {
|
||||||
url: '/schedule/api/v1/schedule/mobile-time-slots',
|
url: `${baseScheduleUrl}/mobile-time-slots`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetMobilePremiumFee: {
|
GetMobilePremiumFee: {
|
||||||
url: '/parts/api/v1/parts/mobile-premium-fee',
|
url: `${basePartsUrl}/mobile-premium-fee`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetVehicleYears: {
|
GetVehicleYears: {
|
||||||
url: '/vehicle/api/v1/vehicle/years',
|
url: `${baseVehicleUrl}/years`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetVehicleMakes: {
|
GetVehicleMakes: {
|
||||||
url: '/vehicle/api/v1/vehicle/makes/',
|
url: `${baseVehicleUrl}/makes/`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetVehicleModels: {
|
GetVehicleModels: {
|
||||||
url: '/vehicle/api/v1/vehicle/models',
|
url: `${baseVehicleUrl}/models`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetVehicleStyles: {
|
GetVehicleStyles: {
|
||||||
url: '/vehicle/api/v1/vehicle/styles',
|
url: `${baseVehicleUrl}/styles`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetDamageOptions: {
|
GetDamageOptions: {
|
||||||
url: '/parts/api/v1/parts/damage-options',
|
url: `${basePartsUrl}/damage-options`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetPartsOrQuestions: {
|
GetPartsOrQuestions: {
|
||||||
url: '/parts/api/v1/parts/parts-or-questions',
|
url: `${basePartsUrl}/parts-or-questions`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetParts: {
|
GetParts: {
|
||||||
url: '/parts/api/v1/parts/parts',
|
url: `${basePartsUrl}/parts`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
|
// TODO finish
|
||||||
GetInsurancePriceOrderItems: {
|
GetInsurancePriceOrderItems: {
|
||||||
url: '/price/api/v1/price/order-items-with-insurance-pricing',
|
url: () => `${basePriceUrl}/order-items-with-insurance-pricing`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetPriceOrderItems: {
|
GetPriceOrderItems: {
|
||||||
url: '/price/api/v1/price/order-items',
|
url: `${basePriceUrl}/order-items`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetProviders: {
|
GetProviders: {
|
||||||
url: '/location/api/v1/location/providers',
|
url: `${baseLocationUrl}/providers`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetCapabilityQuestions: {
|
GetCapabilityQuestions: {
|
||||||
url: '/parts/api/v1/parts/capability-questions',
|
url: `${basePartsUrl}/capability-questions`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetPartFromCapabilityAnswer: {
|
GetPartFromCapabilityAnswer: {
|
||||||
url: '/parts/api/v1/parts/part-from-capability-answer',
|
url: `${basePartsUrl}/part-from-capability-answer`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetWipers: {
|
GetWipers: {
|
||||||
url: '/parts/api/v1/parts/wipers',
|
url: `${basePartsUrl}/wipers`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetRainDefense: {
|
GetRainDefense: {
|
||||||
url: '/parts/api/v1/parts/rain-defense',
|
url: `${basePartsUrl}/rain-defense`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetSupportingItems: {
|
GetSupportingItems: {
|
||||||
url: '/parts/api/v1/parts/supporting-items',
|
url: `${basePartsUrl}/supporting-items`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetMobileFeePart: {
|
GetMobileFeePart: {
|
||||||
url: '/parts/api/v1/parts/mobile-fee',
|
url: `${basePartsUrl}/mobile-fee`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetServiceabilityDetails: {
|
GetServiceabilityDetails: {
|
||||||
url: '/location/api/v1/location/serviceability-details',
|
url: `${baseLocationUrl}/serviceability-details`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetVehicle: {
|
GetVehicle: {
|
||||||
url: '/vehicle/api/v1/vehicle/lookup',
|
url: `${baseVehicleUrl}/lookup`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GetAccountInfo: {
|
GetAccountInfo: {
|
||||||
url: '/account/api/v1/account/',
|
url: baseAccountUrl,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
LogExperimentExposureIfAssigned: {
|
LogExperimentExposureIfAssigned: {
|
||||||
url: '/experiments/api/v1/experiments/log-exposure',
|
url: `${baseExperimentsUrl}/log-exposure`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
LogPageView: {
|
LogPageView: {
|
||||||
url: '/analytics/api/v1/analytics/log-page-view',
|
url: `${baseAnalyticsUrl}/log-page-view`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
LogCustomEvent: {
|
LogCustomEvent: {
|
||||||
url: '/analytics/api/v1/analytics/log-custom-event',
|
url: `${baseAnalyticsUrl}/log-custom-event`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
LookupVehicleByVin: {
|
LookupVehicleByVin: {
|
||||||
url: '/vehicle/api/v1/vehicle/lookup',
|
url: `${baseVehicleUrl}/lookup`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
LookupVinByAddress: {
|
LookupVinByAddress: {
|
||||||
url: '/vehicle/api/v1/vehicle/lookup-vin-by-address',
|
url: `${baseVehicleUrl}/lookup-vin-by-address`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
LookupVinByPlate: {
|
LookupVinByPlate: {
|
||||||
url: '/vehicle/api/v1/vehicle/lookup-vin-by-plate',
|
url: `${baseVehicleUrl}/lookup-vin-by-plate`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
InitializeSession: {
|
InitializeSession: {
|
||||||
url: '/analytics/api/v1/analytics/initialize',
|
url: `${baseAnalyticsUrl}/initialize`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetExperimentsByUser: {
|
GetExperimentsByUser: {
|
||||||
url: '/analytics/api/v1/analytics/get-experiments',
|
url: `${baseAnalyticsUrl}/get-experiments`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
RunExperimentsForTrigger: {
|
RunExperimentsForTrigger: {
|
||||||
url: '/experiments/api/v1/experiments/run',
|
url: `${baseExperimentsUrl}/run`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
ValidateZip: {
|
ValidateZip: {
|
||||||
url: '/location/api/v1/location/zip',
|
url: `${baseLocationUrl}/zip`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
GooglePlaces: {
|
GooglePlaces: {
|
||||||
url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`
|
url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`
|
||||||
},
|
},
|
||||||
ValidateClientTag: {
|
ValidateClientTag: {
|
||||||
url: '/clientauth/api/v1/clientauth/validate-client-tag',
|
url: `${baseClientAuthUrl}/validate-client-tag`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
ValidateClientSignature: {
|
ValidateClientSignature: {
|
||||||
url: '/clientauth/api/v1/clientauth/validate-client-signature',
|
url: `${baseClientAuthUrl}/validate-client-signature`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
IsVinbyAddressPermissible: {
|
IsVinbyAddressPermissible: {
|
||||||
url: '/vehicle/api/v1/vehicle/is-vin-by-address-permissible',
|
url: `${baseVehicleUrl}/is-vin-by-address-permissible`,
|
||||||
method: 'Get'
|
method: 'Get'
|
||||||
},
|
},
|
||||||
CoveragePolicyInfo: {
|
CoveragePolicyInfo: {
|
||||||
url: '/coverage/api/v1/coverage/policy-information',
|
url: `${baseCoverageUrl}/policy-information`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
RegisterClaim: {
|
RegisterClaim: {
|
||||||
url: '/coverage/api/v1/coverage/register-claim',
|
url: `${baseCoverageUrl}/register-claim`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
SaveSession: {
|
SaveSession: {
|
||||||
url: '/order/api/v1/order/save-session/iss',
|
url: `${baseOrderUrl}/save-session/iss`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
LoadSession: {
|
LoadSession: {
|
||||||
url: '/order/api/v1/order/load-session',
|
url: `${baseOrderUrl}/load-session`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
DuplicateSearch: {
|
DuplicateSearch: {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
url: (accountNumber, policyNumber, dateOfLoss) => `/order/api/v1/order/duplicate-check/${accountNumber}/${policyNumber}/${dateOfLoss}`,
|
url: (accountNumber, policyNumber, dateOfLoss) => `${baseOrderUrl}/duplicate-check/${accountNumber}/${policyNumber}/${dateOfLoss}`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
FinalDeductible: {
|
FinalDeductible: {
|
||||||
url: '/coverage/api/v1/coverage/final-deductible',
|
url: `${baseCoverageUrl}/final-deductible`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
},
|
},
|
||||||
GetPaymentSignature: {
|
GetPaymentSignature: {
|
||||||
url: '/order/api/v1/order/sign',
|
url: `${baseOrderUrl}/sign`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ export default {
|
||||||
showAsPaid: Boolean,
|
showAsPaid: Boolean,
|
||||||
amountDueLabel: String,
|
amountDueLabel: String,
|
||||||
deductibleLabel: String,
|
deductibleLabel: String,
|
||||||
basePriceLabel: String
|
basePriceLabel: String,
|
||||||
|
baseServiceLineItems: Array
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -69,19 +70,9 @@ export default {
|
||||||
deductible() {
|
deductible() {
|
||||||
return useMainStore().order.currentDeductible;
|
return useMainStore().order.currentDeductible;
|
||||||
},
|
},
|
||||||
availableLineItems() {
|
|
||||||
// TODO make real
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
kitPrice: 1,
|
|
||||||
laborAmount: 2,
|
|
||||||
sellingPrice: 3
|
|
||||||
}
|
|
||||||
];
|
|
||||||
},
|
|
||||||
// TODO share with claim registration page
|
// TODO share with claim registration page
|
||||||
baseServicePrice() {
|
baseServicePrice() {
|
||||||
return this.availableLineItems
|
return this.baseServiceLineItems
|
||||||
.reduce(
|
.reduce(
|
||||||
(accumulator, lineItem) => accumulator + this.getTotalLineItemPrice(lineItem),
|
(accumulator, lineItem) => accumulator + this.getTotalLineItemPrice(lineItem),
|
||||||
0
|
0
|
||||||
|
|
@ -105,6 +96,10 @@ export default {
|
||||||
return this.showAsPaid
|
return this.showAsPaid
|
||||||
? 0
|
? 0
|
||||||
: this.subTotal + this.salesTax;
|
: this.subTotal + this.salesTax;
|
||||||
|
},
|
||||||
|
clonedGlassParts() {
|
||||||
|
const valueToClone = useMainStore().order.lineItems.glassParts ?? [];
|
||||||
|
return JSON.parse(JSON.stringify(valueToClone)) ?? [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -122,6 +117,34 @@ export default {
|
||||||
return this.isUnverified && this.showDeductibleLineItem
|
return this.isUnverified && this.showDeductibleLineItem
|
||||||
? VERIFYING_COVERAGE
|
? VERIFYING_COVERAGE
|
||||||
: this.getFormattedAmount(amount);
|
: this.getFormattedAmount(amount);
|
||||||
|
},
|
||||||
|
async temporaryMethod() {
|
||||||
|
// TODO need supporting items
|
||||||
|
// TODO need pricing results from getPriceOrderItems
|
||||||
|
// get base service line items
|
||||||
|
const supportingItems = await useMainStore().getSupportingItems();
|
||||||
|
supportingItems.then((data) => {
|
||||||
|
// TODO do something
|
||||||
|
});
|
||||||
|
const availableLineItems = [
|
||||||
|
...(supportingItems ?? []),
|
||||||
|
...(this.clonedGlassParts)
|
||||||
|
];
|
||||||
|
|
||||||
|
let pricingResults = [];
|
||||||
|
if (useMainStore().policy.policyLookupSuccessful && useMainStore().vehicle.policyVehicleId >= 0) {
|
||||||
|
// await useMainStore().getFinalDeductible();
|
||||||
|
// I don't think we need to perform the getFinalDeductible call
|
||||||
|
// policy data is set in policy.policyData
|
||||||
|
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the "next" function to complete the transition to this page.
|
||||||
|
// vm.setSupportingItems(supportingItems);
|
||||||
|
// // eslint-disable-next-line no-param-reassign
|
||||||
|
// vm.availableLineItems = pricingResults;
|
||||||
|
// vm.initializeComponent(availableLineItems);
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@
|
||||||
:showAsPaid="false"
|
:showAsPaid="false"
|
||||||
:amountDueLabel="amountDueText"
|
:amountDueLabel="amountDueText"
|
||||||
:deductibleLabel="deductibleLabel"
|
:deductibleLabel="deductibleLabel"
|
||||||
:basePriceLabel="basePriceLabel" />
|
:basePriceLabel="basePriceLabel"
|
||||||
|
:baseServiceLineItems="baseServiceLineItems" />
|
||||||
<hr class="mt-0 mb-5" />
|
<hr class="mt-0 mb-5" />
|
||||||
<div>Pia Alert Placeholder</div>
|
<div>Pia Alert Placeholder</div>
|
||||||
<paymentMethodQuestion
|
<paymentMethodQuestion
|
||||||
|
|
@ -107,6 +108,14 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
||||||
|
// TODO set line items
|
||||||
|
baseServiceLineItems: [
|
||||||
|
{
|
||||||
|
kitPrice: 1,
|
||||||
|
laborAmount: 2,
|
||||||
|
sellingPrice: 3
|
||||||
|
}
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
optionRequired: globalRules.OPTION_REQUIRED
|
optionRequired: globalRules.OPTION_REQUIRED
|
||||||
},
|
},
|
||||||
|
|
|
||||||
112
src/store/paymentStore.js
Normal file
112
src/store/paymentStore.js
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { endpoints } from '@/constants/endpoints';
|
||||||
|
import globalMethods from '@/global-methods';
|
||||||
|
import applicationConfig from '@/constants/application-config';
|
||||||
|
import coverageStatuses from '@/constants/coverage-statuses';
|
||||||
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
|
const paymentStoreId = 'payment';
|
||||||
|
|
||||||
|
function getLineItemQueryStringForPricing(lineItems) {
|
||||||
|
return lineItems.map((lineItem, index) => {
|
||||||
|
let queryStringSnippet = `&LineItems[${index}].partNumber=${lineItem.partNumber}`;
|
||||||
|
if (lineItem.childParts) {
|
||||||
|
queryStringSnippet += getLineItemQueryStringForPricing(lineItem.childParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryStringSnippet;
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPricesToLineItems(lineItems, pricingLineItems) {
|
||||||
|
return lineItems.map((lineItem) => {
|
||||||
|
const updatedLineItem = lineItem;
|
||||||
|
updatedLineItem.childParts = lineItem.childParts.map((childItem) => addPricesToLineItems(childItem, pricingLineItems));
|
||||||
|
|
||||||
|
const lineItemIndex = pricingLineItems.findIndex((pricingLineItem) => pricingLineItem.partNumber === lineItem.partNumber);
|
||||||
|
|
||||||
|
if (lineItemIndex > -1) {
|
||||||
|
const pricedLineItem = pricingLineItems[lineItemIndex];
|
||||||
|
updatedLineItem.laborAmount = pricedLineItem.laborAmount;
|
||||||
|
updatedLineItem.sellingPrice = pricedLineItem.sellingPrice;
|
||||||
|
updatedLineItem.kitPrice = pricedLineItem.kitPrice;
|
||||||
|
}
|
||||||
|
return updatedLineItem;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const usePaymentStore = defineStore({
|
||||||
|
id: paymentStoreId,
|
||||||
|
state: () => ({
|
||||||
|
deductible: null,
|
||||||
|
coverageStatus: coverageStatuses.PENDING,
|
||||||
|
isITAC: false,
|
||||||
|
isNoComp: false,
|
||||||
|
baseServiceLineItems: null,
|
||||||
|
supportingItems: null
|
||||||
|
}),
|
||||||
|
getters: {},
|
||||||
|
actions: {
|
||||||
|
setBaseServiceLineItems() {
|
||||||
|
this.baseServiceLineItems = [];
|
||||||
|
},
|
||||||
|
async getPriceOrderItems(availableLineItems) {
|
||||||
|
const zipCodeToUse = this.order.serviceLocation.zipCode;
|
||||||
|
if (!this.order.serviceLocation.zipCodeCtu) {
|
||||||
|
const zipInfo = await this.validateZip({ zip: zipCodeToUse });
|
||||||
|
this.order.serviceLocation.zipCodeCtu = zipInfo.data.zipCodeCtu;
|
||||||
|
}
|
||||||
|
const ctuToUse = this.order.serviceLocation.zipCodeCtu;
|
||||||
|
const availableLineItemsFormattedForRequest = getLineItemQueryStringForPricing(availableLineItems);
|
||||||
|
const deductibleToUse = this.order.currentDeductible ?? 0;
|
||||||
|
|
||||||
|
let queryString =
|
||||||
|
`ParentAccountNumber=${this.order.accountNumber}`
|
||||||
|
+ `&CTU=${ctuToUse}`
|
||||||
|
+ `&Deductible=${deductibleToUse}`
|
||||||
|
+ `&ZipCode=${zipCodeToUse}`
|
||||||
|
+ `${availableLineItemsFormattedForRequest}`;
|
||||||
|
|
||||||
|
const lineItemServerData = this.order.lineItems?.serverData;
|
||||||
|
if (lineItemServerData) {
|
||||||
|
queryString += `&ServerData=${encodeURIComponent(lineItemServerData)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await globalMethods
|
||||||
|
.callHttpClient({
|
||||||
|
method: endpoints.GetInsurancePriceOrderItems.method,
|
||||||
|
endpoint: `${endpoints.GetInsurancePriceOrderItems.url}?${queryString}`
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data?.lineItems) {
|
||||||
|
const retAvailableLineItems = addPricesToLineItems(availableLineItems, response.data.lineItems);
|
||||||
|
return retAvailableLineItems;
|
||||||
|
}
|
||||||
|
return availableLineItems;
|
||||||
|
},
|
||||||
|
async setSupportingItems() {
|
||||||
|
const glassPartsArray = useMainStore().lineItems.glassParts ?? [];
|
||||||
|
const { carId } = useMainStore().vehicle;
|
||||||
|
const { isRepair, numberOfChips } = useMainStore().damage;
|
||||||
|
|
||||||
|
this.supportingItems = await globalMethods
|
||||||
|
.callHttpClient({
|
||||||
|
method: endpoints.GetSupportingItems.method,
|
||||||
|
endpoint: endpoints.GetSupportingItems.url,
|
||||||
|
payload: {
|
||||||
|
carId,
|
||||||
|
damageType: isRepair ? 'Repair' : 'Replace',
|
||||||
|
parentAccountNumber: applicationConfig.CASH_PARENT_ACCOUNT_NUMBER,
|
||||||
|
parts: glassPartsArray,
|
||||||
|
numberOfRepairChips: isRepair ? numberOfChips : 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
persist: true
|
||||||
|
});
|
||||||
|
|
||||||
|
export { usePaymentStore };
|
||||||
Loading…
Reference in a new issue