latest
This commit is contained in:
4
bookstore-api/.idea/workspace.xml
generated
4
bookstore-api/.idea/workspace.xml
generated
@@ -1017,12 +1017,12 @@
|
||||
<workItem from="1488378219247" duration="650000" />
|
||||
<workItem from="1488461561430" duration="18419000" />
|
||||
<workItem from="1488731165185" duration="30270000" />
|
||||
<workItem from="1489159532831" duration="13556000" />
|
||||
<workItem from="1489159532831" duration="13888000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="105838000" />
|
||||
<option name="totallyTimeSpent" value="106170000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="72" y="23" width="1280" height="797" extended-state="0" />
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<!-- <a md-raised-button *ngIf="displayUpdateCart" class="mat-accent" (click)="onUpdateCart()">Update Cart</a> -->
|
||||
</div>
|
||||
<div class="col-xs-6 text-right">
|
||||
<a md-raised-button class="mat-primary" routerLink="/order">Check Out</a>
|
||||
<a md-raised-button class="mat-primary" (click)="onCheckout()">Check Out</a>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
@@ -47,7 +47,6 @@
|
||||
<div class="col-xs-6">
|
||||
<a class="pointer" (click)="onSelect(cartItem.book)"><h4>
|
||||
{{cartItem.book.title}}</h4></a>
|
||||
|
||||
<p *ngIf="cartItem.book.inStockNumber > 10" style="color: green;">In Stock</p>
|
||||
<p *ngIf="cartItem.book.inStockNumber < 10 && cartItem.book.inStockNumber > 0" style="color: green;"> Only <span>{{cartItem.book.inStockNumber}}</span> In Stock
|
||||
</p>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user