import { Box, Button, Input, Text, Tooltip, useDisclosure, } from "@chakra-ui/react"; import React, { useContext, useEffect, useRef, useState } from "react"; import InvestmentDocuments from "../InvestmentDocuments"; import DataTable from "../../../Components/DataTable/DataTable"; import CustomAlertDialog from "../../../Components/CustomAlertDialog"; import GlobalStateContext from "../../../Contexts/GlobalStateContext"; import { debounce } from "../../Master/Sponser/AddSponser"; import { formatDate } from "../../../Components/Functions/UTCConvertor"; import { AddIcon, DeleteIcon, DownloadIcon, EditIcon, ViewIcon, } from "@chakra-ui/icons"; const IOArtifacts = () => { const { iOArtifacts, setIOArtifacts, slideFromRight } = useContext(GlobalStateContext); const firstField = useRef(); 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, onOpen, onClose } = useDisclosure(); useEffect(() => { // Simulate loading const timer = setTimeout(() => { setIsLoading(false); }, 1500); // Cleanup the timer on component unmount return () => clearTimeout(timer); }, []); const tableHeadRow = [ "Sr.no", "Type", "File Name", "Document", "Action" ]; const handleUpdateStatus = debounce((id) => { setIOArtifacts((prevIOArtifacts) => prevIOArtifacts.map((iOArtifacts) => iOArtifacts.id === id ? { ...iOArtifacts, status: !iOArtifacts.status } : iOArtifacts ) ); toast({ render: () => , }); }, 300); const filteredData = iOArtifacts?.filter((item) => { // Filter by name (case insensitive) const name = item.type; const searchLower = searchTerm.toLowerCase(); const nameMatches = name.toLowerCase().includes(searchLower); return nameMatches; }); const handleDelete = () => { const updatedIOArtifacts = iOArtifacts.filter( (iOArtifacts) => iOArtifacts.id !== actionId ); setTimeout(() => { setSponser(updatedIOArtifacts); setDeleteAlert(false); setIsLoading(false); }, 100); setIsLoading(true); }; const extractedArray = filteredData?.map((item, index) => ({ "Sr.no": ( {index + 1} ), Type: ( {item.type} ), "File Name": ( {item.fileName} ), "Document": ( {item.document} ), Action: ( ), })); return ( setSearchTerm(e.target.value)} /> setDeleteAlert(false)} isOpen={deleteAlert} message={"Are you sure you want to delete sponers?"} alertHandler={handleDelete} isLoading={isLoading} /> ); }; export default IOArtifacts;