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.
34 lines
802 B
34 lines
802 B
// Initial State
|
|
const initialState = {
|
|
formType: null
|
|
}
|
|
|
|
// Constants
|
|
// ------------------------------------
|
|
export const SET_FORM_TYPE = 'SET_FORM_TYPE'
|
|
|
|
// ------------------------------------
|
|
// Actions
|
|
// ------------------------------------
|
|
export function setFormType(formType) {
|
|
return {
|
|
type: SET_FORM_TYPE,
|
|
formType
|
|
}
|
|
}
|
|
|
|
// ------------------------------------
|
|
// Action Handlers
|
|
// ------------------------------------
|
|
const ACTION_HANDLERS = {
|
|
[SET_FORM_TYPE]: (state, { formType }) => ({ ...state, formType })
|
|
}
|
|
|
|
// ------------------------------------
|
|
// Reducer
|
|
// ------------------------------------
|
|
export default function formReducer(state = initialState, action) {
|
|
const handler = ACTION_HANDLERS[action.type]
|
|
|
|
return handler ? handler(state, action) : state
|
|
}
|
|
|