View.js 5.09 KB
Newer Older
Giang Tran committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
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,
        permissions,
tdgiang committed
35 36 37
        function_id,
        setFunction,
        listFunction,
Giang Tran committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    } = props
    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 hành động',
                                path: '/role',
                            },
                        ]}
                    />
                </div>

                <Grid
                    style={{
                        padding: 10,
                        marginBottom: 20,
                    }}
                    justify={'space-between'}
                    alignItems={'center'}
                    container
                    spacing={3}
                >
tdgiang committed
67 68 69 70 71 72 73 74 75 76 77 78 79
                    <Grid
                        container
                        item
                        spacing={3}
                        lg={8}
                        md={8}
                        sm={8}
                        xs={8}
                    >
                        <Grid item lg={4} md={4} sm={6} xs={6}>
                            <TextField
                                variant="outlined"
                                className="w-full"
tdgiang committed
80
                                label="Nhập từ khoá"
tdgiang committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
                                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">
                                    Chc năng
                                </InputLabel>
                                <Select
                                    label="Chức năng"
                                    value={function_id}
                                    onChange={(e) =>
                                        setFunction(e.target.value)
                                    }
                                    inputProps={{
                                        name: 'age',
                                        id: 'outlined-age-native-simple',
                                    }}
                                >
                                    <MenuItem value="">
                                        <em>Tt c</em>
                                    </MenuItem>
                                    {listFunction.map((e) => (
                                        <MenuItem value={e.id}>
                                            {e.name}
                                        </MenuItem>
                                    ))}
                                </Select>
                            </FormControl>
                        </Grid>
Giang Tran committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
                    </Grid>
                    {checkRole(user, '/role/create') ? (
                        <Link to="/role/create">
                            <Button
                                variant="contained"
                                className={'bg-light-primary'}
                            >
                                <span className={'text-primary'}>Thêm mi</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}
                />
            </div>
        </Fragment>
    )
}

export default CustomerView