// Callback1.js "use client"; import ReCAPTCHA from "react-google-recaptcha"; import { useState, useRef } from "react"; export default function Callback1() { const [domain, setDomain] = useState(""); const [email, setEmail] = useState(""); const [captchaValue, setCaptchaValue] = useState(null); const recaptchaRef = useRef(null); const handleChange = ({ target: { name, value } }) => { if (name === "domain") { setDomain(value); } else if (name === "email") { setEmail(value); } }; const handleCaptchaChange = (value) => { setCaptchaValue(value); }; const handleSubmit = async (event) => { event.preventDefault(); try { const response = await fetch("/api/checkseo", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ domain, email, captcha: captchaValue }), }); const data = await response.json(); if (response.ok) { // Store domain and email in sessionStorage sessionStorage.setItem("reportData", JSON.stringify({ domain, email })); window.location.href = "/report"; } else { console.error("API response:", data); alert(data.message); } } catch (error) { console.error("Error submitting form:", error); alert("An error occurred. Please try again later."); } }; return ( <>

Download the Case Study

); }