Skip to content

Commit 23e3fa9

Browse files
kimpyphilia
authored andcommitted
refactor: refactor code
1 parent 79026db commit 23e3fa9

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

src/components/play/PlayView.tsx

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -147,45 +147,6 @@ const PlayView = () => {
147147
}
148148
};
149149

150-
const renderNavigationButtons = () => (
151-
<Stack direction="row" justifyContent="space-between" width="100%">
152-
<Button
153-
onClick={moveToPreviousQuestion}
154-
variant="outlined"
155-
data-cy={QUESTION_BAR_PREV_CY}
156-
disabled={currentIdx === 0}
157-
>
158-
{t(QUIZ_TRANSLATIONS.PREV_QUESTION_BTN)}
159-
</Button>
160-
{displaySubmitBtn ? (
161-
<Button
162-
onClick={handleSubmit}
163-
variant="contained"
164-
data-cy={PLAY_VIEW_SUBMIT_BUTTON_CY}
165-
disabled={isReadonly}
166-
>
167-
{t('Submit')}
168-
</Button>
169-
) : (
170-
<Button
171-
onClick={handleRetry}
172-
variant="contained"
173-
data-cy={PLAY_VIEW_RETRY_BUTTON_CY}
174-
>
175-
{t(QUIZ_TRANSLATIONS.PLAY_VIEW_RETRY_BTN)}
176-
</Button>
177-
)}
178-
<Button
179-
onClick={moveToNextQuestion}
180-
variant="outlined"
181-
data-cy={QUESTION_BAR_NEXT_CY}
182-
disabled={currentIdx === questions.length - 1}
183-
>
184-
{t(QUIZ_TRANSLATIONS.NEXT_QUESTION_BTN)}
185-
</Button>
186-
</Stack>
187-
);
188-
189150
if (!questions || questions.length === 0) {
190151
return (
191152
<Alert severity="info" data-cy={PLAY_VIEW_EMPTY_QUIZ_CY}>
@@ -253,7 +214,47 @@ const PlayView = () => {
253214
showCorrection={showCorrection}
254215
currentQuestionData={currentQuestion.data as QuestionData}
255216
/>
256-
<Box mt={4}>{renderNavigationButtons()}</Box>
217+
<Stack
218+
mt={4}
219+
direction="row"
220+
justifyContent="space-between"
221+
width="100%"
222+
>
223+
<Button
224+
onClick={moveToPreviousQuestion}
225+
variant="outlined"
226+
data-cy={QUESTION_BAR_PREV_CY}
227+
disabled={currentIdx === 0}
228+
>
229+
{t(QUIZ_TRANSLATIONS.PREV_QUESTION_BTN)}
230+
</Button>
231+
{displaySubmitBtn ? (
232+
<Button
233+
onClick={handleSubmit}
234+
variant="contained"
235+
data-cy={PLAY_VIEW_SUBMIT_BUTTON_CY}
236+
disabled={isReadonly}
237+
>
238+
{t('Submit')}
239+
</Button>
240+
) : (
241+
<Button
242+
onClick={handleRetry}
243+
variant="contained"
244+
data-cy={PLAY_VIEW_RETRY_BUTTON_CY}
245+
>
246+
{t(QUIZ_TRANSLATIONS.PLAY_VIEW_RETRY_BTN)}
247+
</Button>
248+
)}
249+
<Button
250+
onClick={moveToNextQuestion}
251+
variant="outlined"
252+
data-cy={QUESTION_BAR_NEXT_CY}
253+
disabled={currentIdx === questions.length - 1}
254+
>
255+
{t(QUIZ_TRANSLATIONS.NEXT_QUESTION_BTN)}
256+
</Button>
257+
</Stack>
257258
</Stack>
258259
</Stack>
259260
);

0 commit comments

Comments
 (0)