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,
        listProvide,
        listProduct,
        provide,
        setProvide,
        product,
        setProduct,
        status,
        setStatus,
    } = 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 qua bên thứ 3',
                                path: '/reconciliation/transations',
                            },
                        ]}
                    />
                </div>

                <Grid
                    style={{
                        padding: 10,
                        marginBottom: 10,
                    }}
                    //justify={'space-between'}
                    alignItems={'center'}
                    container
                    spacing={3}
                >
                    <Grid item lg={2} md={2} 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={2} md={2} sm={3} xs={3}>
                        <FormControl variant="outlined" fullWidth>
                            <InputLabel htmlFor="outlined-age-native-simple">
                                Đối tác
                            </InputLabel>
                            <Select
                                label="Đối tác"
                                value={provide}
                                onChange={(e) => setProvide(e.target.value)}
                                inputProps={{
                                    name: 'age',
                                    id: 'outlined-age-native-simple',
                                }}
                            >
                                <MenuItem value="">
                                    <em>Tất cả</em>
                                </MenuItem>
                                {listProvide.map((e) => (
                                    <MenuItem value={e.id}>{e.name}</MenuItem>
                                ))}
                            </Select>
                        </FormControl>
                    </Grid>
                    <Grid item lg={2} md={2} sm={3} xs={3}>
                        <FormControl variant="outlined" fullWidth>
                            <InputLabel htmlFor="outlined-age-native-simple">
                                Sản phẩm
                            </InputLabel>
                            <Select
                                label="Sản phẩm"
                                value={product}
                                onChange={(e) => setProduct(e.target.value)}
                                inputProps={{
                                    name: 'age',
                                    id: 'outlined-age-native-simple',
                                }}
                            >
                                <MenuItem value="">
                                    <em>Tất cả</em>
                                </MenuItem>
                                {listProduct.map((e) => (
                                    <MenuItem value={e.id}>{e.name}</MenuItem>
                                ))}
                            </Select>
                        </FormControl>
                    </Grid>

                    <Grid item lg={2} md={2} sm={3} xs={3}>
                        <FormControl variant="outlined" fullWidth>
                            <InputLabel htmlFor="outlined-age-native-simple">
                                PT thanh toán
                            </InputLabel>
                            <Select
                                label="PT 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>
                                {listType.map((e) => (
                                    <MenuItem value={e.id}>{e.name}</MenuItem>
                                ))}
                            </Select>
                        </FormControl>
                    </Grid>

                    <Grid item lg={2} md={2} 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>
                                {[
                                    {
                                        name: 'Chưa đối soát',
                                        value: 1,
                                        id: 1,
                                    },
                                    {
                                        name: 'Đang đối soát',
                                        value: 2,
                                        id: 2,
                                    },
                                    {
                                        name: 'Đã đối soát',
                                        value: 3,
                                        id: 3,
                                    },
                                ].map((e) => (
                                    <MenuItem value={e.id}>{e.name}</MenuItem>
                                ))}
                            </Select>
                        </FormControl>
                    </Grid>

                    <Grid item lg={2} md={2} 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
