Merge pull request #786 from Safelite/feature/CSR-867-redo
Feature/CSR-867 redo
This commit is contained in:
commit
c96881f288
14 changed files with 274 additions and 229 deletions
|
|
@ -19,7 +19,7 @@ export function getDamageString() {
|
|||
if (damageLocations.length > 1) {
|
||||
returnString = "match"
|
||||
} else {
|
||||
switch(damageLocations[0]?.location) {
|
||||
switch(damageLocations[0]?.glassLocation) {
|
||||
case "Windshield":
|
||||
returnString = "windshield"
|
||||
break;
|
||||
|
|
@ -36,7 +36,7 @@ export function getDamageString() {
|
|||
|
||||
export function getIsWindshieldOnly () {
|
||||
const damageLocations = store.getters.damage.glassToReplace;
|
||||
const returnString = damageLocations.length === 1 && damageLocations[0]?.location === "Windshield" ? "windshield" : "glass";
|
||||
const returnString = damageLocations.length === 1 && damageLocations[0]?.glassLocation === "Windshield" ? "windshield" : "glass";
|
||||
return returnString;
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ export async function isGlassAvailableForCarId(carId){
|
|||
}
|
||||
|
||||
for(const option of currentGlassOptions){
|
||||
if(!newGlassOptions.data[optionsMap[option.location]].availableReplacementOptions.includes(option.name)){
|
||||
if(!newGlassOptions.data[optionsMap[option.glassLocation]].availableReplacementOptions.includes(option.glassName)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
|||
it("Should return match when multiple selected damage options are in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}, {location: "Passenger", name: "sideWindow"}];
|
||||
store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "windshield"}, {glassLocation: "Passenger", glassName: "sideWindow"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
|||
it("Should return windshield when Windshield is the only selected damage option in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}];
|
||||
store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "windshield"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
|||
it("Should return side window when Driver or Passenger is the only selected damage option in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Passenger", name: "sideWindow"}];
|
||||
store.getters.damage.glassToReplace = [{glassLocation: "Passenger", glassName: "sideWindow"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
|||
it("Should return rear window when Rear is the only selected damage option in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Rear", name: "rear"}];
|
||||
store.getters.damage.glassToReplace = [{glassLocation: "Rear", glassName: "rear"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
|||
describe("damage-helper.js", () => {
|
||||
it("Should return true if no mismatches between each array exist", async () => {
|
||||
// Arrange
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}];
|
||||
store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "windshield"}];
|
||||
|
||||
// Act
|
||||
const isGlassAvailable = await isGlassAvailableForCarId();
|
||||
|
|
@ -80,7 +80,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
|||
describe("damage-helper.js", () => {
|
||||
it("Should return false if any mismatches between each array exist", async () => {
|
||||
// Arrange
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "sideWindow"}];
|
||||
store.getters.damage.glassToReplace = [{glassLocation: "Windshield", glassName: "sideWindow"}];
|
||||
|
||||
const isGlassAvailable = await isGlassAvailableForCarId();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
v-bind:isDismissible="false" />
|
||||
<div v-for="(glass, i) in capabilityQuestionsData" :key="glass.key">
|
||||
<questionChain ref="questionChain"
|
||||
v-model="selectedAnswers[glass.location + '-' + glass.name]"
|
||||
v-model="selectedAnswers[glass.glassLocation + '-' + glass.glassName]"
|
||||
:questionData="glass.capabilityQuestions" :glassIndex="i"
|
||||
v-if="showThisQuestionChain(glass, i)"
|
||||
validationRules="questions-required" />
|
||||
|
|
@ -86,7 +86,7 @@ export default {
|
|||
return this.getCmsContent("AdditionalPartsQuestionsAlert", "BodyText");
|
||||
},
|
||||
windshieldPart() {
|
||||
return this.pageData.partsOrQuestions.find(x => x.location === damageLocationsSelected.WINDSHIELD);
|
||||
return this.pageData.partsOrQuestions.find(x => x.glassLocation === damageLocationsSelected.WINDSHIELD);
|
||||
},
|
||||
windshieldPartInfo() {
|
||||
return this.windshieldPart.parts[0];
|
||||
|
|
@ -122,8 +122,8 @@ export default {
|
|||
const selectedAnswerResult2 = this.getCorrespondingAnswerResult2(glass.answerData.answerResult);
|
||||
|
||||
return {
|
||||
location: glass.location,
|
||||
name: glass.name,
|
||||
glassLocation: glass.glassLocation,
|
||||
glassName: glass.glassName,
|
||||
result: glass.answerData.answerResult,
|
||||
result1: glass.answerData.answerResult,
|
||||
result2: selectedAnswerResult2,
|
||||
|
|
@ -143,8 +143,8 @@ export default {
|
|||
// get parts from the capabilityQuestionAnswers
|
||||
let partsOrQuestions = this.pageData.partsOrQuestions;
|
||||
for (let answer of capabilityQuestionsAnswersArray) {
|
||||
const correspondingPart = partsOrQuestions.find(partOrQuestion => partOrQuestion.location === answer.location);
|
||||
const partFromCapabilityQuestionAnswer = (await this.dispatchStoreAction(storeActions.GET_PART_FROM_CAPABILITY_QUESTION_ANSWER, answer.location, false)).data;
|
||||
const correspondingPart = partsOrQuestions.find(partOrQuestion => partOrQuestion.glassLocation === answer.glassLocation);
|
||||
const partFromCapabilityQuestionAnswer = (await this.dispatchStoreAction(storeActions.GET_PART_FROM_CAPABILITY_QUESTION_ANSWER, answer.glassLocation, false)).data;
|
||||
|
||||
partsOrQuestions.find(partOrQuestion => partOrQuestion.location === answer.location).parts = partFromCapabilityQuestionAnswer;
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ export default {
|
|||
});
|
||||
|
||||
// Update the key to re-render this part's question-chain component
|
||||
this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].location + this.capabilityQuestionsData[gpIndex].name + Date.now().toString();
|
||||
this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].glassLocation + this.capabilityQuestionsData[gpIndex].glassName + Date.now().toString();
|
||||
|
||||
// handle suppressing downstream in this question chain
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ export default {
|
|||
});
|
||||
|
||||
// Update the key to re-render this part's question-chain component
|
||||
this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].location + this.capabilityQuestionsData[gpIndex].name + Date.now().toString();
|
||||
this.capabilityQuestionsData[gpIndex].key = this.capabilityQuestionsData[gpIndex].glassLocation + this.capabilityQuestionsData[gpIndex].glassName + Date.now().toString();
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<div v-for="(glass, i) in moldingQuestionsData" :key="glass.key">
|
||||
<questionChain
|
||||
ref="questionChain"
|
||||
v-model="selectedAnswers[glass.location + '-' + glass.name]"
|
||||
v-model="selectedAnswers[glass.glassLocation + '-' + glass.glassName]"
|
||||
:questionData="glass.questions"
|
||||
:glassIndex="i"
|
||||
v-if="showThisQuestionChain(glass, i)"
|
||||
|
|
@ -132,8 +132,8 @@ export default {
|
|||
async forwardButtonAction() {
|
||||
const questionAnswersArray = this.moldingQuestionsData.map((glass) => {
|
||||
return {
|
||||
location: glass.location,
|
||||
name: glass.name,
|
||||
glassLocation: glass.glassLocation,
|
||||
glassName: glass.glassName,
|
||||
partNum: glass.answerData.answerResult,
|
||||
answeredQuestions: glass.answerData.answeredQuestions,
|
||||
isSuppressedPart: glass.isSuppressedPart,
|
||||
|
|
@ -152,7 +152,7 @@ export default {
|
|||
let partsOrQuestions = this.pageData.partsOrQuestions;
|
||||
for (let answer of questionAnswersArray) {
|
||||
partsOrQuestions.find(partOrQuestion => {
|
||||
return partOrQuestion.location === answer.location && partOrQuestion.name === answer.name;
|
||||
return partOrQuestion.glassLocation === answer.glassLocation && partOrQuestion.glassName === answer.glassName;
|
||||
}).parts[0].childParts = [
|
||||
{
|
||||
partNumber: answer.partNum
|
||||
|
|
@ -250,7 +250,7 @@ export default {
|
|||
});
|
||||
|
||||
// Update the key to re-render this part's question-chain component
|
||||
this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].location + this.moldingQuestionsData[gpIndex].name + Date.now().toString();
|
||||
this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].glassLocation + this.moldingQuestionsData[gpIndex].glassName + Date.now().toString();
|
||||
|
||||
// handle suppressing downstream in this question chain
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ export default {
|
|||
});
|
||||
|
||||
// Update the key to re-render this part's question-chain component
|
||||
this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].location + this.moldingQuestionsData[gpIndex].name + Date.now().toString();
|
||||
this.moldingQuestionsData[gpIndex].key = this.moldingQuestionsData[gpIndex].glassLocation + this.moldingQuestionsData[gpIndex].glassName + Date.now().toString();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<div v-for="(glass, i) in partsQuestionsData" :key="glass.key">
|
||||
<questionChain
|
||||
ref="questionChain"
|
||||
v-model="selectedAnswers[glass.location + '-' + glass.name]"
|
||||
v-model="selectedAnswers[glass.glassLocation + '-' + glass.glassName]"
|
||||
:questionData="glass.questions"
|
||||
:glassIndex="i"
|
||||
v-if="showThisQuestionChain(glass, i)"
|
||||
|
|
@ -132,8 +132,8 @@ export default {
|
|||
async forwardButtonAction() {
|
||||
const questionAnswersArray = this.partsQuestionsData.map((glass) => {
|
||||
return {
|
||||
location: glass.location,
|
||||
name: glass.name,
|
||||
glassLocation: glass.glassLocation,
|
||||
glassName: glass.glassName,
|
||||
result: glass.answerData.answerResult,
|
||||
answeredQuestions: glass.answerData.answeredQuestions,
|
||||
isSuppressedPart: glass.isSuppressedPart,
|
||||
|
|
@ -246,7 +246,7 @@ export default {
|
|||
});
|
||||
|
||||
// Update the key to re-render this part's question-chain component
|
||||
this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].location + this.partsQuestionsData[gpIndex].name + Date.now().toString();
|
||||
this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].glassLocation + this.partsQuestionsData[gpIndex].glassName + Date.now().toString();
|
||||
|
||||
// handle suppressing downstream in this question chain
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ export default {
|
|||
});
|
||||
|
||||
// Update the key to re-render this part's question-chain component
|
||||
this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].location + this.partsQuestionsData[gpIndex].name + Date.now().toString();
|
||||
this.partsQuestionsData[gpIndex].key = this.partsQuestionsData[gpIndex].glassLocation + this.partsQuestionsData[gpIndex].glassName + Date.now().toString();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@ describe("vehicle-damage.vue", () => {
|
|||
//Arrange
|
||||
const partsData = {
|
||||
partsOrQuestions: [{
|
||||
name: "Single",
|
||||
location: "Windshield",
|
||||
glassName: "Single",
|
||||
glassLocation: "Windshield",
|
||||
parts: null,
|
||||
partQuestions: [{
|
||||
questionSequence: 1,
|
||||
|
|
@ -144,8 +144,8 @@ describe("vehicle-damage.vue", () => {
|
|||
selectedRearReplaceOptions: "Stationary",
|
||||
})
|
||||
|
||||
const expectedGlassToReplace = [{ location: "Windshield", name: "Single" }, { location: "Driver", name: "Back" },
|
||||
{ location: "Passenger", name: "Quarter" }, { location: "Rear", name: "Stationary" }];
|
||||
const expectedGlassToReplace = [{ glassLocation: "Windshield", glassName: "Single" }, { glassLocation: "Driver", glassName: "Back" },
|
||||
{ glassLocation: "Passenger", glassName: "Quarter" }, { glassLocation: "Rear", glassName: "Stationary" }];
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
|
|
@ -168,8 +168,8 @@ describe("vehicle-damage.vue", () => {
|
|||
const partsData = {
|
||||
partsOrQuestions: [
|
||||
{
|
||||
location: "Windshield",
|
||||
name: "Single",
|
||||
glassLocation: "Windshield",
|
||||
glassName: "Single",
|
||||
partQuestions: null,
|
||||
parts: [
|
||||
{
|
||||
|
|
@ -189,8 +189,8 @@ describe("vehicle-damage.vue", () => {
|
|||
]
|
||||
},
|
||||
{
|
||||
name: "Stationary",
|
||||
location: "Rear",
|
||||
glassName: "Stationary",
|
||||
glassLocation: "Rear",
|
||||
parts: [
|
||||
{
|
||||
partNumber: "DB09626GTYN",
|
||||
|
|
@ -235,7 +235,7 @@ describe("vehicle-damage.vue", () => {
|
|||
selectedWindshieldDamageType: "Replace"
|
||||
};
|
||||
|
||||
const expectedGlassToReplace = [{ location: "Windshield", name: "Single" },];
|
||||
const expectedGlassToReplace = [{ glassLocation: "Windshield", glassName: "Single" },];
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
|
|
@ -509,7 +509,7 @@ describe("vehicle-damage.vue", () => {
|
|||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation }] }, isRepair: true };
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation }] }, isRepair: true };
|
||||
|
||||
var glassSelections = wrapper.vm.getDamageLocationsFromStore();
|
||||
|
||||
|
|
@ -553,7 +553,7 @@ describe("vehicle-damage.vue", () => {
|
|||
eventBusItem: jest.fn(),
|
||||
damage:
|
||||
{
|
||||
glassToReplace: [{ location: damageLocation, name: damageName }],
|
||||
glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }],
|
||||
isRepair: isRepair,
|
||||
numberOfChips: 2
|
||||
},
|
||||
|
|
@ -583,7 +583,7 @@ describe("vehicle-damage.vue", () => {
|
|||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation, name: damageName }] }, isRepair: true };
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }] }, isRepair: true };
|
||||
|
||||
var glassSelections = wrapper.vm.getDriverSideReplaceOptionsFromStore();
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ describe("vehicle-damage.vue", () => {
|
|||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation, name: damageName }] }, isRepair: true };
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }] }, isRepair: true };
|
||||
|
||||
var glassSelections = wrapper.vm.getPassengerSideReplaceOptionsFromStore();
|
||||
|
||||
|
|
@ -634,7 +634,7 @@ describe("vehicle-damage.vue", () => {
|
|||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ location: damageLocation, name: damageName }] }, isRepair: true };
|
||||
store.getters = { vehicle: { carId: "C0000000" }, eventBusItem: jest.fn(), damage: { glassToReplace: [{ glassLocation: damageLocation, glassName: damageName }] }, isRepair: true };
|
||||
|
||||
var glassSelections = wrapper.vm.getRearReplaceOptionsFromStore();
|
||||
|
||||
|
|
|
|||
|
|
@ -179,16 +179,16 @@ export default {
|
|||
getDamageLocationsFromStore() {
|
||||
var glassSelections = [];
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD }) ||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD }) ||
|
||||
store.getters.damage.isRepair) {
|
||||
glassSelections.push(damageLocationsSelected.WINDSHIELD);
|
||||
}
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER ||
|
||||
glass.location === damageLocationsSelected.PASSENGER })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER ||
|
||||
glass.glassLocation === damageLocationsSelected.PASSENGER })) {
|
||||
glassSelections.push(damageLocationsSelected.SIDEDOOR);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.REAR })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.REAR })) {
|
||||
glassSelections.push(damageLocationsSelected.REARWINDOW);
|
||||
}
|
||||
|
||||
|
|
@ -205,20 +205,20 @@ export default {
|
|||
windShieldOptions.selectedWindshieldChipCount = store.getters.damage.numberOfChips;
|
||||
}
|
||||
else {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.name === damageLocationsSelected.SINGLE })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.SINGLE })) {
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.SINGLE);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.name === damageLocationsSelected.DRIVER })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.DRIVER })) {
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.DRIVER);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.name === damageLocationsSelected.PASSENGER })) {
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.WINDSHIELD &&
|
||||
glass.glassName === damageLocationsSelected.PASSENGER })) {
|
||||
windShieldOptions.selectedWindshieldDamageType = damageLocationsSelected.REPLACE;
|
||||
windShieldOptions.selectedWindshieldReplaceOptions.push(damageLocationsSelected.PASSENGER);
|
||||
}
|
||||
|
|
@ -229,11 +229,11 @@ export default {
|
|||
|
||||
getDoorSidesFromStore() {
|
||||
var doorSides = [];
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.DRIVER })){
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.DRIVER })){
|
||||
doorSides.push(damageLocationsSelected.DRIVERSIDE);
|
||||
}
|
||||
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.location === damageLocationsSelected.PASSENGER })){
|
||||
if (store.getters.damage.glassToReplace?.some(glass => { return glass.glassLocation === damageLocationsSelected.PASSENGER })){
|
||||
doorSides.push(damageLocationsSelected.PASSENGERSIDE);
|
||||
}
|
||||
|
||||
|
|
@ -244,8 +244,8 @@ export default {
|
|||
var driverSideReplaceOptions = [];
|
||||
|
||||
store.getters.damage.glassToReplace?.forEach(glass => {
|
||||
if (glass.location === damageLocationsSelected.DRIVER){
|
||||
driverSideReplaceOptions.push(glass.name);
|
||||
if (glass.glassLocation === damageLocationsSelected.DRIVER){
|
||||
driverSideReplaceOptions.push(glass.glassName);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -256,8 +256,8 @@ export default {
|
|||
var passengerSideReplaceOptions = [];
|
||||
|
||||
store.getters.damage.glassToReplace?.forEach(glass => {
|
||||
if (glass.location === damageLocationsSelected.PASSENGER){
|
||||
passengerSideReplaceOptions.push(glass.name);
|
||||
if (glass.glassLocation === damageLocationsSelected.PASSENGER){
|
||||
passengerSideReplaceOptions.push(glass.glassName);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ export default {
|
|||
},
|
||||
|
||||
getRearReplaceOptionsFromStore() {
|
||||
var rearReplaceOptions = store.getters.damage.glassToReplace?.filter(glass => glass.location === damageLocationsSelected.REAR)[0]?.name;
|
||||
var rearReplaceOptions = store.getters.damage.glassToReplace?.filter(glass => glass.glassLocation === damageLocationsSelected.REAR)[0]?.glassName;
|
||||
|
||||
return rearReplaceOptions;
|
||||
},
|
||||
|
|
@ -295,24 +295,24 @@ export default {
|
|||
const selectedGlassToReplace = [];
|
||||
if (this.isWindshieldDamageLocation && !this.isWindshieldRepair){
|
||||
this.selectedWindshieldOptions.selectedWindshieldReplaceOptions.forEach(wsItem => {
|
||||
selectedGlassToReplace.push({ location: damageLocationsSelected.WINDSHIELD, name: wsItem});
|
||||
selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.WINDSHIELD, glassName: wsItem});
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isDriverSideReplace){
|
||||
this.sideDoorOptionsData.selectedDriverSideReplaceOptions.forEach(driverItem => {
|
||||
selectedGlassToReplace.push({ location: damageLocationsSelected.DRIVER, name: driverItem});
|
||||
selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.DRIVER, glassName: driverItem});
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isPassengerSideReplace){
|
||||
this.sideDoorOptionsData.selectedPassengerSideReplaceOptions.forEach(passengerItem => {
|
||||
selectedGlassToReplace.push({ location: damageLocationsSelected.PASSENGER, name: passengerItem});
|
||||
selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.PASSENGER, glassName: passengerItem});
|
||||
})
|
||||
}
|
||||
|
||||
if (this.isRearWindowDamageLocation) {
|
||||
selectedGlassToReplace.push({ location: damageLocationsSelected.REAR, name: this.selectedRearReplaceOptions});
|
||||
selectedGlassToReplace.push({ glassLocation: damageLocationsSelected.REAR, glassName: this.selectedRearReplaceOptions});
|
||||
}
|
||||
|
||||
return selectedGlassToReplace;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ const featureListData = {
|
|||
{ ColorAnswerText: 'Green Tint', FeatureAnswers: [{ FeatureAnswerText: "heated glass, solar, 1 hole", PartNumber: "DB12209GTYN" }] },
|
||||
{ ColorAnswerText: 'Gray Tint Privacy', FeatureAnswers: [{ FeatureAnswerText: "heated glass, solar, 1 hole", PartNumber: "DB12209YPYN" }] }
|
||||
],
|
||||
locationProp: "Rear",
|
||||
nameProp: "Stationary",
|
||||
glassLocationProp: "Rear",
|
||||
glassNameProp: "Stationary",
|
||||
modelValueProp: {}
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ describe("glass-part-question.vue", () => {
|
|||
|
||||
});
|
||||
|
||||
test("Tint mapper, should get tint image by location and tintColor", async () => {
|
||||
test("Tint mapper, should get tint image by glassLocation and tintColor", async () => {
|
||||
|
||||
//Arrange
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ describe("glass-part-question.vue", () => {
|
|||
//Arrange
|
||||
const { wrapper } = setupMocks(featureListData);
|
||||
store.getters.pageData.mockReset();
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] });
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] });
|
||||
|
||||
//Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
|
@ -110,7 +110,7 @@ describe("glass-part-question.vue", () => {
|
|||
test("default is selected if only one option", async () => {
|
||||
// Arrange
|
||||
store.getters.pageData.mockReset();
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] });
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}]}] });
|
||||
const { wrapper } = setupMocks(featureListData);
|
||||
|
||||
// Act
|
||||
|
|
@ -128,7 +128,7 @@ describe("glass-part-question.vue", () => {
|
|||
test("default is not selected if more than one option", async () => {
|
||||
// Arrange
|
||||
store.getters.pageData.mockReset();
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}, { partNumber: "DB12209GTYNXXX", color: "Green Tint"}]}] });
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: [{ partNumber: "DB12209GTYN", color: "Green Tint"}, { partNumber: "DB12209GTYNXXX", color: "Green Tint"}]}] });
|
||||
const { wrapper } = setupMocks(featureListData);
|
||||
|
||||
// Act
|
||||
|
|
@ -149,13 +149,13 @@ describe("glass-part-question.vue", () => {
|
|||
["Windshield", "Single", "Blue Tint", []],
|
||||
["Driver", "Quarter", "Green Tint", []]
|
||||
];
|
||||
test.each(partsForSelectedTintTestCases)("partsForSelectedTint returns correct parts", async (location, name, selectedTint, expectedResults) => {
|
||||
test.each(partsForSelectedTintTestCases)("partsForSelectedTint returns correct parts", async (glassLocation, glassName, selectedTint, expectedResults) => {
|
||||
// Arrange
|
||||
store.getters.pageData.mockReset();
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [
|
||||
{
|
||||
name: "Stationary",
|
||||
location: "Rear",
|
||||
glassName: "Stationary",
|
||||
glassLocation: "Rear",
|
||||
parts: [
|
||||
{ partNumber: "Glass1", color: "Green Tint"},
|
||||
{ partNumber: "Glass2", color: "Blue Tint"},
|
||||
|
|
@ -167,14 +167,14 @@ describe("glass-part-question.vue", () => {
|
|||
]
|
||||
},
|
||||
{
|
||||
name: "Single",
|
||||
location: "Windshield",
|
||||
glassName: "Single",
|
||||
glassLocation: "Windshield",
|
||||
parts: [{ partNumber: "Windshield1", color: "Green Tint"}, { partNumber: "Windshield2", color: "Green Tint"}]
|
||||
}
|
||||
]});
|
||||
const { wrapper } = setupMocks({
|
||||
locationProp: location,
|
||||
nameProp: name,
|
||||
glassLocationProp: glassLocation,
|
||||
glassNameProp: glassName,
|
||||
colorAnswersProp: [],
|
||||
});
|
||||
|
||||
|
|
@ -188,9 +188,9 @@ describe("glass-part-question.vue", () => {
|
|||
|
||||
|
||||
|
||||
function setupMocks({ nameProp, locationProp, colorAnswersProp, modelValueProp }) {
|
||||
function setupMocks({ glassNameProp, glassLocationProp, colorAnswersProp, modelValueProp }) {
|
||||
//Mock store
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{name: "Stationary", location: "Rear", parts: []}] });
|
||||
store.getters.pageData.mockReturnValueOnce({ partsOrQuestions: [{glassName: "Stationary", glassLocation: "Rear", parts: []}] });
|
||||
store.getters.lineItems = { glassParts: {} }
|
||||
|
||||
const mountOptions = getMountOptions({
|
||||
|
|
@ -205,8 +205,8 @@ function setupMocks({ nameProp, locationProp, colorAnswersProp, modelValueProp }
|
|||
});
|
||||
|
||||
mountOptions.propsData = {
|
||||
name: nameProp,
|
||||
location: locationProp,
|
||||
glassName: glassNameProp,
|
||||
glassLocation: glassLocationProp,
|
||||
colorAnswers: colorAnswersProp,
|
||||
modelValue: modelValueProp
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
:isWide="true"
|
||||
altText=""
|
||||
isRequired
|
||||
:groupName="`${location}-${name}`"
|
||||
:groupName="`${glassLocation}-${glassName}`"
|
||||
:validationRules="tintValidationRules">
|
||||
<div class="row my-2" aria-live="polite">
|
||||
<div class="col">
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
textPosition="text-start"
|
||||
:loaderEnabled="false"
|
||||
isRequired
|
||||
:groupName="`${location}-${name}-${selectedTint}`"
|
||||
:groupName="`${glassLocation}-${glassName}-${selectedTint}`"
|
||||
:validationRules="partValidationRules"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -58,8 +58,8 @@ export default {
|
|||
};
|
||||
},
|
||||
props: {
|
||||
name: String,
|
||||
location: String,
|
||||
glassName: String,
|
||||
glassLocation: String,
|
||||
colorAnswers: Array,
|
||||
modelValue: Object,
|
||||
alreadyPopulatedPartsData: {
|
||||
|
|
@ -75,7 +75,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
tintValidationRules() {
|
||||
const validationRuleName = `${this.location}-${this.name}-tint-required`;
|
||||
const validationRuleName = `${this.glassLocation}-${this.glassName}-tint-required`;
|
||||
|
||||
defineRule(
|
||||
validationRuleName,
|
||||
|
|
@ -85,7 +85,7 @@ export default {
|
|||
return validationRuleName;
|
||||
},
|
||||
partValidationRules() {
|
||||
const validationRuleName = `${this.location}-${this.name}-part-required`;
|
||||
const validationRuleName = `${this.glassLocation}-${this.glassName}-part-required`;
|
||||
|
||||
defineRule(
|
||||
validationRuleName,
|
||||
|
|
@ -96,7 +96,7 @@ export default {
|
|||
colorQuestionText() {
|
||||
return getCustomTransformValue(
|
||||
this.glassColorQuestion,
|
||||
`${this.location} ${this.name}`
|
||||
`${this.glassLocation} ${this.glassName}`
|
||||
);
|
||||
},
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ export default {
|
|||
value: tintOption,
|
||||
buttonLabel: tintOption,
|
||||
buttonImage: require(`@/assets/img/tints/${this.getTintSourceImage(
|
||||
this.location,
|
||||
this.glassLocation,
|
||||
tintOption
|
||||
)}`),
|
||||
});
|
||||
|
|
@ -134,9 +134,9 @@ export default {
|
|||
partsForSelectedTint() {
|
||||
const matchingGlass = this.PartDataFromApi.partsOrQuestions?.filter(
|
||||
(dataForGlassLocationAndName) =>
|
||||
dataForGlassLocationAndName.name == this.name &&
|
||||
dataForGlassLocationAndName.location ==
|
||||
this.location
|
||||
dataForGlassLocationAndName.glassName == this.glassName &&
|
||||
dataForGlassLocationAndName.glassLocation ==
|
||||
this.glassLocation
|
||||
);
|
||||
const matchingGlassParts =
|
||||
matchingGlass?.length == 1 ? matchingGlass[0].parts : [];
|
||||
|
|
@ -192,8 +192,8 @@ export default {
|
|||
|
||||
// Gets tint images based on the glass type, and tint name.
|
||||
// Returns an empty string if the src or object is undefined.
|
||||
getTintSourceImage(location, tintColor) {
|
||||
const tintSourceObject = getTintImage(location, tintColor);
|
||||
getTintSourceImage(glassLocation, tintColor) {
|
||||
const tintSourceObject = getTintImage(glassLocation, tintColor);
|
||||
|
||||
if (
|
||||
tintSourceObject === undefined ||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ store.getters = {
|
|||
const basePartResponse = {
|
||||
partsOrQuestions: [
|
||||
{
|
||||
name: "Stationary",
|
||||
location: "Rear",
|
||||
glassName: "Stationary",
|
||||
glassLocation: "Rear",
|
||||
parts: [
|
||||
{
|
||||
partNumber: "DB12209GTYN",
|
||||
|
|
@ -216,8 +216,8 @@ describe("vehicle-parts.vue", () => {
|
|||
return {
|
||||
partsOrQuestions: [
|
||||
{
|
||||
name: "Stationary",
|
||||
location: "Rear",
|
||||
glassName: "Stationary",
|
||||
glassLocation: "Rear",
|
||||
parts: null,
|
||||
partQuestions: [{
|
||||
testProperty: "some value"
|
||||
|
|
@ -296,8 +296,8 @@ describe("vehicle-parts.vue", () => {
|
|||
store.getters.pageData.mockReturnValueOnce({
|
||||
partsOrQuestions: [
|
||||
{
|
||||
name: "Single",
|
||||
location: "Windshield",
|
||||
glassName: "Single",
|
||||
glassLocation: "Windshield",
|
||||
parts: [
|
||||
{
|
||||
"partNumber": "FW03861GTYN",
|
||||
|
|
@ -374,8 +374,8 @@ describe("vehicle-parts.vue", () => {
|
|||
store.getters.pageData.mockReturnValueOnce({
|
||||
partsOrQuestions: [
|
||||
{
|
||||
name: "Single",
|
||||
location: "Windshield",
|
||||
glassName: "Single",
|
||||
glassLocation: "Windshield",
|
||||
parts: [
|
||||
{
|
||||
partNumber: "DB12209GTYN",
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
<!-- Render horizontal lines if there is multi-glass (aka if i > 0) -->
|
||||
<hr v-if="i > 0" />
|
||||
<glassPartQuestion
|
||||
:ref="`${RefPrefix}-${item.location}-${item.name}`"
|
||||
v-model="selectedGlassParts[item.location + '-' + item.name]"
|
||||
:location="item.location"
|
||||
:name="item.name"
|
||||
:ref="`${RefPrefix}-${item.glassLocation}-${item.glassName}`"
|
||||
v-model="selectedGlassParts[item.glassLocation + '-' + item.glassName]"
|
||||
:glassLocation="item.glassLocation"
|
||||
:glassName="item.glassName"
|
||||
:colorAnswers="item.colorAnswers"
|
||||
:alreadyPopulatedPartsData="alreadyPopulatedPartsData" />
|
||||
</div>
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
@ForwardClicked="forwardButtonAction" />
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
@ -117,8 +117,8 @@ export default {
|
|||
// Map API result data, to vehicle-parts data structure
|
||||
const mappedData = partsData.partsOrQuestions.map((g) => {
|
||||
return {
|
||||
name: g.name,
|
||||
location: g.location,
|
||||
glassName: g.glassName,
|
||||
glassLocation: g.glassLocation,
|
||||
colorAnswers: g.parts?.reduce((arr, p) => {
|
||||
arr.push({
|
||||
ColorAnswerText: p.color,
|
||||
|
|
@ -169,9 +169,9 @@ export default {
|
|||
|
||||
if (isMatched) {
|
||||
matchedParts.push({
|
||||
location: value.location,
|
||||
name: value.name,
|
||||
parts: [currentPart],
|
||||
glassLocation: value.glassLocation,
|
||||
glassName: value.glassName,
|
||||
parts: [currentPart]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ export default {
|
|||
const partNumber = this.alreadyPopulatedPartsData[key].partNumber;
|
||||
g.parts.forEach((p) => {
|
||||
if (p.partNumber === partNumber) {
|
||||
this.selectedGlassParts[g.location + "-" + g.name] = p;
|
||||
this.selectedGlassParts[g.glassLocation + "-" + g.glassName] = p;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,20 +65,20 @@ export default {
|
|||
return this.comparePageIndices(currentPage, fmgPage) > 0;
|
||||
},
|
||||
setupInitialData(glass, i, alreadyAnsweredQuestions, vm) {
|
||||
glass.key = glass.location + "-" + glass.name;
|
||||
glass.key = glass.glassLocation + "-" + glass.glassName;
|
||||
const self = vm ?? this;
|
||||
// clear answerData if no questions are already answered
|
||||
if (!alreadyAnsweredQuestions) { glass.answerData = null }
|
||||
|
||||
alreadyAnsweredQuestions?.forEach((answeredGlass) => {
|
||||
// if answeredGlass lacks any of these properties then exit
|
||||
if (!answeredGlass.location ||
|
||||
!answeredGlass.name ||
|
||||
if (!answeredGlass.glassLocation ||
|
||||
!answeredGlass.glassName ||
|
||||
!answeredGlass.answeredQuestions ||
|
||||
!answeredGlass.result && !answeredGlass.partNum) { return }
|
||||
|
||||
// test if glass parts match
|
||||
if (glass.location === answeredGlass.location && glass.name === answeredGlass.name) {
|
||||
if (glass.glassLocation === answeredGlass.glassLocation && glass.glassName === answeredGlass.glassName) {
|
||||
let answerString = "";
|
||||
|
||||
// loop through answeredQuestions for matches
|
||||
|
|
@ -118,7 +118,7 @@ export default {
|
|||
|
||||
// Set up watch for each set of glass questions
|
||||
// (updated when all questions for a glass have been answered in question-chain)
|
||||
self.$watch("selectedAnswers." + glass.location + '-' + glass.name, (newValue) => {
|
||||
self.$watch("selectedAnswers." + glass.glassLocation + '-' + glass.glassName, (newValue) => {
|
||||
if (newValue) {
|
||||
self.handleAnswerUpdates(newValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Act
|
||||
const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([
|
||||
{
|
||||
name: "Something",
|
||||
location: "somewhere",
|
||||
glassName: "Something",
|
||||
glassLocation: "somewhere",
|
||||
parts: [{
|
||||
partNumber: "1234567"
|
||||
}]
|
||||
|
|
@ -90,22 +90,22 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Act
|
||||
const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([
|
||||
{
|
||||
name: "Something",
|
||||
location: "somewhere",
|
||||
glassName: "Something",
|
||||
glassLocation: "somewhere",
|
||||
parts: [{
|
||||
partNumber: "1234567"
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "Another glass",
|
||||
location: "somewhere else",
|
||||
glassName: "Another glass",
|
||||
glassLocation: "somewhere else",
|
||||
parts: [{
|
||||
partNumber: "1234568"
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "Special glass",
|
||||
location: "Another where",
|
||||
glassName: "Special glass",
|
||||
glassLocation: "Another where",
|
||||
parts: [{
|
||||
partNumber: "1234569"
|
||||
}]
|
||||
|
|
@ -123,22 +123,22 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Act
|
||||
const hasGlassLocationWithMultipleParts = wrapper.vm.hasGlassLocationWithMultipleParts([
|
||||
{
|
||||
name: "Something",
|
||||
location: "somewhere",
|
||||
glassName: "Something",
|
||||
glassLocation: "somewhere",
|
||||
parts: [{
|
||||
partNumber: "1234567"
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "Another glass",
|
||||
location: "somewhere else",
|
||||
glassName: "Another glass",
|
||||
glassLocation: "somewhere else",
|
||||
parts: [{
|
||||
partNumber: "1234568"
|
||||
}]
|
||||
},
|
||||
{
|
||||
name: "Special glass",
|
||||
location: "Another where",
|
||||
glassName: "Special glass",
|
||||
glassLocation: "Another where",
|
||||
parts: [
|
||||
{
|
||||
partNumber: "1234569"
|
||||
|
|
@ -321,8 +321,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
const glass = {
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
};
|
||||
const i = 0;
|
||||
|
||||
|
|
@ -338,8 +338,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
test("should return glass with answerData of null", async () => {
|
||||
// Arrange
|
||||
const glass = {
|
||||
"name": "Single",
|
||||
"location": "Windshield"
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield"
|
||||
};
|
||||
const i = 0;
|
||||
const { wrapper } = setupMocks({});
|
||||
|
|
@ -356,8 +356,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
test("should return glass with answerResult within answerData", async () => {
|
||||
// Arrange
|
||||
const glass = {
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"questions": [
|
||||
{
|
||||
"questionSequence": 1,
|
||||
|
|
@ -380,8 +380,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
const i = 0;
|
||||
const alreadyAnsweredQuestions = [
|
||||
{
|
||||
"location": "Windshield",
|
||||
"name": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"glassName": "Single",
|
||||
"partNum": "WKT D1106 C",
|
||||
"answeredQuestions": [
|
||||
{
|
||||
|
|
@ -409,8 +409,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": null,
|
||||
"partQuestions": [
|
||||
{
|
||||
|
|
@ -449,8 +449,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": null,
|
||||
"partQuestions": [
|
||||
{
|
||||
|
|
@ -472,8 +472,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "Front",
|
||||
"location": "Driver",
|
||||
"glassName": "Front",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD08158GTYN",
|
||||
|
|
@ -487,8 +487,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Quarter",
|
||||
"location": "Driver",
|
||||
"glassName": "Quarter",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DQ08162GTYN",
|
||||
|
|
@ -502,8 +502,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "SideDoor",
|
||||
"location": "Driver",
|
||||
"glassName": "SideDoor",
|
||||
"glassLocation": "Driver",
|
||||
"parts": null,
|
||||
"partQuestions": [
|
||||
{
|
||||
|
|
@ -525,8 +525,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DB08165GTNN",
|
||||
|
|
@ -557,8 +557,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": null,
|
||||
"partQuestions": [
|
||||
{
|
||||
|
|
@ -580,8 +580,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "Front",
|
||||
"location": "Driver",
|
||||
"glassName": "Front",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD08158GTYN",
|
||||
|
|
@ -595,8 +595,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Quarter",
|
||||
"location": "Driver",
|
||||
"glassName": "Quarter",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DQ08162GTYN",
|
||||
|
|
@ -610,8 +610,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "SideDoor",
|
||||
"location": "Driver",
|
||||
"glassName": "SideDoor",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD08160GTYN",
|
||||
|
|
@ -625,8 +625,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DB08165GTNN",
|
||||
|
|
@ -657,8 +657,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": null,
|
||||
"partQuestions": [
|
||||
{
|
||||
|
|
@ -680,8 +680,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "Front",
|
||||
"location": "Driver",
|
||||
"glassName": "Front",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD08158GTYN",
|
||||
|
|
@ -695,8 +695,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Quarter",
|
||||
"location": "Driver",
|
||||
"glassName": "Quarter",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DQ08162GTYN",
|
||||
|
|
@ -718,8 +718,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "SideDoor",
|
||||
"location": "Driver",
|
||||
"glassName": "SideDoor",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD08160GTYN",
|
||||
|
|
@ -741,8 +741,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DB08165GTNN",
|
||||
|
|
@ -807,8 +807,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FB25724GTYN",
|
||||
|
|
@ -847,8 +847,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FW03647GTNN",
|
||||
|
|
@ -868,8 +868,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"location": "Driver",
|
||||
"glassName": "Back",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FD25747GTYN",
|
||||
|
|
@ -883,8 +883,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Front",
|
||||
"location": "Driver",
|
||||
"glassName": "Front",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FD25719GTYN",
|
||||
|
|
@ -898,8 +898,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Vent",
|
||||
"location": "Driver",
|
||||
"glassName": "Vent",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FV25749GTNN",
|
||||
|
|
@ -913,8 +913,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FB25724GTYN",
|
||||
|
|
@ -953,8 +953,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DW02101GTYN",
|
||||
|
|
@ -968,8 +968,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"location": "Driver",
|
||||
"glassName": "Back",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD12202GTYN",
|
||||
|
|
@ -991,8 +991,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Front",
|
||||
"location": "Driver",
|
||||
"glassName": "Front",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DD12198GTYN",
|
||||
|
|
@ -1014,8 +1014,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Quarter",
|
||||
"location": "Driver",
|
||||
"glassName": "Quarter",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DQ12204GTYNOEM",
|
||||
|
|
@ -1085,8 +1085,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "DB12209GTYN",
|
||||
|
|
@ -1127,8 +1127,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FB25724GTYN",
|
||||
|
|
@ -1180,8 +1180,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FB25724GTYN",
|
||||
|
|
@ -1216,8 +1216,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FW04186GTYN",
|
||||
|
|
@ -1253,8 +1253,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
// Arrange
|
||||
const partsOrQuestions = [
|
||||
{
|
||||
"name": "Single",
|
||||
"location": "Windshield",
|
||||
"glassName": "Single",
|
||||
"glassLocation": "Windshield",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FW04186GTYN",
|
||||
|
|
@ -1274,8 +1274,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"location": "Driver",
|
||||
"glassName": "Back",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FD25457GTYN",
|
||||
|
|
@ -1289,8 +1289,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Front",
|
||||
"location": "Driver",
|
||||
"glassName": "Front",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FD27090GTYN",
|
||||
|
|
@ -1304,8 +1304,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Vent",
|
||||
"location": "Driver",
|
||||
"glassName": "Vent",
|
||||
"glassLocation": "Driver",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FV25459GTNN",
|
||||
|
|
@ -1319,8 +1319,8 @@ describe("vehicle-questions-mixin", () => {
|
|||
"partQuestions": null
|
||||
},
|
||||
{
|
||||
"name": "Stationary",
|
||||
"location": "Rear",
|
||||
"glassName": "Stationary",
|
||||
"glassLocation": "Rear",
|
||||
"parts": [
|
||||
{
|
||||
"partNumber": "FB25460GTYN",
|
||||
|
|
|
|||
|
|
@ -799,24 +799,22 @@ export const actions = {
|
|||
const zipCode = order.serviceLocation.zipCode;
|
||||
const vin = vehicle.vin;
|
||||
|
||||
// create a new array to avoid mutating state
|
||||
const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray);
|
||||
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetPartsOrQuestions.method,
|
||||
endpoint: endpoints.GetPartsOrQuestions.url,
|
||||
payload: {
|
||||
carId: carId,
|
||||
glassPieces: glassArray ?? [],
|
||||
glassPieces: glassArrayForPayload,
|
||||
zip: zipCode,
|
||||
vin: vin,
|
||||
},
|
||||
});
|
||||
|
||||
// Flatten location and name properties
|
||||
response.data.partsOrQuestions.map(glass => {
|
||||
glass.location = glass.glassPiece.location;
|
||||
glass.name = glass.glassPiece.name;
|
||||
delete glass.glassPiece;
|
||||
return glass;
|
||||
});
|
||||
response.data.partsOrQuestions = convertGlassPieceNamingFromApi(response.data.partsOrQuestions);
|
||||
|
||||
return response;
|
||||
},
|
||||
|
|
@ -833,25 +831,24 @@ export const actions = {
|
|||
const zipCode = order.serviceLocation.zipCode;
|
||||
const vin = vehicle.vin;
|
||||
|
||||
// Flatten location and name properties
|
||||
// create a new array to avoid mutating state
|
||||
const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray);
|
||||
const resultsArrayForPayload = convertResultsForApi(resultsArray);
|
||||
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetParts.method,
|
||||
endpoint: endpoints.GetParts.url,
|
||||
payload: {
|
||||
carId: carId,
|
||||
glassPieces: glassArray,
|
||||
answerResults: resultsArray,
|
||||
glassPieces: glassArrayForPayload,
|
||||
answerResults: resultsArrayForPayload,
|
||||
zip: zipCode,
|
||||
vin: vin,
|
||||
},
|
||||
});
|
||||
|
||||
response.data.glassPieceParts.map(glass => {
|
||||
glass.location = glass.glassPiece.location;
|
||||
glass.name = glass.glassPiece.name;
|
||||
delete glass.glassPiece;
|
||||
return glass;
|
||||
});
|
||||
|
||||
// Flatten location and name properties
|
||||
response.data.glassPieceParts = convertGlassPieceNamingFromApi(response.data.glassPieceParts);
|
||||
|
||||
return response;
|
||||
},
|
||||
|
|
@ -869,12 +866,12 @@ export const actions = {
|
|||
);
|
||||
|
||||
const part = pageData.partsOrQuestions.find(
|
||||
(x) => x.location === glassLocation
|
||||
(x) => x.glassLocation === glassLocation
|
||||
).parts[0];
|
||||
const capabilityQuestionAnswers =
|
||||
context.getters.damage.capabilityQuestionAnswers;
|
||||
const capabilityQuestionAnswersForPart = capabilityQuestionAnswers.find(
|
||||
(x) => x.location === glassLocation
|
||||
(x) => x.glassLocation === glassLocation
|
||||
);
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
|
|
@ -895,6 +892,9 @@ export const actions = {
|
|||
const applicationUser = context.getters.applicationUser;
|
||||
const lineItems = context.state.order.lineItems;
|
||||
|
||||
// create a new array to avoid mutating state
|
||||
const newGlassToReplace = convertGlassPieceNamingForApi(damage.glassToReplace);
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url,
|
||||
|
|
@ -918,7 +918,7 @@ export const actions = {
|
|||
},
|
||||
damage: {
|
||||
numberOfChips: damage.numberOfChips,
|
||||
glassToReplace: damage.glassToReplace,
|
||||
glassToReplace: newGlassToReplace,
|
||||
isRepair: damage.isRepair,
|
||||
},
|
||||
customer: {
|
||||
|
|
@ -945,6 +945,7 @@ export const actions = {
|
|||
});
|
||||
},
|
||||
loadSession(context, { referralNumber, referralDate, referralCorrelationId, accountNumber }) {
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.LoadSession.method,
|
||||
endpoint: endpoints.LoadSession.url,
|
||||
|
|
@ -955,6 +956,15 @@ export const actions = {
|
|||
accountNumber: accountNumber?.toString()
|
||||
},
|
||||
}).then((response) => {
|
||||
// Flatten location and name properties
|
||||
response.data.damage?.glassToReplace?.map(glass => {
|
||||
glass.glassLocation = glass.location;
|
||||
glass.glassName = glass.name;
|
||||
delete glass.location;
|
||||
delete glass.name;
|
||||
return glass;
|
||||
});
|
||||
|
||||
// clear the state if the existing EON does not equal what is returned from loadSession
|
||||
if (context.state.order.eon && context.state.order.eon != response.data.eon) {
|
||||
context.commit(storeMutations.RESET_STATE);
|
||||
|
|
@ -1364,3 +1374,38 @@ function sortArrayOfObjectsByPropertyValue(arrayOfObjects, propertyName) {
|
|||
else return 0;
|
||||
});
|
||||
}
|
||||
|
||||
function convertGlassPieceNamingForApi(glassArray) {
|
||||
if (!glassArray) return [];
|
||||
const converted = [];
|
||||
glassArray.forEach(glass => {
|
||||
converted.push({
|
||||
location: glass.glassLocation,
|
||||
name: glass.glassName
|
||||
})
|
||||
});
|
||||
return converted;
|
||||
}
|
||||
|
||||
function convertResultsForApi(resultsArray) {
|
||||
if (!resultsArray) return [];
|
||||
const converted = [];
|
||||
resultsArray.forEach(answer => {
|
||||
converted.push({
|
||||
location: answer.glassLocation,
|
||||
name: answer.glassName,
|
||||
result: answer.result
|
||||
})
|
||||
});
|
||||
return converted;
|
||||
}
|
||||
|
||||
function convertGlassPieceNamingFromApi(glassArray) {
|
||||
glassArray.forEach(glass => {
|
||||
glass.glassLocation = glass.glassPiece.location;
|
||||
glass.glassName = glass.glassPiece.name;
|
||||
delete glass.glassPiece;
|
||||
return glass;
|
||||
});
|
||||
return glassArray;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue