2018-06-25 16:40:43 +02:00
|
|
|
/* @flow */
|
2018-06-25 19:08:09 +02:00
|
|
|
import type {
|
2018-07-18 10:57:56 +02:00
|
|
|
ChooseCompanyLiabilityAction,
|
|
|
|
CompanyLiability,
|
2018-09-10 11:10:41 +02:00
|
|
|
CompanyHasMultipleAssociatesAction,
|
2018-06-25 19:08:09 +02:00
|
|
|
DirectorStatus,
|
2018-07-23 15:21:00 +02:00
|
|
|
CompanyIsMicroenterpriseAction,
|
2018-08-23 16:42:02 +02:00
|
|
|
ResetCompanyStatusAction,
|
2018-08-02 12:20:53 +02:00
|
|
|
DirectorIsInAMinorityAction,
|
2018-06-25 19:08:09 +02:00
|
|
|
DefineDirectorStatusAction
|
2018-10-09 17:34:52 +02:00
|
|
|
} from 'Types/companyTypes'
|
2018-07-23 15:21:00 +02:00
|
|
|
import type { RouterHistory } from 'react-router'
|
|
|
|
import { nextQuestionUrlSelector } from 'Selectors/companyStatusSelectors'
|
2018-11-09 12:36:29 +01:00
|
|
|
import sitePaths from '../sites/mycompanyinfrance.fr/sitePaths';
|
2018-06-25 16:40:43 +02:00
|
|
|
|
2018-07-23 15:21:00 +02: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 19:08:09 +02:00
|
|
|
type: 'CHOOSE_COMPANY_LEGAL_SETUP',
|
2018-06-25 16:40:43 +02:00
|
|
|
setup
|
2018-07-23 15:21:00 +02:00
|
|
|
})
|
|
|
|
)
|
2018-06-25 19:08:09 +02:00
|
|
|
|
2018-07-23 15:21:00 +02:00
|
|
|
export const defineDirectorStatus = thenGoToNextQuestion(
|
|
|
|
(status: ?DirectorStatus): DefineDirectorStatusAction => ({
|
2018-06-25 19:08:09 +02:00
|
|
|
type: 'DEFINE_DIRECTOR_STATUS',
|
|
|
|
status
|
2018-07-23 15:21:00 +02:00
|
|
|
})
|
|
|
|
)
|
2018-06-26 17:57:50 +02:00
|
|
|
|
2018-09-10 11:10:41 +02:00
|
|
|
export const companyHasMultipleAssociates = thenGoToNextQuestion(
|
|
|
|
(multipleAssociates: ?boolean): CompanyHasMultipleAssociatesAction => ({
|
|
|
|
type: 'COMPANY_HAS_MULTIPLE_ASSOCIATES',
|
2018-07-23 15:21:00 +02:00
|
|
|
multipleAssociates
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
export const companyIsMicroenterprise = thenGoToNextQuestion(
|
2018-09-19 15:31:53 +02:00
|
|
|
(microEnterprise: ?boolean): CompanyIsMicroenterpriseAction => ({
|
2018-07-23 15:21:00 +02:00
|
|
|
type: 'COMPANY_IS_MICROENTERPRISE',
|
2018-09-19 15:31:53 +02:00
|
|
|
microEnterprise
|
2018-07-23 15:21:00 +02:00
|
|
|
})
|
|
|
|
)
|
2018-07-23 18:38:25 +02:00
|
|
|
|
2018-08-02 12:20:53 +02:00
|
|
|
export const directorIsInAMinority = thenGoToNextQuestion(
|
|
|
|
(minorityDirector: ?boolean): DirectorIsInAMinorityAction => ({
|
|
|
|
type: 'SPECIFY_DIRECTORS_SHARE',
|
|
|
|
minorityDirector
|
|
|
|
})
|
2018-08-23 14:00:49 +02:00
|
|
|
)
|
2018-08-23 16:42:02 +02:00
|
|
|
|
2018-09-10 11:10:41 +02:00
|
|
|
export const goToCompanyStatusChoice = () => (
|
|
|
|
dispatch: ResetCompanyStatusAction => void,
|
|
|
|
_: any,
|
|
|
|
history: RouterHistory
|
|
|
|
) => {
|
|
|
|
dispatch(
|
|
|
|
({
|
|
|
|
type: 'RESET_COMPANY_STATUS_CHOICE'
|
|
|
|
}: ResetCompanyStatusAction)
|
|
|
|
)
|
2018-11-09 12:36:29 +01:00
|
|
|
history.push(sitePaths().entreprise.index)
|
2018-09-10 11:10:41 +02:00
|
|
|
}
|