import {
  Box,
  Button,
  Input,
  Tab,
  TabList,
  TabPanel,
  TabPanels,
  Tabs,
  Text,
} from "@chakra-ui/react";
import { useNavigate, useParams } from "react-router-dom";
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
import { useContext, useEffect, useState } from "react";
import FormInputView from "../../../Components/FormInputView";
import { useForm } from "react-hook-form"; // assuming react-hook-form is used
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
import { ArrowBackIcon } from "@chakra-ui/icons";
import CustomAlertDialog from "../../../Components/CustomAlertDialog";
import ViewIOdataHeader from "./ViewIOdataHeader";
import ViewIOdetails from "./ViewIOdetails";
import ViewIOdocs from "./ViewIOdocs";
import ViewKeyMerits from "./ViewKeyMerits";
import ViewIOartifacts from "./ViewIOartifacts";
import ViewInvestors from "./ViewInvestors";
import ViewIOcash from "./ViewIOcash";
import ViewIOnav from "./ViewIOnav";
import ViewDistribution from "./ViewDistribution";

const ViewIOdata = () => {
  const [isEditing, setIsEditing] = useState(false);
  const navigate = useNavigate();

  const tabs = [
    { label: "IO Details", content: <ViewIOdetails /> },
    { label: "Investment documents", content: <ViewIOdocs /> },
    { label: "Key merits", content: <ViewKeyMerits /> },
    { label: "IO artifacts", content: <ViewIOartifacts /> },
    { label: "Investors", content: <ViewInvestors /> },
    { label: "IO Cash Details", content: <ViewIOcash /> },
    { label: "IO NAV Details", content: <ViewIOnav /> },
    { label: "Distribution", content: <ViewDistribution /> },
  ];

  return (
    <Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14}>
      <Box paddingInline={"12px"}>
        <span
          onClick={() => navigate(-1)}
          style={{ fontSize: "15px", cursor: "pointer" }}
        >
          <ArrowBackIcon cursor={"pointer"} /> Back
        </span>
        <ViewIOdataHeader />
      </Box>

      <Tabs mt={4}>
        <TabList>
          {tabs.map(({ label }, index) => (
            <Tab
              disabled={true}
              key={index}
              fontSize={"sm"}
              _selected={{
                color: "#004118",
                borderBottom: "2px solid #38a169",
              }}
            >
              {label}
            </Tab>
          ))}
        </TabList>

        <TabPanels>
          {tabs.map(({ content }, index) => (
            <TabPanel key={index}>{content}</TabPanel>
          ))}
        </TabPanels>
      </Tabs>
    </Box>
  );
};

export default ViewIOdata;
