Commit edc6c82f authored by prumde's avatar prumde

Added A New Reducers


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174478 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7b133261
...@@ -14,6 +14,8 @@ import categoryReducer, * as fromCategory from './category'; ...@@ -14,6 +14,8 @@ import categoryReducer, * as fromCategory from './category';
import subCategoryReducer, * as fromSubCategory from './subcategory'; import subCategoryReducer, * as fromSubCategory from './subcategory';
import itemReducer, * as fromItem from './item'; import itemReducer, * as fromItem from './item';
import locationReducer, * as fromLocation from './location'; import locationReducer, * as fromLocation from './location';
import profileReducer, * as fromProfile from './profile-info';
import addressReducer, * as fromAddress from './manage-adress-list';
export interface AppState { export interface AppState {
...@@ -28,6 +30,8 @@ export interface AppState { ...@@ -28,6 +30,8 @@ export interface AppState {
subcategory: fromSubCategory.SubCategoryState; subcategory: fromSubCategory.SubCategoryState;
item: fromItem.ItemState; item: fromItem.ItemState;
location: fromLocation.LocationState; location: fromLocation.LocationState;
profileInfo: fromProfile.ProfileState;
Address: fromAddress.AddressState
}; };
export default compose(storeLogger(),combineReducers)({ export default compose(storeLogger(),combineReducers)({
...@@ -42,5 +46,7 @@ export default compose(storeLogger(),combineReducers)({ ...@@ -42,5 +46,7 @@ export default compose(storeLogger(),combineReducers)({
category: categoryReducer, category: categoryReducer,
subcategory: subCategoryReducer, subcategory: subCategoryReducer,
item: itemReducer, item: itemReducer,
location: locationReducer location: locationReducer,
profileInfo: profileReducer,
Address: addressReducer
}); });
\ No newline at end of file
...@@ -8,8 +8,11 @@ const initialState: LocationState = { ...@@ -8,8 +8,11 @@ const initialState: LocationState = {
latitude: '', latitude: '',
longitude: '', longitude: '',
address: '', address: '',
pincode: 0, pincode: '',
city: '' city: '',
state: '',
country: ''
}; };
export default function (state = initialState, action: Action): LocationState { export default function (state = initialState, action: Action): LocationState {
......
import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable';
import {Address} from '../../user-address/address-manager/address.model';
import {AdressAction} from '../actions';
import * as _ from 'lodash';
export type AddressState = Address[];
const initialState: AddressState = [];
export default function (state = initialState, action: Action): AddressState {
switch (action.type){
case AdressAction.LOAD_ADDRESS_SUCCESS: {
return action.payload;
}
case AdressAction.ADD_NEW_ADDRESS_SUCCESS: {
return [...state, action.payload];
}
case AdressAction.DELETE_ADDRESS_SUCCESS: {
return state.filter(userAddress => {
return userAddress.lineNo !== action.payload.lineNo;
});
}
case AdressAction.UPDATE_ADDRESS_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;
}
default: {
return state;
}
}
}
\ No newline at end of file
import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable';
import {Profile} from '../../user-profile/profile-manager/profile.model';
import {ProfileActions} from '../actions';
import * as _ from 'lodash';
export type ProfileState = Profile;
const initialState: ProfileState = {
id: 'ADDR_' + Math.random(),
userName: '',
firstName: '',
lastName: '',
emailId: '',
contactNo: '',
birthDate: '',
gender: ''
};
export default function (state = initialState, action: Action): ProfileState {
switch (action.type) {
case ProfileActions.LOAD_USER_INFO_SUCCESS: {
return action.payload;
}
case ProfileActions.UPDATE_USER_INFO_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