|
- // material-ui
- import * as React from 'react';
- import {
- DataGrid,
- GridActionsCellItem
- } from "@mui/x-data-grid";
- import VisibilityIcon from '@mui/icons-material/Visibility';
- import HighlightOff from '@mui/icons-material/HighlightOff';
- import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
- import {useEffect} from "react";
- import {useNavigate} from "react-router-dom";
- import * as DateUtils from "../../utils/DateUtils";
- // ==============================|| EVENT TABLE ||============================== //
-
- export default function UserTable_Individual({recordList}) {
- const [rows, setRows] = React.useState(recordList);
- const [rowModesModel] = React.useState({});
-
- const navigate = useNavigate()
-
- useEffect(() => {
- setRows(recordList);
- }, [recordList]);
-
- const handleActionClick = (id) => () => {
- navigate('/indUser/'+ id);
- };
-
- const columns = [
- {
- field: 'actions',
- type: 'actions',
- headerName: 'Actions',
- width: 100,
- cellClassName: 'actions',
- getActions: ({id}) => {
- return [
- <GridActionsCellItem
- key="OutSave"
- icon={<VisibilityIcon/>}
- label="View"
- className="textPrimary"
- onClick={handleActionClick(id)}
- color="primary"
- />]
- },
- },
- {
- id: 'username',
- field: 'username',
- headerName: 'User Name',
- flex: 1,
- },
- {
- id: 'enName',
- field: 'enName',
- headerName: 'Name (Eng)',
- flex: 1,
- },
- {
- id: 'chName',
- field: 'chName',
- headerName: 'Name (Ch)',
- flex: 1,
- },
- {
- id: 'mobileNumber',
- field: 'mobileNumber',
- headerName: 'Tel.',
- flex: 1,
- valueGetter:(params)=>{
- if(params.value){
- let tel = JSON.parse(params.value);
- return "+"+tel.countryCode+ " "+tel.phoneNumber;
- }
-
- }
- },
- {
- id: 'emailAddress',
- field: 'emailAddress',
- headerName: 'Email',
- flex: 1,
- },
- {
- id: 'lastLogin',
- field: 'lastLogin',
- headerName: 'Last Login',
- flex: 1,
- valueGetter:(params)=>{
- if(params.value){
- return DateUtils.datetimeStr(params.value);
- }
-
- }
- },
- {
- id: 'locked',
- field: 'locked',
- headerName: 'Status',
- flex: 1,
- valueGetter:(params)=>{
- if(params.value){
- return "Locked";
- }else{
- return "Active";
- }
-
- }
- },
- {
- field: 'verifiedDate',
- type: 'actions',
- headerName: 'Verified',
- width: 100,
- cellClassName: 'actions',
- getActions: (params) => {
- if(params.row.verifiedDate)
- return [
- <GridActionsCellItem
- key=""
- icon={<CheckCircleOutline/>}
- color="success"
- />];
- return [
- <GridActionsCellItem
- key=""
- icon={<HighlightOff/>}
- color="error"
- />];
- },
- },
- ];
-
- return (
- <div style={{height: 400, width: '100%'}}>
- <DataGrid
- rows={rows}
- columns={columns}
- editMode="row"
- rowModesModel={rowModesModel}
- initialState={{
- pagination: {
- paginationModel: {page: 0, pageSize: 5},
- },
- }}
- pageSizeOptions={[5, 10]}
- autoHeight = {true}
- />
- </div>
- );
- }
|