check it

check it


import React, {useState, useEffect} from 'react'

import { investPlans } from '../Data/investplans';

import '../../CSS/all.css'

import img1 from '../../Images/Tabbar/main_tab_3.png'

import img2 from '../../Images/Tabbar/main_tab_14.png'

import img3 from '../../Images/Tabbar/i11.png'

import img4 from '../../Images/Carousel/index_ico2.png'

import img5 from '../../Images/Tabbar/main_tab_8.png'

import { Link } from 'react-router-dom';

import DemoCarousel from './carousel';

import firebase from '../firebase';

import { db } from '../firebase';

import img6 from '../../Images/Others/custemService2.png'

import img7 from '../../Images/Others/treasure.gif'

import { FaCentercode } from 'react-icons/fa';

import img18 from '../../Images/Others/9f98fd9c-3e43-4e6c-aa16-314f56fe0f72.png'


const Home = () => {

    const [currentBalance, setCurrentBalance] = useState(0)

    const [value, setValue] = useState(0)

    const [todos, setTodos] = useState([])

    const [popup, setPopup] = useState(false)

    const [buy, setBuy] = useState(false)

    const [decision, setDecision] = useState(null)

    const [price, setPrice] = useState(0)

    const [id, setId] = useState()

    const [cut, setCut] = useState(false)

    const [cut2, setCut2] = useState()

    const [popup2, setPopup2] = useState("false")


    if(popup2 === "false") {

        setTimeout(() => {

            setPopup2("true")

        }, 1000)

    }

   

    var today = new Date();


    const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();

    const time = today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds();

    const endDate = (today.getFullYear() + 1) + '-' + (today.getMonth() + 1) + '-' + today.getDate();

    console.log("Date: ", endDate +' '+ time)

    var Uhours = (today.getHours() + 1) % 24

    const Utime = Uhours + ':' + today.getMinutes() + ':' + today.getSeconds();


    const user = firebase.auth().currentUser?.uid


    db.collection("personal").doc(user).get().then((doc) => {

        setId(doc.data()?.user_id)

    })


    useEffect(() => {

        const docRef = db.collection("balance").doc(id);

        docRef.get().then((doc) => {

            setCurrentBalance(doc.data()?.deposit_balance)

        })

    })


    const investNow = (e) => {

        e.preventDefault()


        setTimeout(() => {

            setPopup(true)

            setPrice(investPlans[value].price)

        }, 0)

    }



    const checkItFast = () => {

        setCut2(investPlans[value].price)

        if(buy) {

            if(investPlans[value].price > currentBalance) {

                setDecision(`Your balance is insufficient Whether you need to recharge?`)

            }else{

                setDecision("Congrats! You have sucessfully purchased this product.")

                setCut(true)

            }

            return;

        }

       


    if(cut) {

        db.collection('investments').doc(user).collection('data').add({

            product_name: investPlans[value].title,

            product_cost: investPlans[value].price,

            product_income: investPlans[value].income,

            product_image: investPlans[value].image,

            gain: 0,

            invested_at: date + ' ' + time,

            ended_at: endDate + ' ' + time,

            updated_time: Utime,

        })


        db.collection("balance").doc(id).update({

            deposit_balance: currentBalance - cut2,

        })

        setCut(false)

        }

    }


   

    useEffect(() => {

        checkItFast()

    })


    console.log(cut);


    const newClick = () => {

        setPopup(false)

        setBuy(false)

    }

    return (

        <div className="homePage">

            {popup2 === "true" ? (

                <div className="Popup-container" style={{background: "#0000008a",}}>

                    <div className="popupStart lalala" style={{height: "90vh", width: "90%", position: "relative", paddingTop: 35, boxShadow: "0px 0px 3px #fff"}}>

                        <div>

                        <div className="text" style={{textAlign: "center"}}>💐Important Notice💐</div>

                        <br />

                        <div>Please rest assured that the withdrawal shows success because we have already submitted this batch of funds to the bank. The bank will transfer the money to your personal account before December 30, so please be patient. The bonus and income you get every day are all Can withdraw normally</div>

                        <br />

                        <div>🔥If you have any questions, please join the telegram group: https://t.me/agridevelop_01</div>

                        <br /><br />

                        <div>💹Many friends don’t understand how AgriDevelop Pro makes money:Buy 3500rs products now and give away 500RS products</div>

                        <br /><br />

                        <div>👉1. Users invest in agriculture on the platform</div>

                        <br />

                        <div>👉2. The platform is responsible for production, promotion and sales</div>

                        <br />

                        <div>👉3. The agricultural income generated is the income of investment users and the platform</div>

                        <br />

                        <div>👉4. Brand promotion through user promotion</div>

                        <br />

                        <div>👉5. Invite your friends & get Rs5 instantly in your withdrawal wallet + 10% commission in every investment</div>

                        <br />

                        <div>💹In short, if you invest in AgriDevelop Pro, the platform is responsible for promoting sales. <br /><br /> 💹AgriDevelop Pro income = 24 hours income, which means you can earn income by eating and sleeping</div>

                        <br /><br />

                        <div>💹Start a new day, open AgriDevelop Pro App to start recharge</div>

                        <br />

                        <a href="https://t.me/agridevelop_01">

                        <center>

                            <div style={{color: "red"}}>💥Newly join Telegram channel to get 10RS</div>

                        </center>

                        <br />

                        <img src={img18} width="275" />

                        </a>

                        </div>

                        <br />

                        <button onClick={() => setPopup2("hide")} style={{width: "90%", background: "#fff", height: 40, position: "fixed", bottom: 30, marginLeft: "-15px", border: 0, borderTop: "1px solid #aaa", borderBottomLeftRadius: 15, borderBottomRightRadius: 15}}>Okay</button>

                    </div>

                </div>

            ):(

                <></>

            )}

            <DemoCarousel />

            <div className="customerService">

                <div className="customerServiceStart">

                    <a href="/customer-service">

                        <div className="customerServiceTop" style={{marginTop: 25}}>

                            <img src={img6} height="50" />

                        </div>

                    </a>

                    <a href="/my/dig-treasure">

                        <div className="customerServiceTop" style={{marginTop: 25}}>

                            <img src={img7} height="50" />

                        </div>

                    </a>

                </div>

            </div>

            <div className="tabbarContainer">

                <div className="tab">

                    <img src={img1} height="25" />

                    <div className="tabName" style={{color: '#05a971'}}> Home </div>

                </div>

                <a href="/earning">

                    <div className="tab">

                        <img src={img3} height="25" />

                        <div className="tabName" style={{marginLeft: -10}}>Earnings</div>

                    </div>

                </a>

                <a href="/task">

                    <div className="tab">

                        <img src={img4} height="25" />

                        <div className="tabName" style={{marginLeft: 1, marginTop: -5}}>Task</div>

                    </div>

                </a>

                <a href="/share">

                    <div className="tab">

                        <img src={img2} height="25" />

                        <div className="tabName">Share</div>

                    </div>

                </a>

                <a href="/my">

               <div className="tab">

                    <img src={img5} height="25" />

                    <div className="tabName" style={{marginLeft: 4, color: '#05a971'}}>My</div>

               </div>

            </a>

            </div>

            <div className="carouselBottom">

                {investPlans.map((item) => {

                    return (

                        <div className="plansContainer">

                            <div className="plansContainerTop">

                                <div className="plansContainerTopLeft">

                                    <div className="plansContainerTopLeftLeft">

                                        <div className="planTitle" style={{marginLeft: 75}}> {item.title} </div>

                                    </div>

                                </div>

                            </div>

                            <div className="plansContainerMiddle">

                                <div className="plansContainerMiddleLeft">

                                    <div className="plansContainerMiddleLeftLeft">

                                        <img src={item.image} height="60" width="60" style={{borderRadius: 5}} />

                                        <div className="plansDetail">

                                            <div className="tagContainer">

                                                <div className="tag"> {item.tag1} </div>

                                                <div className="tag"> {item.tag2} </div>

                                                <div className="tag"> {item.tag3} </div>

                                            </div>

                                            <div className="planIncome">

                                                <div className="planIncome1">

                                                    <div className="planIncomeTop"> ₹ {item.income}</div>

                                                        <div className="planIncomeTime">Day Income</div>

                                                    </div>

                                                <div className="planIncome2">

                                                    <div className="planIncomeTop"> ₹ {item.price} <span style={{fontSize: 14, color: "#aaa", textDecoration: "line-through"}}>₹{item.real_price}</span></div>

                                                        <div className="planIncomeTime">Bredding Price</div>

                                                    </div>

                                                <div className="planIncomeNo"></div>

                                            </div>

                                        </div>

                                    </div>

                                </div>

                            </div>

                            <Link to="/" onClick={(e)=>{setValue(item.value)}} >

                                <div className="investBtn" onClick={investNow}>Invest Now</div>

                            </Link>

                        </div>

                    )

                })}

            </div>

            {popup ? (

                <div className="Popup-container">

                    <div className="popupStart">

                        {buy ? (

                            <>

                                <div className="popupBuy" style={{width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center", textAlign: "center"}}>

                                    <div className="popupBuyStart">

                                    <div className="popupTop">{decision}</div>

                                        <button className="popupYes" onClick={newClick} style={{marginTop: 40}}>Go Back</button>

                                    </div>

                                </div>

                            </>

                        ):(

                            <>

                                <div className="popupTop">Are you sure, you want to buy this product?</div>

                               

                                <div className="popupBottom">

                                    <button className="popupYes" onClick={() => setBuy(true)}>Buy</button>

                                    <button className="popupNo" onClick={() => setPopup(false)}>Cancel</button>

                                </div>

                            </>

                        )}

                    </div>

                </div>

            ):(

                <></>

            )}

        </div>

    )

}


export default Home


Report Page