Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const activate = (step, key, collection) => ({
- ...step,
- active:
- step.active === undefined &&
- key === Object.keys(collection)[0]
- ? true
- : step.active
- })
- const initSteps = (steps, step, index) => ({
- ...steps,
- [step]: {
- active: index === 0,
- completed: false,
- validating: false,
- validations: false,
- data: null
- }
- })
- // mapValues should take data last for composability and curryability
- const activateTheStep = data =>
- mapValues(cloneDeep(data), activate)
- switch (action.type) {
- case 'FOO': return {
- ...state,
- Steps: {
- this.stepData
- ? activateTheStep(this.stepData)
- : this.getSteps().reduce(initSteps, {})
- }
- }
- default: return state
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement