diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index c92ac6e..07b7465 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -151,8 +151,8 @@ - - + + @@ -1038,12 +1038,12 @@ - + - @@ -1067,7 +1067,7 @@ - + @@ -1555,8 +1555,8 @@ - - + + diff --git a/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java b/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java index 3943dfc..05db602 100644 --- a/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java +++ b/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java @@ -91,7 +91,7 @@ public class ShoppingCartResource { } @RequestMapping("/updateCartItem") - public ResponseEntity updateShoppingCart( + public ResponseEntity updateCartItem( @RequestBody HashMap mapper ) { String cartItemId = mapper.get("cartItemId"); @@ -102,7 +102,7 @@ public class ShoppingCartResource { cartItemService.updateCartItem(cartItem); - return new ResponseEntity("Cart Updated Successfully!", HttpStatus.OK); + return new ResponseEntity("Cart Item Updated Successfully!", HttpStatus.OK); } } diff --git a/bookstore-api/target/classes/com/bookstore/resource/ShoppingCartResource.class b/bookstore-api/target/classes/com/bookstore/resource/ShoppingCartResource.class index 32fbc0a..034ddab 100644 Binary files a/bookstore-api/target/classes/com/bookstore/resource/ShoppingCartResource.class and b/bookstore-api/target/classes/com/bookstore/resource/ShoppingCartResource.class differ diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.html b/store-front/src/app/components/shopping-cart/shopping-cart.component.html index 7bbd71d..d24cf0e 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.html +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.html @@ -14,12 +14,16 @@
+
+ Cart Item Updated Successfully! +
Oops, some of the products don't have enough stock. Please update product quantity.
@@ -36,32 +40,30 @@
-
-
-
- -
-
-

+
+
+ +
+
+

{{cartItem.book.title}}

-

In Stock

-

Only {{cartItem.book.inStockNumber}} In Stock -

-

Product Unavailable

- delete -
-
-
$In Stock

+

Only {{cartItem.book.inStockNumber}} In Stock +

+

Product Unavailable

+ delete +
+
+
${{cartItem.book.ourPrice}}
-
-
- - - -
- +

+
+ + + Update +

diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts index 709466d..74e8530 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts @@ -17,6 +17,7 @@ export class ShoppingCartComponent implements OnInit { private cartItemList: CartItem[] = []; private cartItemNumber: number; private shoppingCart: ShoppingCart = new ShoppingCart(); + private cartItemUpdated:boolean; constructor(private router:Router, private cartService: CartService) { } @@ -37,6 +38,18 @@ export class ShoppingCartComponent implements OnInit { ); } + onUpdateCartItem(cartItem:CartItem) { + this.cartService.updateCartItem(cartItem.id, cartItem.qty).subscribe( + res=>{ + console.log(res.text()); + this.cartItemUpdated=true; + }, + error=>{ + console.log(error.text()); + } + ); + } + getCartItemList(){ this.cartService.getCartItemList().subscribe( res=>{ diff --git a/store-front/src/app/models/cart-item.ts b/store-front/src/app/models/cart-item.ts index 85d6c4f..2ae5aa2 100644 --- a/store-front/src/app/models/cart-item.ts +++ b/store-front/src/app/models/cart-item.ts @@ -10,5 +10,5 @@ export class CartItem { public book: Book; public shoppingCart: ShoppingCart; public order: Order; - + public toUpdate:boolean; } diff --git a/store-front/src/app/services/cart.service.ts b/store-front/src/app/services/cart.service.ts index 15de943..99ade3a 100644 --- a/store-front/src/app/services/cart.service.ts +++ b/store-front/src/app/services/cart.service.ts @@ -37,8 +37,8 @@ export class CartService { return this.http.get(url, {headers : tokenHeader}); } - updateShoppingCart(cartItemId:number, qty:number) { - let url = AppConst.serverPath+"/cart/removeItem"; + updateCartItem(cartItemId:number, qty:number) { + let url = AppConst.serverPath+"/cart/updateCartItem"; let cartItemInfo = { "cartItemId" : cartItemId, "qty" : qty