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 {
        data,
        updateItem,
        removeItem,
        setTxtSearch,
        changeActive,
        setChangeActive,
        handeChangeActive,
        setPageIndex,
        pageIndex,
        totalRecords,
        permissions,
        merchant,
        setMerchant,
        listMerchant,
        status,
        setStatus,
        listStatus,
        acceptStoreSub,
        acceptUpdateTime,
    } = props
    const [age, setAge] = React.useState('')
    const { user } = useAuth()
    const handleChange = (event) => {
        setAge(event.target.value)
    }

    return (
        <Fragment>
            <div className="m-sm-30">
                <div className="mb-sm-30">
                    <Breadcrumb
                        routeSegments={[
                            {
                                name: 'Danh sách cây xăng',
                                path: '/gas-station',
                            },
                        ]}
                    />
                </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={4} md={4} sm={6} xs={6}>
                            <TextField
                                variant="outlined"
                                className="w-full"
                                label="Tên cây xăng"
                                onChange={(e) => {
                                    const text = e.target.value
                                    setTimeout(() => {
                                        setTxtSearch(text)
                                    }, 1000)
                                }}
                            />
                        </Grid>

                        <Grid item lg={4} md={4} sm={6} xs={6}>
                            <FormControl variant="outlined" fullWidth>
                                <InputLabel htmlFor="outlined-age-native-simple">
                                    Pháp nhân
                                </InputLabel>
                                <Select
                                    label="Pháp nhân"
                                    value={merchant}
                                    onChange={(e) =>
                                        setMerchant(e.target.value)
                                    }
                                    inputProps={{
                                        name: 'age',
                                        id: 'outlined-age-native-simple',
                                    }}
                                >
                                    <MenuItem value="">
                                        <em>Tất cả</em>
                                    </MenuItem>
                                    {listMerchant.map((e) => (
                                        <MenuItem value={e.id}>
                                            {e.name}
                                        </MenuItem>
                                    ))}
                                </Select>
                            </FormControl>
                        </Grid>

                        <Grid item lg={4} md={4} sm={6} xs={6}>
                            <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>
                                    {listStatus.map((e) => (
                                        <MenuItem value={e.id}>
                                            {e.name}
                                        </MenuItem>
                                    ))}
                                </Select>
                            </FormControl>
                        </Grid>
                    </Grid>
                    {/* {checkRole(user, '/gas-station/create') ? (
                        <Link to="/gas-station/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}
                    permissions={permissions}
                    acceptStoreSub={acceptStoreSub}
                    acceptUpdateTime={acceptUpdateTime}
                />
            </div>
        </Fragment>
    )
}

export default CustomerView
