I have a list of airplanes departing or arriving at the airport and i also had a search filter where i enter the time of arrival or departure and filtering of the airplanes. I do this using the actual
property of my API. But I needed to change my search. Now I need to search by flight number - the planeTypeID.code
property of my API. But when I changed it, stopped showing a list of airplanes. What is my mistake and how to fix it?
I just instead actual
everywhere wrote ["planeTypeID.code"]
and delete method:
.split("-").reverse().join("-")
OLD version:
small part airplane.js(reducer)
case "RUN_FILTER":
var newData = state.data[action.shift || state.shift].filter(x => {
return (
x.actual &&
x.actual.includes(
state.day
.split("-")
.reverse()
.join("-")
)
);
});
case "LOAD_DATA_END":
var newData = action.payload.data[state.shift].filter(x => {
return (
x.actual &&
x.actual.includes(
action.payload.day
.split("-")
.reverse()
.join("-")
)
);
});
small part app.js(main component)
export function searchFilter(search, data) {
return data.filter(n => n.actual.toLowerCase().includes(search));
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NEW version:
small part airplane.js(reducer)
case "RUN_FILTER":
var newData = state.data[action.shift || state.shift].filter(x => {
return (
x["planeTypeID.code"] && // Сhange
x["planeTypeID.code"].includes( // Сhange
state.day
// delete
)
);
});
return Object.assign({}, state, {
case "LOAD_DATA_END":
var newData = action.payload.data[state.shift].filter(x => {
return (
x["planeTypeID.code"] && // Сhange
x["planeTypeID.code"].includes( // Сhange
action.payload.day
// delete
)
);
});
small part app.js(main component)
export function searchFilter(search, data) {
return data.filter(n => n["planeTypeID.code"].toLowerCase().includes(search)); // Сhange
}
All project code in sandbox:
https://codesandbox.io/s/redux-ant-design-filter-table-column-with-slider-jj6mu
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…