diff --git a/src/Components/CurrencyInput.jsx b/src/Components/CurrencyInput.jsx
index 45932c4..facdca8 100644
--- a/src/Components/CurrencyInput.jsx
+++ b/src/Components/CurrencyInput.jsx
@@ -9,6 +9,8 @@ export const formatCurrency = (value) => {
};
const CurrencyInput = forwardRef(({ value, onChange, ...props }, ref) => {
+ console.log(props);
+
const handleChange = (event) => {
let { value } = event.target;
diff --git a/src/Pages/Deposit/DepositRequest/DepositRequest.jsx b/src/Pages/Deposit/DepositRequest/DepositRequest.jsx
index 0490be4..f17fae3 100644
--- a/src/Pages/Deposit/DepositRequest/DepositRequest.jsx
+++ b/src/Pages/Deposit/DepositRequest/DepositRequest.jsx
@@ -148,34 +148,34 @@ const DepositRequest = () => {
fontWeight={"500"}
className="d-flex align-items-center web-text-small"
>
- {item?.principal?.investor_details?.clientReference_id}
+ {item?.clientReference_id}
),
"First Name": (
- {item?.principal?.firstName}
+ {item?.firstName}
),
"Last Name": (
- {item?.principal?.lastName}
+ {item?.lastName}
),
Country: (
- {item?.principal?.investor_details?.country?.countryName}
+ {item?.countryName}
),
"Phone Number": (
- {item?.principal?.mobileNumber}
+ {item?.mobileNumber}
),
diff --git a/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx b/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx
index 00c73c6..dc21c41 100644
--- a/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx
+++ b/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx
@@ -64,10 +64,6 @@ const DepositRequestApprove = ({ isOpen, onClose, firstField, id, data:requestDa
}, [requestData, id])
-
-
-
-
const onSubmit = async(data) => {
setIsBtnLoading(true)
const formData = new FormData();
diff --git a/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx b/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx
index 1d385b8..0a898b5 100644
--- a/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx
+++ b/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx
@@ -1,3 +1,4 @@
+import React, { useContext, useEffect, useState } from 'react';
import {
Box,
Button,
@@ -12,10 +13,86 @@ import {
ModalHeader,
ModalOverlay,
Text,
- Textarea,
+ useToast,
} from "@chakra-ui/react";
+import { useForm } from 'react-hook-form';
+import * as yup from 'yup';
+import { yupResolver } from '@hookform/resolvers/yup';
+import GlobalStateContext from '../../../../Contexts/GlobalStateContext';
+import { useParams } from 'react-router-dom';
+import { useAmountIvestmentMutation } from '../../../../Services/io.service';
+import ToastBox from '../../../../Components/ToastBox';
+
+// Validation schema
+const validationSchema = yup.object().shape({
+ transactionDate: yup.date().required('Date is required'),
+ Total_Amount: yup.number().positive('Amount must be positive').required('Amount is required'),
+ amountInvested: yup.number().positive('Amount to invest must be positive').required('Amount to invest is required'),
+ IoCash: yup.number().positive('IO Cash must be positive').required('IO Cash is required'),
+});
+
const AmountInvested = ({ isOpen, onClose }) => {
+ const params = useParams()
+ const toast = useToast()
+ const id = params?.id
+ const { register, handleSubmit, reset, watch, formState: { errors } } = useForm({
+ resolver: yupResolver(validationSchema),
+ });
+ const [ isLoading, setIsLoading ] = useState(false)
+ const { IODetails } = useContext(GlobalStateContext);
+ const [ amountInvested ] = useAmountIvestmentMutation()
+
+ useEffect(() => {
+ reset({
+ Total_Amount: IODetails?.goalAmount,
+ IoCash: IODetails?.goalAmount
+ })
+ }, [IODetails])
+
+
+ const onSubmit = async (data) => {
+ console.log(data);
+ setIsLoading(true)
+
+ try {
+ const res = await amountInvested({data, id})
+ console.log(res);
+ if (res?.data?.statusCode === 200 ) {
+ toast({
+ render: () => ,
+ });
+ setIsLoading(false)
+ onClose()
+
+ }else if(response?.error?.status === 400) {
+ toast({
+ render: () => (
+
+ ),
+ });
+ setIsLoading(false)
+ }
+
+
+
+ } catch (error) {
+
+ }
+ // Handle form submission
+ };
+
+ const handleAmountChange = (e) => {
+ const amount = parseFloat(e.target.value) || 0;
+ const totalAmount = parseFloat(IODetails?.goalAmount) || 0;
+ const ioCash = (totalAmount - amount).toFixed(2); // Ensure precision with toFixed
+
+ reset({
+ amountInvested: amount,
+ IoCash: parseFloat(ioCash), // Convert to number for consistent formatting
+ });
+ };
+
return (
@@ -23,73 +100,93 @@ const AmountInvested = ({ isOpen, onClose }) => {
Amount Invested
-
-
- Date
-
-
-
+
-
-
-
-
);
diff --git a/src/Services/io.service.js b/src/Services/io.service.js
index 5b7049e..d200ff3 100644
--- a/src/Services/io.service.js
+++ b/src/Services/io.service.js
@@ -231,6 +231,22 @@ export const ioService = createApi({
+ // =====[ Amount Investment ]
+ amountIvestment : builder.mutation({
+ query: ({ data, id }) => ({
+ url: `/io/admin/amount-invested/${id}`,
+ method: "POST",
+ body: data,
+ }),
+ invalidatesTags: ["getIOById"],
+ }),
+
+
+
+
+
+
+
@@ -277,5 +293,11 @@ export const {
- useUpdateStatusIoMutation
+ useUpdateStatusIoMutation,
+
+
+
+
+
+ useAmountIvestmentMutation,
} = ioService;