// material-ui
import {FiDataGrid} from "components/FiDataGrid";
import * as DateUtils from "utils/DateUtils"
import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
import {useTheme} from "@emotion/react";
import {useMediaQuery} from "@mui/material";

import {GET_PUBLIC_NOTICE_APPLY_DETAIL_STATUS_HISTORY } from "utils/ApiPathConst"

// ==============================|| EVENT TABLE ||============================== //

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

    const columns = [
        {
            id: 'created',
            field: 'created',
            headerName: 'Date',
            width: isMdOrLg ? 'auto' : 160,
            flex: isMdOrLg ? 1 : undefined,
            valueGetter: (params) => {
                return DateUtils.datetimeStr(params?.value);
            }
            
        },
        {
            id: 'createdBy',
            field: 'createdBy',
            headerName: 'Changed By',
            width: isMdOrLg ? 'auto' : 160,
            flex: isMdOrLg ? 1 : undefined,
        },
        {
            id: 'status',
            field: 'status',
            headerName: 'Status',
            width: isMdOrLg ? 'auto' : 160,
            flex: isMdOrLg ? 1 : undefined,
            renderCell: (params) => {
                return [StatusUtils.getStatusEng(params)]
            },
        },
    ];

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