import React, { useState } from 'react'
import {
    Paper,
    Table,
    TableBody,
    TableCell,
    TableHead,
    TableContainer,
    TablePagination,
    TableRow,
    IconButton,
    MenuItem,
    Tooltip,
    Icon,
} from '@material-ui/core'
import EditIcon from '@material-ui/icons/Edit'
import DeleteIcon from '@material-ui/icons/Delete'
import colors from '../../assets/Color'
import useStyles from '../../styles/Table'
import { Breadcrumb, SimpleCard } from 'app/components'
import { toPriceVnd } from 'app/config/Function'
const columns = [
    {
        id: 'index',
        label: 'STT',
        align: 'center',
        minWidth: 80,
    },

    {
        id: 'date_trans',
        label: 'Ngày giao dịch',
        align: 'left',
        minWidth: 'auto',
    },

    {
        id: 'store_name',
        label: 'Tên cây xăng',
        align: 'left',
        minWidth: 'auto',
    },
    {
        id: 'total_trans',
        label: 'Tổng số giao dịch',
        align: 'left',
        minWidth: 'auto',
    },

    {
        id: 'fee',
        label: 'Tổng phí phải nộp',
        align: 'left',
        minWidth: 'auto',
        isMonney: true,
    },

    {
        id: 'status',
        label: 'Trạng thái thu phí',
        align: 'left',
        minWidth: 160,
    },
]

function TableList(props) {
    const classes = useStyles()
    const {
        data,
        handeChangeActive,
        removeItem,
        changeActive,
        setChangeActive,
        setPageIndex,
        setPageSize,
        pageIndex,
        totalRecords,
    } = props

    const handleChangePage = (event, newPage) => {
        setPageIndex(newPage)
    }
    const handleChangeRowsPerPage = (event) => {
        setPageSize(event.target.value)
    }

    return (
        <Paper className={classes.root}>
            <TableContainer className={classes.container}>
                <Table stickyHeader aria-label="sticky table">
                    <TableHead>
                        <TableRow>
                            {columns.map((column) => (
                                <TableCell
                                    key={column.id}
                                    align={'center'}
                                    style={{
                                        width: column.minWidth,
                                        backgroundColor: colors.headerTable,
                                    }}
                                >
                                    {column.label}
                                </TableCell>
                            ))}
                        </TableRow>
                    </TableHead>
                    <TableBody className={classes.columnTable}>
                        {data.map((row) => {
                            return (
                                <TableRow
                                    hover
                                    role="checkbox"
                                    tabIndex={-1}
                                    key={row.id}
                                >
                                    {columns.map((column) => {
                                        const data = row[column.id]
                                        return (
                                            <TableCell
                                                key={column.id}
                                                align={column.align}
                                                style={{
                                                    textAlign:
                                                        column.id === 'index'
                                                            ? 'center'
                                                            : typeof data ==
                                                              'string'
                                                            ? 'left'
                                                            : 'right',
                                                }}
                                            >
                                                {column.isMonney
                                                    ? toPriceVnd(data)
                                                    : data}
                                            </TableCell>
                                        )
                                    })}
                                </TableRow>
                            )
                        })}
                    </TableBody>
                </Table>
            </TableContainer>
            <TablePagination
                component="div"
                page={pageIndex}
                count={totalRecords}
                rowsPerPage={10}
                rowsPerPageOptions={[]}
                onChangePage={handleChangePage}
                onChangeRowsPerPage={handleChangeRowsPerPage}
            />
        </Paper>
    )
}

export default TableList
