"use client";

import AppHeader from "@comp/AppHeader/page";
// import TaskCard from "@comp/TaskCard/page";
import AppContext from "@ctx/AppContext";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { getToken } from "plugins/Chapar";
import { ParseJwt } from "plugins/ParseJwt/page";
import PersianNumber from "plugins/PersianNumber";
import React, { useContext, useEffect } from "react";
// import { Swiper, SwiperSlide } from "swiper/react";

const Home = (props) => {
  const CTX = useContext(AppContext);
  const router = useRouter();

  const profile = CTX.state.profile;

  useEffect(() => {
    if (!!localStorage.token) {
      const datatoken = ParseJwt(getToken());
      CTX.setComplexId(datatoken.ComplexId);

      if (datatoken.SignUpStatus == 1) {
        CTX.setStepLogin(2);
        router.push(`/login?phoneNumber=${datatoken.unique_name}`);
      }
    } else {
      router.push("/login");
    }
  }, []);

  return (
    <div className="pb-20">
      <AppHeader
        title={profile?.firstName + "     " + profile?.lastName}
        sub={profile.selectedComplexName}
        icon1={true}
        iconName1="ACOUNT"
        iconHref1="/acount"
        iconEvent1={() => {
          return undefined;
        }}
        icon2={true}
        iconName2="NINJA"
        iconHref2="#"
        iconEvent2={() => {
          return undefined;
        }}
        userIcon={true}
        userIconData={profile.firstName}
      />

      <div className="bg-body-100 relative top-[-30px] rounded-t-3xl overflow-hidden p-5 rtl">
        اینجا برای مدیریت میشه همون چارت ها و ...
      </div>
    </div>
  );
};

export default Home;
