2018-06-25 14:40:43 +00:00
|
|
|
/* @flow */
|
2018-06-25 17:08:09 +00:00
|
|
|
import type {
|
2018-07-18 08:57:56 +00:00
|
|
|
ChooseCompanyLiabilityAction,
|
|
|
|
CompanyLiability,
|
2018-07-23 13:21:00 +00:00
|
|
|
CompanyHaveMultipleAssociatesAction,
|
2018-06-25 17:08:09 +00:00
|
|
|
DirectorStatus,
|
2018-07-23 13:21:00 +00:00
|
|
|
CompanyIsMicroenterpriseAction,
|
2018-06-25 17:08:09 +00:00
|
|
|
DefineDirectorStatusAction
|
2018-07-12 08:09:41 +00:00
|
|
|
} from 'Types/companyStatusTypes'
|
2018-07-23 13:21:00 +00:00
|
|
|
import type { RouterHistory } from 'react-router'
|
|
|
|
import { nextQuestionUrlSelector } from 'Selectors/companyStatusSelectors'
|
2018-06-25 14:40:43 +00:00
|
|
|
|
2018-07-23 13:21:00 +00:00
|
|
|
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',
|
2018-06-25 14:40:43 +00:00
|
|
|
setup
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
2018-06-25 17:08:09 +00:00
|
|
|
|
2018-07-23 13:21:00 +00:00
|
|
|
export const defineDirectorStatus = thenGoToNextQuestion(
|
|
|
|
(status: ?DirectorStatus): DefineDirectorStatusAction => ({
|
2018-06-25 17:08:09 +00:00
|
|
|
type: 'DEFINE_DIRECTOR_STATUS',
|
|
|
|
status
|
2018-07-23 13:21:00 +00:00
|
|
|
})
|
|
|
|
)
|
2018-06-26 15:57:50 +00:00
|
|
|
|
2018-07-23 13:21:00 +00:00
|
|
|
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
|
|
|
|
})
|
|
|
|
)
|