diff --git a/.env b/.env index b1322fbf..5a3736dc 100644 --- a/.env +++ b/.env @@ -1,3 +1,6 @@ VITE_PROJECT_ID=aa1989b48f2f9f37e9e29811f97d58af VITE_IS_MAINTENANCE = 0 VITE_MAINTENANCE_TIPS = 'The website is currently undergoing maintenance to add support for Phase II Upgrading.' + +VITE_SITE_KEY="6LcfgBYqAAAAAMWveYEvnQQFNg33AU71GBj60Rwl" +VITE_SECRET_KEY="6LcfgBYqAAAAAHCFhPK_oiBKNts8JXKRMh9auxxr" diff --git a/index.html b/index.html index 7000c977..b04603b4 100644 --- a/index.html +++ b/index.html @@ -46,6 +46,10 @@ gtag("js", new Date()); gtag("config", "G-LHZKFW0MBZ"); + + +
diff --git a/package.json b/package.json index 1eedc789..ddb2e585 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "react": "^18.2.0", "react-device-detect": "^2.2.3", "react-dom": "^18.2.0", + "react-google-recaptcha": "^3.1.0", "react-hot-toast": "^2.4.1", "react-icons": "^5.0.1", "react-loadable": "^5.5.0", @@ -55,6 +56,7 @@ "@types/qs": "^6.9.12", "@types/react": "^18.2.56", "@types/react-dom": "^18.2.19", + "@types/react-google-recaptcha": "^2.1.9", "@typescript-eslint/eslint-plugin": "^7.0.2", "@typescript-eslint/parser": "^7.0.2", "@vitejs/plugin-react": "^4.2.1", diff --git a/src/components/DashboardS2/DailyRoulette/DailyBox.tsx b/src/components/DashboardS2/DailyRoulette/DailyBox.tsx index b72bc4cd..c423b1d8 100644 --- a/src/components/DashboardS2/DailyRoulette/DailyBox.tsx +++ b/src/components/DashboardS2/DailyRoulette/DailyBox.tsx @@ -1,11 +1,13 @@ import styled from "styled-components"; -import { useCallback, useMemo } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import dayjs from "dayjs"; import utc from "dayjs/plugin/utc"; import timezone from "dayjs/plugin/timezone"; import DailyDrawModal from "./DailyDrawModal"; import { useDisclosure } from "@nextui-org/react"; import { dailyOpen } from "@/api"; +import { useReCaptchaStore } from "@/hooks/useReCaptchaStore"; +import GoogleRecaptcha from "@/components/GoogleRecaptcha"; dayjs.extend(utc); dayjs.extend(timezone); export enum BoxType { @@ -24,6 +26,14 @@ interface DailyBoxProps { remain?: number; } +const RecaptchaContainer = styled.div` + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 9999; +`; + const DailyBox = (props: DailyBoxProps) => { const modal = useDisclosure(); const { type, weekday, date, amount, index, remain, onDrawed } = props; @@ -52,11 +62,39 @@ const DailyBox = (props: DailyBoxProps) => { return `Exactly in ${hours + (index - 5) * 24} Hours`; } }, [index]); + + const { reCaptchaTs, reCaptchaValue } = useReCaptchaStore(); + + const [isShowRecaptcha, setIsShowRecaptcha] = useState(false); + + useEffect(() => { + console.log("isShowRecaptcha", isShowRecaptcha); + }, [isShowRecaptcha]); + const handleClaim = useCallback(async () => { + console.log("handleClaim"); + if (type === BoxType.Active) { + const ts = Date.now(); + + if ( + reCaptchaTs === 0 || + ts - reCaptchaTs > 1000 * 60 * 60 * 12 || + !reCaptchaValue + ) { + setIsShowRecaptcha(true); + return; + } modal.onOpen(); } - }, [type, modal]); + }, [type, modal, reCaptchaValue, reCaptchaTs]); + + const handleReCaptchaSuccess = () => { + console.log("handleReCaptchaSuccess"); + setIsShowRecaptcha(false); + modal.onOpen(); + }; + return ({weekday}
@@ -100,6 +138,12 @@ const DailyBox = (props: DailyBoxProps) => { onDrawed={onDrawed} remain={remain} /> + + {isShowRecaptcha && ( +