Skip to content

Commit 7d26ef8

Browse files
committed
Initial SPA application working
1 parent ae45ffb commit 7d26ef8

7 files changed

Lines changed: 1 addition & 119 deletions

File tree

src/Web/WebSPA/Client/src/modules/basket/basket.component.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@
106106
background-color: $color-brightest;
107107
}
108108

109-
&-coupon {
110-
width: 7rem;
111-
}
112-
113109
&-checkout-title {
114110
font-weight: $font-weight-semibold;
115111
text-align: center;

src/Web/WebSPA/Client/src/modules/basket/basket.service.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { StorageService } from '../shared/services/storage.service';
1313

1414
import { Observable, Observer, Subject } from 'rxjs';
1515
import { map, catchError, tap } from 'rxjs/operators';
16-
import { ICoupon } from '../shared/models/coupon.model';
1716

1817
@Injectable()
1918
export class BasketService {
@@ -96,27 +95,6 @@ export class BasketService {
9695
}));
9796
}
9897

99-
checkValidationCoupon(code: string): Observable<ICoupon> {
100-
let url = this.purchaseUrl + `/cp/api/v1/coupon/${code}`;
101-
102-
return this.service
103-
.get(url)
104-
.pipe<ICoupon>(map<Response, ICoupon>((response) =>
105-
{
106-
console.log(`Coupon: ${response.json()} (${response.ok})`);
107-
var item = <ICoupon>response.json[0];
108-
109-
if (response.ok) {
110-
item.message = "Valid coupon";
111-
}
112-
else {
113-
item.message = "The coupon is not valid or has already been used";
114-
}
115-
116-
return item;
117-
}));
118-
}
119-
12098
mapBasketInfoCheckout(order: IOrder): IBasketCheckout {
12199
let basketCheckout = <IBasketCheckout>{};
122100

@@ -130,8 +108,6 @@ export class BasketService {
130108
basketCheckout.cardsecuritynumber = order.cardsecuritynumber;
131109
basketCheckout.cardtypeid = order.cardtypeid;
132110
basketCheckout.cardholdername = order.cardholdername;
133-
basketCheckout.coupon = order.coupon;
134-
basketCheckout.discount = order.discount;
135111
basketCheckout.total = 0;
136112
basketCheckout.expiration = order.expiration;
137113

src/Web/WebSPA/Client/src/modules/orders/orders-detail/orders-detail.component.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ <h2 class="esh-orders_detail-title mt-5">Shiping address</h2>
3434
</div>
3535
</article>
3636

37-
<div class="d-flex align-items-center justify-content-end mt-4 mb-4 text-uppercase">
38-
<div>Subtotal</div>
39-
<div class="ml-3">${{order.subtotal | number:'.2-2'}}</div>
40-
</div>
41-
<div class="d-flex align-items-center justify-content-end mt-4 mb-4 text-uppercase">
42-
<div>{{order.coupon}}</div>
43-
<div class="ml-3">- ${{order.discount | number:'.2-2'}}</div>
44-
</div>
45-
4637
<div class="d-flex align-items-center justify-content-end mt-4 mb-4 text-uppercase u-text-xl">
4738
<div>Total</div>
4839
<div class="ml-3">${{order.total | number:'.2-2'}}</div>

src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.html

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,41 +84,9 @@ <h2 class="mt-5 mb-4">Order details</h2>
8484
</div>
8585
</article>
8686

87-
<div class="d-flex align-items-center justify-content-end mt-4 mb-4 text-uppercase">
88-
<div>Subtotal</div>
89-
<div class="ml-3">${{order.total | number:'.2-2'}}</div>
90-
</div>
91-
92-
<div class="d-flex flex-nowrap justify-content-between align-items-center mb-3 mt-3">
93-
<div>
94-
<div *ngIf="!coupon">
95-
<div class="u-text-uppercase">Have a discount code?</div>
96-
<div class="d-flex flex-nowrap justify-content-between align-items-center mt-1">
97-
<input
98-
#discountcode
99-
class="esh-orders_new-coupon mr-2 form-control"
100-
type="text"
101-
placeholder="Coupon number"
102-
(keydown)="keyDownValidationCoupon($event, discountcode.value)">
103-
<button
104-
type="button"
105-
(click)="checkValidationCoupon(discountcode.value)"
106-
class="btn btn-secondary u-minwidth-unset">Apply</button>
107-
</div>
108-
<div class="mt-1" *ngIf="couponValidationMessage">{{couponValidationMessage}}</div>
109-
</div>
110-
</div>
111-
<div class="d-flex align-items-center justify-content-end text-uppercase">
112-
<div *ngIf="coupon?.code">{{coupon?.code}}</div>
113-
<div>
114-
<div class="text-right ml-3" *ngIf="coupon?.discount">-${{coupon?.discount | number:'.2-2'}}</div>
115-
</div>
116-
</div>
117-
</div>
118-
11987
<div class="divider d-flex align-items-center justify-content-end mb-4 pt-4 text-uppercase u-text-xl">
12088
<div>Total</div>
121-
<div class="ml-3">${{ (coupon?.discount ? ((order.total - coupon?.discount) < 0 ? 0 : (order.total - coupon?.discount)) : order.total) | number:'.2-2'}}</div>
89+
<div class="ml-3">${{ order.total | number:'.2-2'}}</div>
12290
</div>
12391

12492
<div class="esh-orders_new-buttons d-flex justify-content-end align-items-center">

src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
width: auto;
3434
}
3535

36-
&-coupon {
37-
width: 15rem;
38-
}
39-
4036
&-buttons {
4137
margin-top: 5rem;
4238
}

src/Web/WebSPA/Client/src/modules/orders/orders-new/orders-new.component.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { OrdersService } from '../orders.service';
66
import { BasketService } from '../../basket/basket.service';
77
import { IOrder } from '../../shared/models/order.model';
88
import { BasketWrapperService } from '../../shared/services/basket.wrapper.service';
9-
import { ICoupon } from '../../shared/models/coupon.model';
109

1110
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
1211
import { Router } from '@angular/router';
@@ -21,9 +20,6 @@ export class OrdersNewComponent implements OnInit {
2120
isOrderProcessing: boolean;
2221
errorReceived: boolean;
2322
order: IOrder;
24-
coupon: ICoupon;
25-
discountCode: string;
26-
couponValidationMessage: string;
2723

2824
constructor(private orderService: OrdersService, private basketService: BasketService, fb: FormBuilder, private router: Router) {
2925
// Obtain user profile information
@@ -43,30 +39,6 @@ export class OrdersNewComponent implements OnInit {
4339
ngOnInit() {
4440
}
4541

46-
keyDownValidationCoupon(event: KeyboardEvent, discountCode: string) {
47-
if(event.keyCode === 13) {
48-
event.preventDefault();
49-
this.checkValidationCoupon(discountCode);
50-
}
51-
}
52-
53-
checkValidationCoupon(discountCode: string) {
54-
this.couponValidationMessage = null;
55-
this.coupon = null;
56-
this.orderService
57-
.checkValidationCoupon(discountCode)
58-
.subscribe(
59-
coupon => this.coupon = coupon,
60-
error => {
61-
if (error.status == 404) {
62-
this.couponValidationMessage = `${error.error}!`;
63-
} else {
64-
this.couponValidationMessage = `ERROR: ${error.status} - ${error.statusText}!`;
65-
}
66-
console.log(error);
67-
});
68-
}
69-
7042
submitForm(value: any) {
7143
this.order.street = this.newOrderForm.controls['street'].value;
7244
this.order.city = this.newOrderForm.controls['city'].value;
@@ -77,14 +49,6 @@ export class OrdersNewComponent implements OnInit {
7749
this.order.cardholdername = this.newOrderForm.controls['cardholdername'].value;
7850
this.order.cardexpiration = new Date(20 + this.newOrderForm.controls['expirationdate'].value.split('/')[1], this.newOrderForm.controls['expirationdate'].value.split('/')[0]);
7951
this.order.cardsecuritynumber = this.newOrderForm.controls['securitycode'].value;
80-
81-
if (this.coupon) {
82-
console.log(`Coupon: ${this.coupon.code} (${this.coupon.discount})`);
83-
84-
this.order.coupon = this.coupon.code;
85-
this.order.discount = this.coupon.discount;
86-
}
87-
8852
let basketCheckout = this.basketService.mapBasketInfoCheckout(this.order);
8953
this.basketService.setBasketCheckout(basketCheckout)
9054
.pipe(catchError((errMessage) => {

src/Web/WebSPA/Client/src/modules/orders/orders.service.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { BasketWrapperService } from '../shared/services/basket.wrapper.service'
1010

1111
import { Observable } from 'rxjs';
1212
import { tap, map } from 'rxjs/operators';
13-
import { ICoupon } from '../shared/models/coupon.model';
1413

1514
@Injectable()
1615
export class OrdersService {
@@ -49,14 +48,6 @@ export class OrdersService {
4948
}));
5049
}
5150

52-
checkValidationCoupon(code: string): Observable<ICoupon> {
53-
let url = this.ordersUrl + `/cp/api/v1/coupon/${code}`;
54-
55-
return this.service.get(url).pipe<ICoupon>(tap((response: any) => {
56-
return response;
57-
}));
58-
}
59-
6051
mapOrderAndIdentityInfoNewOrder(): IOrder {
6152
let order = <IOrder>{};
6253
let basket = this.basketService.basket;

0 commit comments

Comments
 (0)