Merge pull request #1639 from Safelite/feature/CSR-1885

CSR-1885
This commit is contained in:
AMSNEHA 2023-12-14 17:58:29 +05:30 committed by GitHub
commit 511da76fa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 72 deletions

View file

@ -216,9 +216,9 @@ export default {
styleQuestionInitialDataPromise styleQuestionInitialDataPromise
) )
vm.initializeMMSComponent( vm.initializeMMSComponent(
resultMap.makeQuestionInitialData, resultMap.makeQuestionInitialData?.response?.data,
resultMap.modelQuestionInitialData, resultMap.modelQuestionInitialData?.response?.data,
resultMap.styleQuestionInitialData resultMap.styleQuestionInitialData?.response?.data
); );
}); });
}, },
@ -226,17 +226,16 @@ export default {
watch: { watch: {
async selectedYear(year) { async selectedYear(year) {
if (year) { if (year) {
this.yearDropdown.disabled = true;
const result = await this.getMakeOptions(year); const result = await this.getMakeOptions(year);
this.makeOptions = result?.data; if (result?.year == year) {
if (this.selectedYearfromStore() !== year) { this.makeOptions = result?.response?.data;
this.selectedMake = null; if (this.selectedYearfromStore() !== year) {
this.selectedModel = null; this.selectedMake = null;
this.selectedStyle = null; this.selectedModel = null;
this.carId = null; this.selectedStyle = null;
this.carId = null;
}
} }
this.yearDropdown.disabled = false;
this.yearDropdown.focus();
} else { } else {
this.makeOptions = []; this.makeOptions = [];
this.selectedMake = null; this.selectedMake = null;
@ -247,17 +246,16 @@ export default {
}, },
async selectedMake(make) { async selectedMake(make) {
if (make) { if (make) {
this.makeDropdown.disabled = true;
const result = await this.getModelOptions(this.selectedYear, make); const result = await this.getModelOptions(this.selectedYear, make);
this.modelOptions = result?.data; if (decodeURIComponent(result?.make) == make) {
if (this.modelOptions.length === 1) this.selectedModel = this.modelOptions[0]; this.modelOptions = result?.response?.data;
else { if (this.modelOptions.length === 1) this.selectedModel = this.modelOptions[0];
this.selectedModel = null; else {
this.selectedStyle = null; this.selectedModel = null;
this.carId = null; this.selectedStyle = null;
this.carId = null;
}
} }
this.makeDropdown.disabled = false;
this.makeDropdown.focus();
} else { } else {
this.modelOptions = []; this.modelOptions = [];
this.selectedModel = null; this.selectedModel = null;
@ -267,25 +265,24 @@ export default {
}, },
async selectedModel(model) { async selectedModel(model) {
if (model) { if (model) {
this.modelDropdown.disabled = true;
const result = await this.getStyleOptions( const result = await this.getStyleOptions(
this.selectedYear, this.selectedYear,
this.selectedMake, this.selectedMake,
model model
); );
this.styleOptions = result?.data; if (decodeURIComponent(result?.model) == model) {
if (this.styleOptions.length === 1) { this.styleOptions = result?.response?.data;
const sameStyle = this.selectedStyle === this.styleOptions[0]; if (this.styleOptions.length === 1) {
this.selectedStyle = this.styleOptions[0]; const sameStyle = this.selectedStyle === this.styleOptions[0];
if (sameStyle) { this.selectedStyle = this.styleOptions[0];
this.getVehicleDetails(); if (sameStyle) {
this.getVehicleDetails();
}
} else {
this.selectedStyle = null;
this.carId = null;
} }
} else {
this.selectedStyle = null;
this.carId = null;
} }
this.modelDropdown.disabled = false;
this.modelDropdown.focus();
} else { } else {
this.styleOptions = []; this.styleOptions = [];
this.selectedStyle = null; this.selectedStyle = null;
@ -294,10 +291,7 @@ export default {
}, },
async selectedStyle(style) { async selectedStyle(style) {
if (style) { if (style) {
this.styleDropdown.disabled = true;
this.getVehicleDetails(); this.getVehicleDetails();
this.styleDropdown.disabled = false;
this.styleDropdown.focus();
} else { } else {
this.imageUrl = null; this.imageUrl = null;
this.carId = null; this.carId = null;
@ -315,18 +309,6 @@ export default {
else if (this.imageUrl == null && this.carId !== null) return false; else if (this.imageUrl == null && this.carId !== null) return false;
else return true; else return true;
}, },
yearDropdown() {
return document.getElementById("yearQuestionField");
},
makeDropdown() {
return document.getElementById("makeQuestionField");
},
modelDropdown() {
return document.getElementById("modelQuestionField");
},
styleDropdown() {
return document.getElementById("styleQuestionField");
},
allDataRetrieved() { allDataRetrieved() {
return ( return (
!!this.selectedYear && !!this.selectedYear &&

View file

@ -854,33 +854,54 @@ export const actions = {
}, },
getVehicleMakes(context, { payload: { year }, pageNameToLog }) { getVehicleMakes(context, { payload: { year }, pageNameToLog }) {
return globalMethods.callHttpClient({ return globalMethods
method: endpoints.GetVehicleMakes.method, .callHttpClient({
endpoint: `${endpoints.GetVehicleMakes.url}/${year}`, method: endpoints.GetVehicleMakes.method,
payload: {}, endpoint: `${endpoints.GetVehicleMakes.url}/${year}`,
logApiCall: true, payload: {},
pageNameToLog: pageNameToLog, logApiCall: true,
}); pageNameToLog: pageNameToLog,
})
.then((response) => {
return {
response,
year,
};
});
}, },
getVehicleModels(context, { payload: { year, make }, pageNameToLog }) { getVehicleModels(context, { payload: { year, make }, pageNameToLog }) {
return globalMethods.callHttpClient({ return globalMethods
method: endpoints.GetVehicleModels.method, .callHttpClient({
endpoint: `${endpoints.GetVehicleModels.url}/${year}/${make}`, method: endpoints.GetVehicleModels.method,
payload: {}, endpoint: `${endpoints.GetVehicleModels.url}/${year}/${make}`,
logApiCall: true, payload: {},
pageNameToLog: pageNameToLog, logApiCall: true,
}); pageNameToLog: pageNameToLog,
})
.then((response) => {
return {
response,
make,
};
});
}, },
getVehicleStyles(context, { payload: { year, make, model }, pageNameToLog }) { getVehicleStyles(context, { payload: { year, make, model }, pageNameToLog }) {
return globalMethods.callHttpClient({ return globalMethods
method: endpoints.GetVehicleStyles.method, .callHttpClient({
endpoint: `${endpoints.GetVehicleStyles.url}/${year}/${make}/${model}`, method: endpoints.GetVehicleStyles.method,
payload: {}, endpoint: `${endpoints.GetVehicleStyles.url}/${year}/${make}/${model}`,
logApiCall: true, payload: {},
pageNameToLog: pageNameToLog, logApiCall: true,
}); pageNameToLog: pageNameToLog,
})
.then((response) => {
return {
response,
model,
};
});
}, },
getVehicle(context, { payload: { year, make, model, style }, pageNameToLog }) { getVehicle(context, { payload: { year, make, model, style }, pageNameToLog }) {

View file

@ -493,7 +493,7 @@ describe("Actions", () => {
pageNameToLog: "test", pageNameToLog: "test",
}); });
expect(response.data).toEqual(["Acura", "Honda"]); expect(response.response.data).toEqual(["Acura", "Honda"]);
}); });
it("getVehicleModels action, should return models list", async () => { it("getVehicleModels action, should return models list", async () => {
@ -511,7 +511,7 @@ describe("Actions", () => {
pageNameToLog: "test", pageNameToLog: "test",
}); });
expect(response.data).toEqual(["ILX", "RDX"]); expect(response.response.data).toEqual(["ILX", "RDX"]);
}); });
it("getVehicleStyles action, should return models list", async () => { it("getVehicleStyles action, should return models list", async () => {
@ -529,7 +529,7 @@ describe("Actions", () => {
pageNameToLog: "test", pageNameToLog: "test",
}); });
expect(response.data).toEqual({ style: "4 DOOR SEDAN" }); expect(response.response.data).toEqual({ style: "4 DOOR SEDAN" });
}); });
it("getVehicle action, should get vehicle data ", async () => { it("getVehicle action, should get vehicle data ", async () => {