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.
 
 
 

35 lines
833 B

// Constants
// ------------------------------------
export const SET_FORM = 'SET_FORM'
// ------------------------------------
// Actions
// ------------------------------------
export function setForm({ modalOpen, formType }) {
return {
type: SET_FORM,
modalOpen,
formType
}
}
// ------------------------------------
// Action Handlers
// ------------------------------------
const ACTION_HANDLERS = {
[SET_FORM]: (state, { modalOpen, formType }) => ({ ...state, modalOpen, formType })
}
// ------------------------------------
// Reducer
// ------------------------------------
const initialState = {
modalOpen: false,
formType: 'pay'
}
export default function formReducer(state = initialState, action) {
const handler = ACTION_HANDLERS[action.type]
return handler ? handler(state, action) : state
}