From a944303707a83c49f6a96bdf96165dcfddcf605a Mon Sep 17 00:00:00 2001 From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:19:45 +0530 Subject: [PATCH] withdrawal table --- src/Contexts/GlobalStateProvider.jsx | 309 ++++++------------ src/Pages/Admin/BankInvestor.jsx | 57 +++- src/Pages/Deposit/DepositHistory.jsx | 272 --------------- src/Pages/Deposit/DepositRequest.jsx | 19 +- .../DepositViewHistory/ConfirmModal.jsx | 128 ++++++++ .../DepositViewHistory/DepositHistory.jsx | 307 +++++++++++++++++ .../DepositViewHistory/RejectModal.jsx | 99 ++++++ .../CreateIO/InvestmentDocument.jsx | 3 +- .../InvestorDetails/InvestorDetails.jsx | 63 +--- .../InvestorDetails/ProfileView.jsx | 62 +++- .../InvestorDetails/ViewInvestorDetails.jsx | 26 +- .../WithDrawal/DrawalView/ConfirmModal.jsx | 95 ++++++ .../WithDrawal/DrawalView/RejectModal.jsx | 100 ++++++ .../WithDrawal/DrawalView/ViewHistory.jsx | 274 ++++++++++++++++ src/Pages/WithDrawal/PendingRequest.jsx | 247 ++++++++------ src/Pages/WithDrawal/ViewHistory.jsx | 220 ------------- src/Routes/Routes.js | 6 +- 17 files changed, 1375 insertions(+), 912 deletions(-) delete mode 100644 src/Pages/Deposit/DepositHistory.jsx create mode 100644 src/Pages/Deposit/DepositViewHistory/ConfirmModal.jsx create mode 100644 src/Pages/Deposit/DepositViewHistory/DepositHistory.jsx create mode 100644 src/Pages/Deposit/DepositViewHistory/RejectModal.jsx create mode 100644 src/Pages/WithDrawal/DrawalView/ConfirmModal.jsx create mode 100644 src/Pages/WithDrawal/DrawalView/RejectModal.jsx create mode 100644 src/Pages/WithDrawal/DrawalView/ViewHistory.jsx delete mode 100644 src/Pages/WithDrawal/ViewHistory.jsx diff --git a/src/Contexts/GlobalStateProvider.jsx b/src/Contexts/GlobalStateProvider.jsx index 2b8d04c..b8a573d 100644 --- a/src/Contexts/GlobalStateProvider.jsx +++ b/src/Contexts/GlobalStateProvider.jsx @@ -756,6 +756,7 @@ const GlobalStateProvider = ({ children }) => { const [InvestorDetails, setInvestorDetails] = useState([ { id: 1, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -773,6 +774,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 2, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -790,6 +792,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 3, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -807,6 +810,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 4, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -824,6 +828,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 5, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -841,6 +846,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 6, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -858,6 +864,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 7, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -875,6 +882,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 8, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -892,6 +900,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 9, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -909,6 +918,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 10, + clientId:"SA00000001", fullName:"John David", firstName:"John", lastName: "David", @@ -930,7 +940,7 @@ const GlobalStateProvider = ({ children }) => { { id: 1, dealId:"UWE3424992", - dealId: "KKR Private Equity Fund", + dealName: "KKR Private Equity Fund", sponsorName: "KKR", investAmount: "$100,000", holdingPeriod: "4-5 years", @@ -940,7 +950,7 @@ const GlobalStateProvider = ({ children }) => { { id: 2, dealId:"UWE3424992", - dealId: "Blackstone Real Estate Income Trust", + dealName: "Blackstone Real Estate Income Trust", sponsorName: "Blackstone", investAmount: "$100,000", holdingPeriod: "4-5 years", @@ -950,7 +960,7 @@ const GlobalStateProvider = ({ children }) => { { id: 3, dealId:"UWE3424992", - dealId: "J.P. Morgan", + dealName: "J.P. Morgan", sponsorName: "J.P. Morgan", investAmount: "$100,000", holdingPeriod: "4-5 years", @@ -989,224 +999,109 @@ const GlobalStateProvider = ({ children }) => { Action: "Distribute", }, ]); + const [pendingRequest, setPendingRequest] = useState([ { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, + id: 1, + date:"02-Jan-2024", + clientId: "SA00000001", + firstName: "John", + lastName: "David", + country: "Saudi Arabia", + phoneNumber: "8940035906", + currency: "SAR", + withDrawalAmount: "$100,000", + amountcurrency:"382574.17", }, { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, + id: 2, + date:"02-Jan-2024", + clientId: "KU00000001", + firstName: "Faisal", + lastName: "Aljalahma", + country: "Kuwait", + phoneNumber: "8226278945", + currency: "KWD", + withDrawalAmount: "$200,000", + amountcurrency:"62438.98", }, { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, + id: 3, + date:"02-Jan-2024", + clientId: "BH00000001", + firstName: "Nawaf", + lastName: "Almaskati", + country: "Bahrain", + phoneNumber: "8940035906", + currency: "BHD", + withDrawalAmount: "$300,000", + amountcurrency:"115328.04", }, { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, + id: 4, + date:"02-Jan-2024", + clientId: "SA00000002", + firstName: "Sulaiman", + lastName: "AlBassam", + country: "Saudi Arabia", + phoneNumber: "8226278945", + currency: "SAR", + withDrawalAmount: "$400,000", + amountcurrency:"1530296.67", }, ]); const [viewHistory, setViewHistory] = useState([ { - id: uuidv4(), - date: "2024-01-15", - Distribution: "Office supplies", - charge: "200.50", - year: "2024", - quarter: "Q1", - amount: 1500, + id: 1, + date:"02-Jan-2024", + clientId: "SA00000001", + firstName: "John", + lastName: "David", + country: "Saudi Arabia", + phoneNumber: "8940035906", + currency: "SAR", + withDrawalAmount: "$100,000", + amountcurrency:"382574.17", + status:"Approved", }, { - id: uuidv4(), - date: "2024-02-10", - Distribution: "Marketing expenses", - charge: "450.00", - year: "2024", - quarter: "Q1", - amount: 2000, + id: 2, + date:"02-Jan-2024", + clientId: "KU00000001", + firstName: "Faisal", + lastName: "Aljalahma", + country: "Kuwait", + phoneNumber: "8226278945", + currency: "KWD", + withDrawalAmount: "$200,000", + amountcurrency:"62438.98", + status:"Rejected", }, { - id: uuidv4(), - date: "2024-03-05", - Distribution: "Software subscription", - charge: "300.75", - year: "2024", - quarter: "Q1", - amount: 1200, + id: 3, + date:"02-Jan-2024", + clientId: "BH00000001", + firstName: "Nawaf", + lastName: "Almaskati", + country: "Bahrain", + phoneNumber: "8940035906", + currency: "BHD", + withDrawalAmount: "$300,000", + amountcurrency:"115328.04", + status:"Approved", }, { - id: uuidv4(), - date: "2024-04-18", - Distribution: "Travel expenses", - charge: "600.30", - year: "2024", - quarter: "Q2", - amount: 2500, - }, - { - id: uuidv4(), - date: "2024-05-22", - Distribution: "Consulting fees", - charge: "800.00", - year: "2024", - quarter: "Q2", - amount: 3000, - }, - { - id: uuidv4(), - date: "2024-06-14", - Distribution: "Office rent", - charge: "1200.25", - year: "2024", - quarter: "Q2", - amount: 3500, - }, - { - id: uuidv4(), - date: "2024-07-09", - Distribution: "Utilities", - charge: "150.40", - year: "2024", - quarter: "Q3", - amount: 1000, - }, - { - id: uuidv4(), - date: "2024-08-29", - Distribution: "Employee training", - charge: "500.00", - year: "2024", - quarter: "Q3", - amount: 1800, - }, - { - id: uuidv4(), - date: "2024-09-13", - Distribution: "Website maintenance", - charge: "350.65", - year: "2024", - quarter: "Q3", - amount: 1400, - }, - { - id: uuidv4(), - date: "2024-10-23", - Distribution: "Advertising", - charge: "900.50", - year: "2024", - quarter: "Q4", - amount: 2200, - }, - { - id: uuidv4(), - date: "2024-10-23", - Distribution: "Advertising", - charge: "900.50", - year: "2024", - quarter: "Q4", - amount: 2200, - }, - { - id: uuidv4(), - date: "2024-10-23", - Distribution: "Advertising", - charge: "900.50", - year: "2024", - quarter: "Q4", - amount: 2200, + id: 4, + date:"02-Jan-2024", + clientId: "SA00000002", + firstName: "Sulaiman", + lastName: "AlBassam", + country: "Saudi Arabia", + phoneNumber: "8226278945", + currency: "SAR", + withDrawalAmount: "$400,000", + amountcurrency:"1530296.67", + status:"Rejected", }, ]); const [upgradeHistory, setUpgradeHistory] = useState([ @@ -1766,6 +1661,7 @@ const GlobalStateProvider = ({ children }) => { const [depositRequest, setDepositRequest] = useState([ { id: 1, + date:"02-Jan-2024", clientId: "SA00000001", firstName: "John", lastName: "David", @@ -1779,6 +1675,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 2, + date:"02-Jan-2024", clientId: "KU00000001", firstName: "Faisal", lastName: "Aljalahma", @@ -1792,6 +1689,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 3, + date:"02-Jan-2024", clientId: "BH00000001", firstName: "Nawaf", lastName: "Almaskati", @@ -1805,6 +1703,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 4, + date:"02-Jan-2024", clientId: "SA00000002", firstName: "Sulaiman", lastName: "AlBassam", @@ -1821,6 +1720,7 @@ const GlobalStateProvider = ({ children }) => { const [depositHistory, setDepositHistory] = useState([ { id: 1, + date:"02-Jan-2024", clientId: "SA00000001", firstName: "John", lastName: "David", @@ -1835,6 +1735,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 2, + date:"02-Jan-2024", clientId: "KU00000001", firstName: "Faisal", lastName: "Aljalahma", @@ -1849,6 +1750,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 3, + date:"02-Jan-2024", clientId: "BH00000001", firstName: "Nawaf", lastName: "Almaskati", @@ -1863,6 +1765,7 @@ const GlobalStateProvider = ({ children }) => { }, { id: 4, + date:"02-Jan-2024", clientId: "SA00000002", firstName: "Sulaiman", lastName: "AlBassam", diff --git a/src/Pages/Admin/BankInvestor.jsx b/src/Pages/Admin/BankInvestor.jsx index f2045d2..cde3502 100644 --- a/src/Pages/Admin/BankInvestor.jsx +++ b/src/Pages/Admin/BankInvestor.jsx @@ -1,22 +1,43 @@ -import { Box, Image, Text } from "@chakra-ui/react" +import { Box, HStack, Image, Input, Text } from "@chakra-ui/react"; // import error from "../assets/Error.svg" -import robot from "../../assets/robot.png" +import robot from "../../assets/robot.png"; +import { OPACITY_ON_LOAD } from "../../Layout/animations"; +import { useState } from "react"; +import Pagination from "../../Components/Pagination"; // import robot from "../assets/robot.png" const BankInvestor = () => { - return ( - - - - {/* The requested URL was not found on this server. */} - - ) -} + const [searchTerm, setSearchTerm] = useState(""); -export default BankInvestor \ No newline at end of file + return ( + + + + setSearchTerm(e.target.value)} + > + {/* + + */} + + + + + ); +}; + +export default BankInvestor; diff --git a/src/Pages/Deposit/DepositHistory.jsx b/src/Pages/Deposit/DepositHistory.jsx deleted file mode 100644 index afea25b..0000000 --- a/src/Pages/Deposit/DepositHistory.jsx +++ /dev/null @@ -1,272 +0,0 @@ -import { - Badge, - Box, - Button, - HStack, - Input, - Switch, - Text, - Tooltip, - useToast, - } from "@chakra-ui/react"; - import React, { useContext, useEffect, useState } from "react"; - import { HiDotsVertical } from "react-icons/hi"; - import { Link, Link as RouterLink, useNavigate } from "react-router-dom"; - import { - AddIcon, - CheckIcon, - CloseIcon, - DeleteIcon, - EditIcon, - ViewIcon, - } from "@chakra-ui/icons"; - // import { debounce } from "./AddInvestmentType"; - import { debounce } from "../Master/Sponser/AddSponser"; - import { OPACITY_ON_LOAD } from "../../Layout/animations"; - import Pagination from "../../Components/Pagination"; - import GlobalStateContext from "../../Contexts/GlobalStateContext"; - import CustomAlertDialog from "../../Components/CustomAlertDialog"; - import ToastBox from "../../Components/ToastBox"; - import DataTable from "../../Components/DataTable/DataTable"; - - const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter - - const DepositHistory = () => { - const navigate = useNavigate(); - const toast = useToast(); - const { depositHistory, setDepositHistory, slideFromRight } = - useContext(GlobalStateContext); - const [searchTerm, setSearchTerm] = useState(""); - const [isLoading, setIsLoading] = useState(true); - const [deleteAlert, setDeleteAlert] = useState(false); - const [actionId, setActionId] = useState(false); - const [mouseEntered, setMouseEntered] = useState(false); - const [mouseEnteredId, setMouseEnteredId] = useState(""); - - useEffect(() => { - // Simulate loading - const timer = setTimeout(() => { - setIsLoading(false); - }, 1500); - - // Cleanup the timer on component unmount - return () => clearTimeout(timer); - }, []); - - // ====================================================[Table Setup]================================================================ - const tableHeadRow = [ - "Sr.no", - "Client ID", - "First Name", - "Last Name", - "Country", - "Phone Number", - "Currency", - "Deposit Amount", - "Fees", - "Total Amount", - "Amount in Investor currency", - "Status", - ]; - - const handleUpdateStatus = debounce((id) => { - setDepositHistory((prevDepositHistory) => - prevDepositHistory.map((depositHistory) => - depositHistory.id === id - ? { ...depositHistory, status: !depositHistory.status } - : depositHistory - ) - ); - toast({ - render: () => , - }); - }, 300); - - // ====================================================[Table Filter]================================================================ - const filteredData = depositHistory.filter((item) => { - // Filter by name (case insensitive) - const name = item.clientId; - const searchLower = searchTerm.toLowerCase(); - const nameMatches = name.toLowerCase().includes(searchLower); - - // Filter by status - // const status = item.status; - // const statusLower = status ? "active" : "inactive"; - - // const statusMatches = - // statusFilter === "all" || - // (statusFilter === "active" && status === true) || - // (statusFilter === "inactive" && status === false); - - return nameMatches; - }); - - const [extractedArray, setExtractedArray] = useState( - filteredData?.map((item, index) => ({ - // id: item?.id, - "Sr.no": ( - - {index + 1} - - ), - "Client ID": ( - - {item.clientId} - - ), - "First Name": ( - - - {item.firstName} - - - ), - "Last Name": ( - - - {item.lastName} - - - ), - Country: ( - - - {item.country} - - - ), - "Phone Number": ( - - - {item.phoneNumber} - - - ), - Currency: ( - - - {item.currency} - - - ), - "Deposit Amount": ( - - - {item.depositAmount} - - - ), - Fees: ( - - - {item.fees} - - - ), - "Total Amount": ( - - - {item.totalAmount} - - - ), - "Amount in Investor currency": ( - - - {item.amountcurrency} - - - ), - Status: ( - - - {item.status} - - - ), - })) - ); - - const handleDelete = () => { - const IOtype = investmentType.filter( - (investmentType) => investmentType.id !== actionId - ); - - setTimeout(() => { - setInvestmentType(IOtype); - setDeleteAlert(false); - setIsLoading(false); - }, 100); - setIsLoading(true); - }; - - return ( - - - - setSearchTerm(e.target.value)} - /> - - - - - - - - - - setDeleteAlert(false)} - isOpen={deleteAlert} - message={"Are you sure you want to delete sponers?"} - alertHandler={handleDelete} - isLoading={isLoading} - /> - - ); - }; - - export default DepositHistory; - \ No newline at end of file diff --git a/src/Pages/Deposit/DepositRequest.jsx b/src/Pages/Deposit/DepositRequest.jsx index b165697..882d5d7 100644 --- a/src/Pages/Deposit/DepositRequest.jsx +++ b/src/Pages/Deposit/DepositRequest.jsx @@ -56,6 +56,7 @@ const DepositRequest = () => { // ====================================================[Table Setup]================================================================ const tableHeadRow = [ "Sr.no", + "Date", "Client ID", "First Name", "Last Name", @@ -116,6 +117,18 @@ const DepositRequest = () => { {index + 1} ), + "Date": ( + + {item.date} + + ), "Client ID": ( { { px={2} py={1} > - Approve + { px={2} py={1} > - Reject + diff --git a/src/Pages/Deposit/DepositViewHistory/ConfirmModal.jsx b/src/Pages/Deposit/DepositViewHistory/ConfirmModal.jsx new file mode 100644 index 0000000..d2b854f --- /dev/null +++ b/src/Pages/Deposit/DepositViewHistory/ConfirmModal.jsx @@ -0,0 +1,128 @@ +import { + Box, + Button, + FormControl, + FormLabel, + Input, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Text, + useDisclosure, +} from "@chakra-ui/react"; +import React from "react"; +import * as yup from "yup"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { useForm } from "react-hook-form"; + +export const conformModalSchema = yup.object().shape({ + fees: yup.string().required("File name is required"), + totalAmount: yup.string().required("File name is required"), +}); + +const ConfirmModal = ({ isOpen, onClose, firstField }) => { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: yupResolver(conformModalSchema), + }); + + const onSubmit = (data) => { + console.log(data); + setFile(data.document[0]); + + const newDocument = { + ...data, + document: data.document[0].name, // Store the document name + status: true, + id: uuidv4(), + createdAt: new Date().toISOString(), + Type: getFileIcon(file.type), + }; + + setCreate((prevCreate) => [...prevCreate, newDocument]); + onClose(); + }; + + const handleFileChange = (event) => { + const selectedFile = event.target.files[0]; + setFile(selectedFile); + }; + + return ( + + + + Confirm + + + + + Deposit Amount + + + + Fees + + {errors.fees && ( + + {errors.fees.message} + + )} + + + Total Amount + + {errors.totalAmount && ( + + {errors.totalAmount.message} + + )} + + + + + + + + + + ); +}; + +export default ConfirmModal; diff --git a/src/Pages/Deposit/DepositViewHistory/DepositHistory.jsx b/src/Pages/Deposit/DepositViewHistory/DepositHistory.jsx new file mode 100644 index 0000000..7c22add --- /dev/null +++ b/src/Pages/Deposit/DepositViewHistory/DepositHistory.jsx @@ -0,0 +1,307 @@ +import { + Badge, + Box, + Button, + HStack, + Input, + Switch, + Text, + Tooltip, + useToast, + useDisclosure +} from "@chakra-ui/react"; +import React, { useContext, useEffect, useState } from "react"; +import { HiDotsVertical } from "react-icons/hi"; +import { Link, Link as RouterLink, useNavigate } from "react-router-dom"; +import { debounce } from "../../Master/Sponser/AddSponser"; +import { OPACITY_ON_LOAD } from "../../../Layout/animations"; +import Pagination from "../../../Components/Pagination"; +import GlobalStateContext from "../../../Contexts/GlobalStateContext"; +import CustomAlertDialog from "../../../Components/CustomAlertDialog"; +import ToastBox from "../../../Components/ToastBox"; +import DataTable from "../../../Components/DataTable/DataTable"; +import ConfirmModal from "./ConfirmModal"; +import RejectModal from "./RejectModal"; + +const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter + +const DepositHistory = () => { + const navigate = useNavigate(); + const toast = useToast(); + const { depositHistory, setDepositHistory, slideFromRight } = + useContext(GlobalStateContext); + const [searchTerm, setSearchTerm] = useState(""); + const [isLoading, setIsLoading] = useState(true); + const [deleteAlert, setDeleteAlert] = useState(false); + const [actionId, setActionId] = useState(false); + const [mouseEntered, setMouseEntered] = useState(false); + const [mouseEnteredId, setMouseEnteredId] = useState(""); + const { + isOpen: isConfirmOpen, + onOpen: onConfirmOpen, + onClose: onConfirmClose, + } = useDisclosure(); + const { + isOpen: isRejectOpen, + onOpen: onRejectOpen, + onClose: onRejectClose, + } = useDisclosure(); + + useEffect(() => { + // Simulate loading + const timer = setTimeout(() => { + setIsLoading(false); + }, 1500); + + // Cleanup the timer on component unmount + return () => clearTimeout(timer); + }, []); + + // ====================================================[Table Setup]================================================================ + const tableHeadRow = [ + "Sr.no", + "Date", + "Client ID", + "First Name", + "Last Name", + "Country", + "Phone Number", + "Currency", + "Deposit Amount", + "Fees", + "Total Amount", + "Amount in Investor currency", + "Status", + ]; + + const handleUpdateStatus = debounce((id) => { + setDepositHistory((prevDepositHistory) => + prevDepositHistory.map((depositHistory) => + depositHistory.id === id + ? { ...depositHistory, status: !depositHistory.status } + : depositHistory + ) + ); + toast({ + render: () => , + }); + }, 300); + + // ====================================================[Table Filter]================================================================ + const filteredData = depositHistory.filter((item) => { + // Filter by name (case insensitive) + const name = item.clientId; + const searchLower = searchTerm.toLowerCase(); + const nameMatches = name.toLowerCase().includes(searchLower); + + return nameMatches; + }); + + // const handleView = (id) => { + // setActionId(id); + // onViewOpen(); + // }; + + const [extractedArray, setExtractedArray] = useState( + filteredData?.map((item, index) => ({ + "Sr.no": ( + + {index + 1} + + ), + "Date": ( + + {item.date} + + ), + "Client ID": ( + + {item.clientId} + + ), + "First Name": ( + + + {item.firstName} + + + ), + "Last Name": ( + + + {item.lastName} + + + ), + Country: ( + + + {item.country} + + + ), + "Phone Number": ( + + + {item.phoneNumber} + + + ), + Currency: ( + + + + {item.currency} + + + + ), + "Deposit Amount": ( + + + {item.depositAmount} + + + ), + Fees: ( + + + {item.fees} + + + ), + "Total Amount": ( + + + {item.totalAmount} + + + ), + "Amount in Investor currency": ( + + + {item.amountcurrency} + + + ), + Status: ( + + { + // setActionId(item.id); + // onConfirmOpen(); + // }} + onClick={() => { + setActionId(item.id); + if (item.status === "Approved") { + onConfirmOpen(); + } else { + onRejectOpen(); + } + }} + as={"span"} + color={item.status === "Approved" ? "green" : "red"} + > + {item.status} + + + ), + })) + ); + + const handleDelete = () => { + const IOtype = investmentType.filter( + (investmentType) => investmentType.id !== actionId + ); + + setTimeout(() => { + setInvestmentType(IOtype); + setDeleteAlert(false); + setIsLoading(false); + }, 100); + setIsLoading(true); + }; + + return ( + + + + + + setSearchTerm(e.target.value)} + /> + + + + + + + + + + setDeleteAlert(false)} + isOpen={deleteAlert} + message={"Are you sure you want to delete sponers?"} + alertHandler={handleDelete} + isLoading={isLoading} + /> + + ); +}; + +export default DepositHistory; diff --git a/src/Pages/Deposit/DepositViewHistory/RejectModal.jsx b/src/Pages/Deposit/DepositViewHistory/RejectModal.jsx new file mode 100644 index 0000000..66952dd --- /dev/null +++ b/src/Pages/Deposit/DepositViewHistory/RejectModal.jsx @@ -0,0 +1,99 @@ +import { + Box, + Button, + FormControl, + FormLabel, + Input, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Text, + Textarea, + useDisclosure, +} from "@chakra-ui/react"; +import React from "react"; +import * as yup from "yup"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { useForm } from "react-hook-form"; + +export const conformModalSchema = yup.object().shape({ + comment: yup.string().required("Comment is required"), +}); + +const RejectModal = ({ isOpen, onClose, firstField }) => { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: yupResolver(conformModalSchema), + }); + + const onSubmit = (data) => { + console.log(data); + setFile(data.document[0]); + + const newDocument = { + ...data, + document: data.document[0].name, // Store the document name + comment: true, + id: uuidv4(), + Type: getFileIcon(file.type), + }; + + setCreate((prevCreate) => [...prevCreate, newDocument]); + onClose(); + }; + + const handleFileChange = (event) => { + const selectedFile = event.target.files[0]; + setFile(selectedFile); + }; + + return ( + + + + Reject + + + + + Comment +