From 84298ff453f998eefe597d95ccb1ef2913b0016b Mon Sep 17 00:00:00 2001 From: Swapnil Bendal <84583651+Swapnil155@users.noreply.github.com> Date: Tue, 24 Dec 2024 16:59:01 +0530 Subject: [PATCH 1/2] [update] - IO Transaction bug fix --- .../CreateIO/IOTransaction/Pending.jsx | 32 +++---- .../ViewDistributionInvestor.jsx | 89 +++++++++---------- 2 files changed, 53 insertions(+), 68 deletions(-) diff --git a/src/Pages/IO_Management/CreateIO/IOTransaction/Pending.jsx b/src/Pages/IO_Management/CreateIO/IOTransaction/Pending.jsx index 2653a94..9bfffed 100644 --- a/src/Pages/IO_Management/CreateIO/IOTransaction/Pending.jsx +++ b/src/Pages/IO_Management/CreateIO/IOTransaction/Pending.jsx @@ -1,33 +1,26 @@ +import { ViewIcon } from "@chakra-ui/icons"; import { - Avatar, Badge, Box, Button, HStack, Input, - Table, - Tag, - Tbody, Text, - Th, - Tooltip, - Tr, useDisclosure, useToast, } from "@chakra-ui/react"; import React, { useContext, useEffect, useRef, useState } from "react"; -import { OPACITY_ON_LOAD } from "../../../../Layout/animations"; -import NormalTable from "../../../../Components/DataTable/NormalTable"; -import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; import CustomAlertDialog from "../../../../Components/CustomAlertDialog"; -import { CheckIcon, CloseIcon, ViewIcon } from "@chakra-ui/icons"; +import NormalTable from "../../../../Components/DataTable/NormalTable"; +import { isMaker } from "../../../../Constants/Constants"; +import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; +import { OPACITY_ON_LOAD } from "../../../../Layout/animations"; import RequestApproveModal from "./RequestApproveModal"; import RequestRejectModal from "./RequestRejectModal"; import ViewAmountInvested from "./ViewAmountInvested"; +import ViewCancel from "./ViewCancel"; import ViewDistributionInvestor from "./ViewDistributionInvestor"; import ViewExit from "./ViewExit"; -import ViewCancel from "./ViewCancel"; -import { encryptString, isMaker } from "../../../../Constants/Constants"; const formatDate = (date) => new Date(date).toLocaleDateString(); @@ -43,6 +36,7 @@ const Pending = () => { const [actionId, setActionId] = useState(false); const [mouseEntered, setMouseEntered] = useState(false); const [mouseEnteredId, setMouseEnteredId] = useState(""); + const [distributedAmt, setDistributedAmt] = useState(); const { isOpen: isConfirmOpen, @@ -93,11 +87,6 @@ const Pending = () => { }); }; - console.log( - "==============panding", - IODetails?.ioTransactionRecords?.Pending - ); - // Table filter // const filteredData = IODetails?.ioTransactionRecords?.Pending?.filter((item) => { // // Filter by name (case insensitive) @@ -195,6 +184,7 @@ const Pending = () => { onInvestmentOpen(); } else if (item?.transactionType === "Distribution To Investor") { onDistInvestorOpen(); + setDistributedAmt(item?.transactionAmount); } else if (item?.transactionType === "Exit") { onExitOpen(); } else if (item?.transactionType === "Cancel") { @@ -203,10 +193,7 @@ const Pending = () => { }} > {isMaker() ? : null}{" "} - {localStorage?.getItem("role") === - encryptString(import.meta.env.VITE_VITE_MAKER) - ? "View" - : "Approve / Reject"} + {isMaker() ? "View" : "Approve / Reject"} ), @@ -276,6 +263,7 @@ const Pending = () => { isOpen={isDistInvestorOpen} onClose={onDistInvestorClose} id={actionId} + amount={distributedAmt} /> diff --git a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewDistributionInvestor.jsx b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewDistributionInvestor.jsx index dddd11e..fc1c594 100644 --- a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewDistributionInvestor.jsx +++ b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewDistributionInvestor.jsx @@ -23,9 +23,9 @@ import { yupResolver } from "@hookform/resolvers/yup"; import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; import ApproveDistrubationModal from "./ApproveDistrubationModal"; import RequestRejectModal from "./RequestRejectModal"; -import { encryptString } from "../../../../Constants/Constants"; +import { encryptString, isMaker } from "../../../../Constants/Constants"; -const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => { +const ViewDistributionInvestor = ({ isOpen, onClose, id: exitId, amount }) => { const params = useParams(); const toast = useToast(); const id = params?.id; @@ -72,19 +72,15 @@ const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => { }); useEffect(() => { - console.log("hiit useEffectc"); - // handleCalculate(id, { - // amount: IODetails?.ioMVNAV, - // }); if (id && IODetails) { handleCalculate(id, { - amount: IODetails?.ioMVNAV, + amount: Math.abs(amount), }); - } + } reset({ - amount: IODetails?.ioMVNAV, + amount: amount, }); - }, [IODetails, id]); + }, [IODetails, id, amount]); const handleCalculate = async (id, data) => { try { @@ -201,7 +197,6 @@ const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => { setIsFinalCalculateLoading(false); setIsCalcualtedData(false); }; - return ( @@ -219,41 +214,43 @@ const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => { /> {/* ...(localStorage?.getItem("role") !== "Maker" ? ["Status"] : []), */} - {localStorage?.getItem("role") !== encryptString(import.meta.env.VITE_VITE_MAKER) && - - - - - } + {!isMaker() && ( + + + + + + + )} Date: Tue, 24 Dec 2024 18:08:15 +0530 Subject: [PATCH 2/2] [fixed] - on IO Transaction --- .../IOTransaction/ViewAmountInvested.jsx | 75 +- .../CreateIO/IOTransaction/ViewCancel.jsx | 669 +++++++++--------- .../CreateIO/IOTransaction/ViewExit.jsx | 634 ++++++++--------- 3 files changed, 691 insertions(+), 687 deletions(-) diff --git a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewAmountInvested.jsx b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewAmountInvested.jsx index 6c8cdbc..f23cef4 100644 --- a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewAmountInvested.jsx +++ b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewAmountInvested.jsx @@ -27,7 +27,7 @@ import CurrencyInput from "../../../../Components/CurrencyInput"; import RequestRejectModal from "./RequestRejectModal"; import ApproveInvestedModal from "./ApproveInvestedModal"; import { formatDate } from "../../../Master/Sponser/Sponsers"; -import { encryptString } from "../../../../Constants/Constants"; +import { encryptString, isMaker } from "../../../../Constants/Constants"; // Validation schema const validationSchema = yup.object().shape({ @@ -117,7 +117,6 @@ const ViewAmountInvested = ({ isOpen, onClose, id: investorId }) => { }; // const formatDate = (date) => new Date(date).toLocaleDateString(); - const handleAmountChange = (e) => { // e might be an object or just a value, handle both cases @@ -237,41 +236,43 @@ const ViewAmountInvested = ({ isOpen, onClose, id: investorId }) => { /> - {localStorage?.getItem("role") !== encryptString(import.meta.env.VITE_VITE_MAKER) && - - - - - } + {!isMaker() && ( + + + + + + + )} diff --git a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewCancel.jsx b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewCancel.jsx index a829be5..4cacaa3 100644 --- a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewCancel.jsx +++ b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewCancel.jsx @@ -1,128 +1,128 @@ import { - Badge, - Box, - Button, - HStack, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, - Table, - Tbody, - Text, - Th, - Tr, - useDisclosure, - useToast, - } from "@chakra-ui/react"; - import NormalData from "../../../../Components/DataTable/NormalTable"; - import { useContext, useState } from "react"; - import { - useExitIOTransactionMutation, - useGetDistributedToInvestorMutation, - useGetDistributionInvestorMutation, - useGetIOByIdQuery, - } from "../../../../Services/io.service"; - import { useParams } from "react-router-dom"; - import { useEffect } from "react"; - import { useForm } from "react-hook-form"; - import * as yup from "yup"; - import { yupResolver } from "@hookform/resolvers/yup"; - import ToastBox from "../../../../Components/ToastBox"; - import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; + Badge, + Box, + Button, + HStack, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Table, + Tbody, + Text, + Th, + Tr, + useDisclosure, + useToast, +} from "@chakra-ui/react"; +import NormalData from "../../../../Components/DataTable/NormalTable"; +import { useContext, useState } from "react"; +import { + useExitIOTransactionMutation, + useGetDistributedToInvestorMutation, + useGetDistributionInvestorMutation, + useGetIOByIdQuery, +} from "../../../../Services/io.service"; +import { useParams } from "react-router-dom"; +import { useEffect } from "react"; +import { useForm } from "react-hook-form"; +import * as yup from "yup"; +import { yupResolver } from "@hookform/resolvers/yup"; +import ToastBox from "../../../../Components/ToastBox"; +import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; import ApprovedCancelTransaction from "./ApprovedCancelTransaction"; import RequestRejectModal from "./RequestRejectModal"; -import { encryptString } from "../../../../Constants/Constants"; - - const ViewCancel = ({ isOpen, onClose,id:cancleId }) => { - const params = useParams(); - const toast = useToast(); - const id = params?.id; - const [isCalculateLoading, setIsCalculateLoading] = useState(false); - const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false); - const [calcualtedData, setCalculatedDate] = useState(null); - const [isCalcualtedData, setIsCalcualtedData] = useState(false); - const { investors, setInvestors, slideFromRight, IODetails } = +import { encryptString, isMaker } from "../../../../Constants/Constants"; + +const ViewCancel = ({ isOpen, onClose, id: cancleId }) => { + const params = useParams(); + const toast = useToast(); + const id = params?.id; + const [isCalculateLoading, setIsCalculateLoading] = useState(false); + const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false); + const [calcualtedData, setCalculatedDate] = useState(null); + const [isCalcualtedData, setIsCalcualtedData] = useState(false); + const { investors, setInvestors, slideFromRight, IODetails } = useContext(GlobalStateContext); - const [actionId, setActionId] = useState(false); + const [actionId, setActionId] = useState(false); - const { - isOpen: isConfirmOpen, - onOpen: onConfirmOpen, - onClose: onConfirmClose, - } = useDisclosure(); - const { - isOpen: isRejectOpen, - onOpen: onRejectOpen, - onClose: onRejectClose, - } = useDisclosure(); - - const investorExit = yup.object().shape({ - amount: yup - .string() - .required("Amount is required") - .test( - "max", - `Distribution amount should not be greater than IO cash amount ${IODetails?.ioCash}`, - function (value) { - const { ioCash } = IODetails || {}; // Safely get ioCash - if (value && ioCash) { - return parseFloat(value) <= parseFloat(ioCash); // Ensure both are compared as numbers - } - return true; // If ioCash is not available, skip validation + const { + isOpen: isConfirmOpen, + onOpen: onConfirmOpen, + onClose: onConfirmClose, + } = useDisclosure(); + const { + isOpen: isRejectOpen, + onOpen: onRejectOpen, + onClose: onRejectClose, + } = useDisclosure(); + + const investorExit = yup.object().shape({ + amount: yup + .string() + .required("Amount is required") + .test( + "max", + `Distribution amount should not be greater than IO cash amount ${IODetails?.ioCash}`, + function (value) { + const { ioCash } = IODetails || {}; // Safely get ioCash + if (value && ioCash) { + return parseFloat(value) <= parseFloat(ioCash); // Ensure both are compared as numbers } - ), - }); - - const { - control, - handleSubmit, - formState: { errors }, - reset, - } = useForm({ - resolver: yupResolver(investorExit), - }); - - useEffect(() => { - console.log("hiit useEffectc"); - if (id && IODetails) { - handleCalculate(id, { - amount: IODetails?.ioMVNAV, - }); - } - reset({ + return true; // If ioCash is not available, skip validation + } + ), + }); + + const { + control, + handleSubmit, + formState: { errors }, + reset, + } = useForm({ + resolver: yupResolver(investorExit), + }); + + useEffect(() => { + console.log("hiit useEffectc"); + if (id && IODetails) { + handleCalculate(id, { amount: IODetails?.ioMVNAV, }); - }, [IODetails, id]); - - const handleCalculate = async (id, data) => { - try { - const res = await getDistributionInvestment({ id, data }); - console.log(res?.data?.data); - - if (res?.error?.status === 401) { - setIsCalculateLoading(false); - setIsCalcualtedData(false); - } else if (res?.data?.statusCode === 200) { - setCalculatedDate(res?.data?.data); - setIsCalculateLoading(false); - setIsCalcualtedData(true); - } - } catch (error) {} - }; - - const [getDistributionInvestment] = useGetDistributionInvestorMutation(); - - const investor = yup.object().shape({ - amount: yup.string().required("Amount is required"), + } + reset({ + amount: IODetails?.ioMVNAV, }); - - // ====================================================[Table Setup]================================================================ - const tableHeadRow = [ + }, [IODetails, id]); + + const handleCalculate = async (id, data) => { + try { + const res = await getDistributionInvestment({ id, data }); + console.log(res?.data?.data); + + if (res?.error?.status === 401) { + setIsCalculateLoading(false); + setIsCalcualtedData(false); + } else if (res?.data?.statusCode === 200) { + setCalculatedDate(res?.data?.data); + setIsCalculateLoading(false); + setIsCalcualtedData(true); + } + } catch (error) {} + }; + + const [getDistributionInvestment] = useGetDistributionInvestorMutation(); + + const investor = yup.object().shape({ + amount: yup.string().required("Amount is required"), + }); + + // ====================================================[Table Setup]================================================================ + const tableHeadRow = [ "Client ID", "First name", "Last name", @@ -134,221 +134,223 @@ import { encryptString } from "../../../../Constants/Constants"; "Distribution Percent", "Total Return", "Total return on Investment", - ]; - - const extractedArray = IODetails?.investors?.map((item, index) => ({ - id: item?.id, - "Client ID": ( - - {item?.clientReference_id} - - ), - "First name": ( - - {item.firstName} - - ), - "Last name": ( - - {item.lastName} - - ), - "Investment amount": ( - - - $ - - {/* {`$${formatCurrency(item.InvestedAmount_USD)}`} */} - {`${parseFloat(item.InvestedAmount_USD || 0).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })}`} - - ), - Percentage: ( - - {item.Investor_Holidings} % - - ), - "Market Value": ( - - - $ - - {`${parseFloat(item.Market_Value || 0).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })}`} - - ), - "Return on Investment": ( - - {item.Return_On_Investment || 0} % - - ), - Distribution: ( - - - $ - - {/* {`$${item.Distribution_Amt}`} */} - {`${parseFloat(item.Distribution_Amt || 0).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })}`} - - ), - "Distribution Percent": ( - - {/* {`$${item.Distribution_Amt}`} */} - {`${parseFloat(item.Distribution_Per || 0).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })} %`} - - ), - "Total Return": ( - - - $ - - {/* {`$${formatCurrency(item.Total_Return) || 0}`} */} - {`${parseFloat(item.Total_Return || 0).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })}`} - - ), - "Total return on Investment": ( - - {item.Total_Return_On_Investment || 0} % - - ), - })); - - const handleClose = () => { - onClose(); - setIsFinalCalculateLoading(false); - setIsCalcualtedData(false); - }; - - return ( - - - - Cancel Transaction - - - - - {localStorage?.getItem("role") !== encryptString(import.meta.env.VITE_VITE_MAKER) && + ]; + + const extractedArray = IODetails?.investors?.map((item, index) => ({ + id: item?.id, + "Client ID": ( + + {item?.clientReference_id} + + ), + "First name": ( + + {item.firstName} + + ), + "Last name": ( + + {item.lastName} + + ), + "Investment amount": ( + + + $ + + {/* {`$${formatCurrency(item.InvestedAmount_USD)}`} */} + {`${parseFloat(item.InvestedAmount_USD || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} + + ), + Percentage: ( + + {item.Investor_Holidings} % + + ), + "Market Value": ( + + + $ + + {`${parseFloat(item.Market_Value || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} + + ), + "Return on Investment": ( + + {item.Return_On_Investment || 0} % + + ), + Distribution: ( + + + $ + + {/* {`$${item.Distribution_Amt}`} */} + {`${parseFloat(item.Distribution_Amt || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} + + ), + "Distribution Percent": ( + + {/* {`$${item.Distribution_Amt}`} */} + {`${parseFloat(item.Distribution_Per || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} %`} + + ), + "Total Return": ( + + + $ + + {/* {`$${formatCurrency(item.Total_Return) || 0}`} */} + {`${parseFloat(item.Total_Return || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} + + ), + "Total return on Investment": ( + + {item.Total_Return_On_Investment || 0} % + + ), + })); + + const handleClose = () => { + onClose(); + setIsFinalCalculateLoading(false); + setIsCalcualtedData(false); + }; + + return ( + + + + Cancel Transaction + + + + + {!isMaker() && ( + - - + + - } - - + )} + + - - ); - }; - - export default ViewCancel; - \ No newline at end of file + + ); +}; + +export default ViewCancel; diff --git a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewExit.jsx b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewExit.jsx index 4b217bf..b550a28 100644 --- a/src/Pages/IO_Management/CreateIO/IOTransaction/ViewExit.jsx +++ b/src/Pages/IO_Management/CreateIO/IOTransaction/ViewExit.jsx @@ -1,330 +1,332 @@ import { - Alert, - AlertIcon, - Box, - Button, - FormControl, - FormErrorMessage, - FormLabel, - HStack, - Input, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, - Switch, - Table, - Tbody, - Text, - Textarea, - Th, - Tr, - useDisclosure, - useToast, - } from "@chakra-ui/react"; - import NormalData from "../../../../Components/DataTable/NormalTable"; - import { useContext, useState } from "react"; - import { AddIcon } from "@chakra-ui/icons"; - import { - useExitIOTransactionMutation, - useGetDistributedToInvestorMutation, - useGetDistributionInvestorMutation, - useUpdateExitToInvestorMutation, - } from "../../../../Services/io.service"; - import { useParams } from "react-router-dom"; - import { useEffect } from "react"; - import { Controller, useForm } from "react-hook-form"; - import * as yup from "yup"; - import { yupResolver } from "@hookform/resolvers/yup"; - import ToastBox from "../../../../Components/ToastBox"; - import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; + Alert, + AlertIcon, + Box, + Button, + FormControl, + FormErrorMessage, + FormLabel, + HStack, + Input, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Switch, + Table, + Tbody, + Text, + Textarea, + Th, + Tr, + useDisclosure, + useToast, +} from "@chakra-ui/react"; +import NormalData from "../../../../Components/DataTable/NormalTable"; +import { useContext, useState } from "react"; +import { AddIcon } from "@chakra-ui/icons"; +import { + useExitIOTransactionMutation, + useGetDistributedToInvestorMutation, + useGetDistributionInvestorMutation, + useUpdateExitToInvestorMutation, +} from "../../../../Services/io.service"; +import { useParams } from "react-router-dom"; +import { useEffect } from "react"; +import { Controller, useForm } from "react-hook-form"; +import * as yup from "yup"; +import { yupResolver } from "@hookform/resolvers/yup"; +import ToastBox from "../../../../Components/ToastBox"; +import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; import ApprovedExit from "./ApprovedExit"; import RequestRejectModal from "./RequestRejectModal"; -import { encryptString } from "../../../../Constants/Constants"; - - const ViewExit = ({ isOpen, onClose ,id:investerId}) => { - const params = useParams(); - const toast = useToast(); - const id = params?.id; - const [isCalculateLoading, setIsCalculateLoading] = useState(false); - const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false); - const [calcualtedData, setCalculatedDate] = useState(null); - const [isCalcualtedData, setIsCalcualtedData] = useState(false); - const { IODetails } = useContext(GlobalStateContext); - const [actionId, setActionId] = useState(false); +import { encryptString, isMaker } from "../../../../Constants/Constants"; - const { - isOpen: isConfirmOpen, - onOpen: onConfirmOpen, - onClose: onConfirmClose, - } = useDisclosure(); - const { - isOpen: isRejectOpen, - onOpen: onRejectOpen, - onClose: onRejectClose, - } = useDisclosure(); - - - const { - control, - handleSubmit, - formState: { errors }, - reset, - } = useForm({ - resolver: yupResolver(), - }); - - useEffect(() => { - console.log("hiit useEffectc"); - if (id && IODetails) { +const ViewExit = ({ isOpen, onClose, id: investerId }) => { + const params = useParams(); + const toast = useToast(); + const id = params?.id; + const [isCalculateLoading, setIsCalculateLoading] = useState(false); + const [isFinalCalculateLoading, setIsFinalCalculateLoading] = useState(false); + const [calcualtedData, setCalculatedDate] = useState(null); + const [isCalcualtedData, setIsCalcualtedData] = useState(false); + const { IODetails } = useContext(GlobalStateContext); + const [actionId, setActionId] = useState(false); + + const { + isOpen: isConfirmOpen, + onOpen: onConfirmOpen, + onClose: onConfirmClose, + } = useDisclosure(); + const { + isOpen: isRejectOpen, + onOpen: onRejectOpen, + onClose: onRejectClose, + } = useDisclosure(); + + const { + control, + handleSubmit, + formState: { errors }, + reset, + } = useForm({ + resolver: yupResolver(), + }); + + useEffect(() => { + console.log("hiit useEffectc"); + if (id && IODetails) { handleCalculate(id, { amount: IODetails?.ioMVNAV, }); - } - reset({ - amount: IODetails?.ioMVNAV, - }); - }, [IODetails, id]); - - const handleCalculate = async (id, data) => { - try { - - const res = await getDistributionInvestment({ id, data }); - console.log(res?.data?.data); - - if (res?.error?.status === 401) { - setIsCalculateLoading(false); - setIsCalcualtedData(false); - } else if (res?.data?.statusCode === 200) { - setCalculatedDate(res?.data?.data); - setIsCalculateLoading(false); - setIsCalcualtedData(true); - } - } catch (error) {} - }; - - const [getDistributionInvestment] = useGetDistributionInvestorMutation(); - - const investor = yup.object().shape({ - amount: yup.string().required("Amount is required"), + } + reset({ + amount: IODetails?.ioMVNAV, }); - - // ====================================================[Table Setup]================================================================ - const tableHeadRow = [ - "Sr No.", - "Client Id", - "First name", - "Last Name", - "Amount", - "Holding (%)", - "Exit Amt($)", - ]; + }, [IODetails, id]); - - - const extractedArray = calcualtedData?.data?.map((item, index) => ({ - id: item?.id, - "Sr No.": ( - - - {index + 1} - - - ), - "Client Id": ( - - - {item?.clientId} - - - ), - "First name": ( - - - {item?.firstName} - - - ), - "Last Name": ( - - - {item?.lastName} - - - ), - Amount: ( - - - {item?.amount?.toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })} - - - ), - "Holding (%)": ( - - - {item?.investor_holidings?.toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })}% - - - ), - "Exit Amt($)": ( - - - {item?.distribution_amt?.toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })} - - - ), - })); - - const onSubmit = async (data) => { - setIsCalculateLoading(true); - - try { - const res = await getDistributionInvestment({ id, data }); - console.log(res?.data?.data); - - if (res?.error?.status === 401) { - toast({ - render: () => ( - - ), - }); - setIsCalculateLoading(false); - setIsCalcualtedData(false); - } else if (res?.data?.statusCode === 200) { - setCalculatedDate(res?.data?.data); - toast({ - render: () => , - }); - setIsCalculateLoading(false); - setIsCalcualtedData(true); - } - } catch (error) {} - }; - - const handleClose = () => { - onClose(); - setIsFinalCalculateLoading(false); - setIsCalcualtedData(false); - }; - - console.log(id); - + const handleCalculate = async (id, data) => { + try { + const res = await getDistributionInvestment({ id, data }); + console.log(res?.data?.data); - return ( - - - - Exit Transaction - - - {/* + if (res?.error?.status === 401) { + setIsCalculateLoading(false); + setIsCalcualtedData(false); + } else if (res?.data?.statusCode === 200) { + setCalculatedDate(res?.data?.data); + setIsCalculateLoading(false); + setIsCalcualtedData(true); + } + } catch (error) {} + }; + + const [getDistributionInvestment] = useGetDistributionInvestorMutation(); + + const investor = yup.object().shape({ + amount: yup.string().required("Amount is required"), + }); + + // ====================================================[Table Setup]================================================================ + const tableHeadRow = [ + "Sr No.", + "Client Id", + "First name", + "Last Name", + "Amount", + "Holding (%)", + "Exit Amt($)", + ]; + + const extractedArray = calcualtedData?.data?.map((item, index) => ({ + id: item?.id, + "Sr No.": ( + + + {index + 1} + + + ), + "Client Id": ( + + + {item?.clientId} + + + ), + "First name": ( + + + {item?.firstName} + + + ), + "Last Name": ( + + + {item?.lastName} + + + ), + Amount: ( + + + {item?.amount?.toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + + + ), + "Holding (%)": ( + + + {item?.investor_holidings?.toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + % + + + ), + "Exit Amt($)": ( + + + {item?.distribution_amt?.toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + + + ), + })); + + const onSubmit = async (data) => { + setIsCalculateLoading(true); + + try { + const res = await getDistributionInvestment({ id, data }); + console.log(res?.data?.data); + + if (res?.error?.status === 401) { + toast({ + render: () => ( + + ), + }); + setIsCalculateLoading(false); + setIsCalcualtedData(false); + } else if (res?.data?.statusCode === 200) { + setCalculatedDate(res?.data?.data); + toast({ + render: () => , + }); + setIsCalculateLoading(false); + setIsCalcualtedData(true); + } + } catch (error) {} + }; + + const handleClose = () => { + onClose(); + setIsFinalCalculateLoading(false); + setIsCalcualtedData(false); + }; + + console.log(id); + + return ( + + + + Exit Transaction + + + {/* Amount to Distribute */} - - {/* */} - {/* */} - - Exit Amount : - - - ${" "} - {parseFloat(IODetails?.ioMVNAV || 0).toLocaleString(undefined, { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })} - - - {/* */} - - - {/* {calcualtedData && ( */} - } - // isLoading={isLoading} - /> - {/* ) } */} - - {localStorage?.getItem("role") !== encryptString(import.meta.env.VITE_VITE_MAKER) && + + {/* */} + {/* */} + + Exit Amount : + + + ${" "} + {parseFloat(IODetails?.ioMVNAV || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + + + {/* */} + + + {/* {calcualtedData && ( */} + } + // isLoading={isLoading} + /> + {/* ) } */} + + {!isMaker() && ( + - - + + - } - - - - - ); - }; - - export default ViewExit; - \ No newline at end of file + + )} + + + + + ); +}; + +export default ViewExit;