text: /**
   * Created by steve on 07/04/15.
   */
  
  var ModalTrigger = require('react-bootstrap').ModalTrigger
  var CatalogPage = React.createClass({displayName: "CatalogPage",
      loadCatalogFromServer: function() {
          $.ajax({
              url: this.props.url,
              dataType: 'json',
              success: function(data) {
                  this.setState({data: data});
              }.bind(this),
              error: function(xhr, status, err) {
                  console.error(this.props.url, status, err.toString());
              }.bind(this)
          });
      },
      handleCommentSubmit: function(comment) {
          var comments = this.state.data;
          comments.push(comment);
          this.setState({data: comments}, function() {
              // `setState` accepts a callback. To avoid (improbable) race condition,
              // `we'll send the ajax request right after we optimistically set the new
              // `state.
              $.ajax({
                  url: this.props.url,
                  dataType: 'json',
                  type: 'POST',
                  data: comment,
                  success: function(data) {
                      this.setState({data: data});
                  }.bind(this),
                  error: function(xhr, status, err) {
                      console.error(this.props.url, status, err.toString());
                  }.bind(this)
              });
          });
      },
      getInitialState: function() {
          return {data: []};
      },
      componentDidMount: function() {
          this.loadCatalogFromServer();
      },
      render: function() {
          return (
              React.createElement(SearchForm, null)
          );
      }
  });
  
  var SearchForm = React.createClass({displayName: "SearchForm",
      render: function() {
          return (
              React.createElement("div", null, "This is a search form.")
          );
      }
  });
  
  var CheckoutButton = React.createClass({displayName: "CheckoutButton",
      render: function() {
          return (
              React.createElement(ModalTrigger, {modal: React.createElement(CheckoutModal, {products: this.state.products})}, 
                  React.createElement("a", {href: "#cart"}, 
                      React.createElement("span", {className: "glyphicon glyphicon-shopping-cart"}), 
                      React.createElement("span", {className: "badge"}, this.state.products.length), 
                      React.createElement("span", null, "Checkout")
                  )
              )
          )
      }
  })
  
  
  React.render(
      React.createElement(CatalogPage, null),
      document.getElementById('content')
  );
  