Commit 98c5af6c authored by prumde's avatar prumde

Updated for wishlist


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174457 ce508802-f39f-4f6c-b175-0d175dae99d5
parent aecb2060
...@@ -25,6 +25,13 @@ export class CategoryActions { ...@@ -25,6 +25,13 @@ export class CategoryActions {
} }
static RESET_CATEGORY_LIST = '[CATEGORY LIST] Reset CATEGORY_LIST';
resetCategoryList(): Action {
return {
type: CategoryActions.RESET_CATEGORY_LIST
};
}
static GET_CATEGORY = '[CATEGORY] Get CATEGORY'; static GET_CATEGORY = '[CATEGORY] Get CATEGORY';
getCategory(catCode): Action { getCategory(catCode): Action {
return { return {
......
...@@ -2,6 +2,7 @@ import { CartActions } from './cart'; ...@@ -2,6 +2,7 @@ import { CartActions } from './cart';
import { CategoryActions } from './category'; import { CategoryActions } from './category';
import { SubCategoryActions } from './subcategory'; import { SubCategoryActions } from './subcategory';
import { ItemActions } from './item'; import { ItemActions } from './item';
import { WishListActions } from './wishlist';
import { LocationActions } from './location'; import { LocationActions } from './location';
export { export {
...@@ -9,7 +10,8 @@ export { ...@@ -9,7 +10,8 @@ export {
CategoryActions, CategoryActions,
SubCategoryActions, SubCategoryActions,
ItemActions, ItemActions,
LocationActions LocationActions,
WishListActions
}; };
export default [ export default [
...@@ -17,5 +19,6 @@ export default [ ...@@ -17,5 +19,6 @@ export default [
CategoryActions, CategoryActions,
SubCategoryActions, SubCategoryActions,
ItemActions, ItemActions,
LocationActions LocationActions,
WishListActions
]; ];
\ No newline at end of file
...@@ -26,6 +26,13 @@ export class ItemActions { ...@@ -26,6 +26,13 @@ export class ItemActions {
} }
static RESET_ITEM_LIST = '[ITEM LIST] Reset ITEM LIST';
resetItemList(): Action {
return {
type: ItemActions.RESET_ITEM_LIST
};
}
static GET_ITEM = '[ITEM] Get ITEM'; static GET_ITEM = '[ITEM] Get ITEM';
getItem(itemCode): Action { getItem(itemCode): Action {
return { return {
......
...@@ -28,6 +28,13 @@ export class SubCategoryActions { ...@@ -28,6 +28,13 @@ export class SubCategoryActions {
} }
static RESET_SUBCATEGORY_LIST = '[SUBCATEGORY_LIST] Reset SUBCATEGORY_LIST';
resetSubCategoryList(): Action {
return {
type: SubCategoryActions.RESET_SUBCATEGORY_LIST
};
}
static GET_SUBCATEGORY = '[SUBCATEGORY] Get SUBCATEGORY'; static GET_SUBCATEGORY = '[SUBCATEGORY] Get SUBCATEGORY';
getSubCategory(scatCode): Action { getSubCategory(scatCode): Action {
return { return {
......
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
import {ItemDetail} from '../../ecm-model/product-detail-model';
@Injectable()
export class WishListActions {
static LOAD_WISHLIST_ITEMS = '[WISHLIST] Load WISHLIST Items';
loadWishlistItems(): Action {
return {
type: WishListActions.LOAD_WISHLIST_ITEMS
};
}
static LOAD_WISHLIST_ITEMS_SUCCESS = '[WISHLIST] Load WISHLIST Items Success';
loadWishlistItemsSuccess(wishlistItems): Action {
console.log('[Cart] Load Wishlist Items Success',wishlistItems.length);
if(!wishlistItems.length)
{
wishlistItems = [];
}
return {
type: WishListActions.LOAD_WISHLIST_ITEMS_SUCCESS,
payload: wishlistItems
};
}
static ADD_TO_WISHLIST = '[WISHLIST] Add to WISHLIST';
addToWishlist(wishlistItem): Action {
return {
type: WishListActions.ADD_TO_WISHLIST,
payload: wishlistItem
};
}
static ADD_TO_WISHLIST_SUCCESS = '[WISHLIST] Add to WISHLIST Success';
addToWishlistSuccess(wishlistItem): Action {
return {
type: WishListActions.ADD_TO_WISHLIST_SUCCESS,
payload: wishlistItem
};
}
static DELETE_WISHLIST_ITEM = '[WISHLIST] Delete WISHLIST_ITEM';
deleteWishlistItem(item): Action {
return {
type: WishListActions.DELETE_WISHLIST_ITEM,
payload: item
};
}
static DELETE_WISHLIST_ITEM_SUCCESS = '[WISHLIST] Delete WISHLIST Success';
deleteWishlistItemSuccess(item): Action {
return {
type: WishListActions.DELETE_WISHLIST_ITEM_SUCCESS,
payload: item
};
}
static RESET_WISHLIST = '[WISHLIST] Reset WISHLIST';
resetWishlist(): Action {
return {
type: WishListActions.RESET_WISHLIST
};
}
}
\ No newline at end of file
...@@ -2,17 +2,20 @@ import { CartEffects } from './cart'; ...@@ -2,17 +2,20 @@ import { CartEffects } from './cart';
import { CategoryEffects } from './category'; import { CategoryEffects } from './category';
import { SubCategoryEffects } from './subcategory'; import { SubCategoryEffects } from './subcategory';
import { ItemEffects } from './item'; import { ItemEffects } from './item';
import { WishlistEffects } from './wishlist';
export { export {
CartEffects, CartEffects,
CategoryEffects, CategoryEffects,
SubCategoryEffects, SubCategoryEffects,
ItemEffects ItemEffects,
WishlistEffects
}; };
export default [ export default [
CartEffects, CartEffects,
CategoryEffects, CategoryEffects,
SubCategoryEffects, SubCategoryEffects,
ItemEffects ItemEffects,
WishlistEffects
]; ];
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {WishListActions} from '../actions';
import {EcmWishListService} from '../../ecm-view/ecm-wish-list/ecm-wish-list.service';
@Injectable()
export class WishlistEffects {
constructor (
private update$: Actions,
private wishlistActions: WishListActions,
private svc: EcmWishListService,
) {}
@Effect() loadWishlistItems$ = this.update$
.ofType(WishListActions.LOAD_WISHLIST_ITEMS)
.switchMap(() => this.svc.fetchWishlistItems())
.map(items => this.wishlistActions.loadWishlistItemsSuccess(items));
@Effect() addToWishlist$ = this.update$
.ofType(WishListActions.ADD_TO_WISHLIST)
.map(action => action.payload)
.switchMap(item => this.svc.addToWishlist(item)
.map(item => this.wishlistActions.addToWishlistSuccess(item)));
@Effect() deleteFromWishlist$ = this.update$
.ofType(WishListActions.DELETE_WISHLIST_ITEM)
.map(action => action.payload)
.switchMap(item => this.svc.deleteWishlistItem(item))
.map(item => this.wishlistActions.deleteWishlistItemSuccess(item));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment