mon-entreprise/source/reducers/inFranceAppReducer.js

77 lines
1.6 KiB
JavaScript
Raw Normal View History

/* @flow */
import { combineReducers } from 'redux'
2018-07-12 08:09:41 +00:00
import type {
Action,
CompanyLegalStatus,
State
} from 'Types/companyStatusTypes'
function companyLegalStatus(
state: CompanyLegalStatus = {},
action: Action
): CompanyLegalStatus {
switch (action.type) {
case 'CHOOSE_COMPANY_LEGAL_SETUP':
return { ...state, liability: action.setup }
case 'DEFINE_DIRECTOR_STATUS':
return { ...state, directorStatus: action.status }
case 'COMPANY_HAVE_MULTIPLE_ASSOCIATES':
return { ...state, multipleAssociates: action.multipleAssociates }
case 'COMPANY_IS_MICROENTERPRISE':
return { ...state, microenterprise: action.microenterprise }
case 'SPECIFY_DIRECTORS_SHARE':
return { ...state, minorityDirector: action.minorityDirector }
}
return state
}
function checklists(
2018-07-06 14:03:25 +00:00
state: { [string]: { [string]: boolean } } = { hire: {}, register: {} },
action: Action
) {
switch (action.type) {
case 'CHANGE_CHECKLIST_ITEM':
return {
...state,
[action.checklist]: {
2018-07-06 14:03:25 +00:00
...state[action.checklist],
...{ [action.name]: action.value }
}
}
default:
return state
}
}
function existingCompanyDetails(
state: ?{ [string]: string } = null,
action: Action
): ?{ [string]: string } {
switch (action.type) {
case 'SAVE_EXISTING_COMPANY_DETAILS':
return action.details
default:
return state
}
}
function companyRegistrationStarted(
state: boolean = false,
action: Action
) {
if (action.type ==='START_COMPANY_REGISTRATION') {
return true;
}
return state;
}
2018-07-12 08:09:41 +00:00
// $FlowFixMe
export default (combineReducers({
companyLegalStatus,
checklists,
companyRegistrationStarted,
existingCompanyDetails
}): (State, Action) => State)