2018-06-25 14:40:43 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import { combineReducers } from 'redux'
|
2018-07-12 08:09:41 +00:00
|
|
|
import type {
|
2018-08-20 17:02:56 +00:00
|
|
|
Action as CompanyStatusAction,
|
2018-07-12 08:09:41 +00:00
|
|
|
CompanyLegalStatus,
|
|
|
|
State
|
|
|
|
} from 'Types/companyStatusTypes'
|
2018-08-20 17:02:56 +00:00
|
|
|
import type {
|
|
|
|
Action as CreationChecklistAction,
|
|
|
|
} from 'Types/companyCreationChecklistTypes'
|
|
|
|
type Action = CompanyStatusAction | CreationChecklistAction
|
2018-06-27 14:22:42 +00:00
|
|
|
function companyLegalStatus(
|
|
|
|
state: CompanyLegalStatus = {},
|
2018-06-26 15:57:50 +00:00
|
|
|
action: Action
|
2018-06-27 14:22:42 +00:00
|
|
|
): CompanyLegalStatus {
|
|
|
|
switch (action.type) {
|
|
|
|
case 'CHOOSE_COMPANY_LEGAL_SETUP':
|
2018-07-18 08:57:56 +00:00
|
|
|
return { ...state, liability: action.setup }
|
2018-06-26 15:57:50 +00:00
|
|
|
|
2018-06-27 14:22:42 +00:00
|
|
|
case 'DEFINE_DIRECTOR_STATUS':
|
|
|
|
return { ...state, directorStatus: action.status }
|
2018-07-23 13:21:00 +00:00
|
|
|
case 'COMPANY_HAVE_MULTIPLE_ASSOCIATES':
|
|
|
|
return { ...state, multipleAssociates: action.multipleAssociates }
|
|
|
|
case 'COMPANY_IS_MICROENTERPRISE':
|
|
|
|
return { ...state, microenterprise: action.microenterprise }
|
2018-08-02 10:20:53 +00:00
|
|
|
case 'SPECIFY_DIRECTORS_SHARE':
|
|
|
|
return { ...state, minorityDirector: action.minorityDirector }
|
2018-06-26 15:57:50 +00:00
|
|
|
}
|
2018-06-27 14:22:42 +00:00
|
|
|
return state
|
2018-06-26 15:57:50 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 17:02:56 +00:00
|
|
|
function companyCreationChecklist(
|
|
|
|
state: { [string]: boolean } = {},
|
2018-07-06 12:31:30 +00:00
|
|
|
action: Action
|
2018-07-04 09:42:41 +00:00
|
|
|
) {
|
2018-07-06 12:31:30 +00:00
|
|
|
switch (action.type) {
|
2018-08-20 17:02:56 +00:00
|
|
|
case 'CHECK_COMPANY_CREATION_ITEM':
|
2018-07-04 09:42:41 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2018-08-20 17:02:56 +00:00
|
|
|
[action.name]: action.checked
|
2018-07-04 09:42:41 +00:00
|
|
|
}
|
2018-08-20 17:02:56 +00:00
|
|
|
case 'INITIALIZE_COMPANY_CREATION_CHECKLIST':
|
|
|
|
return action.checklistItems.reduce(
|
|
|
|
(checklist, item) => ({...checklist, [item]: false })
|
|
|
|
, {});
|
2018-07-06 12:31:30 +00:00
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
2018-08-20 17:02:56 +00:00
|
|
|
function companyStatusChoice(
|
|
|
|
state: ?string = null,
|
|
|
|
action: Action
|
|
|
|
) {
|
|
|
|
if (action.type !== 'INITIALIZE_COMPANY_CREATION_CHECKLIST') {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return action.statusName
|
|
|
|
}
|
2018-07-06 12:31:30 +00:00
|
|
|
|
2018-07-06 13:48:41 +00:00
|
|
|
function existingCompanyDetails(
|
|
|
|
state: ?{ [string]: string } = null,
|
|
|
|
action: Action
|
|
|
|
): ?{ [string]: string } {
|
|
|
|
switch (action.type) {
|
|
|
|
case 'SAVE_EXISTING_COMPANY_DETAILS':
|
|
|
|
return action.details
|
|
|
|
default:
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-23 16:38:25 +00:00
|
|
|
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
|
2018-07-06 13:48:41 +00:00
|
|
|
export default (combineReducers({
|
2018-07-06 12:31:30 +00:00
|
|
|
companyLegalStatus,
|
2018-08-20 17:02:56 +00:00
|
|
|
companyStatusChoice,
|
|
|
|
companyCreationChecklist,
|
2018-07-23 16:38:25 +00:00
|
|
|
companyRegistrationStarted,
|
2018-07-06 13:48:41 +00:00
|
|
|
existingCompanyDetails
|
|
|
|
}): (State, Action) => State)
|