diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 5f3b1a91..6ac0a793 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -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({ GetRouteInfo: { - url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/RouteInfo`, + url: (applicationAbbreviation) => `${baseContentUrl}/${applicationAbbreviation}/RouteInfo`, method: 'POST' }, GetHomepageInfo: { - url: (applicationAbbreviation) => `/content/api/v1/content/${applicationAbbreviation}/HomepageInfo`, + url: (applicationAbbreviation) => `${baseContentUrl}/${applicationAbbreviation}/HomepageInfo`, method: 'GET' }, GetPageData: { - url: (applicationAbbreviation, pageName) => `/content/api/v1/content/${applicationAbbreviation}/${pageName}`, + url: (applicationAbbreviation, pageName) => `${baseContentUrl}/${applicationAbbreviation}/${pageName}`, method: 'GET' }, GetAlertReasons: { - url: '/location/api/v1/location/alert-reasons', + url: `${baseLocationUrl}/alert-reasons`, method: 'GET' }, GetShopTimeSlots: { - url: '/schedule/api/v1/schedule/shop-time-slots', + url: `${baseScheduleUrl}/shop-time-slots`, method: 'POST' }, GetMobileTimeSlots: { - url: '/schedule/api/v1/schedule/mobile-time-slots', + url: `${baseScheduleUrl}/mobile-time-slots`, method: 'POST' }, GetMobilePremiumFee: { - url: '/parts/api/v1/parts/mobile-premium-fee', + url: `${basePartsUrl}/mobile-premium-fee`, method: 'GET' }, GetVehicleYears: { - url: '/vehicle/api/v1/vehicle/years', + url: `${baseVehicleUrl}/years`, method: 'GET' }, GetVehicleMakes: { - url: '/vehicle/api/v1/vehicle/makes/', + url: `${baseVehicleUrl}/makes/`, method: 'GET' }, GetVehicleModels: { - url: '/vehicle/api/v1/vehicle/models', + url: `${baseVehicleUrl}/models`, method: 'GET' }, GetVehicleStyles: { - url: '/vehicle/api/v1/vehicle/styles', + url: `${baseVehicleUrl}/styles`, method: 'GET' }, GetDamageOptions: { - url: '/parts/api/v1/parts/damage-options', + url: `${basePartsUrl}/damage-options`, method: 'GET' }, GetPartsOrQuestions: { - url: '/parts/api/v1/parts/parts-or-questions', + url: `${basePartsUrl}/parts-or-questions`, method: 'POST' }, GetParts: { - url: '/parts/api/v1/parts/parts', + url: `${basePartsUrl}/parts`, method: 'POST' }, + // TODO finish GetInsurancePriceOrderItems: { - url: '/price/api/v1/price/order-items-with-insurance-pricing', + url: () => `${basePriceUrl}/order-items-with-insurance-pricing`, method: 'GET' }, GetPriceOrderItems: { - url: '/price/api/v1/price/order-items', + url: `${basePriceUrl}/order-items`, method: 'GET' }, GetProviders: { - url: '/location/api/v1/location/providers', + url: `${baseLocationUrl}/providers`, method: 'GET' }, GetCapabilityQuestions: { - url: '/parts/api/v1/parts/capability-questions', + url: `${basePartsUrl}/capability-questions`, method: 'GET' }, GetPartFromCapabilityAnswer: { - url: '/parts/api/v1/parts/part-from-capability-answer', + url: `${basePartsUrl}/part-from-capability-answer`, method: 'POST' }, GetWipers: { - url: '/parts/api/v1/parts/wipers', + url: `${basePartsUrl}/wipers`, method: 'GET' }, GetRainDefense: { - url: '/parts/api/v1/parts/rain-defense', + url: `${basePartsUrl}/rain-defense`, method: 'GET' }, GetSupportingItems: { - url: '/parts/api/v1/parts/supporting-items', + url: `${basePartsUrl}/supporting-items`, method: 'POST' }, GetMobileFeePart: { - url: '/parts/api/v1/parts/mobile-fee', + url: `${basePartsUrl}/mobile-fee`, method: 'GET' }, GetServiceabilityDetails: { - url: '/location/api/v1/location/serviceability-details', + url: `${baseLocationUrl}/serviceability-details`, method: 'GET' }, GetVehicle: { - url: '/vehicle/api/v1/vehicle/lookup', + url: `${baseVehicleUrl}/lookup`, method: 'GET' }, GetAccountInfo: { - url: '/account/api/v1/account/', + url: baseAccountUrl, method: 'GET' }, LogExperimentExposureIfAssigned: { - url: '/experiments/api/v1/experiments/log-exposure', + url: `${baseExperimentsUrl}/log-exposure`, method: 'POST' }, LogPageView: { - url: '/analytics/api/v1/analytics/log-page-view', + url: `${baseAnalyticsUrl}/log-page-view`, method: 'POST' }, LogCustomEvent: { - url: '/analytics/api/v1/analytics/log-custom-event', + url: `${baseAnalyticsUrl}/log-custom-event`, method: 'POST' }, LookupVehicleByVin: { - url: '/vehicle/api/v1/vehicle/lookup', + url: `${baseVehicleUrl}/lookup`, method: 'POST' }, LookupVinByAddress: { - url: '/vehicle/api/v1/vehicle/lookup-vin-by-address', + url: `${baseVehicleUrl}/lookup-vin-by-address`, method: 'POST' }, LookupVinByPlate: { - url: '/vehicle/api/v1/vehicle/lookup-vin-by-plate', + url: `${baseVehicleUrl}/lookup-vin-by-plate`, method: 'POST' }, InitializeSession: { - url: '/analytics/api/v1/analytics/initialize', + url: `${baseAnalyticsUrl}/initialize`, method: 'POST' }, GetExperimentsByUser: { - url: '/analytics/api/v1/analytics/get-experiments', + url: `${baseAnalyticsUrl}/get-experiments`, method: 'GET' }, RunExperimentsForTrigger: { - url: '/experiments/api/v1/experiments/run', + url: `${baseExperimentsUrl}/run`, method: 'POST' }, ValidateZip: { - url: '/location/api/v1/location/zip', + url: `${baseLocationUrl}/zip`, method: 'GET' }, GooglePlaces: { url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places` }, ValidateClientTag: { - url: '/clientauth/api/v1/clientauth/validate-client-tag', + url: `${baseClientAuthUrl}/validate-client-tag`, method: 'GET' }, ValidateClientSignature: { - url: '/clientauth/api/v1/clientauth/validate-client-signature', + url: `${baseClientAuthUrl}/validate-client-signature`, method: 'POST' }, IsVinbyAddressPermissible: { - url: '/vehicle/api/v1/vehicle/is-vin-by-address-permissible', + url: `${baseVehicleUrl}/is-vin-by-address-permissible`, method: 'Get' }, CoveragePolicyInfo: { - url: '/coverage/api/v1/coverage/policy-information', + url: `${baseCoverageUrl}/policy-information`, method: 'POST' }, RegisterClaim: { - url: '/coverage/api/v1/coverage/register-claim', + url: `${baseCoverageUrl}/register-claim`, method: 'POST' }, SaveSession: { - url: '/order/api/v1/order/save-session/iss', + url: `${baseOrderUrl}/save-session/iss`, method: 'POST' }, LoadSession: { - url: '/order/api/v1/order/load-session', + url: `${baseOrderUrl}/load-session`, method: 'POST' }, DuplicateSearch: { // 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' }, FinalDeductible: { - url: '/coverage/api/v1/coverage/final-deductible', + url: `${baseCoverageUrl}/final-deductible`, method: 'POST' }, GetPaymentSignature: { - url: '/order/api/v1/order/sign', + url: `${baseOrderUrl}/sign`, method: 'POST' } }); diff --git a/src/iss-components/cart-dropdown/cart-dropdown.vue b/src/iss-components/cart-dropdown/cart-dropdown.vue index e9b23408..4e2caae7 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.vue +++ b/src/iss-components/cart-dropdown/cart-dropdown.vue @@ -54,7 +54,8 @@ export default { showAsPaid: Boolean, amountDueLabel: String, deductibleLabel: String, - basePriceLabel: String + basePriceLabel: String, + baseServiceLineItems: Array }, data() { return { @@ -69,19 +70,9 @@ export default { deductible() { return useMainStore().order.currentDeductible; }, - availableLineItems() { - // TODO make real - return [ - { - kitPrice: 1, - laborAmount: 2, - sellingPrice: 3 - } - ]; - }, // TODO share with claim registration page baseServicePrice() { - return this.availableLineItems + return this.baseServiceLineItems .reduce( (accumulator, lineItem) => accumulator + this.getTotalLineItemPrice(lineItem), 0 @@ -105,6 +96,10 @@ export default { return this.showAsPaid ? 0 : this.subTotal + this.salesTax; + }, + clonedGlassParts() { + const valueToClone = useMainStore().order.lineItems.glassParts ?? []; + return JSON.parse(JSON.stringify(valueToClone)) ?? []; } }, methods: { @@ -122,6 +117,34 @@ export default { return this.isUnverified && this.showDeductibleLineItem ? VERIFYING_COVERAGE : 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 []; } } }; diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index efdbb703..d7c6b0df 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -23,7 +23,8 @@ :showAsPaid="false" :amountDueLabel="amountDueText" :deductibleLabel="deductibleLabel" - :basePriceLabel="basePriceLabel" /> + :basePriceLabel="basePriceLabel" + :baseServiceLineItems="baseServiceLineItems" />