const initialState = {
type_transport_id: null,
brand_id: null,
automodel_id: null,
year: null,
body_id: null,
};
export default function model(state = initialState, action) {
const { type, payload } = action;
switch(type) {
case SET_TYPE:
return {
...initialState,
type_transport_id: payload,
};
case SET_BRAND:
return {
...state,
brand_id: payload,
automodel_id: null,
year: null,
body_id: null,
};
default:
return state;
}
}
Либо кейс SET_BRAND можно еще так представить:
case SET_BRAND:
return {
...initialState,
type_transport_id: state.type_transport_id,
brand_id: payload,
};