// material-ui
import * as React from 'react';
import {
DataGrid,
GridActionsCellItem,
} from "@mui/x-data-grid";
import EditIcon from '@mui/icons-material/Edit';
import PictureAsPdfIcon from '@mui/icons-material/PictureAsPdf';
import {useContext, useEffect} from "react";
import {useNavigate} from "react-router-dom";
import {CustomNoRowsOverlay, dateComparator, getDateString} from "../../../utils/CommonFunction";
import AbilityContext from "../../../components/AbilityProvider";
import {LIONER_BUTTON_THEME} from "../../../themes/colorConst";
import {ThemeProvider} from "@emotion/react";
// ==============================|| CLIENT TABLE ||============================== //
export default function ClientTable({recordList}) {
const [rows, setRows] = React.useState(recordList);
const [rowModesModel] = React.useState({});
const navigate = useNavigate()
const ability = useContext(AbilityContext);
const [paginationModel, setPaginationModel] = React.useState({
page: 0,
pageSize:10
});
useEffect(() => {
setPaginationModel({page:0,pageSize:10});
setRows(recordList);
}, [recordList]);
const handleEditClick = (id) => () => {
navigate('/client/maintain/'+ id);
};
const handlePdfClick = (id) => () => {
navigate(`/pdf/${id}`);
};
const columns = [
{
field: 'actions',
type: 'actions',
headerName: 'Actions',
// flex: 0.5,
width: 100,
cellClassName: 'actions',
getActions: ({id}) => {
return [
}
label="Edit"
className="textPrimary"
onClick={handleEditClick(id)}
color="edit"
// disabled={'true'}
// disabled={!ability.can('VIEW','DASHBOARD')}
/>
}
label="Edit PDF"
className="textPrimary"
onClick={handlePdfClick(id)}
color="edit"
// disabled={'true'}
// disabled={!ability.can('VIEW','DASHBOARD')}
/>
]
},
},
// {
// id: 'title',
// field: 'title',
// headerName: 'Title',
// // sortComparator: dateComparator,
// flex: 0.75,
// renderCell: (params) => (
//
// {params.value}
//
// //
// // {getDateString(params.row.clientFrom,false)}
// //
// ),
// },
{
id: 'fullname',
field: 'fullname',
headerName: 'Client Name',
flex: 1.5,
renderCell: (params) => {
return (
{params.value}
{/* {params.row.title ? `(${params.row.title})` : ''} {params.value} */}
);
}
},
{
id: 'title',
field: 'title',
headerName: 'Title',
flex: 1.5,
},
{
id: 'joinDate',
field: 'joinDate',
headerName: 'Join Date',
flex: 1,
sortComparator: dateComparator,
renderCell: (params) => (
{getDateString(params.row.joinDate, 'dd/MM/yyyy')}
),
},
// {
// id: 'lastname',
// field: 'lastname',
// headerName: 'Last Name',
// flex: 1.5,
// sortComparator: dateComparator,
// renderCell: (params) => (
//
// {params.value}
//
// //
// // {getDateString(params.row.startDate,false)}
// //
// ),
// },
// {
// id: 'firstname',
// field: 'firstname',
// headerName: 'First Name',
// // sortComparator: dateComparator,
// flex: 2,
// renderCell: (params) => (
//
// {params.value}
//
// //
// // {getDateString(params.row.applicationDeadline,false)}
// //
// ),
// },
{
id: 'email',
field: 'email',
headerName: 'Email',
flex: 1.5,
renderCell: (params) => {
return (
{params.value}
);
}
},
{
id: 'phone1',
field: 'phone1',
headerName: 'Phone No.',
flex: 1,
renderCell: (params) => {
return (
{params.value}
);
}
},
{
id: 'phone2',
field: 'phone2',
headerName: '2nd Phone No.',
flex: 1,
renderCell: (params) => {
return (
{params.value}
);
}
},
{
id: 'remarks',
field: 'remarks',
headerName: 'Remarks',
flex: 3,
renderCell: (params) => {
return (
{params.value}
);
}
},
];
return (
'auto'}
paginationModel={paginationModel}
onPaginationModelChange={setPaginationModel}
slots={{
noRowsOverlay: () => (
CustomNoRowsOverlay()
)
}}
pageSizeOptions={[10]}
autoHeight
/>
);
}