2024-07-08 20:14:34 +05:30
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
2024-07-09 19:05:08 +05:30
|
|
|
FormControl,
|
2024-08-20 19:10:58 +05:30
|
|
|
FormErrorMessage,
|
2024-07-09 19:05:08 +05:30
|
|
|
FormLabel,
|
2024-07-15 12:27:23 +05:30
|
|
|
HStack,
|
2024-07-08 20:14:34 +05:30
|
|
|
Input,
|
|
|
|
|
Modal,
|
|
|
|
|
ModalBody,
|
|
|
|
|
ModalCloseButton,
|
|
|
|
|
ModalContent,
|
|
|
|
|
ModalFooter,
|
|
|
|
|
ModalHeader,
|
|
|
|
|
ModalOverlay,
|
2024-07-15 12:27:23 +05:30
|
|
|
Switch,
|
|
|
|
|
Table,
|
|
|
|
|
Tbody,
|
2024-07-08 20:14:34 +05:30
|
|
|
Text,
|
|
|
|
|
Textarea,
|
2024-07-15 12:27:23 +05:30
|
|
|
Th,
|
|
|
|
|
Tr,
|
2024-07-08 20:14:34 +05:30
|
|
|
} from "@chakra-ui/react";
|
2024-07-15 12:27:23 +05:30
|
|
|
import DataTable from "../../../../Components/DataTable/DataTable";
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import { AddIcon } from "@chakra-ui/icons";
|
2024-08-20 19:10:58 +05:30
|
|
|
import { useGetDistributionInvestorMutation } from "../../../../Services/io.service";
|
|
|
|
|
import { useParams } from "react-router-dom";
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
import { Controller, useForm } from "react-hook-form";
|
|
|
|
|
import * as yup from "yup";
|
|
|
|
|
import { yupResolver } from "@hookform/resolvers/yup";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const investor = yup.object().shape({
|
|
|
|
|
amount: yup.string().required("Amount is required"),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const DistributionInvestor = ({ isOpen, onClose, }) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = useParams()
|
|
|
|
|
const id = params?.id
|
|
|
|
|
|
|
|
|
|
// const {
|
|
|
|
|
// data:IObyID,
|
|
|
|
|
// error,
|
|
|
|
|
// isLoading,
|
|
|
|
|
// } = useGetDistributionInvestorMutation(id);
|
|
|
|
|
|
|
|
|
|
const [ getDistributionInvestment ] = useGetDistributionInvestorMutation()
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
control,
|
|
|
|
|
handleSubmit,
|
|
|
|
|
formState: { errors },
|
|
|
|
|
reset,
|
|
|
|
|
} = useForm({
|
|
|
|
|
resolver: yupResolver(investor),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// useEffect(()=>{
|
|
|
|
|
// try {
|
|
|
|
|
// const res = getDistributionInvestment({id,data})
|
|
|
|
|
// console.log(res);
|
|
|
|
|
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// },[])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(IObyID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-08 20:14:34 +05:30
|
|
|
|
2024-07-15 12:27:23 +05:30
|
|
|
// ====================================================[Table Setup]================================================================
|
|
|
|
|
const tableHeadRow = [
|
|
|
|
|
"Sr No.",
|
|
|
|
|
"Client Id",
|
|
|
|
|
"First name",
|
|
|
|
|
"Last Name",
|
|
|
|
|
"Amount",
|
|
|
|
|
"%",
|
|
|
|
|
"($)",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const filteredData = [
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
2024-07-30 13:30:34 +05:30
|
|
|
},
|
|
|
|
|
];
|
2024-07-15 12:27:23 +05:30
|
|
|
|
|
|
|
|
const [extractedArray, setExtractedArray] = useState(
|
|
|
|
|
filteredData?.map((item, index) => ({
|
|
|
|
|
id: item?.id,
|
2024-07-30 13:30:34 +05:30
|
|
|
"Sr No.": (
|
|
|
|
|
<Box
|
|
|
|
|
w={9}
|
|
|
|
|
display={"flex"}
|
|
|
|
|
alignItems={"center"}
|
|
|
|
|
isTruncated={true}
|
|
|
|
|
h={25}
|
|
|
|
|
>
|
|
|
|
|
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
|
|
|
|
{index + 1}
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
),
|
2024-07-15 12:27:23 +05:30
|
|
|
"Client Id": (
|
|
|
|
|
<Box w={100} isTruncated={true}>
|
|
|
|
|
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
2024-07-30 13:30:34 +05:30
|
|
|
BH00000001
|
2024-07-15 12:27:23 +05:30
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
),
|
|
|
|
|
"First name": (
|
|
|
|
|
<Box minW={24} isTruncated={true}>
|
|
|
|
|
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
2024-07-30 13:30:34 +05:30
|
|
|
Faisal
|
2024-07-15 12:27:23 +05:30
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
),
|
|
|
|
|
"Last Name": (
|
|
|
|
|
<Box minW={24} isTruncated={true}>
|
2024-07-30 13:30:34 +05:30
|
|
|
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
|
|
|
|
Aljalahma
|
|
|
|
|
</Text>
|
2024-07-15 12:27:23 +05:30
|
|
|
</Box>
|
|
|
|
|
),
|
2024-07-30 13:30:34 +05:30
|
|
|
Amount: (
|
2024-07-15 12:27:23 +05:30
|
|
|
<Box minW={24} isTruncated={true}>
|
2024-07-30 13:30:34 +05:30
|
|
|
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
|
|
|
|
$100,000 /-
|
|
|
|
|
</Text>
|
2024-07-15 12:27:23 +05:30
|
|
|
</Box>
|
|
|
|
|
),
|
|
|
|
|
"%": (
|
|
|
|
|
<Box minW={19} isTruncated={true}>
|
2024-07-30 13:30:34 +05:30
|
|
|
<Text
|
|
|
|
|
textAlign={"right"}
|
|
|
|
|
as={"span"}
|
|
|
|
|
color={"teal.900"}
|
|
|
|
|
fontWeight={"500"}
|
|
|
|
|
>
|
|
|
|
|
26.0 %
|
|
|
|
|
</Text>
|
2024-07-15 12:27:23 +05:30
|
|
|
</Box>
|
|
|
|
|
),
|
|
|
|
|
"($)": (
|
|
|
|
|
<Box minW={24} isTruncated={true}>
|
2024-07-30 13:30:34 +05:30
|
|
|
<Text as={"span"} color={"teal.900"} fontWeight={"500"}>
|
|
|
|
|
$100,000 /-
|
|
|
|
|
</Text>
|
2024-07-15 12:27:23 +05:30
|
|
|
</Box>
|
|
|
|
|
),
|
|
|
|
|
}))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const Total = () => {
|
|
|
|
|
return (
|
|
|
|
|
<Table size="sm">
|
|
|
|
|
<Tbody backgroundColor="gray.50">
|
2024-07-30 13:30:34 +05:30
|
|
|
<Tr>
|
2024-07-15 12:27:23 +05:30
|
|
|
<Th
|
|
|
|
|
textAlign={"left"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="90px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
|
|
|
|
Total
|
|
|
|
|
</Th>
|
|
|
|
|
<Th
|
|
|
|
|
textAlign={"center"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="110px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
|
|
|
|
{" "}
|
|
|
|
|
</Th>
|
|
|
|
|
<Th
|
|
|
|
|
textAlign={"center"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="110px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
|
|
|
|
{" "}
|
|
|
|
|
</Th>
|
|
|
|
|
<Th
|
|
|
|
|
textAlign={"center"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="110px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
|
|
|
|
{" "}
|
|
|
|
|
</Th>
|
|
|
|
|
<Th
|
|
|
|
|
textAlign={"left"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="110px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
|
|
|
|
$100200
|
|
|
|
|
</Th>
|
|
|
|
|
<Th
|
|
|
|
|
textAlign={"left"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="90px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
2024-07-30 13:30:34 +05:30
|
|
|
100.0%
|
2024-07-15 12:27:23 +05:30
|
|
|
</Th>
|
|
|
|
|
<Th
|
|
|
|
|
textAlign={"center"}
|
|
|
|
|
p={3}
|
|
|
|
|
width="100px"
|
|
|
|
|
color={"#004118"}
|
|
|
|
|
whiteSpace="normal"
|
|
|
|
|
wordBreak="normal"
|
|
|
|
|
overflowWrap="normal"
|
|
|
|
|
>
|
|
|
|
|
$100230
|
|
|
|
|
</Th>
|
|
|
|
|
</Tr>
|
|
|
|
|
</Tbody>
|
|
|
|
|
</Table>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-20 19:10:58 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
const onSubmit = (data) =>{
|
|
|
|
|
console.log( data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-08 20:14:34 +05:30
|
|
|
return (
|
2024-07-30 13:30:34 +05:30
|
|
|
<Modal size={"xl"} isOpen={isOpen} onClose={onClose}>
|
2024-07-08 20:14:34 +05:30
|
|
|
<ModalOverlay />
|
2024-07-30 13:30:34 +05:30
|
|
|
<ModalContent maxW={1000}>
|
2024-08-20 19:10:58 +05:30
|
|
|
<ModalHeader fontSize={"md"}>
|
|
|
|
|
Distribution To Investor Transaction
|
|
|
|
|
</ModalHeader>
|
2024-07-08 20:14:34 +05:30
|
|
|
<ModalCloseButton />
|
2024-07-30 13:30:34 +05:30
|
|
|
<ModalBody>
|
2024-08-20 19:10:58 +05:30
|
|
|
{/* <Text as="label" mb="5px" fontSize="sm" fontWeight={500}>
|
|
|
|
|
Amount to Distribute
|
|
|
|
|
</Text> */}
|
|
|
|
|
<HStack onSubmit={handleSubmit(onSubmit)} as={"form"} mb={4}>
|
2024-07-30 13:30:34 +05:30
|
|
|
{/* <Input placeholder="$00.00" size={"sm"} className="col" /> */}
|
2024-08-20 19:10:58 +05:30
|
|
|
<FormControl isInvalid={errors.amount}>
|
|
|
|
|
<FormLabel fontSize={"sm"}> Amount to Distribute</FormLabel>
|
|
|
|
|
<Controller
|
|
|
|
|
name="amount"
|
|
|
|
|
control={control}
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<Input {...field} fontSize={"sm"} type="number" size={"sm"} textAlign={"right"} />
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
|
|
|
|
{errors.amount?.message}
|
|
|
|
|
</FormErrorMessage>
|
|
|
|
|
</FormControl>
|
2024-07-30 13:30:34 +05:30
|
|
|
<Button
|
|
|
|
|
// leftIcon={<AddIcon />}
|
|
|
|
|
size={"sm"}
|
|
|
|
|
rounded={"sm"}
|
|
|
|
|
colorScheme="forestGreen"
|
2024-08-20 19:10:58 +05:30
|
|
|
type="submit"
|
2024-07-30 13:30:34 +05:30
|
|
|
>
|
|
|
|
|
Calculate
|
|
|
|
|
</Button>
|
|
|
|
|
</HStack>
|
2024-07-15 12:27:23 +05:30
|
|
|
|
2024-07-30 13:30:34 +05:30
|
|
|
<DataTable
|
|
|
|
|
emptyMessage={`We don't have any Sponers `}
|
|
|
|
|
tableHeadRow={tableHeadRow}
|
|
|
|
|
data={extractedArray}
|
|
|
|
|
setData={setExtractedArray}
|
|
|
|
|
caption={<Total />}
|
|
|
|
|
// isLoading={isLoading}
|
|
|
|
|
/>
|
2024-07-08 20:14:34 +05:30
|
|
|
</ModalBody>
|
2024-07-30 13:30:34 +05:30
|
|
|
<ModalFooter pt={0}>
|
2024-07-08 20:14:34 +05:30
|
|
|
<Button
|
|
|
|
|
bg={"hsla(139, 100%, 14%, 1)"}
|
|
|
|
|
mr={3}
|
|
|
|
|
color={"#fff"}
|
|
|
|
|
_hover={{
|
|
|
|
|
bg: "hsl(139deg 98.99% 26.59%)",
|
|
|
|
|
}}
|
2024-08-20 19:10:58 +05:30
|
|
|
size={"sm"}
|
2024-07-09 19:05:08 +05:30
|
|
|
rounded={"sm"}
|
2024-07-08 20:14:34 +05:30
|
|
|
>
|
|
|
|
|
Save
|
|
|
|
|
</Button>
|
2024-08-20 19:10:58 +05:30
|
|
|
<Button size={"sm"} rounded={"sm"} mr={3} onClick={onClose}>
|
2024-07-08 20:14:34 +05:30
|
|
|
Close
|
|
|
|
|
</Button>
|
2024-07-30 13:30:34 +05:30
|
|
|
</ModalFooter>
|
2024-07-08 20:14:34 +05:30
|
|
|
</ModalContent>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default DistributionInvestor;
|