Jack Mallers
7 years ago
9 changed files with 87 additions and 22 deletions
@ -0,0 +1,50 @@ |
|||||
|
// ------------------------------------
|
||||
|
// 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 |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
import Modal from './Modal' |
||||
|
|
||||
|
export default Modal |
Loading…
Reference in new issue