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

75 lines
1.8 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'),
ItemDetailsActions = require('../../actions/itemDetailsActions'),
NavigationStore = require('../../stores/navigationStore'),
ItemDetailsStore = require('../../stores/itemDetailsStore');
2015-01-25 10:26:10 +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-01-28 07:16:48 +01:00
<div className="item-with-details row-fluid center">
<div className="span3">
2015-01-25 16:42:16 +01:00
<h3> {this.state.item.get('name')} </h3>
<div>
2015-01-28 07:16:48 +01:00
<div className='h4'> {this.state.item.get('list_price')} KM</div>
<div> {this.state.item.get('description')}</div>
2015-01-25 16:42:16 +01:00
</div>
2015-01-28 07:16:48 +01:00
<Carousel images={this.state.images}
selected={this.state.currentImage}
onClickLeft={this.onClickLeft}
onClickRight={this.onClickRight}
onSelectImage={this.onSelectImage} />
</div>
<div className="span4">
2015-01-25 16:42:16 +01:00
quantitative descriptions
</div>
2015-01-28 07:16:48 +01:00
</div>
);
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
},
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;