2023-03-13 14:29:34 +01:00
|
|
|
import React from 'react';
|
|
|
|
|
import useBoardStore from '../useBoardStore';
|
2023-03-09 17:51:56 +01:00
|
|
|
import Modal from 'react-modal';
|
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
|
|
|
|
|
const StyledModal = styled(Modal)`
|
|
|
|
|
@media (min-width: 480px) {
|
|
|
|
|
.modal-content {
|
|
|
|
|
width: 450px;
|
2023-03-12 22:07:15 +01:00
|
|
|
height: 300px;
|
2023-03-09 17:51:56 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 480px) {
|
|
|
|
|
.modal-content {
|
|
|
|
|
width: 90%;
|
|
|
|
|
height: 40%;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.modal-content {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-self: center;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 50%;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.75);
|
|
|
|
|
padding: 0;
|
|
|
|
|
z-index: 9999;
|
|
|
|
|
border: 1px solid #aaa;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button.x {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 10px;
|
|
|
|
|
right: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
img {
|
|
|
|
|
width: 80%;
|
|
|
|
|
height: 100px;
|
|
|
|
|
object-fit: contain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.challenge {
|
|
|
|
|
font-size: 12pt;
|
|
|
|
|
margin-bottom: 30px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input {
|
2023-03-12 22:07:15 +01:00
|
|
|
margin-top: 30px;
|
2023-03-09 17:51:56 +01:00
|
|
|
width: 70%;
|
|
|
|
|
padding: 2px;
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
font-family: monospace;
|
|
|
|
|
border: 1px solid #777;
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const customOverlayStyles = {
|
|
|
|
|
overlay: {
|
|
|
|
|
backgroundColor: 'rgba(0,0,0,.4)'
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-12 22:07:15 +01:00
|
|
|
const CaptchaModal = ({ isOpen, closeModal, captchaImage }) => {
|
2023-03-13 14:29:34 +01:00
|
|
|
const { captchaResponse, setCaptchaResponse } = useBoardStore(state => state);
|
2023-03-12 22:07:15 +01:00
|
|
|
|
2023-03-09 17:51:56 +01:00
|
|
|
const handleCloseModal = () => {
|
|
|
|
|
closeModal();
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-12 22:07:15 +01:00
|
|
|
const handleChallengeResponse = (event) => {
|
|
|
|
|
setCaptchaResponse(event.target.value);
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-09 17:51:56 +01:00
|
|
|
return (
|
|
|
|
|
<StyledModal
|
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
onRequestClose={closeModal}
|
|
|
|
|
shouldCloseOnOverlayClick={false}
|
|
|
|
|
contentLabel="Captcha Modal"
|
|
|
|
|
style={customOverlayStyles}
|
|
|
|
|
>
|
|
|
|
|
<div className="modal-content">
|
|
|
|
|
<button className='x' onClick={handleCloseModal}>X</button>
|
|
|
|
|
<div className="challenge">Verification</div>
|
2023-03-12 22:07:15 +01:00
|
|
|
<img src={captchaImage} alt="captcha" />
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
autoComplete='off'
|
|
|
|
|
placeholder="TYPE THE CAPTCHA HERE AND PRESS ENTER"
|
|
|
|
|
value={captchaResponse}
|
2023-03-13 14:29:34 +01:00
|
|
|
onChange={handleChallengeResponse}
|
|
|
|
|
autoFocus />
|
2023-03-09 17:51:56 +01:00
|
|
|
</div>
|
|
|
|
|
</StyledModal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Modal.setAppElement('#root');
|
|
|
|
|
|
|
|
|
|
export default CaptchaModal;
|