diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index 72252bf..3a211d1 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -26,12 +26,14 @@ - + - - - + + + + + @@ -148,7 +150,7 @@ - + @@ -228,7 +230,6 @@ @@ -1036,12 +1038,12 @@ - + - @@ -1065,7 +1067,7 @@ - + @@ -1431,14 +1433,6 @@ - - - - - - - - @@ -1563,5 +1557,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bookstore-api/src/main/java/com/bookstore/resource/ShippingResource.java b/bookstore-api/src/main/java/com/bookstore/resource/ShippingResource.java index 86799b2..09f3c7e 100644 --- a/bookstore-api/src/main/java/com/bookstore/resource/ShippingResource.java +++ b/bookstore-api/src/main/java/com/bookstore/resource/ShippingResource.java @@ -47,6 +47,16 @@ public class ShippingResource { return new ResponseEntity("Shipping Added(Updated) Successfully!", HttpStatus.OK); } + @RequestMapping(value = "/getUserShippingList") + public List getUserShippingList( + Principal principal) { + User user = userService.findByUsername(principal.getName()); + + List userShippingList = user.getUserShippingList(); + + return userShippingList; + } + @RequestMapping(value = "/remove", method = RequestMethod.POST) public ResponseEntity removeUserShippingPost( @RequestBody String id, diff --git a/bookstore-api/target/classes/com/bookstore/domain/Order.class b/bookstore-api/target/classes/com/bookstore/domain/Order.class index 14b1545..56fafe3 100644 Binary files a/bookstore-api/target/classes/com/bookstore/domain/Order.class and b/bookstore-api/target/classes/com/bookstore/domain/Order.class differ diff --git a/bookstore-api/target/classes/com/bookstore/resource/ShippingResource.class b/bookstore-api/target/classes/com/bookstore/resource/ShippingResource.class index 5ef163d..f2bb9da 100644 Binary files a/bookstore-api/target/classes/com/bookstore/resource/ShippingResource.class and b/bookstore-api/target/classes/com/bookstore/resource/ShippingResource.class differ diff --git a/store-front/src/app/components/order/order.component.html b/store-front/src/app/components/order/order.component.html index 65e853e..31e24be 100644 --- a/store-front/src/app/components/order/order.component.html +++ b/store-front/src/app/components/order/order.component.html @@ -14,7 +14,7 @@
-

By placing your order, you agree to Le's Bookstore privacy notice and conditions of use.

@@ -66,7 +66,7 @@
- +
@@ -79,7 +79,7 @@ {{userShipping.userShippingStreet1}}, {{userShipping.userShippingStreet2}}, {{userShipping.userShippingCity}}, {{userShipping.userShippingState}} @@ -107,7 +107,7 @@
diff --git a/store-front/src/app/components/order/order.component.ts b/store-front/src/app/components/order/order.component.ts index f20fc35..54ecf48 100644 --- a/store-front/src/app/components/order/order.component.ts +++ b/store-front/src/app/components/order/order.component.ts @@ -3,6 +3,7 @@ import {AppConst} from '../../constants/app-const'; import {Book} from '../../models/book'; import {Router} from "@angular/router"; import {CartService} from '../../services/cart.service'; +import {ShippingService} from '../../services/shipping.service'; import {CartItem} from '../../models/cart-item'; import {ShoppingCart} from '../../models/shopping-cart'; import {ShippingAddress} from '../../models/shipping-address'; @@ -28,9 +29,12 @@ export class OrderComponent implements OnInit { private userPayment:UserPayment = new UserPayment(); private userShipping:UserShipping = new UserShipping(); private userBilling: UserBilling = new UserBilling(); + private userShippingList: UserShipping[] = []; private selectedTab: number; + private emptyShippingList: boolean = true; + private stateList: string[] = []; - constructor(private router:Router, private cartService: CartService) { } + constructor(private router:Router, private cartService: CartService, private shippingService: ShippingService) { } onSelect(book:Book) { this.selectedBook = book; @@ -61,6 +65,16 @@ export class OrderComponent implements OnInit { ); } + setShippingAddress(userShipping: UserShipping) { + this.shippingAddress.shippingAddressName = userShipping.userShippingNmae; + this.shippingAddress.shippingAddressStreet1 = userShipping.userShippingStreet1; + this.shippingAddress.shippingAddressStreet2 = userShipping.userShippingStreet2; + this.shippingAddress.shippingAddressCity = userShipping.userShippingCity; + this.shippingAddress.shippingAddressState = userShipping.userShippingState; + this.shippingAddress.shippingAddressCountry = userShipping.userShippingCountry; + this.shippingAddress.shippingAddressZipcode = userShipping.userShippingZipcode; + } + ngOnInit() { this.getCartItemList(); @@ -74,6 +88,25 @@ export class OrderComponent implements OnInit { console.log(error.text()); } ); + + this.shippingService.getUserShippingList().subscribe( + res=>{ + console.log(res.json()); + this.userShippingList=res.json(); + this.emptyShippingList = false; + }, + error=>{ + console.log(error.text()); + } + ); + + for (let s in AppConst.usStates) { + this.stateList.push(s); + } + + this.billingAddress.billingAddressState=""; + + this.shippingAddress.shippingAddressState=""; } diff --git a/store-front/src/app/services/shipping.service.ts b/store-front/src/app/services/shipping.service.ts index 970b2ef..e30a6c4 100644 --- a/store-front/src/app/services/shipping.service.ts +++ b/store-front/src/app/services/shipping.service.ts @@ -19,6 +19,16 @@ export class ShippingService { return this.http.post(url, JSON.stringify(shipping), {headers : tokenHeader}); } + getUserShippingList() { + let url = this.serverPath+"/shipping/getUserShippingList"; + + let tokenHeader = new Headers ({ + 'Content-Type': 'application/json', + 'x-auth-token' : localStorage.getItem("xAuthToken") + }); + return this.http.get(url, {headers : tokenHeader}); + } + removeShipping(id: number) { let url = this.serverPath+"/shipping/remove";
Available Shipping Address - use + use this address