Files
tanami-admin-panel/src/Pages/IO_Management/CreateIO/CreateIO.jsx

150 lines
4.1 KiB
React
Raw Normal View History

2024-07-08 12:22:27 +05:30
import React, { useEffect, useState } from "react";
2024-07-05 15:28:02 +05:30
import { OPACITY_ON_LOAD } from "../../../Layout/animations";
2024-07-09 14:49:05 +05:30
import { Box, Tabs, TabList, Tab, TabPanel, TabPanels } from "@chakra-ui/react";
2024-07-08 12:22:27 +05:30
import { useForm } from "react-hook-form";
2024-06-26 17:45:13 +05:30
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
2024-07-05 15:28:02 +05:30
import IODetails from "./IODetails";
import KeyMerits from "./KeyMerits";
import IOArtifacts from "./IOArtifacts";
import Investors from "./Investors";
2024-11-14 12:08:17 +05:30
// import IOCashDetails from "./IOCashDetailsold";
// import IONAVDetails from "./IONAVDetailsOld";
2024-07-08 12:22:27 +05:30
import InvestmentDocument from "./InvestmentDocument"; // Ensure this is the correct import
2024-07-08 20:42:55 +05:30
import ViewIOdataHeader from "../ViewIO/ViewIOdataHeader";
2024-07-09 14:49:05 +05:30
import { useParams } from "react-router-dom";
import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders";
2024-07-25 12:26:18 +05:30
import { useGetIOprepopulateDataQuery } from "../../../Services/io.service";
2024-08-14 12:19:27 +05:30
import UnderConstruction from "../../UnderConstruction";
2024-08-22 12:10:07 +05:30
import Destribution from "./Destribution";
2024-11-14 12:08:17 +05:30
import IOCashDetails from "./IOCashDetails/IOCashDetails";
import IONAVDetails from "./IONAVDetails/IONAVDetails";
import IOTransaction from "./IOTransaction/IOTransaction";
2024-06-26 17:45:13 +05:30
2024-06-25 12:05:39 +05:30
const CreateIO = () => {
2024-07-09 14:49:05 +05:30
const id = useParams()?.id;
2024-07-25 12:26:18 +05:30
const { data, error, isLoading } = useGetIOprepopulateDataQuery();
2024-06-26 17:45:13 +05:30
2024-07-08 12:22:27 +05:30
const enableNextTab = (index) => {
setTabs((prevTabs) => {
const newTabs = [...prevTabs];
if (index < newTabs.length - 1) {
newTabs[index + 1].isDisabled = false;
setActiveIndex(index + 1); // Switch to the next tab
}
return newTabs;
});
};
2024-07-05 20:05:18 +05:30
const initialTabsState = [
2024-07-05 16:16:03 +05:30
{
label: "IO Details",
2024-07-08 12:22:27 +05:30
Content: IODetails,
2024-07-25 12:26:18 +05:30
isDisabled: id ? false : false,
2024-07-05 16:16:03 +05:30
},
{
label: "Investment documents",
2024-07-08 12:22:27 +05:30
Content: InvestmentDocument,
2024-08-23 12:24:34 +05:30
isDisabled: id ? true : true,
2024-07-05 16:16:03 +05:30
},
{
label: "Key merits",
2024-07-08 12:22:27 +05:30
Content: KeyMerits,
2024-08-23 12:24:34 +05:30
isDisabled: id ? true : true,
2024-07-05 16:16:03 +05:30
},
{
label: "IO artifacts",
2024-07-08 12:22:27 +05:30
Content: IOArtifacts,
2024-08-23 12:24:34 +05:30
isDisabled: id ? true : true,
2024-07-05 16:16:03 +05:30
},
{
label: "Investors",
2024-08-23 12:24:34 +05:30
Content: Investors,
// Content: UnderConstruction,
isDisabled: id ? true : true,
2024-07-05 16:16:03 +05:30
},
{
2024-08-07 20:18:36 +05:30
label: "IO Cash Detail",
2024-07-08 12:22:27 +05:30
Content: IOCashDetails,
2024-08-23 12:24:34 +05:30
isDisabled: id ? true : true,
2024-07-05 16:16:03 +05:30
},
{
label: "IO NAV Details",
2024-07-08 12:22:27 +05:30
Content: IONAVDetails,
2024-08-23 12:24:34 +05:30
isDisabled: id ? true : true,
2024-07-05 16:16:03 +05:30
},
2024-08-07 20:18:36 +05:30
{
label: "Distribution to Investors",
2024-08-22 12:10:07 +05:30
Content: Destribution,
2024-08-23 12:24:34 +05:30
isDisabled: id ? true : true,
2024-08-07 20:18:36 +05:30
},
2024-11-14 12:08:17 +05:30
{
label: "IO Transaction",
Content: IOTransaction,
isDisabled: id ? true : true,
},
2024-07-05 15:28:02 +05:30
];
2024-06-26 17:45:13 +05:30
2024-07-05 20:05:18 +05:30
const [tabs, setTabs] = useState(initialTabsState);
const [activeIndex, setActiveIndex] = useState(0);
2024-07-09 14:49:05 +05:30
2024-07-25 12:26:18 +05:30
return isLoading ? (
<FullscreenLoaders />
) : (
<Box
{...OPACITY_ON_LOAD}
w={"100%"}
overflowY={"scroll"}
overflowX={"hidden"}
height={"100vh"}
pb={10}
>
2024-08-13 13:46:41 +05:30
{id && <Box
ps={1}
pe={2} mt={2}>
2024-07-08 20:42:55 +05:30
{/* <span
onClick={() => navigate(-1)}
style={{ fontSize: "15px", cursor: "pointer" }}
>
<ArrowBackIcon cursor={"pointer"} /> Back
</span> */}
2024-08-12 17:22:04 +05:30
<ViewIOdataHeader isLoading={isLoading} data={data?.data} />
2024-08-12 12:22:01 +05:30
</Box>}
2024-07-09 14:49:05 +05:30
<Tabs
index={activeIndex}
onChange={(index) => setActiveIndex(index)}
mt={2}
2024-08-13 13:46:41 +05:30
ps={1}
pe={2}
2024-07-09 14:49:05 +05:30
>
2024-07-05 12:07:52 +05:30
<TabList>
2024-07-09 14:49:05 +05:30
{tabs?.map(({ label, isDisabled }, index) => (
2024-07-05 16:16:03 +05:30
<Tab
isDisabled={isDisabled}
key={index}
2024-11-14 12:08:17 +05:30
fontSize={"xs"}
fontWeight={500}
2024-07-05 16:16:03 +05:30
_selected={{
color: "#004118",
borderBottom: "2px solid #38a169",
}}
>
{label}
</Tab>
))}
2024-07-05 12:07:52 +05:30
</TabList>
<TabPanels>
2024-07-08 12:22:27 +05:30
{tabs.map(({ Content }, index) => (
2024-07-05 20:05:18 +05:30
<TabPanel key={index}>
2024-07-25 12:26:18 +05:30
<Content index={index} enableNextTab={enableNextTab} data={data?.data} />
2024-07-05 20:05:18 +05:30
</TabPanel>
2024-07-05 16:16:03 +05:30
))}
2024-07-05 12:07:52 +05:30
</TabPanels>
</Tabs>
2024-06-25 12:05:39 +05:30
</Box>
2024-06-26 17:45:13 +05:30
);
};
2024-06-25 12:05:39 +05:30
2024-06-26 17:45:13 +05:30
export default CreateIO;