import { data } from "autoprefixer"; import { useState } from "react"; import Header from "../../components/header/Header"; import Nav from "../../components/nav/Nav"; import Payment from "../dashboard/Payment"; import BuyInfo from "./BuyInfo"; import CreditAndDiscount from "./CreditAndDiscount"; import Games from "./Games"; import Packages from "./Packages"; import UserFullInfo from "./UserFullInfo"; import UserInfo from "./UserInfo"; const Dashboard2 = ({ ActiveUserFullInfo, UserFullInfoData, showUserFullInfo, hideUserFullInfo, }) => { console.log("dashboard2 run--------------------"); // Games functions -------------------------- const [gameId, setGameId] = useState(1); const chooseGame = (id) => { setGameId(id); }; const [selectedGames,setSelectedGames] = useState([]); const [buyInfoData,setBuyInfoData]=useState([]); const [fake,setFake]=useState(0); let gameList = ["ماجراجو","فرفره","آشپزباشی","صخره نورد","معمارک","کنجکاو","1"]; const addPackage=(GameID,data,index,remove,removeIndex)=>{ let newArray = selectedGames; if (!newArray.includes(GameID)) { newArray.push(GameID); } console.log("selectedGames"); console.log(newArray); // setSelectedGames(newArray); let newBuyInfoData = buyInfoData; if(remove){ console.log("remove--------------------------"); console.log(GameID, removeIndex); // newBuyInfoData = newBuyInfoData.filter( // (item) => item.gameId !== GameID && item.packageIndex !== removeIndex // ); newBuyInfoData = []; for(let i=0;i{console.log("hooooooo")},200); newBuyInfoData.push({ id: Math.ceil(Math.random() * 10000), title: gameList[GameID-1], price: data.price, time: data.time, type: GameID < 7 ? 0 : 1, gameId: GameID, packageIndex:index }); console.log('add package---------------------------'); console.log(newBuyInfoData); setFake(fake + 1); setBuyInfoData(newBuyInfoData); setSelectedGames(newArray); } //--- const removePackage=(GameID,index)=>{ console.log("remove----------"); console.log(GameID,index); let newBuyInfoData = []; for (let i = 0; i < buyInfoData.length; i++) { if ( buyInfoData[i].gameId !== GameID || buyInfoData[i].packageIndex !== index ) { newBuyInfoData.push(buyInfoData[i]); } } let newArray = []; for(let i=0;i{ console.log("addCredit"); setCreditItem(amount); setFake(fake+1); } const removeCredit=()=>{ setCreditItem(null); } //closePayment-------------------------- const [showPayment, setShowPayment] = useState(false); const closePayment = () => { setShowPayment(false); }; const showPaymentFunc = () => { setShowPayment(true); }; //discount------------------------- const [discount,setDiscount]=useState(null); // const addDiscount=(amount)=>{ // setDiscount(); // } //creditIsActive------------------- const [creditIsActive,setCreditIsActive] = useState(false); return (
{ActiveUserFullInfo && (
)}
{/* {showUserFullInfo && } */} {showPayment && }
); }; export default Dashboard2