feat: n'affiche pas le bouton «précédent» si on est revenu à la première question
parent
f977f24f97
commit
d24a6ff856
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
)
|
Loading…
Reference in New Issue