update invest amount #8

Merged
Siddhesh.More merged 1 commits from Yasin into release/sprint-8 2024-11-21 10:17:32 +00:00
3 changed files with 62 additions and 92 deletions

View File

@@ -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") {

View File

@@ -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}>

View File

@@ -195,8 +195,6 @@ const ViewDistributionInvestor = ({ isOpen, onClose,id:exitId }) => {
setIsFinalCalculateLoading(false);
setIsCalcualtedData(false);
};
console.log(exitId);
return (