From 7d26ef882d161b027f4e2580c2d8aac5e6f254aa Mon Sep 17 00:00:00 2001 From: Miguel Veloso Date: Tue, 15 Jun 2021 17:07:38 +0100 Subject: [PATCH] Initial SPA application working --- .../src/modules/basket/basket.component.scss | 4 --- .../src/modules/basket/basket.service.ts | 24 ------------- .../orders-detail.component.html | 9 ----- .../orders-new/orders-new.component.html | 34 +----------------- .../orders-new/orders-new.component.scss | 4 --- .../orders/orders-new/orders-new.component.ts | 36 ------------------- .../src/modules/orders/orders.service.ts | 9 ----- 7 files changed, 1 insertion(+), 119 deletions(-) diff --git a/src/Web/WebSPA/Client/src/modules/basket/basket.component.scss b/src/Web/WebSPA/Client/src/modules/basket/basket.component.scss index ca6733158..10edb11ec 100644 --- a/src/Web/WebSPA/Client/src/modules/basket/basket.component.scss +++ b/src/Web/WebSPA/Client/src/modules/basket/basket.component.scss @@ -106,10 +106,6 @@ background-color: $color-brightest; } - &-coupon { - width: 7rem; - } - &-checkout-title { font-weight: $font-weight-semibold; text-align: center; diff --git a/src/Web/WebSPA/Client/src/modules/basket/basket.service.ts b/src/Web/WebSPA/Client/src/modules/basket/basket.service.ts index 0686ec1df..b14ff3e9b 100644 --- a/src/Web/WebSPA/Client/src/modules/basket/basket.service.ts +++ b/src/Web/WebSPA/Client/src/modules/basket/basket.service.ts @@ -13,7 +13,6 @@ import { StorageService } from '../shared/services/storage.service'; import { Observable, Observer, Subject } from 'rxjs'; import { map, catchError, tap } from 'rxjs/operators'; -import { ICoupon } from '../shared/models/coupon.model'; @Injectable() export class BasketService { @@ -96,27 +95,6 @@ export class BasketService { })); } - checkValidationCoupon(code: string): Observable { - let url = this.purchaseUrl + `/cp/api/v1/coupon/${code}`; - - return this.service - .get(url) - .pipe(map((response) => - { - console.log(`Coupon: ${response.json()} (${response.ok})`); - var item = response.json[0]; - - if (response.ok) { - item.message = "Valid coupon"; - } - else { - item.message = "The coupon is not valid or has already been used"; - } - - return item; - })); - } - mapBasketInfoCheckout(order: IOrder): IBasketCheckout { let basketCheckout = {}; @@ -130,8 +108,6 @@ export class BasketService { basketCheckout.cardsecuritynumber = order.cardsecuritynumber; basketCheckout.cardtypeid = order.cardtypeid; basketCheckout.cardholdername = order.cardholdername; - basketCheckout.coupon = order.coupon; - basketCheckout.discount = order.discount; basketCheckout.total = 0; basketCheckout.expiration = order.expiration; diff --git a/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.html b/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.html index 2e3aa40f9..04face7ff 100644 --- a/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.html +++ b/src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.html @@ -34,15 +34,6 @@ -
-
Subtotal
-
${{order.subtotal | number:'.2-2'}}
-
-
-
{{order.coupon}}
-
- ${{order.discount | number:'.2-2'}}
-
-
Total
${{order.total | number:'.2-2'}}
diff --git a/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.html b/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.html index 579efdd1e..18311597a 100644 --- a/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.html +++ b/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.html @@ -84,41 +84,9 @@
-
-
Subtotal
-
${{order.total | number:'.2-2'}}
-
- -
-
-
-
Have a discount code?
-
- - -
-
{{couponValidationMessage}}
-
-
-
-
{{coupon?.code}}
-
-
-${{coupon?.discount | number:'.2-2'}}
-
-
-
-
Total
-
${{ (coupon?.discount ? ((order.total - coupon?.discount) < 0 ? 0 : (order.total - coupon?.discount)) : order.total) | number:'.2-2'}}
+
${{ order.total | number:'.2-2'}}
diff --git a/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.scss b/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.scss index 91b73c6ed..25bdc60af 100644 --- a/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.scss +++ b/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.scss @@ -33,10 +33,6 @@ width: auto; } - &-coupon { - width: 15rem; - } - &-buttons { margin-top: 5rem; } diff --git a/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.ts b/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.ts index 141e66ff7..ff84b7638 100644 --- a/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.ts +++ b/src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.ts @@ -6,7 +6,6 @@ import { OrdersService } from '../orders.service'; import { BasketService } from '../../basket/basket.service'; import { IOrder } from '../../shared/models/order.model'; import { BasketWrapperService } from '../../shared/services/basket.wrapper.service'; -import { ICoupon } from '../../shared/models/coupon.model'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Router } from '@angular/router'; @@ -21,9 +20,6 @@ export class OrdersNewComponent implements OnInit { isOrderProcessing: boolean; errorReceived: boolean; order: IOrder; - coupon: ICoupon; - discountCode: string; - couponValidationMessage: string; constructor(private orderService: OrdersService, private basketService: BasketService, fb: FormBuilder, private router: Router) { // Obtain user profile information @@ -43,30 +39,6 @@ export class OrdersNewComponent implements OnInit { ngOnInit() { } - keyDownValidationCoupon(event: KeyboardEvent, discountCode: string) { - if(event.keyCode === 13) { - event.preventDefault(); - this.checkValidationCoupon(discountCode); - } - } - - checkValidationCoupon(discountCode: string) { - this.couponValidationMessage = null; - this.coupon = null; - this.orderService - .checkValidationCoupon(discountCode) - .subscribe( - coupon => this.coupon = coupon, - error => { - if (error.status == 404) { - this.couponValidationMessage = `${error.error}!`; - } else { - this.couponValidationMessage = `ERROR: ${error.status} - ${error.statusText}!`; - } - console.log(error); - }); - } - submitForm(value: any) { this.order.street = this.newOrderForm.controls['street'].value; this.order.city = this.newOrderForm.controls['city'].value; @@ -77,14 +49,6 @@ export class OrdersNewComponent implements OnInit { this.order.cardholdername = this.newOrderForm.controls['cardholdername'].value; this.order.cardexpiration = new Date(20 + this.newOrderForm.controls['expirationdate'].value.split('/')[1], this.newOrderForm.controls['expirationdate'].value.split('/')[0]); this.order.cardsecuritynumber = this.newOrderForm.controls['securitycode'].value; - - if (this.coupon) { - console.log(`Coupon: ${this.coupon.code} (${this.coupon.discount})`); - - this.order.coupon = this.coupon.code; - this.order.discount = this.coupon.discount; - } - let basketCheckout = this.basketService.mapBasketInfoCheckout(this.order); this.basketService.setBasketCheckout(basketCheckout) .pipe(catchError((errMessage) => { diff --git a/src/Web/WebSPA/Client/src/modules/orders/orders.service.ts b/src/Web/WebSPA/Client/src/modules/orders/orders.service.ts index 1b9508e62..e81d6da64 100644 --- a/src/Web/WebSPA/Client/src/modules/orders/orders.service.ts +++ b/src/Web/WebSPA/Client/src/modules/orders/orders.service.ts @@ -10,7 +10,6 @@ import { BasketWrapperService } from '../shared/services/basket.wrapper.service' import { Observable } from 'rxjs'; import { tap, map } from 'rxjs/operators'; -import { ICoupon } from '../shared/models/coupon.model'; @Injectable() export class OrdersService { @@ -49,14 +48,6 @@ export class OrdersService { })); } - checkValidationCoupon(code: string): Observable { - let url = this.ordersUrl + `/cp/api/v1/coupon/${code}`; - - return this.service.get(url).pipe(tap((response: any) => { - return response; - })); - } - mapOrderAndIdentityInfoNewOrder(): IOrder { let order = {}; let basket = this.basketService.basket;