diff --git a/src/components/Confirm.js b/src/components/Confirm.js index 84e9123..d74aee5 100644 --- a/src/components/Confirm.js +++ b/src/components/Confirm.js @@ -5,112 +5,73 @@ import { TwitterShareButton, TwitterFollowButton } from "react-twitter-embed"; import { Confetti } from "./Confetti"; import { Bounce, ToastContainer, toast } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; +import { useNavigate } from 'react-router-dom'; function ConfirmationCheckbox() { - const buttonStyle = { - backgroundColor: "#132a13", - color: "yellowgreen", - border: "3px solid currentcolor", - boxShadow: "0 0 3px currentcolor", - borderRadius: "20px", - - }; - const [person, setPerson] = useState(null); const [isActive, setIsActive] = useState(false); const [isChecked, setIsChecked] = useState(false); const [buttonPlayed, setButtonPlayed] = useState(false); const [inputValue, setInputValue] = useState(""); - const [click,setClick]=useState(false); - const [name, setName] = useState(""); + const [click, setClick] = useState(false); + const navigate = useNavigate(); // for navigation + + // Define the buttonStyle after isActive is initialized + const buttonStyle = { + backgroundColor: isActive ? "#132a13" : "transparent", // Transparent when not active + color: isActive ? "yellowgreen" : "grey", + border: "3px solid currentcolor", + boxShadow: isActive ? "0 0 3px currentcolor" : "none", // No shadow when not active + borderRadius: "20px", + cursor: isActive ? "pointer" : "not-allowed", + transition: "background-color 0.3s ease, color 0.3s ease", // Smooth transition + }; + function handleClick() { - - if(inputValue===""){ - + if(inputValue === "") { toast.error("You didn't enter your name!", { position: "top-right", autoClose: 3000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, theme: "dark", - color:"red", transition: Bounce, - }); - } - else if (!click) { + }); + } else if (!click) { toast.error("You didn't tick the checkbox!", { position: "top-right", autoClose: 3000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, theme: "dark", transition: Bounce, }); - } else{ - setIsChecked(oldIsChecked => !oldIsChecked); + } else { + setIsChecked(true); // Move to the next step } } function checkboxon(e) { - setClick(true); - if(e.target.checked){ - if(inputValue===""){ - - toast.error("You didn't enter your name!", { - position: "top-right", - autoClose: 3000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "dark", - color:"red", - transition: Bounce, - }); - - } - setIsActive(oldIsActive => !oldIsActive); - - - }else{ - setIsActive(oldIsActive => !oldIsActive); - toast.error("You did't click the Checkbox", { - position: "top-right", - autoClose: 3000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "dark", - transition: Bounce, - }); - } + setClick(e.target.checked); + setIsActive(e.target.checked); // Button will be enabled only if checkbox is checked } - + function generatorRandomNumber() { return Math.floor(Math.random() * wives.length); } - function handleInputChange(event) { setInputValue(event.target.value); } const playGame = () => { - setButtonPlayed(oldButtonPlayed => !oldButtonPlayed); + setButtonPlayed(true); const randomNum = generatorRandomNumber(); setPerson(wives[randomNum]); }; - + const playAgain = () => { + setButtonPlayed(false); // Reset the game state + setIsChecked(false); // Reset the checkbox state + setClick(false); // Uncheck the checkbox + navigate("/"); // Navigate back to the main page + }; const wifestyle2 = { margin: "0", @@ -137,7 +98,7 @@ function ConfirmationCheckbox() { paddingBottom: "120px", }} > -
+
@@ -156,20 +117,23 @@ function ConfirmationCheckbox() { }} className="form-control" id="nameid" - aria-describedby="emailHelp" placeholder="Enter Your Name" />
- {checkboxon(e)}} /> + checkboxon(e)} + />   Whichever wife I get, I will accept for the rest of my life.

)}