Skip to content

Commit

Permalink
show product image on user favorites page (#114)
Browse files Browse the repository at this point in the history
add td tag in favorite product image
  • Loading branch information
chandradot99 authored and pkrawat1 committed May 2, 2018
1 parent 8883df1 commit 00f2d81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/app/core/services/product.service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getUserFavoriteProducts } from './../../user/reducers/selector';
import { getTaxonomies } from './../../product/reducers/selectors';
import { Taxonomy } from './../models/taxonomy';
import { HttpClient } from '@angular/common/http';
Expand Down Expand Up @@ -48,7 +49,9 @@ export class ProductService {

removeFromFavorite(id: number): Observable<{}> { return this.http.delete<{}>(`favorite_products/${id}`) }

getFavoriteProducts(): Observable<Array<Product>> { return this.http.get<Array<Product>>(`favorite_products`) }
getFavoriteProducts(): Observable<Array<Product>> { return this.http.get<Array<Product>>(`favorite_products.json`) }

getUserFavoriteProducts(): Observable<Array<Product>> { return this.http.get<Array<Product>>(`spree/user_favorite_products.json`) }

// tslint:disable-next-line:max-line-length
getProducts_by_taxon(id: number): Observable<Array<Product>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<tr>
<td>
<img [src]="getProductImageUrl()" width="150px" height="150px">
</td>
<td>{{ product.name }}</td>
<td>{{ product.description }}</td>
<td>
<button (click)="removeFromFavorite(product.id)" class="btn btn-primary">Remove</button>
</td>
</tr>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ export class FavoriteProductListItemComponent implements OnInit {
});
}

getProductImageUrl() {
// tslint:disable-next-line:max-line-length
return environment.apiEndpoint + `/spree/products/${this.product.master.images[0].id}/product/${this.product.master.images[0].attachment_file_name}`
}

}
2 changes: 1 addition & 1 deletion src/app/user/effects/user.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class UserEffects {
@Effect()
GetUserFavoriteProducts$: Observable<Action> = this.actions$
.ofType(UserActions.GET_USER_FAVORITE_PRODUCTS)
.switchMap(() => this.productService.getFavoriteProducts())
.switchMap(() => this.productService.getUserFavoriteProducts())
.map((products) => this.userActions.getUserFavoriteProductsSuccess(products));

}

0 comments on commit 00f2d81

Please sign in to comment.