chen445 / Ama2on

An e-commerce website inspired by Amazon
https://ama2on.herokuapp.com
0 stars 0 forks source link
price product-detail rating review shopping-cart

Ama2on

Introduction

Ama2on is e-commerce website where buyers can search for products they like. They can see the price and select affordable one.

Live Site: Ama2on

demo

Technologies used:

Features

User Auth

Product search

demo

Product Controller

def index
  if (params[:query] == nil) 
    @products = Product.all
      render "api/products/index"
  else
    @products = Product.findBySubstring(params[:query].strip)
      render "api/products/index"
  end
end

Search function

search() { 
    if (this.state.input === undefined || this.state.input === "") {
      return null;
    }
    this.props.fetchProducts(this.state.input);
    this.props.history.push("/search?query=" + escape(this.state.input));
  }

Product details

demo

There is page where details of product are shown to the user.

Shopping cart

demo
  update(cartItemId) {
    const cartItem = this.props.cartItems[cartItemId];
    if (
      !this.state.updatedQty[cartItemId] ||
      this.state.updatedQty[cartItemId] === cartItem.quantity
    ) {
      return;
    }

    let updatedCartItem = {
      product_id: cartItem.product_id,
      quantity: this.state.updatedQty[cartItemId] - cartItem.quantity,
    };

    this.props.createCartItem(updatedCartItem).then(() => {
      let updatedQty = Object.assign({}, this.state.updatedQty);
      updatedQty[cartItemId] = undefined;
      this.setState({
        updatedQty,
      });
    });
  }

Coming soon