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,

        status,
        setStatus,
        provide,
        setProvide,
        listProvide,
    } = 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 phiếu đối soát',
                                path: '/reconciliation/sheet',
                            },
                        ]}
                    />
                </div>

                <Grid
                    style={{
                        padding: 10,
                        marginBottom: 20,
                    }}
                    //justify={'space-between'}
                    alignItems={'center'}
                    container
                    spacing={3}
                >
                    <Grid item lg={3} md={3} sm={4} xs={4}>
                        <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">
                                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: 'Nháp',
                                        value: 1,
                                        id: 1,
                                    },

                                    {
                                        name: 'Chưa đối soát',
                                        value: 2,
                                        id: 2,
                                    },
                                    {
                                        name: 'Đang đối soát',
                                        value: 3,
                                        id: 3,
                                    },
                                    {
                                        name: 'Đã đối soát',
                                        value: 4,
                                        id: 4,
                                    },
                                ].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">
                                Đố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={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
