feat: n'affiche pas le bouton «précédent» si on est revenu à la première question

pull/3115/head
Jalil Arfaoui 2024-05-30 23:29:02 +02:00
parent f977f24f97
commit d24a6ff856
2 changed files with 19 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import { Button } from '@/design-system/buttons'
import { Grid } from '@/design-system/layout'
import { H3 } from '@/design-system/typography/heading'
import { enregistreLaRéponse } from '@/store/actions/actions'
import { estSurLaPremièreQuestionRépondueSelector } from '@/store/selectors/estSurLaPremièreQuestionRépondue.selector'
import { situationSelector } from '@/store/selectors/simulationSelectors'
import { evaluateQuestion } from '@/utils'
@ -61,6 +62,10 @@ export function QuestionEnCours({
focusFirstElemInForm()
}, [focusFirstElemInForm, goToNext])
const estSurLaPremièreQuestion = useSelector(
estSurLaPremièreQuestionRépondueSelector
)
if (!currentQuestion) return null
const onChange = (
@ -112,7 +117,7 @@ export function QuestionEnCours({
/>
</fieldset>
<Grid container spacing={2}>
{previousAnswers.length > 0 && (
{previousAnswers.length > 0 && !estSurLaPremièreQuestion && (
<Grid item xs={6} sm="auto">
<Button
color="primary"

View File

@ -0,0 +1,13 @@
import { createSelector } from 'reselect'
import { currentQuestionSelector } from '@/store/selectors/currentQuestion.selector'
import { answeredQuestionsSelector } from '@/store/selectors/simulationSelectors'
export const estSurLaPremièreQuestionRépondueSelector = createSelector(
[currentQuestionSelector, answeredQuestionsSelector],
(questionEnCours, questionsRépondues) =>
!!questionEnCours &&
!!questionsRépondues &&
!!questionsRépondues.length &&
questionsRépondues[0] === questionEnCours
)