"use client"; import { useCallback, useEffect, useState } from "react"; import { Button, Dialog, DialogTitle, DialogContent, DialogActions, FormControl, Select, MenuItem, FormControlLabel, Checkbox, Stack, Paper, styled, TextField, } from "@mui/material"; import FileUploadIcon from "@mui/icons-material/FileUpload"; import { DataGrid } from "@mui/x-data-grid"; import { depositTransactionsColumns, Labels } from "./constants"; import AdvancedSearch1 from "../../AdvancedSearch/AdvancedSearch1"; import SearchFilters from "@/app/components/searchFilter/SearchFilters"; import { exportData } from "@/app/utils/exportData"; import { ITransaction } from "./types"; import { useSearchParams, useRouter } from "next/navigation"; const paginationModel = { page: 0, pageSize: 50 }; interface DepositProps { data: any } const DepositsTransactionsTable: React.FC = ({ data }) => { const router = useRouter() const searchParams = useSearchParams() // const [form, setForm] = useState({ // userId: "", // transactionId: "", // transactionReferenceId: "", // currency: "", // state: "", // depositMethod: "", // dateTime: "", // }); const [open, setOpen] = useState(false); const [fileType, setFileType] = useState<"csv" | "xls" | "xlsx">("csv"); const [onlyCurrentTable, setOnlyCurrentTable] = useState(false); const [transactions, setTransactions] = useState([]); // console.log(777, form) // const fetchTransactions = useCallback(async () => { // try { // const stringForm: Record = Object.fromEntries( // Object.entries(form).map(([key, value]) => [key, value === null ? "" : String(value)]) // ); // const query = new URLSearchParams(stringForm).toString(); // const res = await fetch(`/api/transactions/deposit?${query}`); // const data = await res.json(); // setTransactions(data); // } catch (error) { // console.error('Error fetching transactions:', error); // } // }, [form]); const resetForm = () => { // setForm({ // userId: "", // transactionId: "", // transactionReferenceId: "", // currency: "", // state: "", // depositMethod: "", // dateTime: "", // }); }; // useEffect(() => { // fetchTransactions(); // }, [form, fetchTransactions]); const handleDeleteFilter = (key: string) => { // setForm((prev) => ({ ...prev, [key]: '' })); }; const handleClearAll = () => { // resetForm() // fetchTransactions() }; const handleClickField = (field: string, value: string) => { // setForm((prev) => ({ ...prev, [field]: value })); const params = new URLSearchParams(searchParams.toString()) params.set(field, value) router.push(`?${params.toString()}`) router.refresh() }; return ( console.log(`setSearchQuery(${e.target.value})`)} sx={{ width: 300 }} /> {/* */} {/* */} { handleClickField(params.field, params.value as string) }} /> {/* Export Dialog */} setOpen(false)}> Export Transactions setOnlyCurrentTable(e.target.checked)} /> } label="Only export the results in the current table" sx={{ mt: 2 }} /> ); } const StyledPaper = styled(Paper)(() => ({ height: "90vh", width: "80vw" })); export default DepositsTransactionsTable