Clean store old code

pull/2782/head
Jérémy Rialland 2023-06-07 16:47:39 +02:00 committed by Johan Girod
parent 5b29aa0927
commit 14f0452089
5 changed files with 0 additions and 209 deletions

View File

@ -2,22 +2,6 @@ import { useTranslation } from 'react-i18next'
import { MetadataSrc } from '@/pages/simulateurs/metadata-src'
// export const LANDING_LEGAL_STATUS_LIST: Array<LegalStatus> = [
// 'EI',
// 'EIRL',
// 'EURL',
// 'SAS',
// 'SARL',
// 'SASU',
// 'auto-entrepreneur',
// 'auto-entrepreneur-EIRL',
// 'SA',
// ]
// const status = Object.fromEntries(
// LANDING_LEGAL_STATUS_LIST.map((statut) => [statut, statut])
// ) as { [statut in LegalStatus]: statut }
const rawSitePathsFr = {
index: '',
assistants: {

View File

@ -6,7 +6,6 @@ import { ImmutableType } from '@/types/utils'
import { buildSituationFromObject } from '@/utils'
import { CompanyActions } from './companyActions'
import { CompanyCreationAction } from './companyCreationChecklistActions'
import { HiringChecklistAction } from './hiringChecklistAction'
export type Action =
@ -25,7 +24,6 @@ export type Action =
| typeof batchUpdateSituation
| typeof updateShouldFocusField
>
| CompanyCreationAction
| CompanyActions
| HiringChecklistAction

View File

@ -1,22 +0,0 @@
import { LegalStatus } from '@/store/selectors/companyStatusSelectors'
export type CompanyCreationAction = ReturnType<
typeof initializeCompanyCreationChecklist | typeof checkCompanyCreationItem
>
export const initializeCompanyCreationChecklist = (
statusName: LegalStatus,
checklistItems: Array<string>
) =>
({
type: 'INITIALIZE_COMPANY_CREATION_CHECKLIST',
checklistItems,
statusName,
} as const)
export const checkCompanyCreationItem = (name: string, checked: boolean) =>
({
type: 'CHECK_COMPANY_CREATION_ITEM',
name,
checked,
} as const)

View File

@ -1,34 +1,6 @@
import { combineReducers } from 'redux'
import { Action } from '@/store/actions/actions'
import { LegalStatus } from '@/store/selectors/companyStatusSelectors'
import { LegalStatusRequirements } from '@/types/companyTypes'
import { omit } from '@/utils'
function companyLegalStatus(
state: LegalStatusRequirements = {},
action: Action
): LegalStatusRequirements {
switch (action.type) {
case 'COMPANY_IS_SOLE_PROPRIETORSHIP':
return { ...state, soleProprietorship: action.isSoleProprietorship }
case 'DEFINE_DIRECTOR_STATUS':
return { ...state, directorStatus: action.status }
case 'COMPANY_HAS_MULTIPLE_ASSOCIATES':
return { ...state, multipleAssociates: action.multipleAssociates }
case 'COMPANY_IS_MICROENTERPRISE':
return { ...state, autoEntrepreneur: action.autoEntrepreneur }
case 'SPECIFY_DIRECTORS_SHARE':
return { ...state, minorityDirector: action.minorityDirector }
case 'RESET_COMPANY_STATUS_CHOICE':
return action.answersToReset
? action.answersToReset.reduce(omit, state)
: {}
}
return state
}
function hiringChecklist(
state: { [key: string]: boolean } = {},
@ -52,45 +24,7 @@ function hiringChecklist(
}
}
function companyCreationChecklist(
state: { [key: string]: boolean } = {},
action: Action
) {
switch (action.type) {
case 'CHECK_COMPANY_CREATION_ITEM':
return {
...state,
[action.name]: action.checked,
}
case 'INITIALIZE_COMPANY_CREATION_CHECKLIST':
return Object.keys(state).length
? state
: action.checklistItems.reduce(
(checklist, item) => ({ ...checklist, [item]: false }),
{}
)
case 'RESET_COMPANY_STATUS_CHOICE':
return {}
default:
return state
}
}
function companyStatusChoice(state: LegalStatus | null = null, action: Action) {
if (action.type === 'RESET_COMPANY_STATUS_CHOICE') {
return null
}
if (action.type !== 'INITIALIZE_COMPANY_CREATION_CHECKLIST') {
return state
}
return action.statusName
}
const choixStatutJuridiqueReducer = combineReducers({
companyLegalStatus,
companyStatusChoice,
companyCreationChecklist,
hiringChecklist,
})

View File

@ -1,103 +0,0 @@
import { describe, expect, it } from 'vitest'
import { nextQuestionSelector } from '@/store/selectors/companyStatusSelectors'
const state = (companyLegalStatus) => ({
choixStatutJuridique: {
companyLegalStatus,
existingCompany: null,
companyStatusChoice: null,
},
})
describe('company status selectors', function () {
describe('nextQuestionSelector', function () {
it('should return null there is only one status possible', () => {
const nextQuestion = nextQuestionSelector(
state({
soleProprietorship: true,
directorStatus: 'SELF_EMPLOYED',
multipleAssociates: true,
})
)
expect(nextQuestion).to.be.equal(null)
})
it('should not return null if no questions have been answered yet', () => {
const nextQuestion = nextQuestionSelector(state({}))
expect(nextQuestion).not.to.be.equal(null)
})
it('should return null if all the questions have been answered', () => {
const nextQuestion = nextQuestionSelector(
state({
soleProprietorship: null,
directorStatus: null,
autoEntrepreneur: null,
multipleAssociates: null,
minorityDirector: null,
})
)
expect(nextQuestion).to.be.equal(null)
})
it('should always return a question that have not been answered yet', () => {
let nextQuestion = nextQuestionSelector(
state({
directorStatus: null,
multipleAssociates: null,
})
)
expect(['directorStatus', 'multipleAssociates']).not.to.contain(
nextQuestion
)
nextQuestion = nextQuestionSelector(
state({
directorStatus: 'SALARIED',
soleProprietorship: false,
})
)
expect(['directorStatus', 'soleProprietorship']).not.to.contain(
nextQuestion
)
nextQuestion = nextQuestionSelector(
state({
multipleAssociates: true,
soleProprietorship: false,
})
)
expect(['multipleAssociates', 'soleProprietorship']).not.to.contain(
nextQuestion
)
})
it('should not return a question which can lead to no matching status', () => {
const nextQuestion = nextQuestionSelector(
state({
multipleAssociates: true,
minorityDirector: true,
})
)
expect(nextQuestion).to.be.equal(null)
})
it('should return a question if it can help to shrink down the possibilities', () => {
const nextQuestion = nextQuestionSelector(
state({
soleProprietorship: false,
directorStatus: 'SALARIED',
})
)
expect(nextQuestion).not.to.be.equal(null)
})
it('should first return the question which convey the most information (which eliminates the most statuses ) ', () => {
const nextQuestion = nextQuestionSelector(state({}))
expect(nextQuestion).to.be.equal('soleProprietorship')
})
it('should allow to skip question', () => {
const nextQuestion = nextQuestionSelector(
state({
multipleAssociates: null,
})
)
expect(nextQuestion).not.to.be.equal(null)
})
})
})