Files
old-ribica/front-ui/app/components/items/itemWithDetailsPage.js

98 lines
3.0 KiB
JavaScript
Raw Normal View History

2015-01-24 18:49:47 +01:00
var React = require('react'),
2015-01-28 07:16:48 +01:00
Carousel = require('../shared/carousel'),
Traits = require('../items/traits'),
2015-01-28 07:16:48 +01:00
ItemDetailsActions = require('../../actions/itemDetailsActions'),
NavigationStore = require('../../stores/navigationStore'),
2015-02-04 06:38:22 +01:00
ItemDetailsStore = require('../../stores/itemDetailsStore'),
AddToCart = require('../cart/addToCart');
2015-01-25 10:26:10 +01:00
var Router = require('react-router');
var Globals = require('../../globals');
2015-01-24 18:49:47 +01:00
2015-01-27 05:47:10 +01:00
var ItemWithDetailsPage = React.createClass({
2015-01-25 10:26:10 +01:00
2015-01-24 18:49:47 +01:00
render: function() {
2015-01-25 16:42:16 +01:00
return (
2015-02-04 06:38:22 +01:00
<div className="item-with-details row-fluid center">
<div className="col-md-5 col-md-offset-2 item_image col-sm-offset-2 col-sm-3">
<img src={this.state.firstImage} width="100%" />
</div>
<div className="col-md-5 col-sm-7 center">
<div className='item_brand_name'> {this.state.item.get('brand').name}</div>
<div className='item_name'> {this.state.item.get('name')}</div>
<div>
<div className='item_price'> {Globals.FormatCurrency(this.state.item.get('list_price'))}</div>
<div>Količina</div>
<div> <AddToCart item={this.state.item} /></div>
</div>
</div>
<div className="item-with-details row-fluid center">
<div className="col-lg-offset-2 col-lg-10 hidden-md hidden-sm hidden-xs">
<div className="item_description_tab">Opis proizvoda</div>
<div className="item_description_tab_area"> </div>
<div className="item_description_text">{this.state.item.get('description')}</div>
</div>
<div className="col-xs-offset-2 col-xs-10 hidden-lg">
<h2>Opis proizvoda: </h2>
<div> </div>
<p className="lead">{this.state.item.get('description')}</p>
</div>
<div className="col-xs-offset-2 col-xs-10">
<Traits traits={this.state.item.get('traits')} />
</div>
</div>
</div>
2015-01-28 07:16:48 +01:00
);
2015-01-24 18:49:47 +01:00
2015-01-25 10:26:10 +01:00
},
2015-01-25 16:42:16 +01:00
// Add change listeners to stores
2015-01-25 10:26:10 +01:00
componentDidMount: function() {
2015-01-28 07:16:48 +01:00
ItemDetailsStore.addChangeListener(this._onChange);
NavigationStore.addChangeListener(this._onChange);
2015-01-28 07:16:48 +01:00
ItemDetailsActions.loadItemWithDetails();
2015-01-25 10:26:10 +01:00
},
componentWillUnmount: function () {
ItemDetailsStore.removeChangeListener(this._onChange);
NavigationStore.removeChangeListener(this._onChange);
},
2015-01-28 07:16:48 +01:00
onClickLeft: function() {
ItemDetailsActions.previousCarouselImage();
},
onClickRight: function() {
ItemDetailsActions.nextCarouselImage();
},
onSelectImage: function(i) {
ItemDetailsActions.selectCarouselImage(i);
},
2015-01-25 10:26:10 +01:00
_onChange: function () {
2015-01-28 05:09:53 +01:00
if (this.isMounted()) {
2015-01-28 07:16:48 +01:00
this.setState(ItemDetailsStore.getState());
}
2015-01-28 05:09:53 +01:00
2015-01-25 10:26:10 +01:00
},
getInitialState: function () {
2015-01-28 07:16:48 +01:00
return ItemDetailsStore.getState();
2015-01-24 18:49:47 +01:00
}
});
module.exports = ItemWithDetailsPage;