mon-entreprise/source/actions/companyStatusActions.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

/* @flow */
2018-06-25 17:08:09 +00:00
import type {
ChooseCompanyLiabilityAction,
CompanyLiability,
CompanyHaveMultipleAssociatesAction,
2018-06-25 17:08:09 +00:00
DirectorStatus,
CompanyIsMicroenterpriseAction,
DirectorIsInAMinorityAction,
2018-06-25 17:08:09 +00:00
DefineDirectorStatusAction
2018-07-12 08:09:41 +00:00
} from 'Types/companyStatusTypes'
import type { RouterHistory } from 'react-router'
import { nextQuestionUrlSelector } from 'Selectors/companyStatusSelectors'
const thenGoToNextQuestion = actionCreator => (...args: any) => (
dispatch: any => void,
getState: () => any,
history: RouterHistory
) => {
dispatch(actionCreator(...args))
history.push(nextQuestionUrlSelector(getState()))
}
export const chooseCompanyLiability = thenGoToNextQuestion(
(setup: ?CompanyLiability): ChooseCompanyLiabilityAction => ({
2018-06-25 17:08:09 +00:00
type: 'CHOOSE_COMPANY_LEGAL_SETUP',
setup
})
)
2018-06-25 17:08:09 +00:00
export const defineDirectorStatus = thenGoToNextQuestion(
(status: ?DirectorStatus): DefineDirectorStatusAction => ({
2018-06-25 17:08:09 +00:00
type: 'DEFINE_DIRECTOR_STATUS',
status
})
)
export const companyHaveMultipleAssociates = thenGoToNextQuestion(
(multipleAssociates: ?boolean): CompanyHaveMultipleAssociatesAction => ({
type: 'COMPANY_HAVE_MULTIPLE_ASSOCIATES',
multipleAssociates
})
)
export const companyIsMicroenterprise = thenGoToNextQuestion(
(microenterprise: ?boolean): CompanyIsMicroenterpriseAction => ({
type: 'COMPANY_IS_MICROENTERPRISE',
microenterprise
})
)
export const directorIsInAMinority = thenGoToNextQuestion(
(minorityDirector: ?boolean): DirectorIsInAMinorityAction => ({
type: 'SPECIFY_DIRECTORS_SHARE',
minorityDirector
})
)