import {
Avatar,
Badge,
Box,
Button,
HStack,
Input,
Text,
Tooltip,
useToast,
} from "@chakra-ui/react";
import React, { useContext, useEffect, useState } from "react";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
import DataTable from "../../Components/DataTable/DataTable";
import Pagination from "../../Components/Pagination";
import GlobalStateContext from "../../Contexts/GlobalStateContext";
import CustomAlertDialog from "../../Components/CustomAlertDialog";
import { formatDate } from "../../Components/Functions/UTCConvertor";
import { CheckIcon, CloseIcon } from "@chakra-ui/icons";
// import { formatDate } from "../../Components/Functions/UTCConvertor";
const PendingRequest = () => {
const toast = useToast();
const { slideFromRight, pendingRequest, setPendingRequest } =
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 Filter]================================================================
const filteredData = pendingRequest.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;
});
// ====================================================[Table Setup]================================================================
const tableHeadRow = [
"Sr.no",
"Date",
"Client ID",
"First Name",
"Last Name",
"Country",
"Phone Number",
"Currency",
"Withdrawal Amount",
"Amount in Investor currency",
"Action",
];
const [extractedArray, setExtractedArray] = useState(
filteredData?.map((item, index) => ({
// id: item?.id,
"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}
),
"Withdrawal Amount": (
{item.withDrawalAmount}
),
"Amount in Investor currency": (
{item.amountcurrency}
),
Action: (
),
}))
);
const handleDelete = () => {
const updatedSponsors = sponser.filter(
(sponsor) => sponsor.id !== actionId
);
setTimeout(() => {
setSponser(updatedSponsors);
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 PendingRequest;