format
This commit is contained in:
parent
791e7d646c
commit
01b8d50f64
@ -1,17 +1,17 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Response } from '@angular/http';
|
import { Response } from '@angular/http';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { DataService } from '../shared/services/data.service';
|
import { DataService } from '../shared/services/data.service';
|
||||||
import { SecurityService } from '../shared/services/security.service';
|
import { SecurityService } from '../shared/services/security.service';
|
||||||
import { IBasket } from '../shared/models/basket.model';
|
import { IBasket } from '../shared/models/basket.model';
|
||||||
import { IOrder } from '../shared/models/order.model';
|
import { IOrder } from '../shared/models/order.model';
|
||||||
import { IBasketCheckout } from '../shared/models/basketCheckout.model';
|
import { IBasketCheckout } from '../shared/models/basketCheckout.model';
|
||||||
import { BasketWrapperService } from '../shared/services/basket.wrapper.service';
|
import { BasketWrapperService } from '../shared/services/basket.wrapper.service';
|
||||||
import { ConfigurationService } from '../shared/services/configuration.service';
|
import { ConfigurationService } from '../shared/services/configuration.service';
|
||||||
import { StorageService } from '../shared/services/storage.service';
|
import { StorageService } from '../shared/services/storage.service';
|
||||||
|
|
||||||
import { Observable, Observer, Subject } from 'rxjs';
|
import { Observable, Observer, Subject } from 'rxjs';
|
||||||
import { map, catchError } from 'rxjs/operators';
|
import { map, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -26,16 +26,16 @@ export class BasketService {
|
|||||||
//observable that is fired when the basket is dropped
|
//observable that is fired when the basket is dropped
|
||||||
private basketDropedSource = new Subject();
|
private basketDropedSource = new Subject();
|
||||||
basketDroped$ = this.basketDropedSource.asObservable();
|
basketDroped$ = this.basketDropedSource.asObservable();
|
||||||
|
|
||||||
constructor(private service: DataService, private authService: SecurityService, private basketEvents: BasketWrapperService, private router: Router, private configurationService: ConfigurationService, private storageService: StorageService) {
|
constructor(private service: DataService, private authService: SecurityService, private basketEvents: BasketWrapperService, private router: Router, private configurationService: ConfigurationService, private storageService: StorageService) {
|
||||||
this.basket.items = [];
|
this.basket.items = [];
|
||||||
|
|
||||||
// Init:
|
// Init:
|
||||||
if (this.authService.IsAuthorized) {
|
if (this.authService.IsAuthorized) {
|
||||||
if (this.authService.UserData) {
|
if (this.authService.UserData) {
|
||||||
this.basket.buyerId = this.authService.UserData.sub;
|
this.basket.buyerId = this.authService.UserData.sub;
|
||||||
if (this.configurationService.isReady) {
|
if (this.configurationService.isReady) {
|
||||||
this.basketUrl = this.configurationService.serverSettings.purchaseUrl;
|
this.basketUrl = this.configurationService.serverSettings.purchaseUrl;
|
||||||
this.purchaseUrl = this.configurationService.serverSettings.purchaseUrl;
|
this.purchaseUrl = this.configurationService.serverSettings.purchaseUrl;
|
||||||
this.loadData();
|
this.loadData();
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ export class BasketService {
|
|||||||
this.dropBasket();
|
this.dropBasket();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addItemToBasket(item): Observable<boolean> {
|
addItemToBasket(item): Observable<boolean> {
|
||||||
this.basket.items.push(item);
|
this.basket.items.push(item);
|
||||||
return this.setBasket(this.basket);
|
return this.setBasket(this.basket);
|
||||||
@ -83,7 +83,7 @@ export class BasketService {
|
|||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
mapBasketInfoCheckout(order: IOrder): IBasketCheckout {
|
mapBasketInfoCheckout(order: IOrder): IBasketCheckout {
|
||||||
let basketCheckout = <IBasketCheckout>{};
|
let basketCheckout = <IBasketCheckout>{};
|
||||||
@ -102,10 +102,10 @@ export class BasketService {
|
|||||||
basketCheckout.expiration = order.expiration;
|
basketCheckout.expiration = order.expiration;
|
||||||
|
|
||||||
return basketCheckout;
|
return basketCheckout;
|
||||||
}
|
}
|
||||||
|
|
||||||
dropBasket() {
|
dropBasket() {
|
||||||
this.basket.items = [];
|
this.basket.items = [];
|
||||||
this.basketDropedSource.next();
|
this.basketDropedSource.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user