DocumentManagement copy.js 4.23 KB
Newer Older
Deni Rinaldi's avatar
Deni Rinaldi 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 35 36 37 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 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 117 118 119 120 121 122 123 124 125 126 127 128 129
import React, {useEffect} from 'react';
import PropTypes from 'prop-types';
import { makeStyles } from '@material-ui/core/styles';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';
import ReactTooltip from 'react-tooltip';
import Images from '../../assets/Images';
import { Paper } from '@material-ui/core';
import ManualBookTia from './ManualBookTia';
import api from '../../api';

function TabPanel(props) {
    const { children, value, index, ...other } = props;

    return (
        <div
            role="tabpanel"
            hidden={value !== index}
            id={`vertical-tabpanel-${index}`}
            aria-labelledby={`vertical-tab-${index}`}
            {...other}
        >
            {value === index && (
                <Box p={3}>
                    <Typography>{children}</Typography>
                </Box>
            )}
        </div>
    );
}

TabPanel.propTypes = {
    children: PropTypes.node,
    index: PropTypes.any.isRequired,
    value: PropTypes.any.isRequired,
};

function a11yProps(index) {
    return {
        id: `vertical-tab-${index}`,
        'aria-controls': `vertical-tabpanel-${index}`,
    };
}

const useStyles = makeStyles((theme) => ({
    root: {
        display: 'flex',
        // height: 244,
    },
    tabs: {
        borderRight: `1px solid ${theme.palette.divider}`,
    },
}));

export default function DocumentManagement() {
    const classes = useStyles();
    const [value, setValue] = React.useState(0);
    const [listData, setListData] = React.useState([])

    const handleChange = (event, newValue) => {
        setValue(newValue);
    };

    useEffect(() => {
        getDataDocument()
    })

    const getDataDocument = () => {
        api.create().getDocumentCategory().then(response => {
            let data = response.data.data
            setListData(data)
        })
    }

    return (
        <div style={{ flex: 1 }}>
            <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
                <Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography>
            </div>
            <Paper style={{ padding: 20 }}>
                <div style={{ display: 'grid', justifyContent: 'flex-end' }}>
                    <a data-tip={'Add New'} data-for="create">
                        <button
                            style={{
                                backgroundColor: 'transparent',
                                cursor: 'pointer',
                                borderColor: 'transparent',
                                margin: 5,
                                marginRight: 20
                            }}
                            onClick={() => null}
                        >
                            <img src={Images.add} />
                        </button>
                    </a>
                    <ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
                </div>
                <div className={classes.root}>
                    <Tabs
                        orientation="vertical"
                        variant="scrollable"
                        value={value}
                        onChange={handleChange}
                        aria-label="Vertical tabs example"
                        className={classes.tabs}
                    >
                        {listData.map((item, index) => {
                            return (
                                <Tab label={item.document_category_name} {...a11yProps(index)} />
                            )
                        })}
                    </Tabs>
                    {listData.map((item, index) => {
                        return (
                            <TabPanel value={value} index={index} style={{ width: '100%'}}>
                                {index === 0 ?
                                    <ManualBookTia /> :
                                    <span>Test</span>
                                }
                            </TabPanel>
                        )
                    })}
                </div>
            </Paper>
        </div>
    );
}