[HIMA-69][HIMA-73] fixed price format

This commit is contained in:
Eraldo Hasanaj
2019-02-10 17:32:50 +01:00
parent b08d1d829c
commit 25146545b5
7 changed files with 36 additions and 6 deletions

View File

@@ -23,7 +23,7 @@
</div>
</div>
<div class="price align-right">
<span>{{ product.price }}</span>
<span>{{ price }}</span>
<span class="currency">{{ product.currency }}</span>
</div>
</div>

View File

@@ -29,6 +29,13 @@ export class ProductCardComponent implements OnInit {
}
}
get price() {
if (this._product.price.toString().indexOf('.') === -1) {
return this._product.price + ',00';
}
return this._product.price.toString().replace('.', ',');
}
eanChangedSub = new ReplaySubject<string>();
imageUrl$: Observable<string>;

View File

@@ -86,7 +86,7 @@ export class ProductDetailsComponent implements OnInit {
if (item.pr) {
ean = item.pr.ean;
eanTag = ean;
productIcon$ = this.catImageService.getImageUrl(ean, { width: 469, height: 575});
productIcon$ = this.catImageService.getImageUrl(ean, { width: 469, height: 575 });
locale = item.pr.locale;
publicationDate = getFormatedPublicationDate(item.pr.publicationDate);
format = this.selectedItem ? this.selectedItem.pr.formatDetail : null;
@@ -109,6 +109,11 @@ export class ProductDetailsComponent implements OnInit {
if (item.av.length > 0) {
quantity = (item.av[0].qty ? item.av[0].qty : 0) + 'x';
price = item.av[0].price.value.value + ' ' + item.av[0].price.value.currency;
if (item.av[0].price.value.value.toString().indexOf('.') === -1) {
price = item.av[0].price.value.value + ',00 ' + item.av[0].price.value.currency;
} else {
price = item.av[0].price.value.value.toString().replace('.', ',') + ' ' + item.av[0].price.value.currency;
}
}
return {

View File

@@ -26,7 +26,8 @@ export class FeedMapping {
firstBookType: feed.items[0].pr.formatDetail,
firstBookIcon: feed.items[0].pr.format,
firstBookLanguage: feed.items[0].pr.locale,
firstBookPrice: feed.items[0].av[0].price.value.value + ' ' + feed.items[0].av[0].price.value.currency
firstBookPrice: feed.items[0].av[0].price.value.value,
firstBookCurrency: feed.items[0].av[0].price.value.currency
};
if (feed.items[1]) {
books = {
@@ -38,7 +39,8 @@ export class FeedMapping {
secondBookTypeIcon: feed.items[1].pr.format,
secondBookIcon: feed.items[1].pr.format,
secondBookLanguage: feed.items[1].pr.locale,
secondBookPrice: feed.items[1].av[0].price.value.value + ' ' + feed.items[0].av[0].price.value.currency
secondBookPrice: feed.items[1].av[0].price.value.value,
secondBookCurrency: feed.items[1].av[0].price.value.currency
};
}
} else if (feed.type === 'events') {

View File

@@ -7,6 +7,7 @@ export interface FeedBook {
firstBookTypeIcon: string;
firstBookLanguage: string;
firstBookPrice: string;
firstBookCurrency: string;
firstBookIcon: string;
secondBookEan?: string;
secondBookAuthor?: string;
@@ -16,4 +17,5 @@ export interface FeedBook {
secondBookLanguage?: string;
secondBookPrice?: string;
secondBookIcon?: string;
secondBookCurrency?: string;
}

View File

@@ -20,7 +20,7 @@
<div class="item-details wrap-text-more">{{card.books.firstBookLanguage}}</div>
<div class="separator">|</div>
</div>
<div class="item-details wrap-text-more">{{card.books.firstBookPrice}}</div>
<div class="item-details wrap-text-more">{{price}}</div>
</div>
</div>
</div>
@@ -41,7 +41,7 @@
<div class="item-details wrap-text-more">{{card.books.secondBookLanguage}}</div>
<div class="separator">|</div>
</div>
<div class="item-details wrap-text-more">{{card.books.secondBookPrice}}</div>
<div class="item-details wrap-text-more">{{secondPrice}}</div>
</div>
</div>
</div>

View File

@@ -16,6 +16,20 @@ export class BookCardComponent implements OnInit {
constructor(private catImageService: CatImageService) { }
get price() {
if (this.card.books.firstBookPrice.toString().indexOf('.') === -1) {
return this.card.books.firstBookPrice + ',00 ' + this.card.books.firstBookCurrency;
}
return this.card.books.firstBookPrice.replace('.', ',') + ' ' + this.card.books.firstBookCurrency;
}
get secondPrice() {
if (this.card.books.secondBookPrice.toString().indexOf('.') === -1) {
return this.card.books.secondBookPrice + ',00 ' + this.card.books.secondBookPrice;
}
return this.card.books.secondBookPrice.replace('.', ',') + ' ' + this.card.books.secondBookPrice;
}
ngOnInit() {
this.catImageService.getImageUrl(this.card.books.firstBookEan).subscribe(
(url: string) => this.firstBookImageUrl$ = of(url)