Commit d2bb5428 authored by prumde's avatar prumde

Updated for ngrx/store to store categories/subcategories/cart/item data.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174452 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c4b47c64
......@@ -6,8 +6,8 @@ import { HttpModule } from '@angular/http';
import { RouterModule, Routes } from '@angular/router';
//import { JwtHelper } from 'angular2-jwt'; //For Future
import {CATEGORY,SUBCATEGORY,ITEM,ECM_LOCATION, CART_ITEMS, WISHLIST_ITEMS} from './ecm-store/ecm-store';
import {StoreModule} from '@ngrx/store';
import {EffectsModule} from '@ngrx/effects';
import { MaterialModule } from '@angular/material';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
......@@ -53,6 +53,14 @@ import { EcmRelatedItemsComponent } from './ecm-view/ecm-related-items/ecm-relat
import { RatingComponent } from './ecm-view/rating/rating.component';
import { EcmWishListComponent } from './ecm-view/ecm-wish-list/ecm-wish-list.component';
import { EcmWishListService } from './ecm-view/ecm-wish-list/ecm-wish-list.service';
import { EcmCategoryService } from './ecm-view/ecm-category/ecm-category.service';
import { EcmSubCategoryService } from './ecm-view/ecm-sub-category/ecm-sub-category.service';
import { EcmProductService } from './ecm-view/ecm-product/ecm-product.service';
import { EcmProductDetailService } from './ecm-product-details/ecm-product-detail.service';
import reducer from './ecm-store/reducers';
import {CartActions, CategoryActions, SubCategoryActions, ItemActions, LocationActions} from './ecm-store/actions';
import {CartEffects, CategoryEffects, SubCategoryEffects, ItemEffects} from './ecm-store/effects';
//Changes by Prajyot
const appRoutes: Routes = [
......@@ -114,17 +122,30 @@ const appRoutes: Routes = [
HttpModule,
RouterModule.forRoot(appRoutes),
ReactiveFormsModule,
StoreModule.provideStore({CATEGORY,SUBCATEGORY,ITEM, location: ECM_LOCATION, cart: CART_ITEMS, wishlist: WISHLIST_ITEMS}),
MaterialModule,
BrowserAnimationsModule
BrowserAnimationsModule,
StoreModule.provideStore(reducer),
EffectsModule.run(CartEffects),
EffectsModule.run(CategoryEffects),
EffectsModule.run(SubCategoryEffects),
EffectsModule.run(ItemEffects)
],
providers: [
{provide: LocationStrategy, useClass: HashLocationStrategy},
ScrollService,
SearchService,
EcmProductReviewService,
EcmWishListService,
EcmCartService,
EcmWishListService
CartActions,
EcmCategoryService,
CategoryActions,
EcmSubCategoryService,
SubCategoryActions,
ItemActions,
EcmProductService,
EcmProductDetailService,
LocationActions
],
entryComponents: [
EcmOutingComponent,
......
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import {AppState} from '../ecm-store/reducers';
import { ECMCard } from '../ecm-model/card-model';
import { Category } from '../ecm-model/category-model';
import { SubCategory } from '../ecm-model/subcategory-model';
......@@ -25,7 +28,7 @@ export class ECMCardComponent implements OnInit {
@Output() storeData = new EventEmitter();
constructor(private router: Router, private productReviewService: EcmProductReviewService) {
constructor(private router: Router, private productReviewService: EcmProductReviewService, private store: Store<AppState>) {
}
......
......@@ -5,8 +5,8 @@ import { MdDialog, MdDialogRef } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import { AppState } from '../ecm-store/reducers';
import { Item } from '../ecm-model/product-model';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { RESIZE_EVENT } from '../ecm-store/ecm-resize';
import { ScrollService } from '../scroll.service';
......@@ -97,7 +97,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
cartCounter: number;
profileImageLink : string;
clientWidth: any;
constructor( @Inject( DOCUMENT ) private document: Document, private route: ActivatedRoute, private router: Router, private scroll_service: ScrollService, private store: Store<EcmStoreModel>, public dialog: MdDialog, public cartService: EcmCartService) { }
constructor( @Inject( DOCUMENT ) private document: Document, private route: ActivatedRoute, private router: Router, private scroll_service: ScrollService, private store: Store<AppState>, public dialog: MdDialog, public cartService: EcmCartService) { }
ngOnInit() {
console.log( 'ECMHeaderComponent onInit' );
......@@ -107,7 +107,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
this.clientWidth = data;
});
this.cartItems = this.store.select('cart');
this.cartItems = this.store.select('cartItems');
}
ngOnDestroy() {
......@@ -218,7 +218,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
hideOverlayPanel() {
this.overlayPanel.nativeElement.style.display = "none";
this.bgGlass.nativeElement.style.display = "none";
//document.body.style.overflow = "visible";
document.body.style.overflow = "visible";
enableScroll();
this.sideOption = null;
}
......
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
import {ItemDetail} from '../../ecm-model/product-detail-model';
@Injectable()
export class CartActions {
static LOAD_CART_ITEMS = '[Cart] Load Cart Items';
loadCartItems(): Action {
return {
type: CartActions.LOAD_CART_ITEMS
};
}
static LOAD_CART_ITEMS_SUCCESS = '[Cart] Load Cart Items Success';
loadCartItemsSuccess(cartItems): Action {
console.log('[Cart] Load Cart Items Success',cartItems.length);
if(!cartItems.length)
{
cartItems = [];
}
return {
type: CartActions.LOAD_CART_ITEMS_SUCCESS,
payload: cartItems
};
}
static ADD_TO_CART = '[Cart] Add to Cart';
addToCart(cartItem): Action {
return {
type: CartActions.ADD_TO_CART,
payload: cartItem
};
}
static ADD_TO_CART_SUCCESS = '[Cart] Add to Cart Success';
addToCartSuccess(cartItem): Action {
return {
type: CartActions.ADD_TO_CART_SUCCESS,
payload: cartItem
};
}
static UPDATE_CART = '[Cart] Update Cart';
updateCart(item): Action {
return {
type: CartActions.UPDATE_CART,
payload: item
};
}
static UPDATE_CART_SUCCESS = '[Cart] Update Cart Success';
updateCartSuccess(item): Action {
return {
type: CartActions.UPDATE_CART_SUCCESS,
payload: item
};
}
static DELETE_CART_ITEM = '[Cart] Delete CartItem';
deleteCartItem(item): Action {
return {
type: CartActions.DELETE_CART_ITEM,
payload: item
};
}
static DELETE_CART_ITEM_SUCCESS = '[Cart] Delete CartItem Success';
deleteCartItemSuccess(item): Action {
return {
type: CartActions.DELETE_CART_ITEM_SUCCESS,
payload: item
};
}
static RESET_CART = '[CART] Reset CART';
resetCart(): Action {
return {
type: CartActions.RESET_CART
};
}
}
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
@Injectable()
export class CategoryActions {
static LOAD_CATEGORY = '[CATEGORY] Load CATEGORY';
loadCategories(): Action {
return {
type: CategoryActions.LOAD_CATEGORY
};
}
static LOAD_CATEGORY_SUCCESS = '[CATEGORY] Load CATEGORY Success';
loadCategoriesSuccess(categories): Action {
console.log('[CATEGORY] Load CATEGORY Success',categories.length);
if(!categories.length)
{
categories = [];
}
return {
type: CategoryActions.LOAD_CATEGORY_SUCCESS,
payload: categories
};
}
static GET_CATEGORY = '[CATEGORY] Get CATEGORY';
getCategory(catCode): Action {
return {
type: CategoryActions.GET_CATEGORY,
payload: catCode
};
}
static GET_CATEGORY_SUCCESS = '[CATEGORY] Get CATEGORY Success';
getCategorySuccess(category): Action {
return {
type: CategoryActions.GET_CATEGORY_SUCCESS,
payload: category
};
}
static RESET_BLANK_CATEGORY = '[CATEGORY] Reset Blank CATEGORY';
resetBlankCategory(): Action {
return {
type: CategoryActions.RESET_BLANK_CATEGORY
};
}
}
\ No newline at end of file
import { CartActions } from './cart';
import { CategoryActions } from './category';
import { SubCategoryActions } from './subcategory';
import { ItemActions } from './item';
import { LocationActions } from './location';
export {
CartActions,
CategoryActions,
SubCategoryActions,
ItemActions,
LocationActions
};
export default [
CartActions,
CategoryActions,
SubCategoryActions,
ItemActions,
LocationActions
];
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
@Injectable()
export class ItemActions {
static LOAD_ITEMS = '[ITEMS] Load ITEMS';
loadItems(scatCode): Action {
return {
type: ItemActions.LOAD_ITEMS,
payload: scatCode
};
}
static LOAD_ITEM_SUCCESS = '[ITEMS] Load ITEMS Success';
loadItemsSuccess(items): Action {
console.log('[ITEM] Load ITEMS Success',items.length);
if(!items.length)
{
items = [];
}
return {
type: ItemActions.LOAD_ITEM_SUCCESS,
payload: items
};
}
static GET_ITEM = '[ITEM] Get ITEM';
getItem(itemCode): Action {
return {
type: ItemActions.GET_ITEM,
payload: itemCode
};
}
static GET_ITEM_SUCCESS = '[ITEM] Get ITEM Success';
getItemSuccess(item): Action {
return {
type: ItemActions.GET_ITEM_SUCCESS,
payload: item
};
}
static RESET_BLANK_ITEM = '[ITEM] Reset Blank ITEM';
resetBlankItem(): Action {
return {
type: ItemActions.RESET_BLANK_ITEM
};
}
}
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
@Injectable()
export class LocationActions {
static GET_LOCATION = '[LOCATION] Get LOCATION';
getLocation(): Action {
return {
type: LocationActions.GET_LOCATION
};
}
static GET_LOCATION_SUCCESS = '[LOCATION] Get LOCATION Success';
getLocationSuccess(location): Action {
return {
type: LocationActions.GET_LOCATION_SUCCESS,
payload : location
};
}
static RESET_BLANK_LOCATION = '[LOCATION] Reset Blank LOCATION';
resetBlankLocation(): Action {
return {
type: LocationActions.RESET_BLANK_LOCATION
};
}
}
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
import {ItemDetail} from '../../ecm-model/product-detail-model';
@Injectable()
export class SubCategoryActions {
static LOAD_SUBCATEGORY = '[SUBCATEGORY] Load SUBCATEGORY';
loadSubCategories(catCode): Action {
return {
type: SubCategoryActions.LOAD_SUBCATEGORY,
payload: catCode
};
}
static LOAD_SUBCATEGORY_SUCCESS = '[SUBCATEGORY] Load SUBCATEGORY Success';
loadSubCategoriesSuccess(subcategories): Action {
console.log('[SUBCATEGORY] Load SUBCATEGORY Success',subcategories.length);
if(!subcategories.length)
{
subcategories = [];
}
return {
type: SubCategoryActions.LOAD_SUBCATEGORY_SUCCESS,
payload: subcategories
};
}
static GET_SUBCATEGORY = '[SUBCATEGORY] Get SUBCATEGORY';
getSubCategory(scatCode): Action {
return {
type: SubCategoryActions.GET_SUBCATEGORY,
payload: scatCode
};
}
static GET_SUBCATEGORY_SUCCESS = '[SUBCATEGORY] Get SUBCATEGORY Success';
getSubCategorySuccess(subCategory): Action {
return {
type: SubCategoryActions.GET_SUBCATEGORY_SUCCESS,
payload: subCategory
};
}
static RESET_BLANK_SUBCATEGORY = '[SUBCATEGORY] Reset Blank SUBCATEGORY';
resetBlankSubCategory(): Action {
return {
type: SubCategoryActions.RESET_BLANK_SUBCATEGORY
};
}
}
\ No newline at end of file
import { Category } from '../ecm-model/category-model';
import { SubCategory } from '../ecm-model/subcategory-model';
import { Item } from '../ecm-model/product-model';
import { EcmLocation} from '../ecm-search/ecm-location';
export class EcmStoreModel {
CATEGORY: Category;
SUBCATEGORY: SubCategory;
ITEM: Item;
ECM_LOCATION: EcmLocation;
CART_COUNTER: number;
CART_ITEMS: Item;
WISHLIST_ITEMS: Item;
};
import { ActionReducer, Action } from '@ngrx/store';
import { ECMCart } from '../ecm-model/cart-model';
import { Item } from '../ecm-model/product-model';
export function CATEGORY (state: any = null, {type, payload}) {
switch (type) {
case 'CATEGORY':
return payload;
case 'CLEAR_CATEGORY':
return state=null;
default:
return state;
}
};
export function SUBCATEGORY (state: any = null, {type, payload}) {
switch (type) {
case 'SUB_CATEGORY':
return payload;
case 'CLEAR_SUB_CATEGORY':
return state=null;
default:
return state;
}
};
export function ITEM (state: any = null, {type, payload}) {
switch (type) {
case 'ITEM':
return payload;
case 'CLEAR_ITEM':
return state=null;
default:
return state;
}
};
export const ADD_TO_CART = 'ADD_TO_CART';
export const UPDATE_QUANTITY = 'UPDATE_QUANTITY';
export const REMOVE = 'REMOVE';
export const RESET = 'RESET';
export function CART_ITEMS (state:any = [], action: Action) {
switch (action.type) {
case ADD_TO_CART:
const item:Item = action.payload;
return [ ...state, item ];
case UPDATE_QUANTITY:
return state.map((item, index) => {
return index === action.payload.index
? Object.assign({}, item, { value: action.payload.newValue })
: item;
});
case REMOVE:
console.log('Delete--');
console.log(JSON.stringify(action.payload));
return state.filter(item => {
return item.itemCode !== action.payload.itemCode;
});
case RESET:
console.log('RESET----');
return state=[];
default:
return state;
}
};
export const ADD_TO_WISHLIST = 'ADD_TO_WISHLIST';
export const REMOVE_WISLIST = 'REMOVE_WISLIST';
export const RESET_WISHLIST = 'RESET_WISHLIST';
export function WISHLIST_ITEMS (state:any = [], action: Action) {
switch (action.type) {
case ADD_TO_WISHLIST:
const item:Item = action.payload;
return [ ...state, item ];
case REMOVE_WISLIST:
console.log('Delete--WISHLIST---');
console.log(JSON.stringify(action.payload));
return state.filter(item => {
return item.itemCode !== action.payload.itemCode;
});
case RESET_WISHLIST:
console.log('RESET----WISHLIST---');
return state=[];
default:
return state;
}
};
export function ECM_LOCATION (state: any = null, {type, payload}) {
switch (type) {
case 'ECMLOCATION':
return payload;
case 'CLEAR_LOCATION':
return state=null;
default:
return state;
}
};
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {CartActions} from '../actions';
import {EcmCartService} from '../../ecm-view/ecm-cart/ecm-cart.service';
@Injectable()
export class CartEffects {
constructor (
private update$: Actions,
private cartActions: CartActions,
private svc: EcmCartService,
) {}
@Effect() loadCartItems$ = this.update$
.ofType(CartActions.LOAD_CART_ITEMS)
.switchMap(() => this.svc.fetchCartItems())
.map(items => this.cartActions.loadCartItemsSuccess(items));
@Effect() addToCart$ = this.update$
.ofType(CartActions.ADD_TO_CART)
.map(action => action.payload)
.switchMap(item => this.svc.addToCart(item)
.map(item => this.cartActions.addToCartSuccess(item)));
@Effect() updateCart$ = this.update$
.ofType(CartActions.UPDATE_CART)
.map(action => action.payload)
.switchMap(item => this.svc.updateCart(item))
.map(item => this.cartActions.updateCartSuccess(item));
@Effect() deleteFromCart$ = this.update$
.ofType(CartActions.DELETE_CART_ITEM)
.map(action => action.payload)
.switchMap(item => this.svc.deleteCartItem(item))
.map(item => this.cartActions.deleteCartItemSuccess(item));
}
import { Injectable } from '@angular/core';
import { Effect, Actions } from '@ngrx/effects';
import { AppState } from '../reducers';
import { CategoryActions } from '../actions';
import { EcmCategoryService } from '../../ecm-view/ecm-category/ecm-category.service';
@Injectable()
export class CategoryEffects {
constructor (
private update$: Actions,
private catgoryActions: CategoryActions,
private svc: EcmCategoryService,
) {}
@Effect() loadCategories$ = this.update$
.ofType(CategoryActions.LOAD_CATEGORY)
.switchMap(() => this.svc.getCategories())
.map(categories => this.catgoryActions.loadCategoriesSuccess(categories));
@Effect() getCategory$ = this.update$
.ofType(CategoryActions.GET_CATEGORY)
.switchMap(catCode => this.svc.getCategory(catCode.payload))
.map(category => this.catgoryActions.getCategorySuccess(category));
}
import { CartEffects } from './cart';
import { CategoryEffects } from './category';
import { SubCategoryEffects } from './subcategory';
import { ItemEffects } from './item';
export {
CartEffects,
CategoryEffects,
SubCategoryEffects,
ItemEffects
};
export default [
CartEffects,
CategoryEffects,
SubCategoryEffects,
ItemEffects
];
\ No newline at end of file
import { Injectable } from '@angular/core';
import { Effect, Actions } from '@ngrx/effects';
import { AppState } from '../reducers';
import { ItemActions } from '../actions';
import { EcmProductService } from '../../ecm-view/ecm-product/ecm-product.service';
import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-detail.service';
@Injectable()
export class ItemEffects {
constructor (
private update$: Actions,
private itemActions: ItemActions,
private svc: EcmProductService,
private svc1: EcmProductDetailService
) {}
@Effect() loadItems$ = this.update$
.ofType(ItemActions.LOAD_ITEMS)
.switchMap(scatCode => this.svc.getItems(scatCode.payload))
.map(items => this.itemActions.loadItemsSuccess(items));
@Effect() getItem$ = this.update$
.ofType(ItemActions.GET_ITEM)
.switchMap(itemCode => this.svc1.getItemDetail(itemCode.payload))
.map(item => this.itemActions.getItemSuccess(item));
}
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {SubCategoryActions} from '../actions';
import { EcmSubCategoryService } from '../../ecm-view/ecm-sub-category/ecm-sub-category.service';
@Injectable()
export class SubCategoryEffects {
constructor (
private update$: Actions,
private subCategoryActions: SubCategoryActions,
private svc: EcmSubCategoryService,
) {}
@Effect() loadCategories$ = this.update$
.ofType(SubCategoryActions.LOAD_SUBCATEGORY)
.switchMap(catCode => this.svc.getSubCategories(catCode.payload))
.map(subcategories => this.subCategoryActions.loadSubCategoriesSuccess(subcategories));
@Effect() getSubCategory$ = this.update$
.ofType(SubCategoryActions.GET_SUBCATEGORY)
.switchMap(scatCode => this.svc.getSubCategory(scatCode.payload))
.map(subcategory => this.subCategoryActions.getSubCategorySuccess(subcategory));
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable';
import {ItemDetail} from '../../ecm-model/product-detail-model';
import {CartActions} from '../actions';
import * as _ from 'lodash';
export type CartListState = ItemDetail[];
const initialState: CartListState = [];
export default function (state = initialState, action: Action): CartListState {
switch (action.type){
case CartActions.LOAD_CART_ITEMS_SUCCESS: {
return action.payload;
}
case CartActions.ADD_TO_CART_SUCCESS: {
return [...state, action.payload];
}
case CartActions.DELETE_CART_ITEM_SUCCESS: {
return state.filter(item => {
return item.itemCode !== action.payload.itemCode;
});
}
case CartActions.UPDATE_CART_SUCCESS: {
let index = _.findIndex(state, {itemCode: action.payload.itemCode});
if (index >= 0) {
return [
...state.slice(0, index),
action.payload,
...state.slice(index + 1)
];
}
return state;
}
case CartActions.RESET_CART: {
return initialState;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable';
import {Category} from '../../ecm-model/category-model';
import {CategoryActions} from '../actions';
import * as _ from 'lodash';
export type CategoryListState = Category[];
const initialState: CategoryListState = [];
export default function (state = initialState, action: Action): CategoryListState {
switch (action.type){
case CategoryActions.LOAD_CATEGORY_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {Category} from '../../ecm-model/category-model';
import {CategoryActions} from '../actions';
export type CategoryState = Category;
const initialState: CategoryState = {
catCode: '',
descr: '',
shDescr: '',
curRank: '',
catLink: '',
ecmTemplate: ''
};
export default function (state = initialState, action: Action): CategoryState {
switch (action.type) {
case CategoryActions.RESET_BLANK_CATEGORY: {
return initialState;
}
case CategoryActions.GET_CATEGORY_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
import '@ngrx/core/add/operator/select';
import {compose} from '@ngrx/core/compose';
import {combineReducers} from '@ngrx/store';
//import {storeLogger} from 'ngrx-store-logger';
import cartListReducer, * as fromCartList from './cart-list';
import categoryListReducer, * as fromCategoryList from './category-list';
import subCategoryListReducer, * as fromSubCategoryList from './subcategory-list';
import itemListReducer, * as fromItemList from './item-list';
import categoryReducer, * as fromCategory from './category';
import subCategoryReducer, * as fromSubCategory from './subcategory';
import itemReducer, * as fromItem from './item';
import locationReducer, * as fromLocation from './location';
export interface AppState {
cartItems: fromCartList.CartListState;
categories: fromCategoryList.CategoryListState;
subcategories: fromSubCategoryList.SubCategoryListState;
items: fromItemList.ItemListState;
category: fromCategory.CategoryState;
subcategory: fromSubCategory.SubCategoryState;
item: fromItem.ItemState;
location: fromLocation.LocationState;
};
//export default compose(storeLogger(),combineReducers)({
export default compose(combineReducers)({
cartItems: cartListReducer,
categories: categoryListReducer,
subcategories: subCategoryListReducer,
items: itemListReducer,
category: categoryReducer,
subcategory: subCategoryReducer,
item: itemReducer,
location: locationReducer
});
\ No newline at end of file
import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable';
import {Item} from '../../ecm-model/product-model';
import {ItemActions} from '../actions';
import * as _ from 'lodash';
export type ItemListState = Item[];
const initialState: ItemListState = [];
export default function (state = initialState, action: Action): ItemListState {
switch (action.type){
case ItemActions.LOAD_ITEM_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {ItemDetail} from '../../ecm-model/product-detail-model';
import {ItemActions} from '../actions';
export type ItemState = ItemDetail;
const initialState: ItemState = {
itemCode: '',
itemQuantity: 0,
itemCategory: '',
itemSubCategory: '',
itemHeader: '',
itemDetail1: '',
itemDetail2: '',
itemRatings: '',
itemVariants: '',
productStatus: ''
};
export default function (state = initialState, action: Action): ItemState {
switch (action.type) {
case ItemActions.RESET_BLANK_ITEM: {
return initialState;
}
case ItemActions.GET_ITEM_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {EcmLocation} from '../../ecm-search/ecm-location';
import {LocationActions} from '../actions';
export type LocationState = EcmLocation;
const initialState: LocationState = {
latitude: '',
longitude: '',
address: '',
pincode: 0,
city: ''
};
export default function (state = initialState, action: Action): LocationState {
switch (action.type) {
case LocationActions.RESET_BLANK_LOCATION: {
return initialState;
}
case LocationActions.GET_LOCATION_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable';
import {SubCategory} from '../../ecm-model/subcategory-model';
import {SubCategoryActions} from '../actions';
import * as _ from 'lodash';
export type SubCategoryListState = SubCategory[];
const initialState: SubCategoryListState = [];
export default function (state = initialState, action: Action): SubCategoryListState {
switch (action.type){
case SubCategoryActions.LOAD_SUBCATEGORY_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {SubCategory} from '../../ecm-model/subcategory-model';
import {SubCategoryActions} from '../actions';
export type SubCategoryState = SubCategory;
const initialState: SubCategoryState = {
scatCode: '',
catCode: '',
descr: '',
shDescr: '',
curRank: '',
catLink: '',
ecmTemplate: ''
};
export default function (state = initialState, action: Action): SubCategoryState {
switch (action.type) {
case SubCategoryActions.RESET_BLANK_SUBCATEGORY: {
return initialState;
}
case SubCategoryActions.GET_SUBCATEGORY_SUCCESS: {
return action.payload;
}
default: {
return state;
}
}
}
\ No newline at end of file
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