import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';

import General from './Tabs/General/General';
import CenteredButton from '../CenteredButton/CenteredButton';

const styles = theme => ({
  root: {
    flexGrow: 1,
    backgroundColor: theme.palette.background.paper,
  },
  container: {
    padding: theme.spacing.unit * 3
  }
});

function TabContainer(props) {
  return (
    <div className={styles.container}>
      {props.children}
    </div>
  );
}

TabContainer.propTypes = {
  children: PropTypes.node.isRequired,
};


class PatientsDetails extends React.Component {
  state = {
    value: 0,
  };

  componentDidMount() {
    const { getPatient } = this.props;
    const { query } = this.props.location;
    const id = query.patientUuid;
    getPatient(id);
  }

  handleChange = (event, value) => {
    this.setState({ value });
  };

  render() {
    const { classes, patientDetails } = this.props;
    const { value } = this.state;
    console.log('Details', patientDetails);

    return (
      <div className={classes.root}>
        <Tabs value={value} onChange={this.handleChange}>
          <Tab label="General" />
          <Tab label="Passport" />
          <Tab label="History" />
        </Tabs>
        {value === 0 && <TabContainer><General details={patientDetails} /></TabContainer>}
        {value === 1 && <TabContainer>Item two</TabContainer>}
        {value === 2 && <TabContainer>Item Three</TabContainer>}
        <CenteredButton title="BEGIN CONSULTATION" variant="contained" color="primary" />
      </div>
    );
  }
}

export default withStyles(styles)(PatientsDetails);
