Untitled

 avatar
unknown
plain_text
a year ago
805 B
5
Indexable
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { resetQuiz } from '../store/actions/quizActions';
import { Box, Button, Text, VStack } from '@chakra-ui/react';

const Result = ({ restartQuiz }) => {
    const score = useSelector(state => state.quiz.score);
    const dispatch = useDispatch();

    const handleRetry = () => {
        dispatch(resetQuiz());
        restartQuiz();
    };

    return (
        <Box p={8} maxWidth="400px" mx="auto" mt={10} boxShadow="md" borderRadius="md">
            <VStack spacing={4}>
                <Text fontSize="2xl">Your Score: {score}</Text>
                <Button colorScheme="teal" onClick={handleRetry}>Retry</Button>
            </VStack>
        </Box>
    );
};

export default Result;
Editor is loading...
Leave a Comment