From fe2c064e3003fbdf79c6dc1cdf02dae0c02353c2 Mon Sep 17 00:00:00 2001 From: Jegor Date: Thu, 17 Jun 2021 10:55:30 +0200 Subject: [PATCH] wip: hot-deals vendors --- .../hot-deals-widget.component.html | 2 +- .../hot-deals-widget/hot-deals-widget.component.ts | 13 ++++++++++++- .../app/components/top-bar/top-bar.component.html | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html index 947b3f9..7a43211 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html @@ -20,7 +20,7 @@
Amazon: {{productsPricesMap[productId]?.amazonPrice?.price_in_cents/100}}$
-
Plantshub: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}
+
{{productsPricesMap[productId]?.vendor?.name}}: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}
diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts index 0fe7af1..95635d7 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts @@ -13,7 +13,7 @@ export class HotDealsWidgetComponent implements OnInit { products: Product[] = []; bestDealsProductIds = []; amazonPrices = []; - productsPricesMap: any = {}; + productsPricesMap = new Map(); @Input() numberOfProducts: number; @Input() showProductPicture: boolean; @Input() searchQuery: string; @@ -52,6 +52,7 @@ export class HotDealsWidgetComponent implements OnInit { default: { this.getProductsByIds(); this.getAmazonPricesForBestDeals(); + this.getVendors() break; } } @@ -79,6 +80,16 @@ export class HotDealsWidgetComponent implements OnInit { ); } + getVendors(): void { + this.productsPricesMap.keys().forEach( + key => { + const currentDeal = this.productsPricesMap[key].lowestPrice; + this.apiService.getVendorById(currentDeal.vendor_id).subscribe( + vendor => { + this.productsPricesMap[key].vendor = vendor + }) + }) + } getAmazonPricesForBestDeals(): void{ diff --git a/Frontend/src/app/components/top-bar/top-bar.component.html b/Frontend/src/app/components/top-bar/top-bar.component.html index 2e3ebd8..651adb2 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.html +++ b/Frontend/src/app/components/top-bar/top-bar.component.html @@ -1,9 +1,9 @@