"use client"; import { Separator } from "@/components/ui/separator"; import { Input } from "@/components/ui/input"; import { CardsPaymentMethod } from "@/components/paymentMethod"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { useState } from "react"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, DialogFooter, DialogClose, } from "@/components/ui/dialog"; import { useRouter } from "next/navigation"; import { toast } from "react-hot-toast"; const term_data = [ { term: "Minimum Investment", description: "The minimum investment amount is $500.", }, { term: "Investment Horizon", description: "Investments are typically locked for a minimum of 12 months.", }, { term: "Fees", description: "A management fee of 2% will be applied annually.", }, { term: "Returns", description: "Expected annual returns are between 8% and 12%.", }, { term: "Risk Disclosure", description: "Investments carry risks, including the loss of principal.", }, { term: "Withdrawal Policy", description: "Withdrawals can be made after the lock-in period.", }, ]; export default function Invest() { const [checkedTerms, setCheckedTerms] = useState(Array(term_data.length).fill(false)); const [error, setError] = useState(""); const router = useRouter(); // Initialize the router const handleCheckboxChange = (index) => { const updatedCheckedTerms = [...checkedTerms]; updatedCheckedTerms[index] = !updatedCheckedTerms[index]; setCheckedTerms(updatedCheckedTerms); }; const handleTermServiceClick = () => { if (checkedTerms.some((checked) => !checked)) { setError("Please accept all terms before proceeding with the investment."); } else { setError(""); handleInvestmentSuccess(); } }; const handleInvestmentSuccess = () => { toast.success("You successfully invested!"); setTimeout(() => { router.push("/"); }, 1000); }; return (

Invest on NVIDIA

Investment Amount

Payment Information

Terms and Services

Select Term Description {term_data.map((item, index) => ( handleCheckboxChange(index)} /> {item.term} {item.description} ))}
Are you absolutely sure? This action cannot be undone. This will permanently! {error &&

{error}

}
); }