diff --git a/src/Components/MobileView.jsx b/src/Components/MobileView.jsx index 4fa04e2..ca022a6 100644 --- a/src/Components/MobileView.jsx +++ b/src/Components/MobileView.jsx @@ -27,7 +27,7 @@ import { BiWifi } from "react-icons/bi"; import { useGetIOByIdQuery } from "../Services/io.service"; import { useNavigate, useParams } from "react-router-dom"; import FullscreenLoaders from "./Loaders/FullscreenLoaders"; -import { formatDate } from "../Constants/Constants"; +import { calculatePercentage, formatDate } from "../Constants/Constants"; import { BsFileText } from "react-icons/bs"; const MobileView = ({ isOpen, onClose, finalRef, actionId }) => { @@ -63,6 +63,13 @@ const MobileView = ({ isOpen, onClose, finalRef, actionId }) => { }); }; + console.log( + calculatePercentage( + IObyID?.data?.totalAmtInvestmentInUSD, + IObyID?.data?.goalAmount + ) + ); + return ( { w={"320px"} sx={{ "@media (max-width: 2024px)": { - height:"695px", - width:"360px", + height: "695px", + width: "360px", }, "@media (max-width: 1440px)": { - height:"600px", - width:"320px", + height: "600px", + width: "320px", }, }} > @@ -117,16 +124,12 @@ const MobileView = ({ isOpen, onClose, finalRef, actionId }) => { > {IObyIDisLoading ? ( - + ) : ( <> @@ -174,10 +177,10 @@ const MobileView = ({ isOpen, onClose, finalRef, actionId }) => { borderBottomRightRadius={"23px"} sx={{ "@media (max-width: 2024px)": { - height:"575px", + height: "575px", }, "@media (max-width: 1440px)": { - height:"483px", + height: "483px", }, }} > @@ -246,7 +249,10 @@ const MobileView = ({ isOpen, onClose, finalRef, actionId }) => { { fontWeight={600} mb={0} > - 0.0% funded + {parseFloat( + calculatePercentage( + IObyID?.data?.totalAmtInvestmentInUSD, + IObyID?.data?.goalAmount + ) || 0 + ).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + % funded { Key Merits - - {keyMerits?.[0]?.icon?.iconFilePath && ( - - )} - - {IObyID?.data?.keyMerits[0]?.meritsDescription} - + + {keyMerits && + keyMerits.map((item, index) => ( + + + + {item?.meritsDescription} + + + ))} { refetch } = useGetDeleteHistoryQuery() + const formatDate = (date) => { + return new Date(date).toLocaleDateString('en-GB', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }); + }; // Use useEffect to refetch data when the component mounts useEffect(() => { diff --git a/src/Pages/IO_Management/CreateIO/CreateIO.jsx b/src/Pages/IO_Management/CreateIO/CreateIO.jsx index 617234a..e049632 100644 --- a/src/Pages/IO_Management/CreateIO/CreateIO.jsx +++ b/src/Pages/IO_Management/CreateIO/CreateIO.jsx @@ -23,7 +23,7 @@ const CreateIO = () => { const { data, error, isLoading } = useGetIOprepopulateDataQuery(); - // console.log(data?.data); + console.log(data?.data); const enableNextTab = (index) => { setTabs((prevTabs) => { diff --git a/src/Pages/IO_Management/CreateIO/Destribution.jsx b/src/Pages/IO_Management/CreateIO/Destribution.jsx index 56c4770..c53d1e2 100644 --- a/src/Pages/IO_Management/CreateIO/Destribution.jsx +++ b/src/Pages/IO_Management/CreateIO/Destribution.jsx @@ -24,7 +24,13 @@ const Destribution = () => { console.log(IODetails?.ioNAVHistory); - + const formatDate = (date) => { + return new Date(date).toLocaleDateString('en-GB', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + }); + }; useEffect(() => { // Simulate loading @@ -69,7 +75,7 @@ const Destribution = () => { fontWeight={"500"} className="d-flex align-items-center web-text-small" > - {formatDatee(item.transactionDate)} + {formatDate(item.transactionDate)} ), "Amount": ( @@ -82,7 +88,11 @@ const Destribution = () => { > {/* {`${item.transactionAmount}`} */} - {`$${parseFloat(item.transactionAmount||0).toLocaleString()}`} + {/* {`$${parseFloat(item.transactionAmount||0).toLocaleString()}`} */} + {`${parseFloat(item.transactionAmount || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} ), "% of Investment": ( diff --git a/src/Pages/IO_Management/CreateIO/IOCashDetails.jsx b/src/Pages/IO_Management/CreateIO/IOCashDetails.jsx index 783ca2b..6f471c4 100644 --- a/src/Pages/IO_Management/CreateIO/IOCashDetails.jsx +++ b/src/Pages/IO_Management/CreateIO/IOCashDetails.jsx @@ -1,5 +1,6 @@ import { Avatar, + Badge, Box, Button, HStack, @@ -30,7 +31,8 @@ const IOCashDetails = () => { const toast = useToast(); const firstField = useRef(); const { isOpen, onOpen, onClose } = useDisclosure(); - const { caseDetails, setCaseDetails, IODetails } = useContext(GlobalStateContext); + const { caseDetails, setCaseDetails, IODetails } = + useContext(GlobalStateContext); const [searchTerm, setSearchTerm] = useState(""); const [isLoading, setIsLoading] = useState(true); const [deleteAlert, setDeleteAlert] = useState(false); @@ -48,6 +50,14 @@ const IOCashDetails = () => { return () => clearTimeout(timer); }, []); + const formatDate = (date) => { + return new Date(date).toLocaleDateString("en-GB", { + day: "2-digit", + month: "2-digit", + year: "numeric", + }); + }; + // Calculate totals const totalAmount = caseDetails.reduce( (acc, caseDetail) => acc + caseDetail.amount, @@ -72,21 +82,22 @@ const IOCashDetails = () => { ); toast({ render: () => , - }); + }); }, 300); // Table filter - const filteredData = IODetails?.ioCashHistory?.filter((item) => { - const name = item.transactionType; - const searchLower = searchTerm.toLowerCase(); - const nameMatches = name.toLowerCase().includes(searchLower); - return nameMatches; - }).sort((b, a) => new Date(a.createdAt) - new Date(b.createdAt)); - + const filteredData = IODetails?.ioCashHistory + ?.filter((item) => { + const name = item.transactionType; + const searchLower = searchTerm.toLowerCase(); + const nameMatches = name.toLowerCase().includes(searchLower); + return nameMatches; + }) + .sort((b, a) => new Date(a.createdAt) - new Date(b.createdAt)); const extractedArray = filteredData?.map((item, index) => ({ id: item?.id, - "Date": ( + Date: ( { ), "Transaction type": ( { {item?.transactionType} ), - "Amount": ( + Amount: ( - {`$${parseFloat(item.transactionAmount||0).toLocaleString()}`} + + $ + + {/* {parseFloat(item.transactionAmount || 0).toLocaleString()} */} + {`${parseFloat(item.transactionAmount || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} ), - "Comments": ( + Comments: ( { ), "Update by ": ( - - {item.creator?.firstName} + + {item.creator?.firstName} ), "Update On": ( { return ( - +
{ onChange={(e) => setSearchTerm(e.target.value)} /> - - {IODetails?.isInvestedAmount ? :null} - + {IODetails?.isInvestedAmount ? ( + + ) : null} @@ -277,7 +308,7 @@ const IOCashDetails = () => { centered={true} emptyMessage={`We don't have any Sponers`} tableHeadRow={tableHeadRow} - data={extractedArray} + data={extractedArray} isLoading={isLoading} viewActionId={actionId} setViewActionId={setActionId} @@ -294,23 +325,11 @@ const IOCashDetails = () => { isLoading={isLoading} /> - - - - - - - - - - - - - - + ); }; diff --git a/src/Pages/IO_Management/CreateIO/IONAVDetails.jsx b/src/Pages/IO_Management/CreateIO/IONAVDetails.jsx index 3a002f0..b518724 100644 --- a/src/Pages/IO_Management/CreateIO/IONAVDetails.jsx +++ b/src/Pages/IO_Management/CreateIO/IONAVDetails.jsx @@ -1,32 +1,42 @@ -import React, { useContext, useEffect, useRef, useState } from 'react' -import GlobalStateContext from '../../../Contexts/GlobalStateContext'; -import { Box, HStack, Input,Text, Table, Tbody, Th, Tr, Avatar, useDisclosure,Button } from '@chakra-ui/react'; -import { OPACITY_ON_LOAD } from '../../../Layout/animations'; -import Pagination from '../../../Components/Pagination'; -import NormalTable from '../../../Components/DataTable/NormalTable'; -import CustomAlertDialog from '../../../Components/CustomAlertDialog'; -import { formatDatee } from '../../../Components/FormField'; -import { AddIcon } from '@chakra-ui/icons'; -import AddIONav from './AddIONav'; -import { formatDate } from '../../Master/Sponser/Sponsers'; +import React, { useContext, useEffect, useRef, useState } from "react"; +import GlobalStateContext from "../../../Contexts/GlobalStateContext"; +import { + Box, + HStack, + Input, + Text, + Table, + Tbody, + Th, + Tr, + Avatar, + useDisclosure, + Button, + Badge, +} from "@chakra-ui/react"; +import { OPACITY_ON_LOAD } from "../../../Layout/animations"; +import Pagination from "../../../Components/Pagination"; +import NormalTable from "../../../Components/DataTable/NormalTable"; +import CustomAlertDialog from "../../../Components/CustomAlertDialog"; +import { formatDatee } from "../../../Components/FormField"; +import { AddIcon } from "@chakra-ui/icons"; +import AddIONav from "./AddIONav"; +import { formatDate } from "../../Master/Sponser/Sponsers"; const IONAVDetails = () => { const { navDetails, setNavDetails, IODetails } = useContext(GlobalStateContext); - const firstField = useRef(); - const { isOpen, onOpen, onClose } = useDisclosure(); - const [searchTerm, setSearchTerm] = useState(""); - const [isLoading, setIsLoading] = useState(true); - const [deleteAlert, setDeleteAlert] = useState(false); - const [actionId, setActionId] = useState(false); - const [mouseEntered, setMouseEntered] = useState(false); - const [mouseEnteredId, setMouseEnteredId] = useState(""); + const firstField = useRef(); + const { isOpen, onOpen, onClose } = useDisclosure(); + const [searchTerm, setSearchTerm] = useState(""); + const [isLoading, setIsLoading] = useState(true); + const [deleteAlert, setDeleteAlert] = useState(false); + const [actionId, setActionId] = useState(false); + const [mouseEntered, setMouseEntered] = useState(false); + const [mouseEnteredId, setMouseEnteredId] = useState(""); + console.log(IODetails?.ioNAVHistory); - console.log(IODetails?.ioNAVHistory); - - - useEffect(() => { // Simulate loading const timer = setTimeout(() => { @@ -37,29 +47,31 @@ const IONAVDetails = () => { return () => clearTimeout(timer); }, []); - // Table setup - const tableHeadRow = [ - // "Sr.No", - "Valuation Date", - "NAV", - "Last NAV update", - "Investment Closed", - "Comments", - "Update by ", - // "Update On", - ]; + // Table setup + const tableHeadRow = [ + // "Sr.No", + "Valuation Date", + "NAV", + "Last NAV update", + "Investment Closed", + "Comments", + "Update by ", + // "Update On", + ]; - // Table filter - const filteredData = IODetails?.ioNAVHistory?.filter((item) => { - const name = item.transactionType; - const searchLower = searchTerm.toLowerCase(); - const nameMatches = name.toLowerCase().includes(searchLower); - return nameMatches; - }).sort((b, a) => new Date(a.transactionDate) - new Date(b.transactionDate)); + // Table filter + const filteredData = IODetails?.ioNAVHistory + ?.filter((item) => { + const name = item.transactionType; + const searchLower = searchTerm.toLowerCase(); + const nameMatches = name.toLowerCase().includes(searchLower); + return nameMatches; + }) + .sort((b, a) => new Date(a.transactionDate) - new Date(b.transactionDate)); - const extractedArray=filteredData?.map((item, index) => ({ + const extractedArray = filteredData?.map((item, index) => ({ id: item?.id, - "Sr.No": index +1, + "Sr.No": index + 1, "Valuation Date": ( { {formatDate(item?.transactionDate)} ), - "NAV": ( + NAV: ( {/* {`${item.transactionAmount}`} */} - {`$${parseFloat(item.transactionAmount||0).toLocaleString()}`} + + $ + + {parseFloat(item.transactionAmount || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} ), "Last NAV update": ( @@ -104,10 +122,10 @@ const IONAVDetails = () => { fontWeight={"500"} className="d-flex align-items-center web-text-small" > - {item.initialNAVvalue&& `${item.initialNAVvalue}`} + {item.initialNAVvalue && `${item.initialNAVvalue}`} ), - "Comments": ( + Comments: ( { ), "Update by ": ( - - Faisal + + Faisal ), "Update On": ( @@ -144,12 +162,8 @@ const IONAVDetails = () => { ), })); - - const handleDelete = () => { - const updatedNav = navDetails.filter( - (sponsor) => sponsor.id !== actionId - ); + const updatedNav = navDetails.filter((sponsor) => sponsor.id !== actionId); setTimeout(() => { setNavDetails(updatedNav); @@ -159,71 +173,71 @@ const IONAVDetails = () => { setIsLoading(true); }; + return ( + + + + setSearchTerm(e.target.value)} + /> - - - return ( - - - setSearchTerm(e.target.value)} - /> - - {/* + {/* */} {/* {IODetails?.isInvestedAmount ? :null} */} + {IODetails?.isInvestedAmount ? ( + + ) : null} + + -{IODetails?.isInvestedAmount ? :null} + - + setDeleteAlert(false)} + isOpen={deleteAlert} + message={"Are you sure you want to delete sponers?"} + alertHandler={handleDelete} + isLoading={isLoading} + /> + + + ); +}; - - - setDeleteAlert(false)} - isOpen={deleteAlert} - message={"Are you sure you want to delete sponers?"} - alertHandler={handleDelete} - isLoading={isLoading} - /> - - - - - - - - ) -} - -export default IONAVDetails \ No newline at end of file +export default IONAVDetails; diff --git a/src/Pages/IO_Management/ViewIO/ViewIOTable.jsx b/src/Pages/IO_Management/ViewIO/ViewIOTable.jsx index 28d76ce..5e347aa 100644 --- a/src/Pages/IO_Management/ViewIO/ViewIOTable.jsx +++ b/src/Pages/IO_Management/ViewIO/ViewIOTable.jsx @@ -42,14 +42,17 @@ import { formatCurrency } from "../../../Components/CurrencyInput"; import { IoIosPhonePortrait } from "react-icons/io"; import MobileView from "../../../Components/MobileView"; import { ImMobile } from "react-icons/im"; -import { generateSerialNumber, removeTrailingZeros } from "../../../Constants/Constants"; +import { + generateSerialNumber, + removeTrailingZeros, +} from "../../../Constants/Constants"; // import { debounce } from "./AddIOCharges"; const formatDate = (date) => { - return new Date(date).toLocaleDateString('en-GB', { - day: '2-digit', - month: '2-digit', - year: 'numeric', + return new Date(date).toLocaleDateString("en-GB", { + day: "2-digit", + month: "2-digit", + year: "numeric", }); }; // Simple date formatter @@ -74,12 +77,11 @@ const ViewIOTable = () => { // ===============================[ RTK Api calls ] ============================================= const { data, isLoading, error } = useGetIOsQuery({ - page: currentPage, + page: currentPage, size: pageSize, }); console.log(data); - // ===============================[ Table Header ] const tableHeadRow = [ @@ -91,7 +93,7 @@ const ViewIOTable = () => { "Goal Amount", "Closing Date", "IO Status", - // "Preview", + "Preview", "Action", ]; @@ -114,16 +116,16 @@ const ViewIOTable = () => { const extractedArray = filteredData?.map((item, idx) => ({ "Sr No.": ( {/* {item.id} */} - {generateSerialNumber(idx,currentPage, pageSize )} - - ), + {generateSerialNumber(idx, currentPage, pageSize)} + + ), "IO ID": ( @@ -140,27 +142,27 @@ const ViewIOTable = () => { // // - - {item.investmentNameEnglish ? item.investmentNameEnglish : "---"} - - + + {item.investmentNameEnglish ? item.investmentNameEnglish : "---"} + + ), Sponsor: ( @@ -179,18 +181,18 @@ const ViewIOTable = () => { ), "Goal Amount": ( - - + + {/* {item.goalAmount ? formatCurrency(removeTrailingZeros(item.goalAmount)) : "---"} */} - {`$${parseFloat(item.goalAmount||0).toLocaleString()}`} + {`${parseFloat(item.goalAmount || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })}`} + + USD + ), @@ -201,7 +203,7 @@ const ViewIOTable = () => { {formatDate(item.closingDate ? item.closingDate : "---")} - ), + ), "IO Status": ( { Preview: ( { - setActionId(item.id) + onClick={() => { + setActionId(item.id); onOpen(); }} rounded={"sm"} diff --git a/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx b/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx index 75d5096..1866daf 100644 --- a/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx +++ b/src/Pages/IO_Management/ViewIO/ViewIOdataHeader.jsx @@ -162,6 +162,9 @@ const ViewIOdataHeader = ({ data, isLoading }) => { apiTransactionTitles?.includes(item.id) ); + + const balanceAmount = IODetails?.goalAmount - IODetails?.totalAmtInvestmentInUSD + return IODetails?.investmentNameEnglish ? ( { boxShadow={"md"} position={"relative"} > - + {/* {IODetails?.ioName}/ */} {IODetails?.artifactsImage?.[0]?.artifactPathName ? ( @@ -225,41 +228,102 @@ const ViewIOdataHeader = ({ data, isLoading }) => { )} - - - IO Name - - - {IODetails?.investmentNameEnglish - ? IODetails?.investmentNameEnglish - : "---"} - - + + + + IO Name :- + + + {IODetails?.investmentNameEnglish + ? IODetails?.investmentNameEnglish + : "---"} + + - - - Sponsor Name - - - {IODetails?.sponsor?.sponsorName - ? IODetails?.sponsor?.sponsorName - : "---"} - + + + Sponsor Name :- + + + {IODetails?.sponsor?.sponsorName + ? IODetails?.sponsor?.sponsorName + : "---"} + + + + - - + + + Goal Amount :- + + + {/* {IODetails?.ioNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioNAV)) : "00.00"} */} + {parseFloat(IODetails?.goalAmount || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + + + + + + Amount Invested :- + + + {/* {IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"} */} + {parseFloat(IODetails?.totalAmtInvestmentInUSD || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + + + + + + Balance :- + + + {/* {IODetails?.ioMVNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioMVNAV)) : "00.00"} */} + {parseFloat(balanceAmount || 0).toLocaleString(undefined, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + + + + + + { color={"gray.500"} fontWeight={"500"} > - IO Status + IO Status :- { - + - IO MV + IO MV :- - + {/* {IODetails?.ioNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioNAV)) : "00.00"} */} {parseFloat(IODetails?.ioNAV || 0).toLocaleString(undefined, { minimumFractionDigits: 2, @@ -317,16 +379,16 @@ const ViewIOdataHeader = ({ data, isLoading }) => { - + - IO cash + IO cash :- - + {/* {IODetails?.ioCash ? formatCurrency(removeTrailingZeros(IODetails?.ioCash)) : "00.00"} */} {parseFloat(IODetails?.ioCash || 0).toLocaleString(undefined, { minimumFractionDigits: 2, @@ -335,16 +397,16 @@ const ViewIOdataHeader = ({ data, isLoading }) => { - + - IO NAV + IO NAV :- - + {/* {IODetails?.ioMVNAV ? formatCurrency(removeTrailingZeros(IODetails?.ioMVNAV)) : "00.00"} */} {parseFloat(IODetails?.ioMVNAV || 0).toLocaleString(undefined, { minimumFractionDigits: 2, @@ -352,7 +414,7 @@ const ViewIOdataHeader = ({ data, isLoading }) => { })} - + ), "Transaction": ( - + {item.investorTransaction?.transactionName} @@ -135,7 +135,7 @@ console.log(transaction); ), "Amount in investors currency": ( - + {/* {item.investorAmount} */} {parseFloat(item?.investorAmount || 0).toLocaleString(undefined, { @@ -147,14 +147,14 @@ console.log(transaction); ), "From USD": ( - + {item.USDToInvCur_Rate} ), "TO USD": ( - + {item.invCurToUSD_Rate} @@ -168,7 +168,8 @@ console.log(transaction); minimumFractionDigits: 2, maximumFractionDigits: 2, })} - $ + {/* $ */} + USD ), @@ -246,7 +247,7 @@ console.log(transaction); {parseFloat(InvestorWallet?.WalletBalance_InUSD).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} - {InvestorWallet?.currencyCode_InCur} + USD { "Withdrawal Amount": ( - ${parseFloat(item?.USDAmount||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} + ${parseFloat(item?.USDAmount||0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ),