Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
805 B
2
Indexable
Never
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;
Leave a Comment