I find it difficult to cope with a task for today since i’m new to react-redux. Let me explain. I have two drop downs list and a grid just like the screenshot below:
The purpose of the drop downs is to filter my dummy data the first one by side and the second one by status. I created two actions:
export function filterBySide(product_side) {
const filtered_data_by_side = data.filter(record =>
{
return record.side.match(product_side)
});
return {
type: FILTER_BY_SIDE,
payload: {
filtered_data_by_side
}
};
}
export function filterByStatus(product_status) {
const filtered_data_by_status = data.filter(record =>
{
return record.status.match(product_status)
});
return {
type: FILTER_BY_STATUS,
payload: {
filtered_data_by_status
}
};
}
As you can see the first one is responsible for the side filtering and the other for the status filtering. Then i pass these to actions to my reducer like this:
case FILTER_BY_SIDE:
return state.set('filtered_data_by_side', List(action.payload.filtered_data_by_side));
case FILTER_BY_STATUS:
return state.set('filtered_data_by_status', List(action.payload.filtered_data_by_status));
and then i use MapStateToProps to make them available in the account list:
function mapStateToProps(state) {
return {
filtered_data_by_side:state.customer.get('filtered_data_by_side'),
filtered_data_by_status:state.customer.get('filtered_data_by_status')
};
}
I also fetch my actions to the drop down lists. My PROBLEM is that when i passed filtered_data_by_side as data in my grid only the first action occurs and when i passed filtered_data_by_status the second which is reasonable of course. The desired functionality is when i choose the first drop down to filter my data and then i choose the second the data that must be filtered by the first and then by the second dropdown and vice versa. How can i do this???