import React, { Component } from 'react';
import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { Typography } from '@material-ui/core';
import Images from '../../../assets/Images';
import MUIDataTable from "mui-datatables";
import { render } from '@testing-library/react';
import { TextField, InputBase } from "@material-ui/core";

var ct = require("../../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();

export default class Perusahaan extends Component {
    constructor(props) {
        super(props)
        this.state = {
            visibleCreate: false,
            visibleEdit: false,
            data: []
        }
    }

    componentDidMount() {
    }

    render() {
        
        console.log(this.props.height)
        const columns = [{
            name: "Action",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <button
                                style={{
                                    backgroundColor: 'transparent',
                                    cursor: 'pointer',
                                    borderColor: 'transparent'
                                }}
                                onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })}
                            >
                                <img src={Images.editCopy} />
                            </button>
                        </div >
                    );
                }
            }
        }, {
            name: "ID",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
                        </div >
                    );
                }
            }
        }, {
            name: "Nama Perusahaan",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
                        </div >
                    );
                }
            }
        }, {
            name: "Nama Perusahaan",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
                        </div >
                    );
                }
            }
        }, {
            name: "Unit Bisnis",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
                        </div >
                    );
                }
            }
        }, {
            name: "Status",
            options: {
                customBodyRender: (val, tableMeta) => {
                    return (
                        <div style={{ display: 'flex' }}>
                            <span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
                        </div >
                    );
                }
            }
        }]
        const data = [
            ["", "1", "Triputra Agro Persada Group", "Triputra Investindo Arya", "Agrobisnis", "Aktif"],
            ["", "2", "Gawi Bahandep Sawit Mekar", "Triputra Agro Persada Group", "Agrobisnis", "Aktif"],
            ["", "3", "Puninar Group", "Triputra Investindo Arya", "Service", "Aktif"],
            ["", "4", "Puninar Infinite Raya", "Puninar Group", "Service", "Non Aktif"],
            ["", "-", "-", "-", "-","-"],
        ]
        return (
            <div style={{ height: this.props.height }}>
                {/* <Row> */}
                <div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
                <div>
                    <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
                        <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Master Data - Perusahaan</label>
                        <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}>
                            <img src={Images.searchBlack} style={{ marginRight: 10 }} />
                            <InputBase
                                style={{ width: '100%' }}
                                placeholder="Search"
                                inputProps={{ 'aria-label': 'naked' }}
                            />
                        </div>
                        <div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}>
                            <img src={Images.template} />
                            <img src={Images.upload} />
                            <img src={Images.download} />
                            <button
                                style={{
                                    backgroundColor: 'transparent',
                                    cursor: 'pointer',
                                    borderColor: 'transparent'
                                }}
                                onClick={() => null}
                            >
                                <img src={Images.visualisasi} />
                            </button>
                            <button
                                style={{
                                    backgroundColor: 'transparent',
                                    cursor: 'pointer',
                                    borderColor: 'transparent'
                                }}
                                onClick={() => this.setState({ visibleCreate: true })}
                            >
                                <img src={Images.add} />
                            </button>
                        </div>
                    </div>
                    <div style={{ padding: 25 }}>
                        <MuiThemeProvider theme={getMuiTheme()}>
                            <MUIDataTable
                                theme={getMuiTheme()}
                                data={data}
                                columns={columns}
                                options={options}
                            />
                        </MuiThemeProvider>

                    </div>
                </div>
            </div>
        );
    }
}

// class Perusahaan extends Component {
//     render() {
//         const columns = [{
//             name: "Action",
//             options: {
//                 customBodyRender: (val, tableMeta) => {
//                     return (
//                         <div style={{ display: 'flex' }}>
//                             <button
//                                 style={{
//                                     backgroundColor: 'transparent',
//                                     cursor: 'pointer',
//                                     borderColor: 'transparent'
//                                 }}
//                                 onClick={() => null}
//                             >
//                                 <img src={Images.editCopy} />
//                             </button>
//                         </div >
//                     );
//                 }
//             }
//         }, "ID", "Nama Perusahaan", "Nama Perusahaan", "Unit Bisnis", "Jumlah Laporan", "Status"]
//         const data = [
//             ["", "1", "Triputra Agro Persada Group", "Triputra Investindo Arya", "Agrobisnis", "5", "Aktif"],
//             ["", "2", "Gawi Bahandep Sawit Mekar", "Triputra Agro Persada Group", "Agrobisnis", "2", "Aktif"],
//             ["", "3", "Puninar Group", "Triputra Investindo Arya", "Service", "5", "Aktif"],
//             ["", "4", "Puninar Infinite Raya", "Puninar Group", "Service", "5", "Non Aktif"],
//             ["", "-", "-", "-", "-", "-", "-"],
//         ]
//         const options = {
//             filter: false,
//             sort: false,
//             responsive: "scroll",
//             print: false,
//             download: false,
//             selectableRows: false,
//             viewColumns: false,
//             rowsPerPage: 5,
//             search: false
//         }

//         return (
//             <div style={{ flex: 1 }}>
//                 <div style={{ height: 150, width: '100%', backgroundColor: '#354960', padding: 24, paddingTop: 30 }}>
//                     <div style={{ display: 'flex' }}>
//                         <Typography style={{ paddingTop: 8, paddingBottom: 7, fontSize: '16px', color: 'white' }}>Master Data - Perusahaan</Typography>
//                         <form style={{ marginLeft: 110 }}>
//                             <TextField id="" label="" variant="outlined" size="small" placeholder="Search" style={{ width: 423, backgroundColor: 'white', borderRadius: 6 }}/>
//                         </form>
//                         <div style={{ display: 'flex' }}>
//                             <button
//                                 style={{
//                                     backgroundColor: 'transparent',
//                                     cursor: 'pointer',
//                                     borderColor: 'transparent',
//                                     marginLeft: 82,
//                                     padding: 0
//                                 }}
//                                 onClick={() => null}
//                             >
//                                 <img src={Images.template} />
//                             </button>
//                             <button
//                                 style={{
//                                     backgroundColor: 'transparent',
//                                     cursor: 'pointer',
//                                     borderColor: 'transparent',
//                                     marginLeft: 16,
//                                     padding:0
//                                 }}
//                                 onClick={() => null}
//                             >
//                                 <img src={Images.upload} />
//                             </button>
//                             <button
//                                 style={{
//                                     backgroundColor: 'transparent',
//                                     cursor: 'pointer',
//                                     borderColor: 'transparent',
//                                     marginLeft: 16,
//                                     padding:0
//                                 }}
//                                 onClick={() => null}
//                             >
//                                 <img src={Images.download} />
//                             </button>
//                             <button
//                                 style={{
//                                     backgroundColor: 'transparent',
//                                     cursor: 'pointer',
//                                     borderColor: 'transparent',
//                                     marginLeft: 16,
//                                     padding:0
//                                 }}
//                                 onClick={() => null}
//                             >
//                                 <img src={Images.visualisasi} />
//                             </button>
//                             <button
//                                 style={{
//                                     backgroundColor: 'transparent',
//                                     cursor: 'pointer',
//                                     borderColor: 'transparent',
//                                     marginLeft: 16,
//                                     padding:0
//                                 }}
//                                 onClick={() => null}
//                             >
//                                 <img src={Images.add} />
//                             </button>
//                         </div >
//                     </div>
                    
//                 </div>
//                 <div style={{ flex: 1, padding: 20, width: '100%' }}>
//                     <div>
//                         <MUIDataTable
//                             data={data}
//                             columns={columns}
//                             options={options}
//                         />
//                     </div>
//                 </div>
//             </div>
//         );
//     }
// }

// export default Perusahaan;