Files
tanami-admin-panel/src/Pages/IO_Management/ViewIO/ViewIOdata.jsx

216 lines
7.1 KiB
React
Raw Normal View History

2024-07-05 20:02:10 +05:30
import {
Box,
Button,
2024-11-25 16:41:19 +05:30
Icon,
2024-07-05 20:02:10 +05:30
Input,
2024-11-25 16:41:19 +05:30
keyframes,
Stack,
2024-07-05 20:02:10 +05:30
Tab,
TabList,
TabPanel,
TabPanels,
Tabs,
Text,
useDisclosure,
2024-07-05 20:02:10 +05:30
} 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";
2024-11-25 16:41:19 +05:30
import { ArrowBackIcon, RepeatIcon } from "@chakra-ui/icons";
2024-07-05 20:02:10 +05:30
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";
2024-07-08 20:42:55 +05:30
import InvestmentDocument from "../CreateIO/InvestmentDocument";
import KeyMerits from "../CreateIO/KeyMerits";
2024-08-22 18:48:45 +05:30
import Investors from "../CreateIO/Investors";
import EditIO from "../EditIO/EditIO";
2024-07-09 19:05:08 +05:30
import IOArtifacts from "../CreateIO/IOArtifacts";
2024-11-14 12:08:17 +05:30
// import IOCashDetails from "../CreateIO/IOCashDetailsold";
// import IONAVDetails from "../CreateIO/IONAVDetailsOld";
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 "../CreateIO/Destribution";
2024-11-14 12:08:17 +05:30
import IOCashDetails from "../CreateIO/IOCashDetails/IOCashDetails";
import IONAVDetails from "../CreateIO/IONAVDetails/IONAVDetails";
import IOTransaction from "../CreateIO/IOTransaction/IOTransaction";
2024-11-22 19:54:12 +05:30
import { GoDotFill } from "react-icons/go";
2024-07-09 14:49:05 +05:30
2024-11-25 16:41:19 +05:30
const rotate = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
`;
2024-07-05 20:02:10 +05:30
const ViewIOdata = () => {
2024-08-22 18:48:45 +05:30
const params = useParams();
const id = params?.id;
2024-11-25 16:41:19 +05:30
const { data, error, isLoading, refetch } = useGetIOprepopulateDataQuery();
const { isOpen, onOpen, onClose } = useDisclosure();
2024-07-05 20:02:10 +05:30
const navigate = useNavigate();
const [isEditing, setIsEditing] = useState(false);
2024-11-25 16:41:19 +05:30
const [isRefetchLoading, setIsRefetchLoading] = useState(false);
2024-08-16 15:02:02 +05:30
const { IODetails, setIODetails } = useContext(GlobalStateContext);
2024-11-25 16:41:19 +05:30
console.log(IODetails?.isInvestedAmount);
2024-07-05 20:02:10 +05:30
const tabs = [
{ label: "IO Details", content: <ViewIOdetails data={data?.data} /> },
2024-08-22 18:48:45 +05:30
{
2024-11-25 16:41:19 +05:30
label: "Investment documents",
2024-08-22 18:48:45 +05:30
content: <InvestmentDocument data={data?.data} />,
},
{ label: "Key merits", content: <KeyMerits data={data?.data} /> },
{ label: "IO artifacts", content: <IOArtifacts data={data?.data} /> },
2024-08-16 16:33:20 +05:30
{ label: "Investors", content: <Investors data={data?.data} /> },
// { label: "Investors", content: <UnderConstruction h={'75vh'} /> },
{ label: "IO Cash Details", content: <IOCashDetails data={data?.data} /> },
{ label: "IO NAV Details", content: <IONAVDetails data={data?.data} /> },
2024-08-22 18:48:45 +05:30
{
label: "Distribution to Investors",
content: <Destribution data={data?.data} />,
},
2024-11-14 12:08:17 +05:30
{
label: "IO Transaction",
content: <IOTransaction data={data?.data} />,
},
2024-08-22 12:10:07 +05:30
// { label: "Distribution to Investors", content: <UnderConstruction h={'75vh'} /> },
2024-07-05 20:02:10 +05:30
];
2024-11-25 16:41:19 +05:30
const handleRefresh = async () => {
setIsRefetchLoading(true);
await refetch();
setIsRefetchLoading(false);
};
2024-11-22 19:54:12 +05:30
console.log(IODetails?.ioNAVHistory);
2024-07-05 20:02:10 +05:30
return (
2024-08-22 18:48:45 +05:30
<Box
{...OPACITY_ON_LOAD}
overflowY={"scroll"}
overflowX={"hidden"}
height={"100vh"}
pb={14}
>
2024-07-08 20:42:55 +05:30
<Box paddingInline={"12px"} mt={2}>
{/* <span
2024-07-05 20:02:10 +05:30
onClick={() => navigate(-1)}
style={{ fontSize: "15px", cursor: "pointer" }}
>
<ArrowBackIcon cursor={"pointer"} /> Back
2024-07-08 20:42:55 +05:30
</span> */}
2024-07-05 20:02:10 +05:30
<ViewIOdataHeader />
</Box>
<Tabs mt={4}>
2024-08-22 18:48:45 +05:30
<TabList justifyContent={"space-between"} pe={4} alignItems={"center"}>
2024-11-25 16:41:19 +05:30
<Box display={"flex"} position={"relative"} w={"100%"}>
2024-08-22 18:48:45 +05:30
{tabs.map(({ label }, index) => (
<Tab
px={3}
2024-11-21 17:42:27 +05:30
isDisabled={
index === 0 ||
index === 1 ||
index === 2 ||
index === 3 ||
index === 4 ||
index === 8
? false
: !IODetails?.isInvestedAmount
}
2024-11-21 16:05:51 +05:30
// isDisabled={
// index === 0 ||
// index === 1 ||
// index === 2 ||
// index === 3 ||
// index === 4
// ? false
// : !IODetails?.isInvestedAmount
// }
2024-08-22 18:48:45 +05:30
key={index}
2024-11-14 12:08:17 +05:30
fontSize={"xs"}
2024-08-22 18:48:45 +05:30
_selected={{
color: "#004118",
borderBottom: "2px solid #38a169",
}}
2024-11-14 12:08:17 +05:30
fontWeight={500}
2024-11-22 19:54:12 +05:30
position={"relative"}
2024-08-22 18:48:45 +05:30
>
2024-11-25 16:41:19 +05:30
{label}{" "}
{(index === 5 &&
IODetails?.ioCashStatusHistory?.Pending?.length !== 0) ||
(index === 6 &&
IODetails?.ioNAVStatusHistory?.Pending?.length !== 0) ||
(index === 8 &&
IODetails?.ioTransactionRecords?.Pending?.length !== 0) ? (
<Box
as="span"
right={0}
color={"forestGreen"}
top={1}
position={"absolute"}
>
<GoDotFill />
</Box>
) : (
""
)}
2024-08-22 18:48:45 +05:30
</Tab>
))}
2024-11-25 16:41:19 +05:30
{/* <Box as="span" position={"absolute"} right={2} bottom={1}>
<Icon
ms={0}
animation={
isRefetchLoading ? `${rotate} 1s linear infinite` : "none"
}
bg={"gray.50"}
onClick={handleRefresh}
fontWeight={600}
as={RepeatIcon}
boxSize={8}
p={2}
rounded={"full"}
_hover={{ bg: "gray.100" }}
cursor={"pointer"}
/>
</Box> */}
<Stack position={"absolute"} right={2} bottom={1} direction="row" spacing={4}>
<Button
isLoading={isRefetchLoading}
loadingText="Refresh"
colorScheme="forestGreen"
variant="solid"
size={'xs'}
onClick={handleRefresh}
fontWeight={400}
>
Refresh
</Button>
</Stack>
2024-07-09 14:49:05 +05:30
</Box>
2024-07-05 20:02:10 +05:30
</TabList>
<TabPanels>
{tabs.map(({ content }, index) => (
2024-08-22 18:48:45 +05:30
<TabPanel key={index}>{content}</TabPanel>
2024-07-05 20:02:10 +05:30
))}
</TabPanels>
</Tabs>
</Box>
);
};
export default ViewIOdata;