// material-ui
import { useMemo} from 'react';
import {
    useMediaQuery
} from '@mui/material';
import {FiDataGrid} from "components/FiDataGrid";
import * as FormatUtils from "utils/FormatUtils"
import * as DateUtils from "utils/DateUtils"
import * as PaymentStatus from "utils/statusUtils/PaymentStatus"
import {useTheme} from "@emotion/react";
import { clickableLink } from 'utils/CommonFunction';
import {GET_PUBLIC_NOTICE_APPLY_DETAIL_PAYMENT } from "utils/ApiPathConst"
// import * as StatusUtils from "./PublicNoteStatusUtils";
// ==============================|| EVENT TABLE ||============================== //

export default function SubmittedTab({ appId, setCount }) {
    const theme = useTheme();
    const isMdOrLg = useMediaQuery(theme.breakpoints.up('md'));

    const renderHeaderWithAria = (params) => (
        <span aria-label={params.colDef.headerName}>{params.colDef.headerName}</span>
    );

    const columns = [
        {
            field: 'actions',
            headerName: 'Trans. No.',
            width: isMdOrLg ? 'auto' : 160,
            flex: isMdOrLg ? 1 : undefined,
            cellClassName: 'actions',
            renderHeader: renderHeaderWithAria,
            renderCell: (params) => {
                return clickableLink('/paymentPage/details/' + params.row.id, params.row.transNo);
            },
        },
        {
            id: 'transDateTime',
            field: 'transDateTime',
            headerName: 'Trans. Date',
            width: isMdOrLg ? 'auto' : 160,
            flex: isMdOrLg ? 1 : undefined,
            renderHeader: renderHeaderWithAria,
            valueGetter: (params) => {
                return DateUtils.datetimeStr(params.value);
            }
        },
        {
            id: 'status',
            field: 'status',
            headerName: 'Status',
            width: isMdOrLg ? 'auto' : 160,
            flex: isMdOrLg ? 1 : undefined,
            renderHeader: renderHeaderWithAria,
            renderCell: (params) => {
                return PaymentStatus.getStatus_Eng(params);
            }
        },
        {
            id: 'payAmount',
            field: 'payAmount',
            headerName: 'Amount',
            width: 150,
            renderHeader: renderHeaderWithAria,
            valueGetter: (params) => {
                return (params?.value) ? "$ " + FormatUtils.currencyFormat(params?.value) : "";
            }
        },
    ];

    return (
        <>
            <div style={{ height:'20%', width: '98%' }}>
                <FiDataGrid
                    columns={columns}
                    customPageSize={10}
                    doLoad={useMemo(() => ({
                        url: GET_PUBLIC_NOTICE_APPLY_DETAIL_PAYMENT+"/"+appId,
                        params: {},
                        callback: function (responseData) {
                            setCount(responseData?.count);
                        }
                    }), [appId])}
                />
            </div>
        </>
    );



}
