quintodrome/ui/src/reducers/settingsReducer.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
843 B
JavaScript
Raw Normal View History

import {
SET_NOTIFICATIONS_STATE,
SET_OMITTED_FIELDS,
SET_TOGGLEABLE_FIELDS,
} from '../actions'
2020-11-19 19:06:09 -09:00
const initialState = {
notifications: false,
toggleableFields: {},
omittedFields: {},
2020-11-19 19:06:09 -09:00
}
export const settingsReducer = (previousState = initialState, payload) => {
const { type, data } = payload
switch (type) {
case SET_NOTIFICATIONS_STATE:
return {
...previousState,
2020-11-19 19:22:18 -09:00
notifications: data,
2020-11-19 19:06:09 -09:00
}
case SET_TOGGLEABLE_FIELDS:
return {
...previousState,
toggleableFields: {
...previousState.toggleableFields,
...data,
},
}
case SET_OMITTED_FIELDS:
return {
...previousState,
omittedFields: {
...previousState.omittedFields,
...data,
},
}
2020-11-19 19:06:09 -09:00
default:
return previousState
}
}