36 lines
878 B
JavaScript
36 lines
878 B
JavaScript
import PropTypes from "prop-types";
|
|
import { useState } from "react";
|
|
import { Modal } from "antd";
|
|
import Turnstile from "react-turnstile";
|
|
|
|
const TurnstileModal = ({ open, onClose, onSuccess }) => {
|
|
const [turnstileToken, setTurnstileToken] = useState("");
|
|
|
|
const handleVerify = (token) => {
|
|
setTurnstileToken(token);
|
|
onClose(); // Close modal after verification
|
|
onSuccess(turnstileToken); // Notify parent component
|
|
};
|
|
|
|
return (
|
|
<Modal
|
|
open={open}
|
|
footer={null}
|
|
onCancel={onClose}
|
|
closeIcon={null}
|
|
centered
|
|
className="tbturnstile"
|
|
>
|
|
<Turnstile sitekey="0x4AAAAAAA_bc3QTrE68whtg" onVerify={handleVerify} />
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
TurnstileModal.propTypes = {
|
|
open: PropTypes.bool.isRequired,
|
|
onClose: PropTypes.func.isRequired,
|
|
onSuccess: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default TurnstileModal;
|