server side for getting items from cart
This commit is contained in:
@@ -17,6 +17,7 @@ get '/cart' do
|
|||||||
Cart.find_or_create(anonymous_id, -1).to_json
|
Cart.find_or_create(anonymous_id, -1).to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# gets number of items in cart for every item
|
||||||
get '/cart/item' do
|
get '/cart/item' do
|
||||||
Cart.find_or_create(anonymous_id, -1).item_in_carts.to_json
|
Cart.find_or_create(anonymous_id, -1).item_in_carts.to_json
|
||||||
end
|
end
|
||||||
@@ -30,4 +31,3 @@ update_cart_item = ->() {
|
|||||||
}
|
}
|
||||||
put '/cart/item', &update_cart_item
|
put '/cart/item', &update_cart_item
|
||||||
post '/cart/item', &update_cart_item
|
post '/cart/item', &update_cart_item
|
||||||
|
|
||||||
|
|||||||
@@ -69,3 +69,11 @@ get '/item/sub_category/:sub_category_id/offset/:offset/limit/:limit' do |sub_ca
|
|||||||
items = Item.best_selling_in_sub_category(sub_category_id, offset, limit)
|
items = Item.best_selling_in_sub_category(sub_category_id, offset, limit)
|
||||||
prepare_items_for_mass_display(items)
|
prepare_items_for_mass_display(items)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# gets list of items in cart without count
|
||||||
|
get '/item/cart' do |cart|
|
||||||
|
cart = Cart.find_or_create(anonymous_id, -1).to_json
|
||||||
|
item_ids = cart.item_in_carts.map ->(x) { x.item_id }
|
||||||
|
items = Item.find(item_ids)
|
||||||
|
prepare_items_for_mass_display(items)
|
||||||
|
end
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
get '/section' do
|
get '/section' do
|
||||||
Section.order(:name).all.to_json(:include =>
|
Section.order(:name).all.to_json(:include =>
|
||||||
[:categories => { :include => :sub_categories }])
|
[:categories => { :include => :sub_categories }])
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/section/:id' do
|
get '/section/:id' do
|
||||||
Section.find(params[:id].to_i).to_json(:include => [
|
Section.find(params[:id].to_i).to_json(:include => [
|
||||||
:categories => { :include => :sub_categories } ])
|
:categories => { :include => :sub_categories } ])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
47
front-ui/app/components/cart/cartPage.js
Normal file
47
front-ui/app/components/cart/cartPage.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
var React = require('react'),
|
||||||
|
CartStore = require('../../stores/cartStore'),
|
||||||
|
AddToCart = require('../cart/addToCart');
|
||||||
|
|
||||||
|
var Router = require('react-router');
|
||||||
|
|
||||||
|
|
||||||
|
var ItemWithDetailsPage = React.createClass({
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div className="cart-page row-fluid center">
|
||||||
|
This is the cart page!
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
// Add change listeners to stores
|
||||||
|
componentDidMount: function() {
|
||||||
|
CartStore.addChangeListener(this._onChange);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function () {
|
||||||
|
CartStore.removeChangeListener(this._onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
_onChange: function () {
|
||||||
|
|
||||||
|
if (this.isMounted()) {
|
||||||
|
this.setState(ItemDetailsStore.getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState: function () {
|
||||||
|
return CartStore.getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = ItemWithDetailsPage;
|
||||||
@@ -10,7 +10,7 @@ var SingleItem = React.createClass({
|
|||||||
var self = this;
|
var self = this;
|
||||||
var itemClick = this.itemClick;
|
var itemClick = this.itemClick;
|
||||||
var firstImage = this.props.item.get('multi_media_descriptions')[0];
|
var firstImage = this.props.item.get('multi_media_descriptions')[0];
|
||||||
firstImage = firstImage || { url: "http://res.cloudinary.com/lfvt7ps2n/image/upload/c_crop,g_center,w_300/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
|
firstImage = firstImage || { url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_crop,g_center,w_300/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
|
||||||
return (
|
return (
|
||||||
<div className="single_item" onClick={itemClick}>
|
<div className="single_item" onClick={itemClick}>
|
||||||
<img src={firstImage.url} className="item_list_image" />
|
<img src={firstImage.url} className="item_list_image" />
|
||||||
|
|||||||
Reference in New Issue
Block a user