// material-ui
import * as React from 'react';
// import {
//     Button
// } from '@mui/material';
import * as FormatUtils from "utils/FormatUtils"
import { useNavigate } from "react-router-dom";
import { FiDataGrid } from "components/FiDataGrid";
// ==============================|| EVENT TABLE ||============================== //

export default function SearchPublicNoticeTable({ recordList }) {
    const [rows, setRows] = React.useState(recordList);
    const navigate = useNavigate()

    const _sx = {
        padding: "4 2 4 2",
        boxShadow: 1,
        border: 1,
        borderColor: '#DDD',
        '& .MuiDataGrid-cell': {
            borderTop: 1,
            borderBottom: 1,
            borderColor: "#EEE"
        },
        '& .MuiDataGrid-footerContainer': {
            border: 1,
            borderColor: "#EEE"
        }
    }

    React.useEffect(() => {
        setRows(recordList);
    }, [recordList]);

    const handleEditClick = (params) => () => {
        navigate('/paymentPage/details/' + params.row.id);
    };

    const columns = [
        // {
        //     field: 'actions',
        //     headerName: 'Trans. No.',
        //     flex: 1,
        //     cellClassName: 'actions',
        //     renderCell: (params) => {
        //         return <Button onClick={handleEditClick(params)}><u>{params.row.transNo}</u></Button>;
        //     },
        // },
        {
            id: 'paymentMethod',
            field: 'paymentMethod',
            headerName: 'Payment Method',
            flex: 4,
            renderCell: (params) => {
                let paymentMethod = params.row.paymentMethod;
                return <div style={{ margin: 4 }}>{paymentMethod}</div>
            },
        },
        {
            id: 'payAmount',
            field: 'payAmount',
            headerName: 'Payment Amount',
            flex: 5,            
            valueGetter: (params) => {
                return (params?.value) ? "$ " + FormatUtils.currencyFormat(params?.value) : "";
            }
        },
    ];
    

    return (
        <div style={{ width: '100%' }}>

            <FiDataGrid
                sx={_sx}
                rowHeight={80}
                rows={rows}
                columns={columns}
                customPageSize={10}
                onRowDoubleClick={handleEditClick}
            />
        </div>
    );
}
