import React from 'react';
import {observer, inject} from 'mobx-react';
import bind from 'bind-decorator';
import {
  Card,
  CardActions,
  CardHeader,
  CardMedia,
  CardTitle,
  AutoComplete,
  CardText,
  FlatButton,
  Divider,
  RaisedButton,
  Toolbar,
  DatePicker,
  FontIcon,
  SelectField,
  MenuItem,
  ToolbarGroup,
  FloatingActionButton,
  ToolbarSeparator,
  IconButton,
  ToolbarTitle,
  RadioButton, RadioButtonGroup,
  Tabs, Tab, TextField, Dialog
} from 'material-ui';
import {withRouter} from 'react-router';
import {BrowserRouter as Router, Route} from 'react-router-dom';
import StarBorder from 'material-ui/svg-icons/toggle/star-border';
import ContentAdd from 'material-ui/svg-icons/content/add';

import '../style.scss';
import {appConfig} from "../../../config/app";

@inject('appstate')
@observer
export default class Confirmation extends React.Component {
  constructor(props) {
    super(props);
    this.props = props;
    this.state = {
      openModal :false
    };
    this.defaultState = Object.assign({}, this.state);
    this.http = props.appstate.http;
    this.authStore = props.appstate.auth;
  }

  componentDidMount() {
    console.log('Profile loaded!');

  }

  handleCloseModal = ()=>{
    this.setState({
      openModal : false
    })
  };

  handleOpenModal = ()=>{
    this.setState({
      openModal : true
    })
  }

  render() {

    const data = {
        bus_name: 'Baraya Travel (U2)',
        bus_code: 'JT902',
        departureStation: 'Bandung - Buah Batu',
        destinationStation: 'Jakarta - Kelapa Gading',
        departureDate: '22 Sep 2017, 07.15',
        destinationDate: '22 Sep 2017, 10.00',
        passengerPrice: '100000',
        totalBuy: '1'
      };

      const actionsModals = [
        <FlatButton
          label="Cancel"
          primary={true}
          onClick={this.handleCloseModal}
        />,
        <FlatButton
          label="Ok"
          primary={true}
          onClick={this.props.onClickBookNow}
        />,
      ];

    return (
      <Card className="animated fadeIn">
        <Toolbar className="toolbarCard" style={{backgroundColor: '#fff'}}>
          <ToolbarGroup>
                <IconButton
                  iconClassName="material-icons"
                  tooltip="Back"
                  style={{marginLeft:'0px'}}
                  onClick={this.props.onClickBack}
                >
                  arrow_back
                </IconButton>
            <ToolbarTitle style={{fontSize: 14, fontWeight: 500, color: '#32325d'}} text="Confirmation"/>
          </ToolbarGroup>
        </Toolbar>
        <Divider/>
          <div style={{padding: '14px'}}>
            <div className="row hover">
              <div className="col l3">
                <p></p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>{data.bus_name}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p>Bus Code</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>{data.bus_code}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p>Departure Station</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>{data.departureStation}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p>Destination Station</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>{data.destinationStation}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p>Departure Date</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>{data.departureDate}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p>Destination Date</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>{data.destinationDate}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l4">
                <p style={{fontWeight: 'bolder'}}>Ticket Price</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p>Passenger</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>Rp. {data.passengerPrice} x {data.totalBuy} {(data.totalBuy > 1) ? <span>Passengers</span> : <span>Passenger</span>}</p>
              </div>
            </div>
            <div className="row hover">
              <div className="col l3">
                <p style={{fontWeight: 'bolder'}}>Total</p>
              </div>
              <div className="col l1">
                <p>:</p>
              </div>
              <div className="col l8">
                <p>Rp. {Number(data.passengerPrice + data.totalBuy)}</p>
              </div>
            </div>
            <div className="row">
              <div className="col l12">
                <blockquote>
                  <p style={{fontWeight: 'bolder'}}>Warning</p>
                  <br />
                  The above price does not include the admin fee.
                </blockquote>
              </div>
            </div>
            <div className="row">
              <div className="col m10" />
              <div className="col m2">
                <RaisedButton label="Confirm" primary={true} style={{marginTop: '30px'}} icon={ <FontIcon className="material-icons">check</FontIcon>} onClick={this.handleOpenModal} />
                <Dialog
                  title="Are you sure that all data is correct?"
                  actions={actionsModals}
                  modal={true}
                  open={this.state.openModal}
                >
                  Booking request will be send and data can't be change again.
                </Dialog>
              </div>
            </div>
          </div>
      </Card>
    )
  }
}
