[update] - role check
This commit is contained in:
@@ -237,4 +237,7 @@ export const decryptString = (ciphertext) => {
|
||||
|
||||
export const SUPER_ADMIN_ID = Number(import.meta.env.VITE_SUPER_ADMIN_ID) || 1
|
||||
export const MAKER_ID = import.meta.env.VITE_MAKER_ID || 1
|
||||
export const CHECKER_ID = import.meta.env.VITE_CHECKER_ID || 2
|
||||
export const CHECKER_ID = import.meta.env.VITE_CHECKER_ID || 2
|
||||
|
||||
export const isMaker = () => decryptString(localStorage?.getItem("role")) === import.meta.env.VITE_MAKER;
|
||||
export const isChecker = () => decryptString(localStorage?.getItem("role")) === import.meta.env.VITE_CHECKER;
|
||||
|
||||
@@ -157,7 +157,9 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
await logout();
|
||||
localStorage.clear();
|
||||
navigate("/login");
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
// // Function to get the title based on the route
|
||||
|
||||
@@ -1,57 +1,45 @@
|
||||
import {
|
||||
Button,
|
||||
Divider,
|
||||
Badge,
|
||||
Box,
|
||||
HStack,
|
||||
Icon,
|
||||
Image,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuItem,
|
||||
MenuList,
|
||||
Modal,
|
||||
ModalBody,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalOverlay,
|
||||
Portal,
|
||||
Text,
|
||||
useDisclosure,
|
||||
MenuItemOption,
|
||||
MenuGroup,
|
||||
MenuOptionGroup,
|
||||
MenuDivider,
|
||||
Badge,
|
||||
Box,
|
||||
Icon,
|
||||
HStack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import header from "../../../assets/IOheader.png";
|
||||
import { useContext, useRef } from "react";
|
||||
import { GrGallery } from "react-icons/gr";
|
||||
import { HiDotsVertical } from "react-icons/hi";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { useParams } from "react-router-dom";
|
||||
import Loader01 from "../../../Components/Loaders/Loader01";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
import {
|
||||
decryptString,
|
||||
encryptString,
|
||||
isMaker,
|
||||
} from "../../../Constants/Constants";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import { useUpdateTransactionMutation } from "../../../Services/io.service";
|
||||
import AmountInvested from "./HeaderModal/AmountInvested";
|
||||
import FeesExpenses from "./HeaderModal/FeesExpenses";
|
||||
import DistributionSponsor from "./HeaderModal/DistributionSponsor";
|
||||
import Cancle from "./HeaderModal/Cancle";
|
||||
import DistributionInvestor from "./HeaderModal/DistributionInvestor";
|
||||
import DistributionSponsor from "./HeaderModal/DistributionSponsor";
|
||||
import Exit from "./HeaderModal/Exit";
|
||||
import FeesExpenses from "./HeaderModal/FeesExpenses";
|
||||
import UpdateIONav from "./HeaderModal/UpdateIONav";
|
||||
import UpdateIOStatus from "./HeaderModal/UpdateIOStatus";
|
||||
import { useContext, useRef } from "react";
|
||||
import GlobalStateContext from "../../../Contexts/GlobalStateContext";
|
||||
import Exit from "./HeaderModal/Exit";
|
||||
import Cancle from "./HeaderModal/Cancle";
|
||||
import { AddIcon } from "@chakra-ui/icons";
|
||||
import { GrGallery } from "react-icons/gr";
|
||||
import Loader01 from "../../../Components/Loaders/Loader01";
|
||||
import { useUpdateTransactionMutation } from "../../../Services/io.service";
|
||||
import ToastBox from "../../../Components/ToastBox";
|
||||
import { encryptString } from "../../../Constants/Constants";
|
||||
// import { formatCurrency } from "../../../Components/CurrencyInput";
|
||||
// import { removeTrailingZeros } from "../../../Constants/Constants";
|
||||
|
||||
const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
const params = useParams()
|
||||
const toast = useToast();
|
||||
const id = params?.id
|
||||
const params = useParams();
|
||||
const toast = useToast();
|
||||
const id = params?.id;
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const btnRef = useRef();
|
||||
const { IODetails, isIOloading } = useContext(GlobalStateContext);
|
||||
@@ -113,89 +101,82 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
IODetails?.artifactsImage?.[0]?.artifactPathName
|
||||
);
|
||||
|
||||
const [updateTransaction] = useUpdateTransactionMutation()
|
||||
const [updateTransaction] = useUpdateTransactionMutation();
|
||||
|
||||
const handleDistributionInvestors = async () =>{
|
||||
|
||||
const handleDistributionInvestors = async () => {
|
||||
try {
|
||||
const res = await updateTransaction(id)
|
||||
|
||||
if (res?.data) {
|
||||
const res = await updateTransaction(id);
|
||||
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onDistInvestorOpen()
|
||||
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
onDistInvestorOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleExit = async () =>{
|
||||
|
||||
const handleExit = async () => {
|
||||
try {
|
||||
const res = await updateTransaction(id)
|
||||
|
||||
if (res?.data) {
|
||||
const res = await updateTransaction(id);
|
||||
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onExitOpen()
|
||||
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
onExitOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvestment = async () =>{
|
||||
|
||||
const handleInvestment = async () => {
|
||||
try {
|
||||
const res = await updateTransaction(id)
|
||||
|
||||
if (res?.data) {
|
||||
const res = await updateTransaction(id);
|
||||
|
||||
if (res?.data) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox status={"success"} message={res?.data?.message} />
|
||||
// ),
|
||||
// });
|
||||
// setIsLoading(false);
|
||||
onInvestmentOpen()
|
||||
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
onInvestmentOpen();
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox status={"error"} message={res?.error?.data?.message} />
|
||||
),
|
||||
});
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const menu = [
|
||||
{
|
||||
@@ -217,7 +198,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
id: 6,
|
||||
title: "Distribution To Investors",
|
||||
onClickFunction: handleDistributionInvestors,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
title: "Update IO NAV",
|
||||
@@ -251,8 +232,8 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
apiTransactionTitles?.includes(item.id)
|
||||
);
|
||||
|
||||
|
||||
const balanceAmount = IODetails?.goalAmount - IODetails?.totalAmtInvestmentInUSD
|
||||
const balanceAmount =
|
||||
IODetails?.goalAmount - IODetails?.totalAmtInvestmentInUSD;
|
||||
|
||||
return IODetails?.investmentNameEnglish ? (
|
||||
<Box
|
||||
@@ -318,7 +299,6 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Box>
|
||||
|
||||
<Box>
|
||||
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
@@ -336,7 +316,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
fontSize={"xs"}
|
||||
@@ -353,7 +333,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Box display={"flex"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
fontSize={"xs"}
|
||||
@@ -364,18 +344,13 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
IO ID :-
|
||||
</Text>
|
||||
<Text as={"span"} fontSize={"xs"} fontWeight={"500"}>
|
||||
{IODetails?.io_id
|
||||
? IODetails?.io_id
|
||||
: "---"}
|
||||
{IODetails?.io_id ? IODetails?.io_id : "---"}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
</Box>
|
||||
|
||||
</HStack>
|
||||
|
||||
<Box gap={8} me={12} w={"220px"}>
|
||||
|
||||
<Box gap={8} me={12} w={"220px"}>
|
||||
<Box display={"flex"} justifyContent={"space-between"} gap={2} pb={1}>
|
||||
<Text
|
||||
as={"span"}
|
||||
@@ -405,10 +380,13 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
</Text>
|
||||
<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,
|
||||
})}
|
||||
{parseFloat(IODetails?.totalAmtInvestmentInUSD || 0).toLocaleString(
|
||||
undefined,
|
||||
{
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
@@ -533,39 +511,41 @@ const ViewIOdataHeader = ({ data, isLoading }) => {
|
||||
alignItems={"start"}
|
||||
height={"95px"}
|
||||
>
|
||||
{localStorage?.getItem("role") === encryptString(import.meta.env.VITE_VITE_MAKER) && <Menu>
|
||||
<MenuButton
|
||||
className="link p-1 rounded-1 "
|
||||
bg={"#fff"}
|
||||
_hover={{ backgroundColor: "#fff !important" }}
|
||||
onClick={onOpen}
|
||||
ref={btnRef}
|
||||
>
|
||||
<HiDotsVertical className="rubix-text-dark fs-6" />
|
||||
</MenuButton>
|
||||
<MenuList fontSize={"sm"}>
|
||||
<MenuItem
|
||||
_hover={{
|
||||
bg: "#fff",
|
||||
}}
|
||||
as={"span"}
|
||||
fontWeight={600}
|
||||
className="border-bottom"
|
||||
{isMaker() && (
|
||||
<Menu>
|
||||
<MenuButton
|
||||
className="link p-1 rounded-1 "
|
||||
bg={"#fff"}
|
||||
_hover={{ backgroundColor: "#fff !important" }}
|
||||
onClick={onOpen}
|
||||
ref={btnRef}
|
||||
>
|
||||
Tansaction
|
||||
</MenuItem>
|
||||
|
||||
{filteredMenu?.map(({ id, title, onClickFunction }) => (
|
||||
<HiDotsVertical className="rubix-text-dark fs-6" />
|
||||
</MenuButton>
|
||||
<MenuList fontSize={"sm"}>
|
||||
<MenuItem
|
||||
key={id}
|
||||
onClick={onClickFunction}
|
||||
_hover={{
|
||||
bg: "#fff",
|
||||
}}
|
||||
as={"span"}
|
||||
fontWeight={600}
|
||||
className="border-bottom"
|
||||
>
|
||||
{title}
|
||||
Tansaction
|
||||
</MenuItem>
|
||||
))}
|
||||
</MenuList>
|
||||
</Menu>}
|
||||
|
||||
{filteredMenu?.map(({ id, title, onClickFunction }) => (
|
||||
<MenuItem
|
||||
key={id}
|
||||
onClick={onClickFunction}
|
||||
className="border-bottom"
|
||||
>
|
||||
{title}
|
||||
</MenuItem>
|
||||
))}
|
||||
</MenuList>
|
||||
</Menu>
|
||||
)}
|
||||
|
||||
{/* Modals */}
|
||||
<AmountInvested isOpen={isInvestmentOpen} onClose={onInvestmentClose} />
|
||||
|
||||
Reference in New Issue
Block a user