diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 2926fe3..877f7e8 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -1017,12 +1017,12 @@ - + - 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 03ad33e..74f6881 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 @@ -17,7 +17,7 @@
@@ -47,7 +47,6 @@

{{cartItem.book.title}}

-

In Stock

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

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 c133081..289108a 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 @@ -18,6 +18,8 @@ export class ShoppingCartComponent implements OnInit { private cartItemNumber: number; private shoppingCart: ShoppingCart = new ShoppingCart(); private cartItemUpdated:boolean; + private emptyCart: boolean; + private notEnoughStock: boolean; constructor(private router:Router, private cartService: CartService) { } @@ -76,6 +78,25 @@ export class ShoppingCartComponent implements OnInit { ); } + onCheckout() { + if (this.cartItemNumber==0) { + this.emptyCart=true; + } else { + + for (let item of this.cartItemList) { + if(item.qty > item.book.inStockNumber) { + console.log("not enough stock"); + + this.notEnoughStock = true; + + return; + } + } + + this.router.navigate(['/order']); + } + } + ngOnInit() { this.getCartItemList();