import { Image, Modal, ModalBody, ModalCloseButton, ModalContent, ModalHeader, ModalOverlay, Text, useColorModeValue, useDisclosure, VStack, } from '@chakra-ui/react'; import React, { useEffect } from 'react'; import { PrimaryBtn, SecondaryBtn } from '../utils/Buttons'; import Logo from '../assets/images/logo.png'; import { useLocation, useNavigate } from 'react-router-dom'; import { useDispatch, useSelector } from 'react-redux'; import { setLoginAlert } from '../store/loginAlert'; const LoginAlert = () => { const { onClose } = useDisclosure(); const dispatch = useDispatch(); const loginAlert = useSelector((state) => state.loginAlert.showLoginAlert); const navigate = useNavigate(); const location = useLocation(); const handleClose = () => { dispatch(setLoginAlert(false)); }; const handleClick = (pathname) => { handleClose(); navigate(`/${pathname}`); }; useEffect(() => { dispatch(setLoginAlert(false)); }, [location, dispatch]); // close modal when route change return ( <> Log in to continue logo We're a place where coders share, stay up-to-date and grow their careers. handleClick('login')} > Log in handleClick('create-account')} > Create account ); }; export default LoginAlert;