import React, { Component } from 'react';
import { Table, Row, Col, Button } from 'antd';
import { $http } from '../../../containers/config/https';
import PatientList from '../Patient/PatientList';
import OrdTableModal from './OrdTableModal';
import './style/orderTable.less'
 
export default class OrderTable extends Component {
    constructor(props) {
        super(props);
        var patientData = window.sessionStorage.patientData ? JSON.parse(window.sessionStorage.patientData) : {};
        this.state = {
            leftspan: 5,
            rightspan: 19,
            patient: "",
            patientData: patientData,
            iconType: "double-left",
        }
 
    }
 
    onBtnClick = () => {
        this.setState({
            leftspan: 5 - this.state.leftspan,
        });
    }
 
    updateState = (patientObj) => {
        if (patientObj.iconType) {
            this.setState({...patientObj})
        }
        console.dir(this.state)
        let admId = patientObj.patient;
        if (admId && admId.length === 0) return
        this.setState({
            patient: admId?admId[0]:'',
        });
    }
 
    render() {
        return (
            <div style={{ height: "100%" }} className='OrderDesc'>
                <Row style={{ border: "2px solid #cccccc", height: "100%", width: "100%", overflowY: "hidden" }}>
                    <Col className={this.state.iconType == "double-left" ? "" : "visibleIcon"} span={this.state.leftspan}
                        style={{ border: this.state.iconType == "double-left" ? "1px solid #cccccc" : "0px", height: "100%", overflowY: 'hidden', background: '#ffffff', boxSizing: 'border-box' }}>
                        <PatientList updateState={this.updateState} iconType={this.state.iconType} type="radio" />
                    </Col>
                    <Col span={this.state.rightspan} >
                        <Row>
                            <OrdTableModal
                                patAdmId={this.state.patient == "" ? this.state.patientData.admID : this.state.patient}
                            />
                        </Row>
 
                    </Col>
                </Row>
 
            </div>
        )
    }
 
 
 
}