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

526 lines
15 KiB
React
Raw Normal View History

import {
Button,
Divider,
Image,
Menu,
MenuButton,
MenuItem,
MenuList,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Portal,
Text,
useDisclosure,
2024-07-09 13:05:58 +05:30
MenuItemOption,
MenuGroup,
MenuOptionGroup,
2024-07-09 19:05:08 +05:30
MenuDivider,
Badge,
Box,
2024-07-15 12:27:23 +05:30
Icon,
2024-08-14 12:19:27 +05:30
HStack,
2024-07-09 12:25:52 +05:30
} from "@chakra-ui/react";
2024-07-05 20:02:10 +05:30
import header from "../../../assets/IOheader.png";
import { HiDotsVertical } from "react-icons/hi";
2024-07-10 12:02:35 +05:30
import { Link, useParams } from "react-router-dom";
import AmountInvested from "./HeaderModal/AmountInvested";
import FeesExpenses from "./HeaderModal/FeesExpenses";
import DistributionSponsor from "./HeaderModal/DistributionSponsor";
import DistributionInvestor from "./HeaderModal/DistributionInvestor";
import UpdateIONav from "./HeaderModal/UpdateIONav";
import UpdateIOStatus from "./HeaderModal/UpdateIOStatus";
2024-07-10 12:02:35 +05:30
import { useContext, useRef } from "react";
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
2024-07-15 12:27:23 +05:30
import Exit from "./HeaderModal/Exit";
import Cancle from "./HeaderModal/Cancle";
import { AddIcon } from "@chakra-ui/icons";
import { GrGallery } from "react-icons/gr";
2024-08-13 13:46:41 +05:30
import Loader01 from "../../../Components/Loaders/Loader01";
2024-08-20 12:19:02 +05:30
// import { formatCurrency } from "../../../Components/CurrencyInput";
// import { removeTrailingZeros } from "../../../Constants/Constants";
2024-07-05 15:33:08 +05:30
2024-08-22 12:10:07 +05:30
const ViewIOdataHeader = ({ data, isLoading }) => {
2024-07-15 12:27:23 +05:30
const params = useParams();
2024-07-10 12:02:35 +05:30
const id = params?.id;
const { isOpen, onOpen, onClose } = useDisclosure();
2024-07-09 12:25:52 +05:30
const btnRef = useRef();
2024-08-12 17:22:04 +05:30
const { IODetails, isIOloading } = useContext(GlobalStateContext);
2024-08-22 12:10:07 +05:30
const {
isOpen: isInvestmentOpen,
onOpen: onInvestmentOpen,
onClose: onInvestmentClose,
} = useDisclosure();
const {
isOpen: isFeesOpen,
onOpen: onFeesOpen,
onClose: onFeesClose,
} = useDisclosure();
const {
isOpen: isDistSponsorOpen,
onOpen: onDistSponsorOpen,
onClose: onDistSponsorClose,
} = useDisclosure();
const {
isOpen: isDistInvestorOpen,
onOpen: onDistInvestorOpen,
onClose: onDistInvestorClose,
} = useDisclosure();
const {
isOpen: isUpdateNavOpen,
onOpen: onUpdateNavOpen,
onClose: onUpdateNavClose,
} = useDisclosure();
const {
isOpen: isUpdateStatusOpen,
onOpen: onUpdateStatusOpen,
onClose: onUpdateStatusClose,
} = useDisclosure();
2024-07-15 12:27:23 +05:30
const {
isOpen: isExitOpen,
onOpen: onExitOpen,
onClose: onExitClose,
} = useDisclosure();
const {
isOpen: isCancleOpen,
onOpen: onCancleOpen,
onClose: onCancleClose,
} = useDisclosure();
const bg = {
bg: "#fff",
};
const hover = {
textDecoration: "underline",
background: "#fff",
};
2024-07-09 13:13:39 +05:30
const style = {
fontSize: "0.875rem",
fontWeight: "400",
};
2024-08-07 20:18:36 +05:30
2024-08-22 12:10:07 +05:30
console.log(
import.meta.env.VITE_IMAGE_URL +
IODetails?.artifactsImage?.[0]?.artifactPathName
);
2024-08-07 20:18:36 +05:30
const menu = [
{
2024-08-22 12:10:07 +05:30
id: 1,
title: "Amount Invested",
onClickFunction: onInvestmentOpen,
2024-08-07 20:18:36 +05:30
},
2024-08-12 12:22:01 +05:30
// {
// id:2,
// title:"Fees & Expenses",
// onClickFunction:onFeesOpen
// },
// {
// id:3,
// title:"Distribution From Sponsors",
// onClickFunction:onDistSponsorOpen
// },
2024-08-07 20:18:36 +05:30
{
2024-08-22 12:10:07 +05:30
id: 6,
title: "Distribution To Investors",
onClickFunction: onDistInvestorOpen,
2024-08-07 20:18:36 +05:30
},
2024-08-12 15:35:39 +05:30
{
2024-08-22 12:10:07 +05:30
id: 5,
title: "Update IO NAV",
onClickFunction: onUpdateNavOpen,
2024-08-12 15:35:39 +05:30
},
2024-08-07 20:18:36 +05:30
{
2024-08-22 12:10:07 +05:30
id: 8,
title: "Exit",
onClickFunction: onExitOpen,
2024-08-07 20:18:36 +05:30
},
{
2024-08-22 12:10:07 +05:30
id: 9,
title: "Cancel",
onClickFunction: onCancleOpen,
2024-08-07 20:18:36 +05:30
},
{
2024-08-22 12:10:07 +05:30
id: 10,
title: "Update IO Status",
onClickFunction: onUpdateStatusOpen,
2024-08-07 20:18:36 +05:30
},
2024-08-22 12:10:07 +05:30
];
2024-08-07 20:18:36 +05:30
2024-08-12 12:22:01 +05:30
// console.log(IODetails?.mainTranscation);
2024-08-07 20:18:36 +05:30
2024-08-22 12:10:07 +05:30
// Extract titles from apiTransaction
const apiTransactionTitles = IODetails?.mainTranscation?.map(
(transaction) => transaction.id
);
// Filter menu items
const filteredMenu = menu?.filter((item) =>
apiTransactionTitles?.includes(item.id)
);
2024-08-07 20:18:36 +05:30
2024-08-28 19:35:39 +05:30
const balanceAmount = IODetails?.goalAmount - IODetails?.totalAmtInvestmentInUSD
2024-08-22 12:10:07 +05:30
return IODetails?.investmentNameEnglish ? (
2024-07-05 15:33:08 +05:30
<Box
display={"flex"}
alignItems={"center"}
2024-08-14 12:19:27 +05:30
justifyContent={"space-between"}
2024-07-24 19:58:15 +05:30
gap={8}
2024-08-12 17:22:04 +05:30
bg={
IODetails?.ioStatus?.statusAdmin === "Draft"
? "#EDF2F7"
: IODetails?.ioStatus?.statusAdmin === "Processing"
? "#FEFBBF"
: IODetails?.ioStatus?.statusAdmin === "Open"
? "#BEE2F8"
: IODetails?.ioStatus?.statusAdmin === "Closed"
? "#C6F6D5"
: IODetails?.ioStatus?.statusAdmin === "Exited"
2024-08-22 12:10:07 +05:30
? "#FED7D7"
2024-08-12 17:22:04 +05:30
: IODetails?.ioStatus?.statusAdmin === "Canclled"
? "orange.500"
: IODetails?.ioStatus?.statusAdmin === "DeActivate"
? "#E9D8FD"
: null
}
2024-07-08 20:42:55 +05:30
rounded={"md"}
// bgGradient='linear(to-r, #caf5d8, #f5e8ca)'
// bgGradient='linear(to-r, #caf5d8, #d4a5a5)'
// bgGradient='linear(to-r, #caf5d8, #d4a5a5)'
// bgGradient='linear(to-r, #caf5d8, #b3e5fc)'
// bgGradient='linear(to-r, #ffd54f, #caf5d8)'
2024-08-12 17:22:04 +05:30
// bgGradient='linear(to-r, #caf5d8, #a8e6cf)'
2024-07-09 19:05:08 +05:30
boxShadow={"md"}
position={"relative"}
2024-07-05 15:33:08 +05:30
>
2024-08-28 19:35:39 +05:30
<HStack gap={4}>
2024-08-22 12:10:07 +05:30
<Box h={100} w={200} p={1.5}>
{/* <Image rounded={'md'} h={"100%"} src={ " https://tanami.betadelivery.com/" + IODetails?.ioName} alt={IODetails?.ioName}/> */}
{IODetails?.artifactsImage?.[0]?.artifactPathName ? (
<Image
rounded={"md"}
h={"100%"}
w={"100%"}
objectFit={"cover"}
src={
import.meta.env.VITE_IMAGE_URL +
IODetails?.artifactsImage?.[0]?.artifactPathName
}
alt={IODetails?.ioName}
/>
) : (
<Box
w={"100%"}
h={"100%"}
display={"flex"}
justifyContent={"center"}
alignItems={"center"}
bg={"#fff"}
rounded={"md"}
>
<Icon color={"gray.700"} as={GrGallery} />
</Box>
)}
</Box>
2024-08-28 19:35:39 +05:30
<Box>
2024-08-29 17:02:43 +05:30
<Box display={"flex"} gap={2} pb={1}>
2024-08-28 19:35:39 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
me={2}
>
IO Name :-
</Text>
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
{IODetails?.investmentNameEnglish
? IODetails?.investmentNameEnglish
: "---"}
</Text>
</Box>
2024-08-29 17:02:43 +05:30
<Box display={"flex"} gap={2} pb={1}>
2024-08-28 19:35:39 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
me={2}
>
Sponsor Name :-
</Text>
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
{IODetails?.sponsor?.sponsorName
? IODetails?.sponsor?.sponsorName
: "---"}
</Text>
</Box>
2024-08-29 17:02:43 +05:30
<Box display={"flex"} gap={2} pb={1}>
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
me={2}
>
IO ID :-
</Text>
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
{IODetails?.io_id
? IODetails?.io_id
: "---"}
</Text>
</Box>
2024-08-28 19:35:39 +05:30
</Box>
2024-08-29 17:02:43 +05:30
2024-08-28 19:35:39 +05:30
</HStack>
2024-09-09 17:49:49 +05:30
<Box gap={8} me={12} w={"220px"}>
2024-08-28 19:35:39 +05:30
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
2024-08-22 12:10:07 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
2024-08-28 19:35:39 +05:30
Goal Amount :-
2024-08-22 12:10:07 +05:30
</Text>
2024-08-28 19:35:39 +05:30
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
{/* {IODetails?.ioNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioNAV)) : "00.00"} */}
{parseFloat(IODetails?.goalAmount || 0).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
2024-08-22 12:10:07 +05:30
</Text>
</Box>
2024-08-28 19:35:39 +05:30
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
2024-08-22 12:10:07 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
2024-09-13 19:43:38 +05:30
Amount Raised :-
2024-08-22 12:10:07 +05:30
</Text>
2024-08-28 19:35:39 +05:30
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
{/* {IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"} */}
{parseFloat(IODetails?.totalAmtInvestmentInUSD || 0).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
2024-08-22 12:10:07 +05:30
</Text>
</Box>
2024-08-14 12:19:27 +05:30
2024-08-28 19:35:39 +05:30
<Box display={"flex"} justifyContent={"space-between"} gap={2}>
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
Balance :-
</Text>
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
{/* {IODetails?.ioMVNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioMVNAV)) : "00.00"} */}
{parseFloat(balanceAmount || 0).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
</Text>
</Box>
</Box>
<Box gap={8} me={12} w={"140px"}>
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
2024-08-22 12:10:07 +05:30
<Text
as={"span"}
textAlign={"center"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
2024-08-28 19:35:39 +05:30
IO Status :-
2024-08-22 12:10:07 +05:30
</Text>
<Badge
rounded={"full"}
pt={0}
pb={0.5}
textTransform={"none"}
// variant={"solid"}
colorScheme={
IODetails?.ioStatus?.statusAdmin === "Draft"
? "gray"
: IODetails?.ioStatus?.statusAdmin === "Processing"
? "yellow"
: IODetails?.ioStatus?.statusAdmin === "Open"
? "blue"
: IODetails?.ioStatus?.statusAdmin === "Closed"
? "green"
: IODetails?.ioStatus?.statusAdmin === "Exited"
? "red"
: IODetails?.ioStatus?.statusAdmin === "Canclled"
? "orange"
: "purple"
}
>
{IODetails?.ioStatus?.statusAdmin
? IODetails?.ioStatus?.statusAdmin
: "---"}
</Badge>
</Box>
2024-08-28 19:35:39 +05:30
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
2024-08-22 12:10:07 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
2024-08-28 19:35:39 +05:30
IO MV :-
2024-08-22 12:10:07 +05:30
</Text>
2024-08-28 19:35:39 +05:30
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
2024-08-22 12:10:07 +05:30
{/* {IODetails?.ioNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioNAV)) : "00.00"} */}
{parseFloat(IODetails?.ioNAV || 0).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
</Text>
</Box>
2024-08-28 19:35:39 +05:30
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
2024-08-22 12:10:07 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
2024-08-28 19:35:39 +05:30
IO cash :-
2024-08-22 12:10:07 +05:30
</Text>
2024-08-28 19:35:39 +05:30
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
2024-08-22 12:10:07 +05:30
{/* {IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"} */}
{parseFloat(IODetails?.ioCash || 0).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
</Text>
</Box>
2024-08-28 19:35:39 +05:30
<Box display={"flex"} justifyContent={"space-between"} gap={2}>
2024-08-22 12:10:07 +05:30
<Text
as={"span"}
fontSize={"xs"}
color={"gray.500"}
fontWeight={"500"}
>
2024-08-28 19:35:39 +05:30
IO NAV :-
2024-08-22 12:10:07 +05:30
</Text>
2024-08-28 19:35:39 +05:30
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
2024-08-22 12:10:07 +05:30
{/* {IODetails?.ioMVNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioMVNAV)) : "00.00"} */}
{parseFloat(IODetails?.ioMVNAV || 0).toLocaleString(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
</Text>
</Box>
2024-08-28 19:35:39 +05:30
</Box>
2024-08-14 12:19:27 +05:30
2024-07-09 19:05:08 +05:30
<Box
position={"absolute"}
right={3}
top={2}
display={"flex"}
alignItems={"start"}
height={"95px"}
>
<Menu>
<MenuButton
2024-07-09 19:05:08 +05:30
className="link p-1 rounded-1 "
bg={"#fff"}
_hover={{ backgroundColor: "#fff !important" }}
onClick={onOpen}
2024-07-09 12:25:52 +05:30
ref={btnRef}
>
<HiDotsVertical className="rubix-text-dark fs-6" />
</MenuButton>
2024-07-09 19:05:08 +05:30
<MenuList fontSize={"sm"}>
2024-07-15 12:27:23 +05:30
<MenuItem
_hover={{
bg: "#fff",
}}
as={"span"}
fontWeight={600}
className="border-bottom"
>
2024-07-09 19:05:08 +05:30
Tansaction
</MenuItem>
2024-08-07 20:18:36 +05:30
2024-08-22 12:10:07 +05:30
{filteredMenu?.map(({ id, title, onClickFunction }) => (
<MenuItem
key={id}
onClick={onClickFunction}
className="border-bottom"
>
{title}
</MenuItem>
))}
2024-07-09 13:05:58 +05:30
</MenuList>
</Menu>
{/* Modals */}
<AmountInvested isOpen={isInvestmentOpen} onClose={onInvestmentClose} />
<FeesExpenses isOpen={isFeesOpen} onClose={onFeesClose} />
2024-08-30 16:09:07 +05:30
<Exit isOpen={isExitOpen} onClose={onExitClose} />
2024-07-15 12:27:23 +05:30
<Cancle isOpen={isCancleOpen} onClose={onCancleClose} />
<DistributionSponsor
isOpen={isDistSponsorOpen}
onClose={onDistSponsorClose}
/>
<DistributionInvestor
isOpen={isDistInvestorOpen}
onClose={onDistInvestorClose}
/>
2024-08-22 12:10:07 +05:30
<UpdateIONav isOpen={isUpdateNavOpen} onClose={onUpdateNavClose} />
<UpdateIOStatus
2024-08-12 12:22:01 +05:30
status={IODetails?.nextStatus}
isOpen={isUpdateStatusOpen}
onClose={onUpdateStatusClose}
/>
</Box>
2024-08-22 12:10:07 +05:30
</Box>
) : (
2024-08-13 13:46:41 +05:30
<Box
display={"flex"}
alignItems={"center"}
justifyContent={"center"}
rounded={"md"}
height={100}
bg={"#fff"}
// bgGradient='linear(to-r, #caf5d8, #f5e8ca)'
// bgGradient='linear(to-r, #caf5d8, #d4a5a5)'
// bgGradient='linear(to-r, #caf5d8, #d4a5a5)'
// bgGradient='linear(to-r, #caf5d8, #b3e5fc)'
// bgGradient='linear(to-r, #ffd54f, #caf5d8)'
// bgGradient='linear(to-r, #caf5d8, #a8e6cf)'
boxShadow={"md"}
2024-08-22 12:10:07 +05:30
>
{" "}
<Loader01 />
</Box>
2024-07-05 15:33:08 +05:30
);
};
export default ViewIOdataHeader;