import React from 'react';
import {observer, inject} from 'mobx-react';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import RaisedButton from 'material-ui/RaisedButton';
import {DIALOG} from "../../stores/global_ui";

@inject('appstate')
@observer
export default class Alert extends React.Component {
  constructor(props) {
    super(props);
    this.props = props;
  }

  render() {
    const actions = [
      <FlatButton
        label="OK"
        primary={true}
        onClick={() => this.props.appstate.globalUI.hideAlert()}
      />,
    ];
    
    return (<div>
      <Dialog
        actions={actions}
        modal={false}
        open={this.props.appstate.globalUI[DIALOG.UI.ALERT]}
        onRequestClose={() => this.props.appstate.globalUI.hideAlert()}
      >
        {this.props.appstate.globalUI.globalAlert}
      </Dialog>
    </div>);
  }
}
