You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

// ------------------------------------
// Initial State
// ------------------------------------
const initialState = {
filter: 'ALL_ACTIVITY',
modal: {
modalType: null,
modalProps: {}
}
}
// ------------------------------------
// Constants
// ------------------------------------
export const SHOW_ACTIVITY_MODAL = 'SHOW_ACTIVITY_MODAL'
export const HIDE_ACTIVITY_MODAL = 'HIDE_ACTIVITY_MODAL'
// ------------------------------------
// Actions
// ------------------------------------
export function showActivityModal(modalType, modalProps) {
return {
type: SHOW_ACTIVITY_MODAL,
modalType,
modalProps
}
}
export function hideActivityModal() {
return {
type: HIDE_ACTIVITY_MODAL
}
}
// ------------------------------------
// Action Handlers
// ------------------------------------
const ACTION_HANDLERS = {
[SHOW_ACTIVITY_MODAL]: (state, { modalType, modalProps }) => ({ ...state, modal: { modalType, modalProps } }),
[HIDE_ACTIVITY_MODAL]: (state) => ({ ...state, modal: { modalType: null, modalProps: {} } })
}
// ------------------------------------
// Reducer
// ------------------------------------
export default function activityReducer(state = initialState, action) {
const handler = ACTION_HANDLERS[action.type]
return handler ? handler(state, action) : state
}