From b1e160310d04ee22024dd18ebbcd0c6f220e626e Mon Sep 17 00:00:00 2001 From: Sravan Gopathi Date: Mon, 10 Apr 2023 08:44:39 -0400 Subject: [PATCH 1/8] Implemented Front End changes as per the card#1204 --- .../service-location-helper.js | 2 +- .../service-location/service-location.spec.js | 1 + src/store/index.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js index 157c28f2b..24be20fc8 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js @@ -35,7 +35,7 @@ export async function getServiceabilityDetails(serviceZipCode, lineItems) { storeActions.GET_SERVICEABILITY_DETAILS, { serviceZipCode: serviceZipCode, - lineItems: lineItems, + lineItems: lineItems }, false ); diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index aad61b630..d7f5348b9 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -39,6 +39,7 @@ const mockGetServiceabilityDetails = (mockServiceZipCode) => { isRecalibrationServiceableInshop: true, isGlassServiceableMobile: true, isRecalibrationServiceableMobile: true, + IsServiceability:true, }; return Promise.resolve(serviceabilityDetails); diff --git a/src/store/index.js b/src/store/index.js index 6da7550a2..0549ed8c4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -941,6 +941,20 @@ export const actions = { // const lineItems = context.getters.order.lineItems; // const lineItemsToSend = [...lineItems.supportingItems]; // const encodedLineItems = encodeURIComponent(JSON.stringify(lineItemsToSend)); + + //TODO: Restore this when CSR-1204 is 100% complete. Line# 958 to 961 should be removed Begin + // const vehicle = context.getters.vehicle; + // const carId = vehicle.carId; + // const damage = context.getters.damage; + // const glassArray = damage.glassToReplace; + // // create a new array to avoid mutating state + // const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray); + // return globalMethods.callHttpClient({ + // method: endpoints.GetServiceabilityDetails.method, + // endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}&carId=${carId}&glassPieces=${glassArrayForPayload}`, + // }); + //TODO: Restore this when CSR-1204 is 100% complete End + // return globalMethods.callHttpClient({ // method: endpoints.GetServiceabilityDetails.method, // endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}`, From 1f2ead4579d057015b9389b8619c2300fa3e06cc Mon Sep 17 00:00:00 2001 From: Sravan Gopathi Date: Tue, 9 May 2023 09:49:34 -0400 Subject: [PATCH 2/8] 1204: Front End changes. Added CarId and Glass Pieces to endpoint --- src/store/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 420248024..bad820b91 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -974,9 +974,15 @@ export const actions = { lineItemsWithOnlyPartNumbers, "lineItems" ); + const vehicle = context.getters.vehicle; + const carId = vehicle.carId; + const damage = context.getters.damage; + const glassArray = damage.glassToReplace; + // create a new array to avoid mutating state + const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray); return globalMethods.callHttpClient({ method: endpoints.GetServiceabilityDetails.method, - endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&${lineItemsToSend}`, + endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}&carId=${carId}&glassPieces=${glassArrayForPayload}`, }); }, From 1c2c44132ebc914cb79acf798b79153e99faeba5 Mon Sep 17 00:00:00 2001 From: Sravan Gopathi Date: Tue, 9 May 2023 10:47:48 -0400 Subject: [PATCH 3/8] 1204: Payload changes --- .../service-location-helper.js | 2 +- src/layouts/service-location/service-location.spec.js | 1 - src/store/index.js | 11 ++++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js index 24be20fc8..157c28f2b 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js @@ -35,7 +35,7 @@ export async function getServiceabilityDetails(serviceZipCode, lineItems) { storeActions.GET_SERVICEABILITY_DETAILS, { serviceZipCode: serviceZipCode, - lineItems: lineItems + lineItems: lineItems, }, false ); diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index dcb176919..52239462c 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -39,7 +39,6 @@ const mockGetServiceabilityDetails = (mockServiceZipCode) => { isRecalibrationServiceableInshop: true, isGlassServiceableMobile: true, isRecalibrationServiceableMobile: true, - IsServiceability:true, }; return Promise.resolve(serviceabilityDetails); diff --git a/src/store/index.js b/src/store/index.js index bad820b91..1548dd702 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -974,15 +974,20 @@ export const actions = { lineItemsWithOnlyPartNumbers, "lineItems" ); - const vehicle = context.getters.vehicle; + const vehicle = context.getters.vehicle; const carId = vehicle.carId; const damage = context.getters.damage; const glassArray = damage.glassToReplace; - // create a new array to avoid mutating state const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray); return globalMethods.callHttpClient({ method: endpoints.GetServiceabilityDetails.method, - endpoint: `${endpoints.GetServiceabilityDetails.url}?zip=${serviceZipCode}&lineItems=${encodedLineItems}&carId=${carId}&glassPieces=${glassArrayForPayload}`, + endpoint: endpoints.GetServiceabilityDetails.url, + payload: { + zip: serviceZipCode, + lineItems: lineItemsToSend, + carId: carId, + glassPieces: glassArrayForPayload, + }, }); }, From 1a47f83301923add9bd7052cca0cea199be5d08f Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 9 May 2023 12:13:04 -0400 Subject: [PATCH 4/8] Updates for weather Alerts --- src/constants/endpoints.js | 4 +++ src/constants/store-actions.js | 1 + src/layouts/schedule/schedule.vue | 50 +++++++++++++++++++++++++++++++ src/store/index.js | 9 ++++++ 4 files changed, 64 insertions(+) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 08f429b5e..ef94c7b18 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -90,6 +90,10 @@ const endpoints = { url: "/parts/api/v1/parts/supporting-items", method: "POST", }, + GetAlertReasons: { + url: "/location/api/v1/location/alert-reasons", + method: "GET", + }, GetProviderLocations: { url: "/location/api/v1/location/providers", method: "GET", diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index db15e9854..3edf8bec3 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -21,6 +21,7 @@ const storeActions = { LOOKUP_VIN_BY_PLATE: "lookupVinByPlate", LOOKUP_VIN_BY_ADDRESS: "lookupVinByAddress", LOOKUP_VIN_BY_IMAGE: "lookupVinByImage", + GET_ALERT_REASONS_BY_CTU: "getAlertReasonsByCtu", GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", GET_PARTS: "getParts", GET_WIPERS: "getWipers", diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 02361128c..e3eb56525 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -18,6 +18,17 @@ + + // Components +import alert from "@/ux-components/alert/alert"; import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; @@ -53,6 +65,8 @@ import { } from "@/helpers/cms-content-helper"; import { errorMessages } from "@/constants/error-messages"; import { required } from "@/helpers/validation-rules"; +import { storeActions } from "@/constants/store-actions"; +import store from "@/store"; defineRule("date-required", required(errorMessages.DATE_REQUIRED)); @@ -61,6 +75,7 @@ export default { data() { return { selectedDate: null, + weatherAlerts: [], mockSelectableDatesData: [ { year: 2023, month: 4, date: 13 }, { year: 2023, month: 4, date: 14 }, @@ -102,6 +117,9 @@ export default { // Splits content when brackets are found in text so that text can be looped through and router-link can be injected when needed return this.splitCopyOnCMSPlaceHolder(this.ChangeShopLinkText); }, + displayWeatherAlert() { + return this.weatherAlerts.length > 0; + }, }, methods: { doesCopyContainRouterLink, @@ -112,9 +130,37 @@ export default { return true; // NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE? }, + cmsHeadlineTextFound(widgetName) { + return this.getCmsContent(widgetName, "HeadlineText") !== "" + }, + async getAlertReasons(ctu) { + await this.dispatchStoreAction( + storeActions.GET_ALERT_REASONS_BY_CTU, + { + ctu: ctu, + } + ) + .then((response) => { + if (response.data) { + this.weatherAlerts = response.data.reduce((newObj, alert) => { + newObj.push({ + cmsWidgetName: `LocationAlert-${alert}`, + alertReason: alert, + }); + return newObj; + }, []); + } + }) + .catch(() => { + console.log("error fetching alert reasons.."); + }); + }, getAvailableDates(startDate, endDate) { return this.mockSelectableDatesData; }, + getServiceZipCtuCodeFromStore() { + return store.getters.order.serviceLocation.zipCodeCtu; + }, backButtonAction() { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, @@ -123,6 +169,7 @@ export default { }, }, components: { + alert, funnelHeader, funnelFooter, funnelSubHeader, @@ -130,6 +177,9 @@ export default { loadingModal, datePicker, }, + mounted() { + this.getAlertReasons(this.getServiceZipCtuCodeFromStore()); + }, }; diff --git a/src/store/index.js b/src/store/index.js index 1548dd702..a61df90d6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -681,6 +681,15 @@ export const actions = { }); }, + // Location API Actions + getAlertReasonsByCtu(context, { ctu }) { + return globalMethods.callHttpClient({ + method: endpoints.GetAlertReasons.method, + endpoint: `${endpoints.GetAlertReasons.url}/${ctu}`, + payload: {}, + }); + }, + // Misc Actions updateStoreWithSaveSessionResponse( context, From 8a55e1dbdd52b21eb655393c355a544b10e21e2c Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 9 May 2023 14:09:50 -0400 Subject: [PATCH 5/8] more inline with other page patterns --- .../schedule/helpers/schedule-helper.js | 13 ++++++ src/layouts/schedule/schedule.vue | 45 ++++++++++++------- 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 src/layouts/schedule/helpers/schedule-helper.js diff --git a/src/layouts/schedule/helpers/schedule-helper.js b/src/layouts/schedule/helpers/schedule-helper.js new file mode 100644 index 000000000..1b743d8ac --- /dev/null +++ b/src/layouts/schedule/helpers/schedule-helper.js @@ -0,0 +1,13 @@ +import { storeActions } from "@/constants/store-actions"; +import baseMixin from "@/mixins/base-mixin.js"; + +export async function getAlertReasons(ctu) { + const alertReasons = await baseMixin.methods.dispatchStoreAction( + storeActions.GET_ALERT_REASONS_BY_CTU, + { + ctu: ctu, + } + ) + + return Promise.resolve(alertReasons); +} \ No newline at end of file diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index e3eb56525..bc980553d 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -57,6 +57,9 @@ import datePicker from "@/digital-components/date-picker/date-picker"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; +import { + getAlertReasons, +} from "@/layouts/schedule/helpers/schedule-helper"; import { doesCopyContainRouterLink, splitCopyOnCMSPlaceHolder, @@ -75,6 +78,7 @@ export default { data() { return { selectedDate: null, + alertReasons: [], weatherAlerts: [], mockSelectableDatesData: [ { year: 2023, month: 4, date: 13 }, @@ -94,19 +98,26 @@ export default { // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); + const alertReasonsPromise = getAlertReasons(store.getters.order.serviceLocation.zipCodeCtu); + // Settle promises and get results const promiseResultMap = [ { resultKey: "cmsContent", promise: cmsContentPromise, }, + { + resultKey: "alertReasons", + promise: alertReasonsPromise, + }, ]; const resultMap = await settleAllPromises(promiseResultMap); - + // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); + vm.setData(resultMap.alertReasons); }); }, computed: { @@ -130,25 +141,28 @@ export default { return true; // NEED TODO - WHAT ARE PAGE REQ'S FOR THIS PAGE? }, + setData(alertReasonsData) { + if (alertReasonsData) { + this.convertReasonsToCmsAlerts(alertReasonsData); + } + }, cmsHeadlineTextFound(widgetName) { return this.getCmsContent(widgetName, "HeadlineText") !== "" }, - async getAlertReasons(ctu) { - await this.dispatchStoreAction( - storeActions.GET_ALERT_REASONS_BY_CTU, - { - ctu: ctu, - } - ) + convertReasonsToCmsAlerts(data) { + this.weatherAlerts = data.reduce((newObj, alert) => { + newObj.push({ + cmsWidgetName: `LocationAlert-${alert}`, + alertReason: alert, + }); + return newObj; + }, []); + }, + async getWeatherAlertReasons(ctu) { + await getAlertReasons(ctu) .then((response) => { if (response.data) { - this.weatherAlerts = response.data.reduce((newObj, alert) => { - newObj.push({ - cmsWidgetName: `LocationAlert-${alert}`, - alertReason: alert, - }); - return newObj; - }, []); + this.convertReasonsToCmsAlerts(response.data); } }) .catch(() => { @@ -178,7 +192,6 @@ export default { datePicker, }, mounted() { - this.getAlertReasons(this.getServiceZipCtuCodeFromStore()); }, }; From 166d52467e22dc7d3082ed796becb5b532f35260 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 9 May 2023 15:39:48 -0400 Subject: [PATCH 6/8] remove unused import --- src/layouts/schedule/schedule.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index bc980553d..c4aeff7eb 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -68,7 +68,6 @@ import { } from "@/helpers/cms-content-helper"; import { errorMessages } from "@/constants/error-messages"; import { required } from "@/helpers/validation-rules"; -import { storeActions } from "@/constants/store-actions"; import store from "@/store"; defineRule("date-required", required(errorMessages.DATE_REQUIRED)); From 0307ab1c0ac549cefe3f43139fa92b118ee884ff Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 10 May 2023 10:56:08 -0400 Subject: [PATCH 7/8] unneeded variable --- src/layouts/schedule/schedule.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index c4aeff7eb..b2e8b0a05 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -77,7 +77,6 @@ export default { data() { return { selectedDate: null, - alertReasons: [], weatherAlerts: [], mockSelectableDatesData: [ { year: 2023, month: 4, date: 13 }, From 78ec13b7febee20a0f4e1a140d7ad93ed6935711 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 10 May 2023 11:07:49 -0400 Subject: [PATCH 8/8] prettier'd --- .../schedule/helpers/schedule-helper.js | 16 +++++------ src/layouts/schedule/schedule.vue | 27 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/layouts/schedule/helpers/schedule-helper.js b/src/layouts/schedule/helpers/schedule-helper.js index 1b743d8ac..005bd4b19 100644 --- a/src/layouts/schedule/helpers/schedule-helper.js +++ b/src/layouts/schedule/helpers/schedule-helper.js @@ -2,12 +2,12 @@ import { storeActions } from "@/constants/store-actions"; import baseMixin from "@/mixins/base-mixin.js"; export async function getAlertReasons(ctu) { - const alertReasons = await baseMixin.methods.dispatchStoreAction( - storeActions.GET_ALERT_REASONS_BY_CTU, - { - ctu: ctu, - } - ) + const alertReasons = await baseMixin.methods.dispatchStoreAction( + storeActions.GET_ALERT_REASONS_BY_CTU, + { + ctu: ctu, + } + ); - return Promise.resolve(alertReasons); -} \ No newline at end of file + return Promise.resolve(alertReasons); +} diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index b2e8b0a05..83c3562bf 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -57,9 +57,7 @@ import datePicker from "@/digital-components/date-picker/date-picker"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; -import { - getAlertReasons, -} from "@/layouts/schedule/helpers/schedule-helper"; +import { getAlertReasons } from "@/layouts/schedule/helpers/schedule-helper"; import { doesCopyContainRouterLink, splitCopyOnCMSPlaceHolder, @@ -111,7 +109,7 @@ export default { ]; const resultMap = await settleAllPromises(promiseResultMap); - + // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); @@ -145,7 +143,7 @@ export default { } }, cmsHeadlineTextFound(widgetName) { - return this.getCmsContent(widgetName, "HeadlineText") !== "" + return this.getCmsContent(widgetName, "HeadlineText") !== ""; }, convertReasonsToCmsAlerts(data) { this.weatherAlerts = data.reduce((newObj, alert) => { @@ -158,14 +156,14 @@ export default { }, async getWeatherAlertReasons(ctu) { await getAlertReasons(ctu) - .then((response) => { - if (response.data) { - this.convertReasonsToCmsAlerts(response.data); - } - }) - .catch(() => { - console.log("error fetching alert reasons.."); - }); + .then((response) => { + if (response.data) { + this.convertReasonsToCmsAlerts(response.data); + } + }) + .catch(() => { + console.log("error fetching alert reasons.."); + }); }, getAvailableDates(startDate, endDate) { return this.mockSelectableDatesData; @@ -189,8 +187,7 @@ export default { loadingModal, datePicker, }, - mounted() { - }, + mounted() {}, };