Merge pull request #2341 from Safelite/feature/CASH-276

CASH-276
This commit is contained in:
CarlNation 2025-03-04 10:31:20 -05:00 committed by GitHub
commit cf280c0dd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 95 additions and 6 deletions

View file

@ -9,6 +9,7 @@ const storeMutations = {
UPDATE_MAKE: "updateMake", UPDATE_MAKE: "updateMake",
UPDATE_MODEL: "updateModel", UPDATE_MODEL: "updateModel",
UPDATE_STYLE: "updateStyle", UPDATE_STYLE: "updateStyle",
UPDATE_VEHICLE_SUBTYPE: "updateVehicleSubType",
UPDATE_CAR_ID: "updateCarId", UPDATE_CAR_ID: "updateCarId",
UPDATE_VEHICLE_CATEGORY: "updateVehicleCategory", UPDATE_VEHICLE_CATEGORY: "updateVehicleCategory",
UPDATE_VEHICLE_IMAGE_URL: "updateVehicleImageUrl", UPDATE_VEHICLE_IMAGE_URL: "updateVehicleImageUrl",

View file

@ -9,3 +9,9 @@ const vehicleCategories = {
}; };
export { vehicleCategories }; export { vehicleCategories };
const vehicleSubTypes = {
HEAVY_TRUCK: "HEAVY TRUCK",
};
export { vehicleSubTypes };

View file

@ -48,6 +48,19 @@
validationRules="style-required" validationRules="style-required"
placeHolderText="Select style" placeHolderText="Select style"
customDropdownId="styleQuestionField" /> customDropdownId="styleQuestionField" />
<div v-if="showHeavyTruck">
<div class="separator-line"></div>
<textboxQuestion
class="mb-4"
cmsWidgetName="ServiceZipQuestionWidget"
v-model="serviceZipCode"
inputId="serviceZipCode"
mask="#####"
isRequired
validationRules="zip-required|zip-format" />
</div>
<alert <alert
ref="AlertNoService" ref="AlertNoService"
v-if="displayNoServiceAlert" v-if="displayNoServiceAlert"
@ -76,6 +89,7 @@ import navbar from "@/fmg-components/nav-bar/nav-bar";
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
import alert from "@/ux-components/alert/alert"; import alert from "@/ux-components/alert/alert";
import vehicleQuestion from "@/layouts/vehicle/vehicle-question/vehicle-question"; import vehicleQuestion from "@/layouts/vehicle/vehicle-question/vehicle-question";
import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
// Supporting files // Supporting files
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
@ -87,7 +101,7 @@ import {
} from "@/helpers/heritage-integration/cookie-helper"; } from "@/helpers/heritage-integration/cookie-helper";
import { settleAllPromises } from "@/helpers/layout-helper"; import { settleAllPromises } from "@/helpers/layout-helper";
import { Form, defineRule } from "vee-validate"; import { Form, defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules"; import { required, regex } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages"; import { errorMessages } from "@/constants/error-messages";
import store from "@/store"; import store from "@/store";
import { storeActions } from "@/constants/store-actions.js"; import { storeActions } from "@/constants/store-actions.js";
@ -96,12 +110,15 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
import { applicationConfig } from "../../constants/application-config"; import { applicationConfig } from "../../constants/application-config";
import { queryStrings } from "@/constants/query-strings"; import { queryStrings } from "@/constants/query-strings";
import { getQuerystringParameter } from "@/helpers/querystring-helper"; import { getQuerystringParameter } from "@/helpers/querystring-helper";
import { vehicleSubTypes } from "@/constants/vehicle-categories.js";
//define validation rules //define validation rules
defineRule("year-required", required(errorMessages.YEAR_REQUIRED)); defineRule("year-required", required(errorMessages.YEAR_REQUIRED));
defineRule("make-required", required(errorMessages.MAKE_REQUIRED)); defineRule("make-required", required(errorMessages.MAKE_REQUIRED));
defineRule("model-required", required(errorMessages.MODEL_REQUIRED)); defineRule("model-required", required(errorMessages.MODEL_REQUIRED));
defineRule("style-required", required(errorMessages.STYLE_REQUIRED)); defineRule("style-required", required(errorMessages.STYLE_REQUIRED));
defineRule("zip-required", required(errorMessages.ZIP_REQUIRED));
defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.ZIP_FORMAT));
export default { export default {
name: "vehicle", name: "vehicle",
@ -116,6 +133,8 @@ export default {
imageUrl: this.getImagefromStore(), imageUrl: this.getImagefromStore(),
imageVifNumber: this.getImageVifNumberfromStore(), imageVifNumber: this.getImageVifNumberfromStore(),
imageVifColor: this.getImageVifColorfromStore(), imageVifColor: this.getImageVifColorfromStore(),
serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipcode,
vehicleSubType: this.getVehicleSubTypefromStore(),
yearOptions: [], yearOptions: [],
makeOptions: [], makeOptions: [],
modelOptions: [], modelOptions: [],
@ -125,11 +144,14 @@ export default {
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
const log = getQuerystringParameter(queryStrings.LOG); if (store.getters.applicationUser.loggingOption) {
if (log === "true") { console.log(
console.log("----------------- applicationConfig start -----------------"); new Date() + "------------- vehicle.vue applicationConfig start -------------"
);
console.log(new Date() + JSON.stringify(applicationConfig)); console.log(new Date() + JSON.stringify(applicationConfig));
console.log("----------------- applicationConfig end -----------------"); console.log(
new Date() + "------------- vehicle.vue applicationConfig end -------------"
);
} }
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage); const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
@ -299,6 +321,7 @@ export default {
this.selectedMake = null; this.selectedMake = null;
this.selectedModel = null; this.selectedModel = null;
this.selectedStyle = null; this.selectedStyle = null;
this.vehicleSubType = null;
this.carId = null; this.carId = null;
if (year) { if (year) {
const result = await this.getMakeOptions(year); const result = await this.getMakeOptions(year);
@ -318,6 +341,7 @@ export default {
this.modelOptions = []; this.modelOptions = [];
this.selectedModel = null; this.selectedModel = null;
this.selectedStyle = null; this.selectedStyle = null;
this.vehicleSubType = null;
this.carId = null; this.carId = null;
if (make) { if (make) {
const result = await this.getModelOptions(this.selectedYear, make); const result = await this.getModelOptions(this.selectedYear, make);
@ -336,6 +360,7 @@ export default {
this.resetAlert(); this.resetAlert();
this.styleOptions = []; this.styleOptions = [];
this.selectedStyle = null; this.selectedStyle = null;
this.vehicleSubType = null;
this.carId = null; this.carId = null;
if (model) { if (model) {
const result = await this.getStyleOptions( const result = await this.getStyleOptions(
@ -400,8 +425,19 @@ export default {
!!this.carId !!this.carId
); );
}, },
showHeavyTruck() {
return (
this.vehicleSubType === vehicleSubTypes.HEAVY_TRUCK && !this.displayNoServiceAlert
);
},
}, },
methods: { methods: {
getZipFromStore() {
return (
store.getters?.externalParameterServiceZip?.zipCode ??
store.getters.order?.serviceLocation?.zipCode
);
},
isDisabled(options) { isDisabled(options) {
if ( if (
!options.length || !options.length ||
@ -443,6 +479,11 @@ export default {
this.imageVifNumber = result?.data.imageVifNumber; this.imageVifNumber = result?.data.imageVifNumber;
this.imageVifColor = result?.data.imageVifColor; this.imageVifColor = result?.data.imageVifColor;
this.displayNoServiceAlert = !result?.data.canSafeliteService; this.displayNoServiceAlert = !result?.data.canSafeliteService;
this.vehicleSubType = result?.data.vehicleSubType;
// if (this.showHeavyTruck) {
// }
}, },
resetAlert() { resetAlert() {
this.displayNoServiceAlert = false; this.displayNoServiceAlert = false;
@ -456,6 +497,7 @@ export default {
make: this.selectedMake, make: this.selectedMake,
model: this.selectedModel, model: this.selectedModel,
style: this.selectedStyle, style: this.selectedStyle,
vehicleSubType: this.vehicleSubType,
carId: this.carId, carId: this.carId,
category: this.category, category: this.category,
imageUrl: this.imageUrl, imageUrl: this.imageUrl,
@ -464,6 +506,20 @@ export default {
}, },
false false
); );
if (this.showHeavyTruck) {
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
await this.dispatchStoreAction(
storeActions.SAVE_SERVICE_ZIP_CODE_INFO,
{
zipCode: this.serviceZipCode,
state: zipCodeData.state,
zipCodeCtu: zipCodeData.zipCodeCtu,
},
false
);
}
this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route); this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route);
}, },
initializeYearComponent(initialData) { initializeYearComponent(initialData) {
@ -536,6 +592,9 @@ export default {
getImageVifColorfromStore() { getImageVifColorfromStore() {
return store.getters.vehicle.imageVifColor; return store.getters.vehicle.imageVifColor;
}, },
getVehicleSubTypefromStore() {
return store.getters.vehicle.vehicleSubType;
},
}, },
components: { components: {
@ -545,6 +604,7 @@ export default {
Form, Form,
alert, alert,
vehicleQuestion, vehicleQuestion,
textboxQuestion,
}, },
}; };
</script> </script>
@ -557,4 +617,9 @@ export default {
margin-top: 1.5rem; margin-top: 1.5rem;
margin-bottom: 0; margin-bottom: 0;
} }
.separator-line {
grid-area: 2/1/2/8;
border-top: 1px solid $gray-500;
margin: 0.5rem 0;
}
</style> </style>

View file

@ -61,6 +61,7 @@ const getDefaultState = () => {
make: null, make: null,
model: null, model: null,
style: null, style: null,
vehicleSubType: null,
carId: null, carId: null,
category: null, category: null,
vin: null, vin: null,
@ -211,6 +212,9 @@ export const mutations = {
updateStyle(state, style) { updateStyle(state, style) {
state.order.vehicle.style = style; state.order.vehicle.style = style;
}, },
updateVehicleSubType(state, vehicleSubType) {
state.order.vehicle.vehicleSubType = vehicleSubType;
},
updateCarId(state, carId) { updateCarId(state, carId) {
state.order.vehicle.carId = carId; state.order.vehicle.carId = carId;
}, },
@ -2125,6 +2129,7 @@ export const actions = {
model: vehicle.model, model: vehicle.model,
style: vehicle.style, style: vehicle.style,
vin: vehicle.vin, vin: vehicle.vin,
vehicleSubType: vehicle.vehicleSubType,
registration: { registration: {
firstName: vehicle.registration.firstName, firstName: vehicle.registration.firstName,
lastName: vehicle.registration.lastName, lastName: vehicle.registration.lastName,
@ -2335,7 +2340,18 @@ export const actions = {
// Vehicle // Vehicle
saveVehicle( saveVehicle(
context, context,
{ year, make, model, style, carId, category, imageUrl, imageVifNumber, imageVifColor } {
year,
make,
model,
style,
vehicleSubType,
carId,
category,
imageUrl,
imageVifNumber,
imageVifColor,
}
) { ) {
if ( if (
context.state.order.vehicle.year != year || context.state.order.vehicle.year != year ||
@ -2351,6 +2367,7 @@ export const actions = {
context.commit(storeMutations.UPDATE_MAKE, make); context.commit(storeMutations.UPDATE_MAKE, make);
context.commit(storeMutations.UPDATE_MODEL, model); context.commit(storeMutations.UPDATE_MODEL, model);
context.commit(storeMutations.UPDATE_STYLE, style); context.commit(storeMutations.UPDATE_STYLE, style);
context.commit(storeMutations.UPDATE_VEHICLE_SUBTYPE, vehicleSubType);
context.commit(storeMutations.UPDATE_CAR_ID, carId); context.commit(storeMutations.UPDATE_CAR_ID, carId);
context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, category); context.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, category);
context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, imageUrl); context.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, imageUrl);