import React, { useState, useEffect } from "react";
import datas from "../../data/product_data.json";
import Layout from "../Partials/Layout";
import usersService from "../../services/UsersService";
import { useSelector } from "react-redux";
import FamilyDash from "./FamilyDash";
import FullAccountDash from "./FullAccountDash";

export default function Home(props) {
  console.log("PROPS IN HOME->", props);

  let [nextDueTask, setNextDueTask] = useState({});

  const userApi = new usersService();

  const { userDetails } = useSelector((state) => state?.userDetails);

  const { commonHeadBanner } = useSelector((state) => state.commonHeadBanner);

  // FUNCTION TO GET DASH DATA TO DETERMINE CURRENT TASK DUE TIME
  const getHomeDate = () => {
    userApi
      .getHomeDate()
      .then((res) => {
        if (res.status != 200 || res.internal_return < 0) {
          return;
        }
        setNextDueTask(res.data);
      })
      .catch((error) => {
        console.log(error);
      });
  };

  useEffect(() => {
    getHomeDate();
  }, []);

  return (
    <Layout>
      <div className="home-page-wrapper">
        {userDetails && userDetails?.account_type == "FAMILY" && (
          <FamilyDash commonHeadData={props.bannerList} />
        )}
        {userDetails && userDetails?.account_type == "FULL" && (
          <FullAccountDash
            nextDueTask={nextDueTask}
            bannerList={props.bannerList}
          />
        )}
      </div>
    </Layout>
  );
}
// /*
//      <Layout>
//             <div className="home-page-wrapper">
//                 <Hero className="mb-10" data={userDetails} />
//                 {/* <CreateNft />
//         <TrendingSection trending={trending} className="mb-10" />*/}
// <HomeTaskDisplay
//     jobData={jobData}
//     className="mb-10"
//     bannerList={props.bannerList}
// />
{
  /*  <SellHistoryMarketVisitorAnalytic className="mb-10"/>
                <TopSellerTopBuyerSliderSection className="mb-10" />
                <UpdateTable className="mb-10"/>*/
}
// </div>
// </Layout>
