Add 'Back' button to QuizRunner component
This commit is contained in:
@@ -445,11 +445,18 @@ export default function QuizRunner({ defaultMode = 'all', defaultEntryId, autoSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status === 'finished') {
|
if (status === 'finished') {
|
||||||
|
const lastIndex = questions.length ? questions.length - 1 : 0;
|
||||||
return (
|
return (
|
||||||
<div className="quiz-finished">
|
<div className="quiz-finished">
|
||||||
<h2>Nice work!</h2>
|
<h2>Nice work!</h2>
|
||||||
<p className="muted">You scored {score} out of {questions.length}.</p>
|
<p className="muted">You scored {score} out of {questions.length}.</p>
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
|
<button className="button button--ghost" onClick={() => {
|
||||||
|
setStatus('running');
|
||||||
|
setCurrentIndex(lastIndex);
|
||||||
|
}}>
|
||||||
|
Back
|
||||||
|
</button>
|
||||||
<button className="button" onClick={startQuiz}>
|
<button className="button" onClick={startQuiz}>
|
||||||
Play again
|
Play again
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user