From e084e2b51832dff8c602681c979b3658582c3b4d Mon Sep 17 00:00:00 2001 From: Johan Gunawan Date: Tue, 3 Jan 2023 10:30:51 -0500 Subject: [PATCH] SSR-188 --- src/constants/damage-custom-labels.js | 8 ++ src/constants/endpoints.js | 4 + src/constants/vehicle-lookup-alert-types.js | 6 + src/helpers/damage-helper.js | 89 +++++++++++++ .../vin-location-information.vue | 113 +++++++++++++++++ .../vehicle-not-found-alert.vue | 25 ++++ .../vehicle-not-matched-alert.vue | 48 +++++++ .../vin-lookup-alerts/vin-lookup-alerts.vue | 49 ++++++++ src/layouts/vin-lookup/vin-lookup.vue | 119 +++++++++++++++--- .../vin-lookup/vin-question/vin-question.vue | 44 +++++++ src/main.js | 7 ++ src/router/router-constants/routing-table.js | 9 ++ 12 files changed, 502 insertions(+), 19 deletions(-) create mode 100644 src/constants/damage-custom-labels.js create mode 100644 src/constants/vehicle-lookup-alert-types.js create mode 100644 src/helpers/damage-helper.js create mode 100644 src/layouts/vin-lookup/vin-location-information/vin-location-information.vue create mode 100644 src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue create mode 100644 src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue create mode 100644 src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue create mode 100644 src/layouts/vin-lookup/vin-question/vin-question.vue diff --git a/src/constants/damage-custom-labels.js b/src/constants/damage-custom-labels.js new file mode 100644 index 00000000..b7ce7608 --- /dev/null +++ b/src/constants/damage-custom-labels.js @@ -0,0 +1,8 @@ +const damageCustomLabels = Object.freeze({ + MATCH: 'match', + REAR_WINDOW: 'rear window', + SIDE_WINDOW: 'side window', + WINDSHIELD: 'windshield', +}); + +export default damageCustomLabels; diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 5778b79a..cadc84fb 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -55,6 +55,10 @@ const endpoints = { url: "/analytics/api/v1/analytics/log-custom-event", method: "POST", }, + LookupVehicleByVin: { + url: "/vehicle/api/v1/vehicle/lookup", + method: "POST", + }, InitializeSession: { url: "/analytics/api/v1/analytics/initialize", method: "POST", diff --git a/src/constants/vehicle-lookup-alert-types.js b/src/constants/vehicle-lookup-alert-types.js new file mode 100644 index 00000000..3bbf686e --- /dev/null +++ b/src/constants/vehicle-lookup-alert-types.js @@ -0,0 +1,6 @@ +const vehicleLookupAlertTypes = Object.freeze({ + NOT_FOUND: 'notFound', + NOT_MATCHED: 'notMatched', +}); + +export default vehicleLookupAlertTypes; diff --git a/src/helpers/damage-helper.js b/src/helpers/damage-helper.js new file mode 100644 index 00000000..1aa4f624 --- /dev/null +++ b/src/helpers/damage-helper.js @@ -0,0 +1,89 @@ +import damageCustomLabels from '@/constants/damage-custom-labels'; +import { damageLocationsSelected } from '@/constants/damage-locations-selected'; +import { useMainStore } from '@/store'; + +export function getDamageString() { + const mainStore = useMainStore(); + + // If it's a repair it's always a windshield. + const { isRepair } = mainStore.damage; + if (isRepair) { + return damageCustomLabels.WINDSHIELD; + } + + const damageLocations = mainStore.damage.glassToReplace; + + if (!damageLocations || !Array.isArray(damageLocations)) { + return ''; + } + + if (damageLocations.length > 1) { + return damageCustomLabels.MATCH; + } + + const { glassLocation } = damageLocations[0]; + if (glassLocation) { + switch (glassLocation) { + case damageLocationsSelected.WINDSHIELD: + return damageCustomLabels.WINDSHIELD; + case damageLocationsSelected.DRIVER: + case damageLocationsSelected.PASSENGER: + return damageCustomLabels.SIDE_WINDOW; + case damageLocationsSelected.REAR: + return damageCustomLabels.REAR_WINDOW; + default: + return ''; + } + } + + // No condition is matched + return ''; +} + +/** + * Commented code are copied directly from DigitalConsumer.FixMyGlass + * and have not been adjusted for ISS. + */ + +// import store from "@/store"; +// import baseMixin from "@/mixins/base-mixin.js"; +// import { storeActions } from "@/constants/store-actions"; + +// export function getIsWindshieldOnly() { +// const damageLocations = store.getters.damage.glassToReplace; +// const returnString = +// damageLocations && +// damageLocations.length === 1 && +// damageLocations[0]?.glassLocation === "Windshield" +// ? "windshield" +// : "glass"; +// return returnString; +// } + +// export async function isGlassAvailableForCarId(carId) { +// const newGlassOptions = await baseMixin.methods.dispatchStoreAction( +// storeActions.GET_DAMAGE_OPTIONS, +// { carId: carId } +// ); + +// const currentGlassOptions = store.getters.damage.glassToReplace; + +// const optionsMap = { +// Windshield: "windshieldOptions", +// Driver: "driverSideOptions", +// Passenger: "passengerSideOptions", +// Rear: "backGlassOptions", +// }; + +// for (const option of currentGlassOptions) { +// if ( +// !newGlassOptions.data[ +// optionsMap[option.glassLocation] +// ].availableReplacementOptions.includes(option.glassName) +// ) { +// return false; +// } +// } + +// return true; +// } diff --git a/src/layouts/vin-lookup/vin-location-information/vin-location-information.vue b/src/layouts/vin-lookup/vin-location-information/vin-location-information.vue new file mode 100644 index 00000000..e0c39296 --- /dev/null +++ b/src/layouts/vin-lookup/vin-location-information/vin-location-information.vue @@ -0,0 +1,113 @@ + + + diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue new file mode 100644 index 00000000..b0c41194 --- /dev/null +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-found-alert/vehicle-not-found-alert.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue new file mode 100644 index 00000000..631a1bc6 --- /dev/null +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vehicle-not-matched-alert/vehicle-not-matched-alert.vue @@ -0,0 +1,48 @@ + + diff --git a/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue b/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue new file mode 100644 index 00000000..dc7f919b --- /dev/null +++ b/src/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue @@ -0,0 +1,49 @@ + + diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index c3b67d93..88fa8171 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -1,5 +1,9 @@ -