Is there a more efficient way to simplify this switch statement for handling 5 different cases? Can I streamline the process of updating the completion status based on each step?
data() {
return {
stepOneIsCompleted: false,
stepTwoIsCompleted: false,
stepThreeIsCompleted: false,
stepFourIsCompleted: false,
stepFiveIsCompleted: false,
};
},
updateViewEditVisibility(step, status) {
switch (step) {
case 1:
status === 200 ? this.stepOneIsCompleted = true : this.stepOneIsCompleted = false;
break;
case 2:
status === 200 ? this.stepTwoIsCompleted = true : this.stepOneIsCompleted = false;
break;
case 3:
status === 200 ? this.stepThreeIsCompleted = true : this.stepOneIsCompleted = false;
break;
case 4:
status === 200 ? this.stepFourIsCompleted = true : this.stepOneIsCompleted = false;
break;
case 5:
status === 200 ? this.stepFiveIsCompleted = true : this.stepOneIsCompleted = false;
break;
}
},
Could I potentially optimize this by using an array and assigning values based on the step number provided as props?