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

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

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

    componentDidMount() {
    }

    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} onClick={() => this.setState({ visibleEdit: true })} />
                            </button>
                        </div >
                    );
                }
            }
        }, "ID", "Tipe Persetujuan", "Order", "Nama Pemberi Persetujuan", "Operator", "Status"]
        const data = [
            ["", "1", "Yearly", "1", "John Doe", "-", "Aktif"],
            ["", "2", "Yearly", "2", "John Doe", "-", "Aktif"],
            ["", "3", "Yearly", "2", "John Doe", "AND", "Aktif"],
            ["", "4", "Yearly", "2", "John Doe", "AND", "Non Aktif"],
            ["", "5", "Yearly", "3", "John Doe", "-", "Non Aktif"],
        ]

        return (
            <div style={{ height: this.props.height }}>
                <div style={{ height: 199, width: '100%', backgroundColor: '#354960' }} />
                <div>    
                    <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
                        <label style={{ color: 'white', width: '20%', fontSize: 16 }}>Master Data - Approval Matrix</label>
                        <form style={{ }}>
                            <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',
                                        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
                                    }}
                                >
                                    <img src={Images.add} onClick={() => this.setState({ visibleCreate: true })} />
                                </button>
                        </div >
                    </div>
                    <div style={{ padding: 25, width: '100%' }}>
                        <MuiThemeProvider theme={getMuiTheme()}>
                            <MUIDataTable
                                data={data}
                                columns={columns}
                                options={options}
                            />
                        </MuiThemeProvider>
                    </div>
                </div>
                {this.state.visibleCreate && (
                    <CreateApprovalMatrix
                        onClickClose={() => this.setState({ visibleCreate: false })}
                    />
                )}
                {this.state.visibleEdit && (
                    <EditApprovalMatrix
                        onClickClose={() => this.setState({ visibleEdit: false })}
                    />
                )}
            </div>
        );
    }
}
