2015-01-24 18:49:47 +01:00
|
|
|
var React = require('react'),
|
2015-01-28 07:16:48 +01:00
|
|
|
Carousel = require('../shared/carousel'),
|
2015-02-03 06:27:54 +01:00
|
|
|
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
|
|
|
|
2015-01-25 12:52:31 +01:00
|
|
|
var Router = require('react-router');
|
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
|
|
|
|
2015-01-29 07:07:08 +01:00
|
|
|
<div className="item-with-details row-fluid center">
|
2015-02-03 06:27:54 +01:00
|
|
|
<div className="col-md-5">
|
|
|
|
|
<Carousel images={this.state.images}
|
|
|
|
|
selected={this.state.currentImage}
|
|
|
|
|
onClickLeft={this.onClickLeft}
|
|
|
|
|
onClickRight={this.onClickRight}
|
|
|
|
|
onSelectImage={this.onSelectImage} />
|
2015-02-08 08:29:24 +01:00
|
|
|
<AddToCart itemId={this.state.item.get('id')} />
|
2015-01-29 07:07:08 +01:00
|
|
|
|
2015-02-03 06:27:54 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="col-md-7">
|
|
|
|
|
<h3> {this.state.item.get('name')}</h3>
|
|
|
|
|
<div>
|
2015-03-28 14:38:15 +01:00
|
|
|
<div className='h4'> {this.state.item.get('brand').name}</div>
|
2015-02-03 06:27:54 +01:00
|
|
|
<div className='h4'> {this.state.item.get('list_price')} KM</div>
|
|
|
|
|
<div className='h5'>{this.state.item.get('pricePerUnit')}</div>
|
|
|
|
|
<div> {this.state.item.get('description')}</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Traits traits={this.state.item.get('traits')} />
|
2015-02-04 06:38:22 +01:00
|
|
|
|
2015-02-03 06:27:54 +01:00
|
|
|
</div>
|
2015-01-29 07:07:08 +01:00
|
|
|
</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);
|
2015-01-28 05:04:45 +01:00
|
|
|
NavigationStore.addChangeListener(this._onChange);
|
2015-01-28 07:16:48 +01:00
|
|
|
ItemDetailsActions.loadItemWithDetails();
|
2015-01-25 10:26:10 +01:00
|
|
|
},
|
|
|
|
|
|
2015-02-03 06:27:54 +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
|
|
|
|
2015-01-28 05:04:45 +01:00
|
|
|
if (this.isMounted()) {
|
2015-01-28 07:16:48 +01:00
|
|
|
this.setState(ItemDetailsStore.getState());
|
2015-01-28 05:04:45 +01:00
|
|
|
}
|
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;
|