Commit 5f1d87f1 authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174534 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 70bdc0f8
...@@ -9,6 +9,8 @@ import { ProfileActions } from './profile-info'; ...@@ -9,6 +9,8 @@ import { ProfileActions } from './profile-info';
import { AdressAction } from './manage-adress'; import { AdressAction } from './manage-adress';
import { ReviewAction } from './my-review'; import { ReviewAction } from './my-review';
import { SavedCardAction } from './saved-card'; import { SavedCardAction } from './saved-card';
import { OrderActions } from './order';
//import { OrderDetailActions } from './order';
//import { ChangePasswordAction } from './change-password'; //import { ChangePasswordAction } from './change-password';
export { export {
...@@ -22,7 +24,9 @@ export { ...@@ -22,7 +24,9 @@ export {
ProfileActions, ProfileActions,
AdressAction, AdressAction,
ReviewAction, ReviewAction,
SavedCardAction SavedCardAction,
OrderActions,
// OrderDetailActions
}; };
...@@ -37,5 +41,7 @@ export default [ ...@@ -37,5 +41,7 @@ export default [
ProfileActions, ProfileActions,
AdressAction, AdressAction,
ReviewAction, ReviewAction,
SavedCardAction SavedCardAction,
OrderActions,
// OrderDetailActions
]; ];
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Action} from '@ngrx/store';
import {Order} from '../../ecm-model/order-model';
@Injectable()
export class OrderActions {
static LOAD_ORDER_ITEMS = '[orderItems] Load Order Items';
loadOrderItems(): Action {
console.log('Kamal Initiate...');
return {
type: OrderActions.LOAD_ORDER_ITEMS
};
}
static LOAD_ORDER_ITEMS_SUCCESS = '[orderItems] Load Order Items Success';
loadOrderItemsSuccess(orderItem): Action {
console.log('[orderItems] Load Orders Success',orderItem.length);
if(!orderItem.length)
{
orderItem = [];
}
return {
type: OrderActions.LOAD_ORDER_ITEMS_SUCCESS,
payload: orderItem
};
}
static ADD_NEW_ORDER = '[orderItems] Add new Order';
addNewOrder(orderItem): Action {
return {
type: OrderActions.ADD_NEW_ORDER,
payload: orderItem
};
}
static ADD_NEW_ORDER_SUCCESS = '[orderItems] Add new Order Success';
addNewOrderSuccess(orderItem): Action {
console.log('orderItem-store: ',orderItem);
return {
type: OrderActions.ADD_NEW_ORDER_SUCCESS,
payload: orderItem
};
}
static UPDATE_ORDER = '[orderItems] Update Order';
updateOrder(orderItem): Action {
return {
type: OrderActions.UPDATE_ORDER,
payload: orderItem
};
}
static UPDATE_ORDER_SUCCESS = '[orderItems] Update Order Success';
updateOrderoSuccess(orderItem): Action {
return {
type: OrderActions.UPDATE_ORDER_SUCCESS,
payload: orderItem
};
}
static CANCEL_ORDER = '[orderItems] Delete Order';
deleteOrder(orderItem): Action {
console.log('Cancel Kamal Initiate...');
return {
type: OrderActions.CANCEL_ORDER,
payload: orderItem
};
}
static DELETE_ORDER_SUCCESS = '[orderItems] Delete Order Success';
deleteOrderSuccess(orderItem): Action {
return {
type: OrderActions.DELETE_ORDER_SUCCESS,
payload: orderItem
};
}
//
// static TRACK_ORDER_ITEM = '[Order] Track OrderItem';
// trackOrderItem(item): Action {
// return {
// type: OrderActions.TRACK_ORDER_ITEM,
// payload: item
// };
// }
//
// static TRACK_ORDER_ITEM_SUCCESS = '[Order] Track OrderItem Success';
// trackOrderItemSuccess(item): Action {
// return {
// type: OrderActions.TRACK_ORDER_ITEM_SUCCESS,
// payload: item
// };
// }
//
static RESET_ORDER = '[orderItems] Reset ORDER';
resetOrder(): Action {
return {
type: OrderActions.RESET_ORDER
};
}
}
\ No newline at end of file
...@@ -8,6 +8,8 @@ import { ProfileEffects } from './profile-info'; ...@@ -8,6 +8,8 @@ import { ProfileEffects } from './profile-info';
import { AddressEffects } from './manage-adress'; import { AddressEffects } from './manage-adress';
import { ReviewsEffects } from './my-review'; import { ReviewsEffects } from './my-review';
import { SavedCardEffects } from './saved-card'; import { SavedCardEffects } from './saved-card';
import { OrderEffects } from './order';
//import { OrderDetailEffects } from './order';
export { export {
CartEffects, CartEffects,
...@@ -19,7 +21,9 @@ export { ...@@ -19,7 +21,9 @@ export {
ProfileEffects, ProfileEffects,
AddressEffects, AddressEffects,
ReviewsEffects, ReviewsEffects,
SavedCardEffects SavedCardEffects,
OrderEffects,
// OrderDetailEffects
}; };
export default [ export default [
...@@ -32,5 +36,7 @@ export default [ ...@@ -32,5 +36,7 @@ export default [
ProfileEffects, ProfileEffects,
AddressEffects, AddressEffects,
ReviewsEffects, ReviewsEffects,
SavedCardEffects SavedCardEffects,
OrderEffects,
// OrderDetailEffects
]; ];
\ No newline at end of file
import {Injectable} from '@angular/core';
import {Effect, Actions} from '@ngrx/effects';
import {AppState} from '../reducers';
import {OrderActions} from '../actions';
import {EcmOrderService} from '../../ecm-order/ecm-order.service';
@Injectable()
export class OrderEffects {
constructor (
private update$: Actions,
private orderActions: OrderActions,
private svc: EcmOrderService,
) {}
@Effect() loadOrderItems$ = this.update$
.ofType(OrderActions.LOAD_ORDER_ITEMS)
.switchMap(() => this.svc.fetchOrder())
.map(orderItem => this.orderActions.loadOrderItemsSuccess(orderItem));
@Effect() addNewOrder$ = this.update$
.ofType(OrderActions.ADD_NEW_ORDER)
.map(action => action.payload)
// .switchMap(item => this.svc.addToCart(item)
.map(orderItem => this.orderActions.addNewOrderSuccess(orderItem));
@Effect() addToOrdNewOrders$art$ = this.update$
.ofType(OrderActions.ADD_NEW_ORDER_SUCCESS)
.map(action => action.payload)
.switchMap(orderItem => this.svc.addToOrder(orderItem));
@Effect() updateOrder$ = this.update$
.ofType(OrderActions.UPDATE_ORDER)
.map(action => action.payload)
.switchMap(orderItem => this.svc.updateOrder(orderItem));
// .map(item => this.orderActions.updateOrderoSuccess(item));
@Effect() deleteOrders$ = this.update$
.ofType(OrderActions.DELETE_ORDER_SUCCESS)
.map(action => action.payload)
.switchMap(orderItem => this.svc.cancelOrder(orderItem))
//.map(card => this.savedCardActions.deleteCardSuccess(card));
// @Effect() trackOrder$ = this.update$
// .ofType(OrderActions.TRACK_ORDER_ITEM)
// .map(action => action.payload)
// .switchMap(item => this.svc.trackOrderItem(item))
// .map(item => this.orderActions.trackOrderItemSuccess(item));
}
...@@ -9,6 +9,8 @@ import subCategoryListReducer, * as fromSubCategoryList from './subcategory-list ...@@ -9,6 +9,8 @@ import subCategoryListReducer, * as fromSubCategoryList from './subcategory-list
import itemListReducer, * as fromItemList from './item-list'; import itemListReducer, * as fromItemList from './item-list';
import wishListReducer, * as fromWishList from './wish-list'; import wishListReducer, * as fromWishList from './wish-list';
import cardListReducer, * as fromSavedCardList from './saved-card-list'; import cardListReducer, * as fromSavedCardList from './saved-card-list';
import orderListReducer, * as fromOrderList from './order-list';
//import orderDetailListReducer, * as fromOrderList from './order-detail-list';
import categoryReducer, * as fromCategory from './category'; import categoryReducer, * as fromCategory from './category';
import subCategoryReducer, * as fromSubCategory from './subcategory'; import subCategoryReducer, * as fromSubCategory from './subcategory';
...@@ -26,6 +28,8 @@ export interface AppState { ...@@ -26,6 +28,8 @@ export interface AppState {
wishlistItems: fromWishList.WishListState; wishlistItems: fromWishList.WishListState;
menuList: fromMenu.MenuState; menuList: fromMenu.MenuState;
savedCards: fromSavedCardList.CardState; savedCards: fromSavedCardList.CardState;
orderItems: fromOrderList.OrderListState;
// orderDetailsItems: fromOrderDetailList.OrderDetailListState;
category: fromCategory.CategoryState; category: fromCategory.CategoryState;
subcategory: fromSubCategory.SubCategoryState; subcategory: fromSubCategory.SubCategoryState;
...@@ -44,6 +48,8 @@ export default compose(storeLogger(),combineReducers)({ ...@@ -44,6 +48,8 @@ export default compose(storeLogger(),combineReducers)({
wishlistItems: wishListReducer, wishlistItems: wishListReducer,
menuList: menuReducer, menuList: menuReducer,
savedCards: cardListReducer, savedCards: cardListReducer,
orderItems: orderListReducer,
// orderDetailsItems: orderDetailListReducer,
category: categoryReducer, category: categoryReducer,
subcategory: subCategoryReducer, subcategory: subCategoryReducer,
......
import {Action} from '@ngrx/store';
import {Order} from '../../ecm-model/order-model';
import {OrderActions} from '../actions';
import * as _ from 'lodash';
export type OrderListState = Order[];
const initialState: OrderListState = [];
export default function (state = initialState, action: Action): OrderListState {
switch (action.type){
case OrderActions.LOAD_ORDER_ITEMS_SUCCESS: {
console.log('reducer--payload',action.payload);
return action.payload;
}
case OrderActions.ADD_NEW_ORDER_SUCCESS: {
return [...state, action.payload];
}
case OrderActions.DELETE_ORDER_SUCCESS: {
return state.filter(orderItem => {
return orderItem.itemCode !== action.payload.itemCode;
});
}
// case OrderActions.TRACK_ORDER_ITEM_SUCCESS: {
// return state.filter(item => {
// return item.itemCode !== action.payload.itemCode;
// });
// }
case OrderActions.UPDATE_ORDER_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 OrderActions.RESET_ORDER: {
return initialState;
}
default: {
return state;
}
}
}
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