From 2e06b5288186f97d89489a98b11ad2c4ca36a36a Mon Sep 17 00:00:00 2001 From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com> Date: Tue, 22 Oct 2024 20:11:00 +0530 Subject: [PATCH] Update investment Amount --- .../ViewIO/HeaderModal/AmountInvested.jsx | 30 +- .../InvestorDetails/Kyc.jsx | 258 +++++++++++++----- 2 files changed, 211 insertions(+), 77 deletions(-) diff --git a/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx b/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx index eb81854..6bb14f9 100644 --- a/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx +++ b/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx @@ -91,16 +91,18 @@ const AmountInvested = ({ isOpen, onClose }) => { }; const handleAmountChange = (e) => { - const amount = parseFloat(e.target.value) || 0; + // e might be an object or just a value, handle both cases + const amount = typeof e === 'object' && e.target ? parseFloat(e.target.value) || 0 : parseFloat(e) || 0; const totalAmount = parseFloat(IODetails?.totalAmtInvestmentInUSD) || 0; const ioCash = (totalAmount - amount).toFixed(2); - + reset({ amountInvested: parseFloat(amount), IoCash: parseFloat(ioCash), - Total_Amount: IODetails?.totalAmtInvestmentInUSD + Total_Amount: IODetails?.totalAmtInvestmentInUSD, }); }; + return ( @@ -153,12 +155,22 @@ const AmountInvested = ({ isOpen, onClose }) => { onChange={handleAmountChange} /> */} ( - - )} - /> + name="amountInvested" + control={control} + render={({ field }) => ( + { + field.onChange(value); // This will keep the form's internal state updated + handleAmountChange(value); // This will trigger your custom logic + }} + /> + )} +/> {errors.amountInvested && {errors.amountInvested.message}} diff --git a/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx b/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx index 5bc030b..4fefc63 100644 --- a/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx +++ b/src/Pages/Investor_Management/InvestorDetails/Kyc.jsx @@ -1,80 +1,206 @@ -import { Box, Checkbox, CheckboxGroup, Divider, FormControl, FormLabel, Heading, HStack, Input, Radio, RadioGroup, Select, Stack, Text, Textarea } from "@chakra-ui/react"; +import { + Box, + Checkbox, + CheckboxGroup, + Divider, + FormControl, + FormLabel, + Heading, + HStack, + Input, + Radio, + RadioGroup, + Select, + Stack, + Text, + Textarea, +} from "@chakra-ui/react"; import React, { useState } from "react"; import { useParams } from "react-router-dom"; import { useGetInvestorsDetailsByIdQuery } from "../../../Services/investor.details.service"; const Kyc = () => { - - const params = useParams(); - const id = params?.id; - const { data, isLoading:bankDetailsLoading, errors, refetch } = useGetInvestorsDetailsByIdQuery( - id,{skip: !id,} - ); - // const [value, setValue] = useState('2') + const params = useParams(); + const id = params?.id; + const { + data, + isLoading: bankDetailsLoading, + errors, + refetch, + } = useGetInvestorsDetailsByIdQuery(id, { skip: !id }); + // const [value, setValue] = useState('2') - console.log(data?.data?.KYC?.questions); - + console.log(data?.data?.KYC?.questions); return ( - (!bankDetailsLoading && - - Additional Questions - Please provide additional Information to complete your profile. - - - City - - - - Country - - - - - - Occupation - - - - Source of Funds - - - - + !bankDetailsLoading && ( + + + {/* + Additional Questions + + + Please provide additional Information to complete your profile. + */} + + Address + + + + + + House/Unit + + + + + + Road/Street + + + + + + + + Block + + + + + + City + + + + + + + + Country + + + + + + + Occupation + + + + + + Occupation + + + + + + Source of Funds + + + + + {/* Address