import React, { Fragment, useState, useEffect } from 'react'
import {
    TextField,
    Icon,
    Button,
    StepLabel,
    Step,
    Stepper,
    Grid,
    FormControl,
    InputLabel,
    Select,
    MenuItem,
} from '@material-ui/core'
import Table from './Table'
import { Breadcrumb } from 'app/components'
import { Link } from 'react-router-dom'
import { Autocomplete, createFilterOptions } from '@material-ui/lab'
import useAuth from 'app/hooks/useAuth'
import { checkRole } from 'app/config/Function'
function CustomerView(props) {
    const [age, setAge] = React.useState('')
    const {
        data,
        updateItem,
        removeItem,
        setTxtSearch,
        changeActive,
        setChangeActive,
        handeChangeActive,
        setPageIndex,
        pageIndex,
        totalRecords,

        status,
        setStatus,
        store,
        setStore,
        listDrop,
        listGroup,
        group,
        setGroup,
    } = props
    const handleChange = (event) => {
        setAge(event.target.value)
    }
    const { user } = useAuth()

    return (
        <Fragment>
            <div className="m-sm-30">
                <div className="mb-sm-30">
                    <Breadcrumb
                        routeSegments={[
                            {
                                name: 'Danh sách nhà cung cấp hoá đơn',
                                path: '/invoice-supplier',
                            },
                        ]}
                    />
                </div>

                <Grid
                    style={{
                        padding: 10,
                        marginBottom: 20,
                    }}
                    justify={'space-between'}
                    alignItems={'center'}
                    container
                    spacing={3}
                >
                    <Grid
                        spacing={3}
                        container
                        item
                        lg={8}
                        md={8}
                        sm={8}
                        xs={8}
                    >
                        <Grid item lg={3} md={3} sm={3} xs={3}>
                            <TextField
                                variant="outlined"
                                className="w-full"
                                label="Nhập từ khoá"
                                onChange={(e) => {
                                    const text = e.target.value
                                    setTimeout(() => {
                                        setTxtSearch(text)
                                    }, 1000)
                                }}
                            />
                        </Grid>

                        <Grid item lg={3} md={3} sm={3} xs={3}>
                            <FormControl variant="outlined" fullWidth>
                                <InputLabel htmlFor="outlined-age-native-simple">
                                    Trạng thái
                                </InputLabel>
                                <Select
                                    label="Trạng thái"
                                    value={status}
                                    onChange={(e) => setStatus(e.target.value)}
                                    inputProps={{
                                        name: 'age',
                                        id: 'outlined-age-native-simple',
                                    }}
                                >
                                    <MenuItem value="">
                                        <em>Tất cả</em>
                                    </MenuItem>
                                    {[
                                        {
                                            id: 1,
                                            name: 'Hoạt động',
                                        },
                                        {
                                            id: 2,
                                            name: 'Khoá',
                                        },
                                    ].map((e) => (
                                        <MenuItem value={e.id}>
                                            {e.name}
                                        </MenuItem>
                                    ))}
                                </Select>
                            </FormControl>
                        </Grid>
                    </Grid>
                    {checkRole(user, '/invoice-supplier/create') ? (
                        <Link to="/invoice-supplier/create">
                            <Button
                                variant="contained"
                                className={'bg-light-primary'}
                            >
                                <span className={'text-primary'}>Thêm mới</span>
                            </Button>
                        </Link>
                    ) : null}
                </Grid>

                <Table
                    data={data}
                    changeActive={changeActive}
                    setChangeActive={setChangeActive}
                    handeChangeActive={handeChangeActive}
                    updateItem={updateItem}
                    removeItem={removeItem}
                    pageIndex={pageIndex}
                    setPageIndex={setPageIndex}
                    totalRecords={totalRecords}
                />
            </div>
        </Fragment>
    )
}

export default CustomerView
