Skip to content

Commit

Permalink
fix: set correct URL for sharing product page via email (#128, #138)
Browse files Browse the repository at this point in the history
- removed currentUrl$ from AppFacade
- use document.URL for sharing link

Closes #128
  • Loading branch information
dhhyi authored and shauke committed Mar 2, 2020
1 parent 68c882d commit a338c22
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 23 deletions.
9 changes: 1 addition & 8 deletions src/app/core/facades/app.facade.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Location } from '@angular/common';
import { Injectable } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';

import { getICMBaseURL } from 'ish-core/store/configuration';
import { LoadCountries, getAllCountries, getCountriesLoading } from 'ish-core/store/countries';
import { getGeneralError, getGeneralErrorType } from 'ish-core/store/error';
import { getAvailableLocales, getCurrentLocale } from 'ish-core/store/locale';
Expand All @@ -19,12 +17,7 @@ import {

@Injectable({ providedIn: 'root' })
export class AppFacade {
constructor(private store: Store<{}>, private location: Location) {}

currentUrl$ = this.store.pipe(
select(getICMBaseURL),
map(baseUrl => baseUrl + this.location.path())
);
constructor(private store: Store<{}>) {}

headerType$ = this.store.pipe(select(getHeaderType));
deviceType$ = this.store.pipe(select(getDeviceType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<a
href="mailto:
?subject={{ 'email.recommended_product.heading' | translate: { '0': channelName } }}
&body={{ 'email.recommended_product.text' | translate: { '0': product.name + '%0A', '1': currentUrl } }}"
&body={{ 'email.recommended_product.text' | translate: { '0': product.name + '%0A', '1': document.URL } }}"
>
<fa-icon [icon]="['fas', 'paper-plane']"></fa-icon>
<span class="share-label">{{ 'product.email_a_friend.link' | translate }}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, Output } from '@angular/core';

import { Product, ProductHelper } from 'ish-core/models/product/product.model';

Expand All @@ -9,7 +10,6 @@ import { Product, ProductHelper } from 'ish-core/models/product/product.model';
})
export class ProductDetailActionsComponent {
@Input() product: Product;
@Input() currentUrl: string;
@Output() productToCompare = new EventEmitter<void>();

// TODO: to be removed once channelName inforamtion available in system
Expand All @@ -20,4 +20,6 @@ export class ProductDetailActionsComponent {
addToCompare() {
this.productToCompare.emit();
}

constructor(@Inject(DOCUMENT) public document: Document) {}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<ish-product-detail-actions
[product]="product"
[currentUrl]="currentUrl"
(productToCompare)="addToCompare()"
></ish-product-detail-actions>
<ish-product-detail-actions [product]="product" (productToCompare)="addToCompare()"></ish-product-detail-actions>

<div class="row product-details">
<div class="col-12 col-md-6 col-lg-8"><ish-product-images [product]="product"></ish-product-images></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class ProductDetailComponent implements OnInit, OnDestroy {
@Input() product: ProductView | VariationProductView | VariationProductMasterView;
@Input() quantity: number;
@Input() price: ProductPrices;
@Input() currentUrl: string;
@Input() variationOptions: VariationOptionGroup[];
@Output() productToBasket = new EventEmitter<{ sku: string; quantity: number }>();
@Output() productToCompare = new EventEmitter<string>();
Expand Down
1 change: 0 additions & 1 deletion src/app/pages/product/product-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
[product]="product"
[price]="price$ | async"
[(quantity)]="quantity"
[currentUrl]="currentUrl$ | async"
[variationOptions]="productVariationOptions$ | async"
(productToBasket)="addToBasket()"
(productToCompare)="addToCompare($event)"
Expand Down
5 changes: 0 additions & 5 deletions src/app/pages/product/product-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Router } from '@angular/router';
import { Observable, ReplaySubject, Subject, of } from 'rxjs';
import { filter, map, switchMap, take, takeUntil, withLatestFrom } from 'rxjs/operators';

import { AppFacade } from 'ish-core/facades/app.facade';
import { ShoppingFacade } from 'ish-core/facades/shopping.facade';
import { FeatureToggleService } from 'ish-core/feature-toggle.module';
import { CategoryView } from 'ish-core/models/category-view/category-view.model';
Expand Down Expand Up @@ -38,8 +37,6 @@ export class ProductPageComponent implements OnInit, OnDestroy {
quantity: number;
price$: Observable<ProductPrices>;

currentUrl$: Observable<string>;

isProductBundle = ProductHelper.isProductBundle;
isRetailSet = ProductHelper.isRetailSet;
isMasterProduct = ProductHelper.isMasterProduct;
Expand All @@ -48,7 +45,6 @@ export class ProductPageComponent implements OnInit, OnDestroy {
retailSetParts$ = new ReplaySubject<SkuQuantityType[]>(1);

constructor(
private appFacade: AppFacade,
private shoppingFacade: ShoppingFacade,
private router: Router,
private featureToggleService: FeatureToggleService,
Expand All @@ -61,7 +57,6 @@ export class ProductPageComponent implements OnInit, OnDestroy {
this.productVariationOptions$ = this.shoppingFacade.selectedProductVariationOptions$;
this.category$ = this.shoppingFacade.selectedCategory$;
this.productLoading$ = this.shoppingFacade.productDetailLoading$;
this.currentUrl$ = this.appFacade.currentUrl$;

this.product$
.pipe(
Expand Down

0 comments on commit a338c22

Please sign in to comment.