mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-03-13 05:05:05 +00:00
feat(économie-collaborative): ne pas afficher le bloc de questions si aucune question à poser
This commit is contained in:
parent
8c177d38ed
commit
484ff26217
3 changed files with 60 additions and 1 deletions
|
@ -10,6 +10,7 @@ import ShareOrSaveSimulationBanner, {
|
|||
import { Button } from '@/design-system/buttons'
|
||||
import { Grid, Spacing } from '@/design-system/layout'
|
||||
import { H3 } from '@/design-system/typography/heading'
|
||||
import { ilYADesQuestionsSelector } from '@/store/selectors/ilYADesQuestions.selector'
|
||||
import { firstStepCompletedSelector } from '@/store/selectors/simulationSelectors'
|
||||
|
||||
import { TrackPage } from '../ATInternetTracking'
|
||||
|
@ -63,6 +64,7 @@ export default function Simulation({
|
|||
entrepriseSelection = true,
|
||||
}: SimulationProps) {
|
||||
const firstStepCompleted = useSelector(firstStepCompletedSelector)
|
||||
const ilYADesQuestions = useSelector(ilYADesQuestionsSelector)
|
||||
const shouldShowFeedback = getShouldAskFeedback(useLocation().pathname)
|
||||
|
||||
return (
|
||||
|
@ -79,7 +81,9 @@ export default function Simulation({
|
|||
<div className="print-hidden">
|
||||
<FromTop>{results}</FromTop>
|
||||
</div>
|
||||
<Questions customEndMessages={customEndMessages} />
|
||||
{ilYADesQuestions && (
|
||||
<Questions customEndMessages={customEndMessages} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<Spacing md />
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { RootState } from '@/store/reducers/rootReducer'
|
||||
import { ilYADesQuestionsSelector } from '@/store/selectors/ilYADesQuestions.selector'
|
||||
|
||||
describe('sélecteur ilYADesQuestions', () => {
|
||||
it('retourne true si une question est en cours', () => {
|
||||
expect(
|
||||
ilYADesQuestionsSelector({
|
||||
simulation: {
|
||||
currentQuestion: 'a',
|
||||
questionsSuivantes: [],
|
||||
},
|
||||
} as unknown as RootState)
|
||||
).toEqual(true)
|
||||
})
|
||||
it('retourne true si au moins une question en attente', () => {
|
||||
expect(
|
||||
ilYADesQuestionsSelector({
|
||||
simulation: {
|
||||
currentQuestion: undefined,
|
||||
questionsSuivantes: ['a'],
|
||||
},
|
||||
} as unknown as RootState)
|
||||
).toEqual(true)
|
||||
})
|
||||
it('retourne true si au moins une question répondue', () => {
|
||||
expect(
|
||||
ilYADesQuestionsSelector({
|
||||
simulation: {
|
||||
currentQuestion: undefined,
|
||||
questionsSuivantes: [],
|
||||
questionsRépondues: ['a'],
|
||||
},
|
||||
} as unknown as RootState)
|
||||
).toEqual(true)
|
||||
})
|
||||
})
|
17
site/source/store/selectors/ilYADesQuestions.selector.ts
Normal file
17
site/source/store/selectors/ilYADesQuestions.selector.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { createSelector } from 'reselect'
|
||||
|
||||
import { currentQuestionSelector } from '@/store/selectors/currentQuestion.selector'
|
||||
import { questionsRéponduesSelector } from '@/store/selectors/questionsRépondues.selector'
|
||||
import { questionsSuivantesSelector } from '@/store/selectors/questionsSuivantes.selector'
|
||||
|
||||
export const ilYADesQuestionsSelector = createSelector(
|
||||
[
|
||||
currentQuestionSelector,
|
||||
questionsSuivantesSelector,
|
||||
questionsRéponduesSelector,
|
||||
],
|
||||
(questionEnCours, questionsSuivantes, questionsRépondues) =>
|
||||
!!questionEnCours ||
|
||||
!!questionsSuivantes.length ||
|
||||
!!questionsRépondues.length
|
||||
)
|
Loading…
Add table
Reference in a new issue