Is the mutation method correctly written to modify the initial state array? I'm uncertain about the last few lines of the mutation method. What am I missing, if anything?
// Storing
state: {
flights: [
{trip_class: 0, number_of_change="1"},
{trip_class: 1, number_of_change="2"},
{trip_class: 1, number_of_change="1"}...
]
} // Expecting to filter the array
mutations: {
setFilteredFlights: (state, data) => {
// Flight classes
if (...) {
state.flights.filter(
(flight) =>
flight.trip_class === data.selectedFlightClass ||
flight.number_of_changes === data.selectedChanges
);
}
// Flight changes
else if (...) {
state.flights; // Unsure about this line of code
}
},
}