diff --git a/src/Components/CurrencyInput.jsx b/src/Components/CurrencyInput.jsx index c972aee..b5d646b 100644 --- a/src/Components/CurrencyInput.jsx +++ b/src/Components/CurrencyInput.jsx @@ -38,6 +38,7 @@ const CurrencyInput = forwardRef(({ value, onChange, ...props }, ref) => { {...props} ref={ref} // Forward ref here type="text" + colorScheme='forestGreen' value={formatCurrency(value)} onChange={handleChange} /> diff --git a/src/Components/DataTable/NormalTable.jsx b/src/Components/DataTable/NormalTable.jsx index 0ae24b8..5c65c88 100644 --- a/src/Components/DataTable/NormalTable.jsx +++ b/src/Components/DataTable/NormalTable.jsx @@ -20,6 +20,7 @@ const DataTable = ({ tableHeadRow, emptyMessage, centered, + total }) => { console.log(data); @@ -34,7 +35,7 @@ const DataTable = ({ ) : ( - Tanami v1.0.0 + {total? total :"Tanami v1.0.0"} {tableHeadRow.map((heading, index) => ( diff --git a/src/Pages/IO_Management/ViewIO/HeaderModal/DistributionInvestor.jsx b/src/Pages/IO_Management/ViewIO/HeaderModal/DistributionInvestor.jsx index e0a9f5a..47d58f5 100644 --- a/src/Pages/IO_Management/ViewIO/HeaderModal/DistributionInvestor.jsx +++ b/src/Pages/IO_Management/ViewIO/HeaderModal/DistributionInvestor.jsx @@ -1,4 +1,6 @@ import { + Alert, + AlertIcon, Box, Button, FormControl, @@ -20,8 +22,9 @@ import { Textarea, Th, Tr, + useToast, } from "@chakra-ui/react"; -import DataTable from "../../../../Components/DataTable/DataTable"; +import NormalData from "../../../../Components/DataTable/NormalTable"; import { useState } from "react"; import { AddIcon } from "@chakra-ui/icons"; import { useGetDistributionInvestorMutation } from "../../../../Services/io.service"; @@ -30,6 +33,9 @@ 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 CurrencyInput from "../../../../Components/CurrencyInput"; +import { IoCalculator } from "react-icons/io5"; export const investor = yup.object().shape({ amount: yup.string().required("Amount is required"), @@ -37,7 +43,10 @@ export const investor = yup.object().shape({ const DistributionInvestor = ({ isOpen, onClose }) => { const params = useParams(); + const toast = useToast(); const id = params?.id; + const [ isCalculateLoading, setIsCalculateLoading ] = useState(false) + const [ calcualtedData, setCalculatedDate ] = useState(null) // const { // data:IObyID, @@ -79,23 +88,8 @@ const DistributionInvestor = ({ isOpen, onClose }) => { "($)", ]; - const filteredData = [ - { - id: 1, - }, - { - id: 1, - }, - { - id: 1, - }, - { - id: 1, - }, - ]; - const [extractedArray, setExtractedArray] = useState( - filteredData?.map((item, index) => ({ + const extractedArray = calcualtedData?.data?.map((item, index) => ({ id: item?.id, "Sr No.": ( { "Client Id": ( - BH00000001 + {item?.clientId} ), "First name": ( - Faisal + {item?.firstName} ), "Last Name": ( - Aljalahma + {item?.lastName} ), Amount: ( - $100,000 /- + {item?.amount} ), @@ -146,25 +140,25 @@ const DistributionInvestor = ({ isOpen, onClose }) => { color={"teal.900"} fontWeight={"500"} > - 26.0 % + {item?.distribution_per} % ), "($)": ( - $100,000 /- + {item?.distribution_amt?.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ), })) - ); + const Total = () => { return (
- - + + @@ -248,8 +242,35 @@ const DistributionInvestor = ({ isOpen, onClose }) => { ); }; - const onSubmit = (data) => { + const onSubmit = async (data) => { console.log(data); + setIsCalculateLoading(true) + + try { + const res = await getDistributionInvestment({id,data}) + console.log(res?.data?.data); + + if (res?.error?.status === 401) { + toast({ + render: () => ( + + ), + }) + setIsCalculateLoading(false) + } else if(res?.data?.statusCode === 200){ + setCalculatedDate(res?.data?.data) + toast({ + render: () => ( + + ), + }) + setIsCalculateLoading(false) + + } + + } catch (error) { + + } }; console.log(errors); @@ -269,13 +290,16 @@ const DistributionInvestor = ({ isOpen, onClose }) => { {/* */} - Amount to Distribute - + Amount to Distribute + ( - { )} /> @@ -301,14 +325,16 @@ const DistributionInvestor = ({ isOpen, onClose }) => { - } + total={} // isLoading={isLoading} - /> + /> : + + Please enter amount to calcutale Distribution! + }
{ wordBreak="normal" overflowWrap="normal" > - $100200 + {calcualtedData?.totalInvestedAmt?.toFixed(2)?.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} { wordBreak="normal" overflowWrap="normal" > - 100.0% + {calcualtedData?.distributed_per?.toFixed(2)}% { wordBreak="normal" overflowWrap="normal" > - $100230 + {calcualtedData?.distributed_amt?.toFixed(2)?.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}