@o2xp/react-datatable
Version:
@o2xp/react-datatable is a modulable component to render data in a table with some nice features !
53 lines (47 loc) • 1.09 kB
JavaScript
const defaultState = {
notifications: []
};
const enqueueSnackbar = (state, payload) => {
return {
...state,
notifications: [
...state.notifications,
{
key: payload.key,
...payload
}
]
};
};
const closeSnackbar = (state, payload) => {
return {
...state,
notifications: state.notifications.map(notification =>
notification.key === payload
? { ...notification, dismissed: true }
: { ...notification }
)
};
};
const removeSnackbar = (state, payload) => {
return {
...state,
notifications: state.notifications.filter(
notification => notification.key !== payload
)
};
};
const notifierReducer = (state = defaultState, action) => {
const { payload, type } = action;
switch (type) {
case "ENQUEUE_SNACKBAR":
return enqueueSnackbar(state, payload);
case "CLOSE_SNACKBAR":
return closeSnackbar(state, payload);
case "REMOVE_SNACKBAR":
return removeSnackbar(state, payload);
default:
return state;
}
};
export default notifierReducer;