var React = require('react');
var ItemActions = require('../../actions/itemActions');
var NavigationActions = require('../../actions/navigationActions');
var InitializationStore = require('../../stores/initializationStore')

var Router = require('react-router');

var LinkBanner = React.createClass({
    propTypes: {
      locationName: React.PropTypes.string.isRequired,
      locationId: React.PropTypes.number,
    },


    render: function() {

      var banners = this.state.banners.map(function (banner) {

         return <div key={"banner" + banner.get('id')}><a href={banner.get('link_url')}><img className='img-responsive center-block' src={banner.get('image_url')} /></a></div>

      });

      return (<div>{ banners }</div>);

    },
    getInitialState: function () {


      var allBanners = InitializationStore.getBanners();
      var locationId = this.props.locationId;
      var locationName = this.props.locationName;
      var bannersToShow = [];

      if (locationId) {
        bannersToShow = allBanners[locationName][locationId];

      }  else  {
        bannersToShow = allBanners[locationName];

      }

      bannersToShow = bannersToShow || [];


      return { banners: bannersToShow };
    }

});


module.exports = LinkBanner;
