update invest amount
This commit is contained in:
@@ -172,7 +172,7 @@ const Pending = () => {
|
||||
if (item?.transactionType === "Amount Invested") {
|
||||
onInvestmentOpen();
|
||||
} else if (item?.transactionType === "Distribution To Investor") {
|
||||
onDistInvestorOpen();
|
||||
onInvestmentOpen();
|
||||
} else if (item?.transactionType === "Exit") {
|
||||
onExitOpen();
|
||||
} else if (item?.transactionType === "Cancel") {
|
||||
|
||||
@@ -114,6 +114,8 @@ 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
|
||||
const amount =
|
||||
@@ -129,6 +131,7 @@ const ViewAmountInvested = ({ isOpen, onClose, id:investorId }) => {
|
||||
Total_Amount: IODetails?.totalAmtInvestmentInUSD,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose}>
|
||||
@@ -146,32 +149,9 @@ const ViewAmountInvested = ({ isOpen, onClose, id:investorId }) => {
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Date
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="date"
|
||||
{...register("transactionDate")}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
fontSize={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
/>
|
||||
{errors.transactionDate && (
|
||||
<Text fontSize={"xs"} fontWeight={600} color="red.500">
|
||||
{errors.transactionDate.message}
|
||||
</Text>
|
||||
)}
|
||||
</FormControl>
|
||||
|
||||
<FormControl
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.Total_Amount}
|
||||
isReadOnly
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Amount
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(watch("Total_Amount"))}
|
||||
value={formatDate(IODetails?.ioTransactionRecords?.Approved?.[0]?.createdAt)}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
textAlign={"end"}
|
||||
@@ -179,75 +159,67 @@ const ViewAmountInvested = ({ isOpen, onClose, id:investorId }) => {
|
||||
fontSize={"sm"}
|
||||
readOnly
|
||||
/>
|
||||
{errors.Total_Amount && (
|
||||
<Text fontSize={"xs"} fontWeight={600} color="red.500">
|
||||
{errors.Total_Amount.message}
|
||||
</Text>
|
||||
)}
|
||||
</FormControl>
|
||||
|
||||
<FormControl
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.amountInvested}
|
||||
isRequired
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Amount to invest
|
||||
</FormLabel>
|
||||
{/* <Input
|
||||
type="number"
|
||||
{...register('amountInvested')}
|
||||
size="sm"
|
||||
rounded={'sm'}
|
||||
textAlign={'end'}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
onChange={handleAmountChange}
|
||||
/> */}
|
||||
<Controller
|
||||
name="amountInvested"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<CurrencyInput
|
||||
{...field}
|
||||
textAlign={"right"}
|
||||
fontSize={"sm"}
|
||||
type="number"
|
||||
size={"sm"}
|
||||
onChange={(value) => {
|
||||
field.onChange(value); // This will keep the form's internal state updated
|
||||
handleAmountChange(value); // This will trigger your custom logic
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
{errors.amountInvested && (
|
||||
<Text fontSize={"xs"} fontWeight={600} color="red.500">
|
||||
{errors.amountInvested.message}
|
||||
</Text>
|
||||
)}
|
||||
</FormControl>
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.Total_Amount}
|
||||
isReadOnly
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Amount
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(watch("Total_Amount"))}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
textAlign={"end"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormControl
|
||||
mb={"15px"}
|
||||
isInvalid={!!errors.amountInvested}
|
||||
isRequired
|
||||
>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
Amount to invest
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(IODetails?.ioTransactionRecords?.Approved?.[0]?.transactionAmount || 0)}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
textAlign={"end"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormControl mb={"15px"} isInvalid={!!errors.IoCash}>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
IO Cash
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(
|
||||
(watch("Total_Amount") || 0) -
|
||||
(IODetails?.ioTransactionRecords?.Approved?.[0]?.transactionAmount || 0)
|
||||
)}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
textAlign={"right"}
|
||||
readOnly
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormControl mb={"15px"} isInvalid={!!errors.IoCash}>
|
||||
<FormLabel as={"label"} fontSize={"sm"} fontWeight={500}>
|
||||
IO Cash
|
||||
</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={formatCurrency(watch("IoCash"))}
|
||||
size="sm"
|
||||
rounded={"sm"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
fontSize={"sm"}
|
||||
textAlign={"right"}
|
||||
readOnly
|
||||
/>
|
||||
{errors.IoCash && (
|
||||
<Text fontSize={"xs"} fontWeight={600} color="red.500">
|
||||
{errors.IoCash.message}
|
||||
</Text>
|
||||
)}
|
||||
</FormControl>
|
||||
|
||||
<ModalFooter>
|
||||
<Box display={"flex"} justifyContent={"center"} gap={2}>
|
||||
|
||||
@@ -195,8 +195,6 @@ const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => {
|
||||
setIsFinalCalculateLoading(false);
|
||||
setIsCalcualtedData(false);
|
||||
};
|
||||
|
||||
console.log(exitId);
|
||||
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user