fix: La conversation repasse sur les questions des objectifs
filtre les objectifs exclusifs et la liste noire des réponses enregistréespull/3115/head
parent
3eaa95c944
commit
0d8c3163e3
|
@ -42,7 +42,9 @@ export const détermineLesProchainesQuestions = (
|
|||
filter(
|
||||
(step) =>
|
||||
(!liste.length || liste.some((name) => step.startsWith(name))) &&
|
||||
(!listeNoire.length || !listeNoire.some((name) => step === name))
|
||||
(!listeNoire.length || !listeNoire.some((name) => step === name)) &&
|
||||
(!config['objectifs exclusifs']?.length ||
|
||||
!config['objectifs exclusifs'].includes(step))
|
||||
),
|
||||
sort((a: DottedName, b: DottedName) => Order.number(score(a), score(b))),
|
||||
filter(
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import { DottedName } from 'modele-social'
|
||||
|
||||
import { SimulationConfig } from '@/domaine/SimulationConfig'
|
||||
|
||||
export const estObjectifExclusifDeLaSimulation =
|
||||
(config: SimulationConfig) =>
|
||||
(question: DottedName): boolean =>
|
||||
config['objectifs exclusifs']?.includes(question) ?? false
|
|
@ -0,0 +1,10 @@
|
|||
import { DottedName } from 'modele-social'
|
||||
|
||||
import { SimulationConfig } from '@/domaine/SimulationConfig'
|
||||
|
||||
export const estQuestionEnListeNoire =
|
||||
(config: SimulationConfig) =>
|
||||
(question: DottedName): boolean =>
|
||||
config.questions?.['liste noire']?.some((préfixe) =>
|
||||
question.startsWith(préfixe)
|
||||
) ?? false
|
|
@ -39,7 +39,6 @@ export const configAutoEntrepreneur: SimulationConfig = {
|
|||
],
|
||||
'non prioritaires': ['établissement . commune'],
|
||||
'liste noire': [
|
||||
'entreprise . activités',
|
||||
'entreprise . activités . revenus mixtes',
|
||||
'entreprise . charges',
|
||||
"entreprise . chiffre d'affaires",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { DottedName } from 'modele-social'
|
||||
|
||||
import { estObjectifExclusifDeLaSimulation } from '@/domaine/estObjectifExclusifDeLaSimulation'
|
||||
import { estQuestionEnListeNoire } from '@/domaine/estQuestionEnListeNoire'
|
||||
import { SimulationConfig } from '@/domaine/SimulationConfig'
|
||||
import { Situation } from '@/domaine/Situation'
|
||||
import { updateSituation } from '@/domaine/updateSituation'
|
||||
|
@ -55,11 +57,16 @@ export function simulationReducer(
|
|||
}
|
||||
|
||||
case 'ENREGISTRE_LA_RÉPONSE': {
|
||||
const answeredQuestions = state.answeredQuestions.includes(
|
||||
const déjàDansLesQuestionsRépondues = state.answeredQuestions.includes(
|
||||
action.fieldName
|
||||
)
|
||||
? state.answeredQuestions
|
||||
: [...state.answeredQuestions, action.fieldName]
|
||||
|
||||
const answeredQuestions =
|
||||
déjàDansLesQuestionsRépondues ||
|
||||
estQuestionEnListeNoire(state.config)(action.fieldName) ||
|
||||
estObjectifExclusifDeLaSimulation(state.config)(action.fieldName)
|
||||
? state.answeredQuestions
|
||||
: [...state.answeredQuestions, action.fieldName]
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
|
Loading…
Reference in New Issue