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 DateRange from 'app/components/Input/DateHome'

function CustomerView(props) {
    const [age, setAge] = React.useState('')
    const {
        data,
        setTxtSearch,
        changeActive,
        setChangeActive,
        handeChangeActive,
        setPageIndex,
        pageIndex,
        totalRecords,
        setApplications,
        applications,
        startDate,
        changeDateRange,
        type,
        setType,
        listType,
        listMerchant,
        setMerchant,
        merchant,
        store,
        setStore,
        listStore,
    } = props

    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 giao dịch',
                                path: '/transations',
                            },
                        ]}
                    />
                </div>

                <Grid
                    style={{
                        padding: 10,
                        marginBottom: 20,
                    }}
                    //justify={'space-between'}
                    alignItems={'center'}
                    container
                    spacing={3}
                >
                    <Grid item lg={3} md={3} sm={3} xs={3}>
                        <TextField
                            variant="outlined"
                            className="w-full"
                            label="Tìm kiếm"
                            onChange={(e) => {
                                const text = e.target.value
                                setTxtSearch(text)
                            }}
                        />
                    </Grid>

                    <Grid item lg={3} md={3} sm={3} xs={3}>
                        <FormControl variant="outlined" fullWidth>
                            <InputLabel htmlFor="outlined-age-native-simple">
                                Phương thức thanh toán
                            </InputLabel>
                            <Select
                                label="Phương thức thanh toán"
                                value={type}
                                onChange={(e) => setType(e.target.value)}
                                inputProps={{
                                    name: 'age',
                                    id: 'outlined-age-native-simple',
                                }}
                            >
                                <MenuItem value="">
                                    <em>Tất cả</em>
                                </MenuItem>
                                {[
                                    {
                                        id: 'QR',
                                        name: 'QR',
                                    },
                                    {
                                        id: 'CASH',
                                        name: 'Tiền mặt',
                                    },
                                    {
                                        id: 'DEBT',
                                        name: 'Công nợ',
                                    },
                                ].map((e) => (
                                    <MenuItem value={e.id}>{e.name}</MenuItem>
                                ))}
                            </Select>
                        </FormControl>
                    </Grid>
                    <Grid item lg={3} md={3} sm={3} xs={3}>
                        <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={3} md={3} sm={3} xs={3}>
                        <FormControl variant="outlined" fullWidth>
                            <InputLabel htmlFor="outlined-age-native-simple">
                                Cây xăng
                            </InputLabel>
                            <Select
                                label="Cây xăng"
                                value={store}
                                onChange={(e) => setStore(e.target.value)}
                                inputProps={{
                                    name: 'age',
                                    id: 'outlined-age-native-simple',
                                }}
                            >
                                <MenuItem value="">
                                    <em>Tất cả</em>
                                </MenuItem>
                                {listStore.map((e) => (
                                    <MenuItem value={e.id}>{e.name}</MenuItem>
                                ))}
                            </Select>
                        </FormControl>
                    </Grid>
                    <Grid item lg={3} md={3} sm={3} xs={3}>
                        <DateRange
                            date={startDate}
                            changeDateRange={changeDateRange}
                        />
                    </Grid>
                </Grid>

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

export default CustomerView
