Commit 50a63b7f authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174439 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6083ffad
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common'; import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
import { EcmCartService } from './ecm-view/ecm-cart/ecm-cart.service';
@Component({ @Component({
selector: 'ecm-root', selector: 'ecm-root',
...@@ -10,7 +11,7 @@ import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common' ...@@ -10,7 +11,7 @@ import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common'
export class AppComponent { export class AppComponent {
title = 'Proteus ECM'; title = 'Proteus ECM';
location: Location; location: Location;
constructor(location: Location) { constructor(location: Location, public cartService: EcmCartService) {
this.location = location; this.location = location;
console.log( ' this.location.path(true)[' + this.location.path(true) + ']'); console.log( ' this.location.path(true)[' + this.location.path(true) + ']');
this.checkAppState(); this.checkAppState();
...@@ -19,6 +20,8 @@ export class AppComponent { ...@@ -19,6 +20,8 @@ export class AppComponent {
this.setItem('jwtToken', this.get('jwtToken'), false ); this.setItem('jwtToken', this.get('jwtToken'), false );
this.setItem('appstate', this.get('app_stat'), true ); this.setItem('appstate', this.get('app_stat'), true );
this.setItem('TOKEN_ID', this.get('TOKEN_ID'), true ); this.setItem('TOKEN_ID', this.get('TOKEN_ID'), true );
this.cartService.setCartItems();
} }
get(name){ get(name){
var retVal = 'undefined'; var retVal = 'undefined';
......
...@@ -6,7 +6,7 @@ import { HttpModule } from '@angular/http'; ...@@ -6,7 +6,7 @@ import { HttpModule } from '@angular/http';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
//import { JwtHelper } from 'angular2-jwt'; //For Future //import { JwtHelper } from 'angular2-jwt'; //For Future
import {CATEGORY,SUBCATEGORY,ITEM,ECM_LOCATION,CART_COUNTER} from './ecm-store/ecm-store'; import {CATEGORY,SUBCATEGORY,ITEM,ECM_LOCATION, CART_ITEMS} from './ecm-store/ecm-store';
import {StoreModule} from '@ngrx/store'; import {StoreModule} from '@ngrx/store';
import { MaterialModule } from '@angular/material'; import { MaterialModule } from '@angular/material';
...@@ -110,7 +110,7 @@ const appRoutes: Routes = [ ...@@ -110,7 +110,7 @@ const appRoutes: Routes = [
HttpModule, HttpModule,
RouterModule.forRoot(appRoutes), RouterModule.forRoot(appRoutes),
ReactiveFormsModule, ReactiveFormsModule,
StoreModule.provideStore({CATEGORY,SUBCATEGORY,ITEM, location: ECM_LOCATION, counter: CART_COUNTER}), StoreModule.provideStore({CATEGORY,SUBCATEGORY,ITEM, location: ECM_LOCATION, cart: CART_ITEMS}),
MaterialModule, MaterialModule,
BrowserAnimationsModule BrowserAnimationsModule
], ],
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<!-- Overlay End --> <!-- Overlay End -->
<!-- SlidePanel Start --> <!-- SlidePanel Start -->
<div #rightSlidePanel class="rightSlidePanel" [ngClass]="{'width-300': ( sideOption=='CART_OPT' && cartItems == 0 ) }" > <div #rightSlidePanel class="rightSlidePanel" [ngClass]="{'width-300': ( sideOption=='CART_OPT' && (cartItems | async)?.length == 0 ) }" >
<span (click)="hideSidePanel();" class="hide-button"></span> <span (click)="hideSidePanel();" class="hide-button"></span>
<ecm-user-option *ngIf="sideOption=='USER_OPT'" (closePanel)="hideSidePanel(); createUserData();" (updateProfileImages) = "updateProfileImages();" ></ecm-user-option> <ecm-user-option *ngIf="sideOption=='USER_OPT'" (closePanel)="hideSidePanel(); createUserData();" (updateProfileImages) = "updateProfileImages();" ></ecm-user-option>
<div *ngIf="sideOption=='CART_OPT'" style="margin: 3rem;" > <div *ngIf="sideOption=='CART_OPT'" style="margin: 3rem;" >
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<ecm-search [compFadeState]="headerFadeState" [headerState]="'fixed'"></ecm-search> <ecm-search [compFadeState]="headerFadeState" [headerState]="'fixed'"></ecm-search>
<span [ngClass]="{'cart-span': sideOption=='CART_OPT'}" (click)="cartAction();" > <span [ngClass]="{'cart-span': sideOption=='CART_OPT'}" (click)="cartAction();" >
<button md-button class="square-button"> <button md-button class="square-button">
<span *ngIf="cartItems > 0" class="fixed-header-badge">{{ cartCounter | async }}</span> <span *ngIf="(cartItems | async)?.length!=0" class="fixed-header-badge">{{(cartItems | async)?.length}}</span>
<img mdTooltip="Show Cart" [mdTooltipPosition]="'below'" class="fixed-header-cart img-cart-32" src="cart_32_32.svg"/> <img mdTooltip="Show Cart" [mdTooltipPosition]="'below'" class="fixed-header-cart img-cart-32" src="cart_32_32.svg"/>
<!-- <img *ngIf="cartItems == 0" class="fixed-header-cart img-cart-32 no-badge" /> --> <!-- <img *ngIf="cartItems == 0" class="fixed-header-cart img-cart-32 no-badge" /> -->
<!--<md-icon class="example-icon">shopping_cart</md-icon>--> <!--<md-icon class="example-icon">shopping_cart</md-icon>-->
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
</span> </span>
<span [ngClass]="{'cart-span': sideOption=='CART_OPT'}" (click)="cartAction();" > <span [ngClass]="{'cart-span': sideOption=='CART_OPT'}" (click)="cartAction();" >
<button md-button class="square-button"> <button md-button class="square-button">
<span *ngIf="cartItems > 0" class="fixed-header-badge">{{ cartCounter | async }}</span> <span *ngIf="cartCounter > 0" class="fixed-header-badge">{{ cartCounter }}</span>
<img mdTooltip="Show Cart" [mdTooltipPosition]="'below'" class="fixed-header-cart img-cart-32" src="cart_32_32.svg"/> <img mdTooltip="Show Cart" [mdTooltipPosition]="'below'" class="fixed-header-cart img-cart-32" src="cart_32_32.svg"/>
<!-- <img *ngIf="cartItems == 0" class="fixed-header-cart img-cart-32 no-badge" /> --> <!-- <img *ngIf="cartItems == 0" class="fixed-header-cart img-cart-32 no-badge" /> -->
<!--<md-icon class="example-icon">shopping_cart</md-icon>--> <!--<md-icon class="example-icon">shopping_cart</md-icon>-->
......
import { Component, Input, Output, Inject, OnInit, OnDestroy, AfterViewChecked, ViewEncapsulation, HostListener, ElementRef, ViewChild, trigger, state, animate, transition, style } from '@angular/core'; import { Component, Input, Output, Inject, OnInit, OnDestroy, ViewEncapsulation, HostListener, ElementRef, ViewChild, trigger, state, animate, transition, style } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser'; import { DOCUMENT } from '@angular/platform-browser';
import { ActivatedRoute, Router,ActivatedRouteSnapshot,RoutesRecognized } from '@angular/router'; import { ActivatedRoute, Router,ActivatedRouteSnapshot,RoutesRecognized } from '@angular/router';
import { MdDialog, MdDialogRef } from '@angular/material'; import { MdDialog, MdDialogRef } from '@angular/material';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Item } from '../ecm-model/product-model';
import { EcmStoreModel } from '../ecm-store/ecm-store.model'; import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { RESIZE_EVENT } from '../ecm-store/ecm-resize'; import { RESIZE_EVENT } from '../ecm-store/ecm-resize';
import { ScrollService } from '../scroll.service'; import { ScrollService } from '../scroll.service';
import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/filter';
//declare var initSearch: any; //declare var initSearch: any;
...@@ -78,7 +79,7 @@ declare var enableScroll: any; ...@@ -78,7 +79,7 @@ declare var enableScroll: any;
] ]
}) })
export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked { export class ECMHeaderComponent implements OnInit, OnDestroy {
@ViewChild( 'rightSlidePanel' ) rightSlidePanel: ElementRef; @ViewChild( 'rightSlidePanel' ) rightSlidePanel: ElementRef;
@ViewChild( 'overlayPanel' ) overlayPanel: ElementRef; @ViewChild( 'overlayPanel' ) overlayPanel: ElementRef;
...@@ -92,11 +93,11 @@ export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked { ...@@ -92,11 +93,11 @@ export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked {
selectedOption: string; selectedOption: string;
userData: any; userData: any;
sideOption: any; sideOption: any;
cartItems = 0; cartItems: Observable<Item>;
cartCounter : Observable<number>; cartCounter: number;
profileImageLink : string; profileImageLink : string;
clientWidth: any; 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) { } 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) { }
ngOnInit() { ngOnInit() {
console.log( 'ECMHeaderComponent onInit' ); console.log( 'ECMHeaderComponent onInit' );
...@@ -105,6 +106,8 @@ export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked { ...@@ -105,6 +106,8 @@ export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked {
RESIZE_EVENT.subscribe(data => { RESIZE_EVENT.subscribe(data => {
this.clientWidth = data; this.clientWidth = data;
}); });
this.cartItems = this.store.select('cart');
} }
ngOnDestroy() { ngOnDestroy() {
...@@ -173,16 +176,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked { ...@@ -173,16 +176,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy, AfterViewChecked {
//Removed Collapsible Search //Removed Collapsible Search
//initSearch(); //initSearch();
} }
ngAfterViewChecked() {
this.cartCounter = this.store.select('counter');
this.cartCounter.subscribe( count => {
this.cartItems = count;
//console.log('>>>count ::' + count);
});
//console.log('this.cartItems ::' + this.cartItems);
}
userAction() { userAction() {
if( this.userData ){ if( this.userData ){
this.showSidePanel('USER_OPT'); this.showSidePanel('USER_OPT');
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
export class Item { export class Item {
public itemCode: string = ''; public itemCode: string = '';
public descr: string = ''; public item_descr: string = '';
public shDescr: string = ''; public shDescr: string = '';
public costRate: string; public costRate: string;
public rating: number; public rating: number;
...@@ -13,5 +13,19 @@ export class Item { ...@@ -13,5 +13,19 @@ export class Item {
public scat_descr: string = ''; public scat_descr: string = '';
public cat_sh_descr: string = ''; public cat_sh_descr: string = '';
public cat_descr: string = ''; public cat_descr: string = '';
public length: number;
public width: number;
public height: number;
public gross_weight: number;
public product_code: string = "";
public price_list: string = "";
public item_type: string = "";
public phyAttribId1: string = "";
public phyAttribId2: string = "";
public phyAttribId3: string = "";
public phyAttribId4: string = "";
public phyAttribId5: string = "";
public phyAttribId6: string = "";
public descr: string = "";
} }
...@@ -4,7 +4,7 @@ import { MdSnackBar } from '@angular/material'; ...@@ -4,7 +4,7 @@ import { MdSnackBar } from '@angular/material';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model'; import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { INCREMENT, DECREMENT, RESET } from '../ecm-store/ecm-store'; import { UPDATE_QUANTITY, ADD_TO_CART, REMOVE } from '../ecm-store/ecm-store';
import { EcmProductDetailService } from './ecm-product-detail.service'; import { EcmProductDetailService } from './ecm-product-detail.service';
import { ScrollService } from '../scroll.service'; import { ScrollService } from '../scroll.service';
...@@ -18,6 +18,7 @@ import { EcmHandicraftComponent } from './ecm-template/ecm-handicraft.component' ...@@ -18,6 +18,7 @@ import { EcmHandicraftComponent } from './ecm-template/ecm-handicraft.component'
import { EcmProductReviewComponent } from './ecm-product-review.component'; import { EcmProductReviewComponent } from './ecm-product-review.component';
import { EcmRelatedItemsComponent } from '../ecm-view/ecm-related-items/ecm-related-items.component'; import { EcmRelatedItemsComponent } from '../ecm-view/ecm-related-items/ecm-related-items.component';
import { ECMCart } from '../ecm-model/cart-model'; import { ECMCart } from '../ecm-model/cart-model';
import { Item } from '../ecm-model/product-model';
import { ECMHeaderComponent } from '../ecm-header/ecm-header.component'; import { ECMHeaderComponent } from '../ecm-header/ecm-header.component';
export const ECM_TEMPLATES: any = { export const ECM_TEMPLATES: any = {
...@@ -44,7 +45,7 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -44,7 +45,7 @@ export class EcmProductDetailsComponent implements OnInit {
scatCode; scatCode;
noOfReviews; noOfReviews;
constructor(private route: ActivatedRoute, private router:Router, public subcategoryService: EcmProductDetailService, public snackBar: MdSnackBar, private store: Store<EcmStoreModel>) { } constructor(private route: ActivatedRoute, private router:Router, public productDetailService: EcmProductDetailService, public snackBar: MdSnackBar, private store: Store<EcmStoreModel>) { }
ngOnInit() { ngOnInit() {
this.route.params.subscribe( params => { this.route.params.subscribe( params => {
...@@ -58,7 +59,7 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -58,7 +59,7 @@ export class EcmProductDetailsComponent implements OnInit {
} }
getItemDetail( itemCode: string ) { getItemDetail( itemCode: string ) {
this.subcategoryService.getItemDetail( itemCode ).subscribe( this.productDetailService.getItemDetail( itemCode ).subscribe(
itemDetail => { itemDetail => {
if( itemDetail ) console.log( 'comp itemCode[' + itemCode + '] itemDetail[' + itemDetail + '] \n this.itemDetail[' + JSON.stringify( itemDetail ) + ']' ); if( itemDetail ) console.log( 'comp itemCode[' + itemCode + '] itemDetail[' + itemDetail + '] \n this.itemDetail[' + JSON.stringify( itemDetail ) + ']' );
...@@ -102,7 +103,7 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -102,7 +103,7 @@ export class EcmProductDetailsComponent implements OnInit {
console.log( 'doActivity > > ' , activity, data ); console.log( 'doActivity > > ' , activity, data );
if( activity == 'ADD_CART' ) { if( activity == 'ADD_CART' ) {
if( data.isAddToCart ) { //GO TO CART if( data.isAddToCart ) { //GO TO CART
this.router.navigate(['/checkout']); this.router.navigate(['/cart']);
} }
else { //ADD TO CART else { //ADD TO CART
this.addToCart(data.itemCode); this.addToCart(data.itemCode);
...@@ -128,13 +129,24 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -128,13 +129,24 @@ export class EcmProductDetailsComponent implements OnInit {
} }
addToCart(data:any) { addToCart(data:any) {
let cartData = new ECMCart; let cartData = new Item;
cartData.itemCode = data; cartData.itemCode = data;
cartData.quantity = 1; cartData.itemQuantity = 1;
cartData.itemCost = this.itemDetail.itemHeader.itemCostRate; cartData.costRate = this.itemDetail.itemHeader.itemCostRate;
cartData.descr = this.itemDetail.itemHeader.itemDescr;
cartData.shDescr = this.itemDetail.itemHeader.itemShDescr;
this.store.dispatch({ type: INCREMENT, payload: cartData }); this.store.dispatch({ type: ADD_TO_CART, payload: cartData });
this.subcategoryService.addToCart(cartData); this.productDetailService.addToCart(cartData);
let cartItems;
this.store.select('cart').forEach(
value => {
cartItems=value;
console.log('Cart Items----');
console.log(value);
}
);
} }
addToWishlist() { addToWishlist() {
......
...@@ -303,7 +303,7 @@ hr { ...@@ -303,7 +303,7 @@ hr {
} }
.selected { .selected {
box-shadow: inset 0 0 1px 1px mediumvioletred; box-shadow: 0 0 1px 1px mediumvioletred;
cursor: auto; cursor: auto;
} }
...@@ -393,12 +393,14 @@ hr { ...@@ -393,12 +393,14 @@ hr {
.item-shdescr { .item-shdescr {
display: block; display: block;
color: mediumvioletred;
font-size: 14px; font-size: 14px;
font-weight: bold; font-weight: bold;
padding-bottom: 8px; padding-bottom: 8px;
padding-top: 28px; padding-top: 28px;
cursor: pointer; }
.subcat-link {
color: mediumvioletred;
} }
.item-descount-rate { .item-descount-rate {
......
...@@ -17,7 +17,11 @@ ...@@ -17,7 +17,11 @@
<i _ngcontent-c30="" class="material-icons share-icon">&#xE80D;</i> <i _ngcontent-c30="" class="material-icons share-icon">&#xE80D;</i>
<span _ngcontent-c30="" class="share">Share</span> <span _ngcontent-c30="" class="share">Share</span>
</div> </div>
<a [routerLink]="['/products', itemDetail.itemSubCategory.scatCode]" class="item-shdescr"> {{itemDetail.itemSubCategory.shDescr}} </a> <span class="item-shdescr">
<a [routerLink]="['/products', itemDetail.itemSubCategory.scatCode]" class="subcat-link">
{{itemDetail.itemSubCategory.shDescr}}
</a>
</span>
<span class="item-descr"> {{itemDetail.itemHeader.itemDescr}} </span> <span class="item-descr"> {{itemDetail.itemHeader.itemDescr}} </span>
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
background-position: 15px 10px; background-position: 15px 10px;
background-size: 24px 24px; background-size: 24px 24px;
font-size: 10pt; font-size: 10pt;
color: black;
} }
.search-which { .search-which {
margin: 0; margin: 0;
......
...@@ -56,7 +56,7 @@ export class ECMSearchComponent implements OnInit { ...@@ -56,7 +56,7 @@ export class ECMSearchComponent implements OnInit {
console.log("Selected Value[" +val+ "]"); console.log("Selected Value[" +val+ "]");
let trimmedVal = val.trim().replace(/<\/?[^>]+(>|$)/g, ""); let trimmedVal = val.trim().replace(/<\/?[^>]+(>|$)/g, "");
if(trimmedVal) if(trimmedVal.length > 2)
{ {
this.search_service.getSuggestions(trimmedVal).subscribe(data => { this.search_service.getSuggestions(trimmedVal).subscribe(data => {
this.filteredOptions = data; this.filteredOptions = data;
......
...@@ -4,11 +4,11 @@ import { Observable } from 'rxjs/Observable'; ...@@ -4,11 +4,11 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model'; import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { RESET } from '../ecm-store/ecm-store'; import { RESET } from '../ecm-store/ecm-store';
import { ECMSigninService } from './ecm-signin.service'; import { ECMSigninService } from './ecm-signin.service';
import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
declare var encPwd: any; declare var encPwd: any;
...@@ -30,7 +30,7 @@ export class EcmSigninComponent implements OnInit { ...@@ -30,7 +30,7 @@ export class EcmSigninComponent implements OnInit {
loginErrorMsg: string; loginErrorMsg: string;
@Output() closePanel = new EventEmitter(); @Output() closePanel = new EventEmitter();
constructor(public signinService: ECMSigninService, private store: Store<EcmStoreModel>) { } constructor(public signinService: ECMSigninService, private store: Store<EcmStoreModel>, public cartService: EcmCartService) { }
ngOnInit() { ngOnInit() {
} }
...@@ -77,14 +77,17 @@ export class EcmSigninComponent implements OnInit { ...@@ -77,14 +77,17 @@ export class EcmSigninComponent implements OnInit {
this.userData.jti = this._username; this.userData.jti = this._username;
this.store.dispatch({ type: RESET }); this.store.dispatch({ type: RESET });
//Fetch User Data and Store in cache //Fetch User Data and Store in cache
this.signinService.fetchUserData().subscribe( this.signinService.fetchUserData().subscribe(
response => { response => {
console.log('response[' + response + ']'); console.log('response[' + response + ']');
if(response)
this.cartService.setCartItems();
}); });
console.log( 'comp Object.keys(this.userData) [' + Object.keys(this.userData) + ']' ); console.log( 'comp Object.keys(this.userData) [' + Object.keys(this.userData) + ']' );
localStorage.setItem('userInfo', JSON.stringify( this.userData ) ); localStorage.setItem('userInfo', JSON.stringify( this.userData ) );
} }
this.closePanel.emit(); this.closePanel.emit();
} }
......
...@@ -8,4 +8,5 @@ export class EcmStoreModel { ...@@ -8,4 +8,5 @@ export class EcmStoreModel {
ITEM: Item; ITEM: Item;
ECM_LOCATION: EcmLocation; ECM_LOCATION: EcmLocation;
CART_COUNTER: number; CART_COUNTER: number;
CART_ITEMS: Item;
}; };
import { ActionReducer, Action } from '@ngrx/store'; import { ActionReducer, Action } from '@ngrx/store';
import { ECMCart } from '../ecm-model/cart-model'; import { ECMCart } from '../ecm-model/cart-model';
import { Item } from '../ecm-model/product-model';
export function CATEGORY (state: any = null, {type, payload}) { export function CATEGORY (state: any = null, {type, payload}) {
switch (type) { switch (type) {
...@@ -40,6 +41,41 @@ export function ITEM (state: any = null, {type, payload}) { ...@@ -40,6 +41,41 @@ export function ITEM (state: any = null, {type, payload}) {
} }
}; };
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 function ECM_LOCATION (state: any = null, {type, payload}) { export function ECM_LOCATION (state: any = null, {type, payload}) {
switch (type) { switch (type) {
case 'ECMLOCATION': case 'ECMLOCATION':
...@@ -52,85 +88,3 @@ export function ECM_LOCATION (state: any = null, {type, payload}) { ...@@ -52,85 +88,3 @@ export function ECM_LOCATION (state: any = null, {type, payload}) {
return state; return state;
} }
}; };
export const INCREMENT = 'INCREMENT';
export const DECREMENT = 'DECREMENT';
export const RESET = 'RESET';
export const REMOVE = 'REMOVE';
const cartInitState = {
cartItems : []
}
export function CART_COUNTER(state: any = cartInitState, action: Action) {
console.log('payload >>' + action.payload);
console.log('cartCount >> ' + cartInitState.cartItems.length);
console.log('cartItems >> ' + cartInitState.cartItems);
let payloadExist = false;
let payloadIdx = -1;
if(action.payload)
cartInitState.cartItems.forEach(check);
function check(item, index)
{
if(item.itemCode == action.payload.itemCode)
{
payloadExist = true;
payloadIdx = index;
}
}
//let payloadIdx = cartInitState.cartItems.indexOf(action.payload);
//let payloadExist = ( payloadIdx > -1 ) ? true : false;
console.log('indexOf payload >>' + payloadExist + 'payloadIdx:' +payloadIdx);
switch (action.type) {
case INCREMENT:
if( ! payloadExist )
{
//cartInitState.cartItems.pop()
cartInitState.cartItems.push(action.payload);
console.log('cartItems after Push>> ' + cartInitState.cartItems);
}
else if(payloadExist)
{
cartInitState.cartItems[payloadIdx].quantity++;
console.log('Quantity = '+ cartInitState.cartItems[payloadIdx].quantity);
}
return cartInitState.cartItems.length;
case DECREMENT:
if( payloadExist )
{
cartInitState.cartItems[payloadIdx].quantity--;
console.log('Quantity = '+ cartInitState.cartItems[payloadIdx].quantity);
//let removed = cartInitState.cartItems.splice(payloadIdx)
//console.log('cartItems after splice >>' + removed + '>> ' + cartInitState.cartItems);
}
return cartInitState.cartItems.length;
case REMOVE:
if( payloadExist )
{
let i ;
for( i = cartInitState.cartItems.length - 1; i >= 0; i--)
{
if( cartInitState.cartItems[i].itemCode == action.payload.itemCode)
{
cartInitState.cartItems.splice(i,1);
}
}
}
return cartInitState.cartItems.length;
case RESET:
return 0;
default:
return cartInitState.cartItems.length;
}
};
import { Component, OnInit, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
import { ECMSigninService } from '../ecm-signin/ecm-signin.service'; import { ECMSigninService } from '../ecm-signin/ecm-signin.service';
import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { RESET } from '../ecm-store/ecm-store';
declare var getContentPlugin: any; declare var getContentPlugin: any;
...@@ -20,7 +25,7 @@ export class EcmUserOptionComponent implements OnInit { ...@@ -20,7 +25,7 @@ export class EcmUserOptionComponent implements OnInit {
userData: any; userData: any;
//profileImageLink : string; //profileImageLink : string;
constructor( public signinService: ECMSigninService ) { } constructor( public signinService: ECMSigninService, private store: Store<EcmStoreModel>, public cartService: EcmCartService ) { }
ngOnInit() { ngOnInit() {
var userInfo = localStorage.getItem( 'userInfo' ); var userInfo = localStorage.getItem( 'userInfo' );
...@@ -77,13 +82,18 @@ export class EcmUserOptionComponent implements OnInit { ...@@ -77,13 +82,18 @@ export class EcmUserOptionComponent implements OnInit {
logout() { logout() {
localStorage.removeItem( 'userInfo' ); localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET });
this.signinService.sendLogout( this.userData.jti, this.userData.TOKEN_ID ).subscribe( this.signinService.sendLogout( this.userData.jti, this.userData.TOKEN_ID ).subscribe(
result => { result => {
console.log( 'comp result.results.indexOf [' + result.Response.results.indexOf( '{' ) + ']' ); console.log( 'comp result.results.indexOf [' + result.Response.results.indexOf( '{' ) + ']' );
if ( result.Response.status == 'success' ) { if ( result.Response.status == 'success' ) {
console.log( 'Logging Out' ); console.log( 'Logging Out' );
this.userData = null; this.userData = null;
localStorage.removeItem( 'userInfo' ); localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET });
this.cartService.setCartItems();
} }
else if ( result.Response.status == 'error' ) { else if ( result.Response.status == 'error' ) {
this.userData = null; this.userData = null;
...@@ -94,6 +104,8 @@ export class EcmUserOptionComponent implements OnInit { ...@@ -94,6 +104,8 @@ export class EcmUserOptionComponent implements OnInit {
console.log( 'comp errorMessage[' + errorMessage + ']' ); console.log( 'comp errorMessage[' + errorMessage + ']' );
} }
); );
this.cartService.setCartItems();
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div *ngIf="isMiniCart then miniCart; else fullCart;"></div> <div *ngIf="isMiniCart then miniCart; else fullCart;"></div>
<ng-template #miniCart> <ng-template #miniCart>
<div *ngIf="cartCount == 0" style="text-align: center;"> <div *ngIf="(cartItems | async)?.length == 0" style="text-align: center;">
<img class="empty-cart-img" src="/ecm/assets/images/svg/Empty Cart.svg"> <img class="empty-cart-img" src="/ecm/assets/images/svg/Empty Cart.svg">
<span class="empty-cart-title">Empty Cart</span> <span <span class="empty-cart-title">Empty Cart</span> <span
class="border-line"></span> <span class="empty-cart-msg">Looks class="border-line"></span> <span class="empty-cart-msg">Looks
...@@ -35,16 +35,16 @@ ...@@ -35,16 +35,16 @@
<i class="material-icons" style="position: relative; left: 8px;">trending_flat</i> <i class="material-icons" style="position: relative; left: 8px;">trending_flat</i>
</button> </button>
</div> --> </div> -->
<div class="scrollMe" #scrollMe *ngIf="cartCount > 0"> <div class="scrollMe" #scrollMe *ngIf="(cartItems | async)?.length > 0">
<div class="cartItemsDetail" <div class="cartItemsDetail"
*ngFor="let item of cartItemsDetail"> *ngFor="let item of cartItems | async">
<table style="width: 100%;"> <table style="width: 100%;">
<tr> <tr>
<td class="itemImage"><ecm-image [refId]='item.itemCode' <td class="itemImage"><ecm-image [refId]='item.itemCode'
[refSer]="'M-ITEM'" [object]="'ITEM'" [isSingleImage]="true" [refSer]="'M-ITEM'" [object]="'ITEM'" [isSingleImage]="true"
[isThumbnail]="true"></ecm-image></td> [isThumbnail]="true"></ecm-image></td>
<td class="itemdescription" (click)="closePanel.emit(viewItem(item.itemCode))"> <td class="itemdescription" (click)="closePanel.emit(viewItem(item.itemCode))">
<span class="item-descr-span">{{item.descr}}</span> <span class="item-descr-span">{{item.shDescr}}</span>
</td> </td>
<td style="padding: 10px;">Rs. {{item.costRate}}</td> <td style="padding: 10px;">Rs. {{item.costRate}}</td>
<td (click)="confirmDialog(item)" style="cursor: pointer;"><span <td (click)="confirmDialog(item)" style="cursor: pointer;"><span
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</table> </table>
</div> </div>
</div> </div>
<div *ngIf="cartCount > displayItem" (click)="showTotalCartItems()"> <div *ngIf="(cartItems | async)?.length > displayItem" (click)="showTotalCartItems()">
<a md-button class="edit-cart-button" [routerLink]="['/cart']" <a md-button class="edit-cart-button" [routerLink]="['/cart']"
(click)="closePanel.emit();">Edit Cart</a> (click)="closePanel.emit();">Edit Cart</a>
</div> </div>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<!-- ---------================ detailCart start==============================---------------------------- --> <!-- ---------================ detailCart start==============================---------------------------- -->
<ng-template #fullCart> <ng-template #fullCart>
<div *ngIf="cartCount == 0"> <div *ngIf="(cartItems | async)?.length == 0">
<ecm-header [isFixedHeader]=false> </ecm-header> <ecm-header [isFixedHeader]=false> </ecm-header>
<ecm-breadcrumbs [pageName]="'CART'"></ecm-breadcrumbs> <ecm-breadcrumbs [pageName]="'CART'"></ecm-breadcrumbs>
<div class="row"> <div class="row">
...@@ -78,16 +78,16 @@ ...@@ -78,16 +78,16 @@
<ecm-footer></ecm-footer> <ecm-footer></ecm-footer>
</div> </div>
</div> </div>
<div *ngIf="cartCount > 0 && cartItemsDetail"> <div *ngIf="(cartItems | async)?.length > 0">
<ecm-header [isFixedHeader]=false> </ecm-header> <ecm-header [isFixedHeader]=false> </ecm-header>
<ecm-breadcrumbs [pageName]="'CART'"></ecm-breadcrumbs> <ecm-breadcrumbs [pageName]="'CART'"></ecm-breadcrumbs>
<div class="row details-of-Cart"> <div class="row details-of-Cart">
<md-card class="medium-8 columns cartItemsDetails"> <md-card class="medium-8 columns cartItemsDetails">
<div class="ecmdetailsItems"> <div class="ecmdetailsItems">
<div class="ecm-headings"> <div class="ecm-headings">
<span class="my-cart-title">({{cartCount}}) My Cart</span> <span class="my-cart-title">( {{(cartItems | async)?.length}} ) My Cart</span>
</div> </div>
<div class="listItems" *ngFor="let item of cartItemsDetail"> <div class="listItems" *ngFor="let item of cartItems | async">
<div class="item-image"> <div class="item-image">
<ecm-image [refId]='item.itemCode' [refSer]="'M-ITEM'" <ecm-image [refId]='item.itemCode' [refSer]="'M-ITEM'"
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
</div> </div>
<div class="totalProductsInfo"> <div class="totalProductsInfo">
<div class="priceItems"> <div class="priceItems">
<span style="font-size: 15px;">Price ( {{cartCount}} Items )</span> <span style="font-size: 15px;">Price ( {{(cartItems | async)?.length}} Items )</span>
<span class="price-info">Rs. {{totalPrice}}</span> <span class="price-info">Rs. {{totalPrice}}</span>
</div> </div>
<br> <br>
......
...@@ -4,12 +4,12 @@ import { MdSnackBar } from '@angular/material'; ...@@ -4,12 +4,12 @@ import { MdSnackBar } from '@angular/material';
import { MdDialog, MdDialogRef } from '@angular/material'; import { MdDialog, MdDialogRef } from '@angular/material';
import { ItemDetail } from '../../ecm-model/product-detail-model'; import { ItemDetail } from '../../ecm-model/product-detail-model';
import { EcmCategoryComponent } from '../ecm-category/ecm-category.component'; import { EcmCategoryComponent } from '../ecm-category/ecm-category.component';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model'; import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { INCREMENT, DECREMENT, REMOVE, RESET } from '../../ecm-store/ecm-store'; import { UPDATE_QUANTITY, REMOVE } from '../../ecm-store/ecm-store';
import { Item } from '../../ecm-model/product-model'; import { Item } from '../../ecm-model/product-model';
import { EcmCartService } from './ecm-cart.service'; import { EcmCartService } from './ecm-cart.service';
...@@ -30,17 +30,17 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -30,17 +30,17 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
catCode; catCode;
displayItem = 3; displayItem = 3;
totalPrice: number = 0; totalPrice: number = 0;
cartItems : Observable<Item[]>;
disableScrollDown = false disableScrollDown = false
@Input() isMiniCart: boolean = false; @Input() isMiniCart: boolean = false;
@Output() closePanel = new EventEmitter(); @Output() closePanel = new EventEmitter();
@Output() doActivity = new EventEmitter(); @Output() doActivity = new EventEmitter();
@ViewChild('scrollMe') private myScrollContainer: ElementRef; @ViewChild('scrollMe') private myScrollContainer: ElementRef;
constructor( private route: ActivatedRoute, public dialog: MdDialog, private router: Router,public subcategoryService: EcmProductDetailService, public cartService: EcmCartService, public snackBar: MdSnackBar, private http: Http, private store: Store<EcmStoreModel> ) { } constructor( private route: ActivatedRoute, public dialog: MdDialog, private router: Router,public productDetailService: EcmProductDetailService, public cartService: EcmCartService, public snackBar: MdSnackBar, private http: Http, private store: Store<EcmStoreModel> ) { }
ngOnInit() { ngOnInit() {
this.getCartItem(); this.getCartItem();
...@@ -52,96 +52,66 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -52,96 +52,66 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
} }
getCartItem() { getCartItem() {
this.cartService.getCartItems().subscribe( this.cartItems = this.store.select('cart');
cartItemsDetail => {
this.cartItemsDetail = cartItemsDetail; this.cartItems.subscribe( cartItems => {
if( this.cartItemsDetail && this.cartItemsDetail.length) this.totalPrice = 0;
{ cartItems.forEach(
this.cartCount = this.cartItemsDetail.length ; item => {
console.log( 'comp cartItemsDetail[' + this.cartItemsDetail + '] \n this.cartItemsDetail[' + this.cartItemsDetail.length + ']' ); this.totalPrice = this.totalPrice + (parseFloat( item.costRate ) * item.itemQuantity);
if ( this.cartItemsDetail ) {
this.getTotalPrice();
console.log( "the total Price is" + this.totalPrice );
} }
} );
else });
{
this.cartCount = 0;
}
},
error => {
this.cartCount = 0;
let errorMessage = <any>error;
console.log( 'comp errorMessage[' + errorMessage + ']' );
});
} }
userActionUrl = '/ecm/service/feeds/cart'; userActionUrl = '/ecm/service/feeds/cart';
deleteCartItem( itemCode ) { deleteCartItem( item ) {
console.log( "deleteCartItem Called" ); console.log( "deleteCartItem Called" );
this.http.delete( this.userActionUrl + '/' + itemCode, {})
this.store.dispatch({ type: REMOVE, payload: item });
this.http.delete( this.userActionUrl + '/' + item.itemCode, {})
.subscribe( data => { .subscribe( data => {
console.log( "deleted item in Cart" ); console.log( "deleted item in Cart" );
}, error => { }, error => {
console.log( error.json() ); console.log( error.json() );
}); });
this.getCartItem(); this.getCartItem();
this.decreasePrice();
let cartData = new ECMCart;
cartData.itemCode = itemCode;
this.store.dispatch({ type: REMOVE, payload: cartData });
this.openSnackBar('Item Removed from your Cart' ); this.openSnackBar('Item Removed from your Cart' );
} }
showTotalCartItems() { showTotalCartItems() {
this.getTotalPrice();
this.router.navigate( ['/cart'] ); this.router.navigate( ['/cart'] );
} }
getTotalPrice() {
this.cartItemsDetail.forEach(( item, i ) => {
item.itemQuantity = 1;
this.totalPrice = this.totalPrice + parseFloat( item.costRate ) ;
// this.totalPrice = this.totalPrice + item.totalAmount ;
});
}
decreasePrice() {
this.cartItemsDetail.forEach(( item, i ) => {
this.totalPrice = this.totalPrice - parseFloat( item.costRate );
});
}
increment(item : Item) { increment(item : Item) {
item.itemQuantity++; item.itemQuantity++;
this.addToCart(item); this.addToCart(item);
} }
addToCart(data : Item) { addToCart(data : Item) {
let cartData = new ECMCart; let cartData = new Item;
cartData.itemCode = data.itemCode; cartData.itemCode = data.itemCode;
cartData.quantity = data.itemQuantity; cartData.itemQuantity = data.itemQuantity;
cartData.itemCost = parseFloat( data.costRate ); cartData.costRate = data.costRate;
// cartData.totalAmount = (cartData.quantity)* (cartData.itemCost);
this.store.dispatch({ type: INCREMENT, payload: cartData }); this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.subcategoryService.addToCart(cartData); this.productDetailService.addToCart(cartData);
this.openSnackBar( data.shDescr + ' Added to your Cart ' ); this.openSnackBar( data.shDescr + ' Added to your Cart ' );
} }
decrement(data : Item) { decrement(data : Item) {
data.itemQuantity--; data.itemQuantity--;
let cartData = new ECMCart; let cartData = new Item;
cartData.itemCode = data.itemCode; cartData.itemCode = data.itemCode;
this.store.dispatch({ type: DECREMENT, payload: cartData }); this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.openSnackBar( data.shDescr + ' Removed from your Cart' ); this.openSnackBar( data.shDescr + ' Removed from your Cart' );
} }
checkQantity(item) checkQantity(item) {
{
if (item.itemQuantity == 1) if (item.itemQuantity == 1)
return true; return true;
else else
...@@ -152,7 +122,6 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -152,7 +122,6 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
this.openSnackBar('Item Added to your Wishlist' ); this.openSnackBar('Item Added to your Wishlist' );
} }
openSnackBar( message: string ) { openSnackBar( message: string ) {
this.snackBar.open( message, '', { this.snackBar.open( message, '', {
duration: 2000, duration: 2000,
...@@ -173,7 +142,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -173,7 +142,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
dialogRef.afterClosed().subscribe( result => { dialogRef.afterClosed().subscribe( result => {
if( result == 'true') if( result == 'true')
{ {
this.deleteCartItem(item.itemCode); this.deleteCartItem(item);
} }
}); });
} }
...@@ -189,7 +158,6 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -189,7 +158,6 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
} }
@Component( { @Component( {
selector: 'ecm-confirm-dialog', selector: 'ecm-confirm-dialog',
templateUrl: 'ecm-confirm-dialog.html', templateUrl: 'ecm-confirm-dialog.html',
......
...@@ -4,17 +4,46 @@ import { Observable } from 'rxjs/Observable'; ...@@ -4,17 +4,46 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { Item } from '../../ecm-model/product-model'; import { Item } from '../../ecm-model/product-model';
import { Store } from '@ngrx/store';
import { ADD_TO_CART } from '../../ecm-store/ecm-store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
@Injectable() @Injectable()
export class EcmCartService { export class EcmCartService {
private userActionUrl = '/ecm/service/feeds/cart'; private userActionUrl = '/ecm/service/feeds/cart';
public itemCode; public itemCode;
cartItems: Item[];
constructor(private http: Http) { } constructor(private http: Http, private store: Store<EcmStoreModel>) { }
getCartItems() {
let cartItems;
this.store.select('cart').forEach(
value => {
cartItems=value;
}
);
return cartItems;
}
setCartItems(){
this.fetchCartItems().subscribe(
data => {
this.cartItems = data;
if ( data && data != null ) {
this.cartItems.forEach( item => {
this.store.dispatch({ type: ADD_TO_CART, payload: item });
})
}
});
}
getCartItems(): Observable<Item[]> { fetchCartItems(): Observable<Item[]> {
let headers = new Headers( { 'Content-Type': 'application/json' }); let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers }); let options = new RequestOptions( { headers: headers });
......
...@@ -162,14 +162,14 @@ ...@@ -162,14 +162,14 @@
</div> </div>
<div *ngIf="cartItemsDetail" class="medium-5 columns"> <div *ngIf="(cartItems | async)?.length > 0" class="medium-5 columns">
<md-card> <md-card>
<div class="orderSummary"> <div class="orderSummary">
<table> <table>
<tr> <tr>
<th class="order-summary-title">Order Summary</th> <th class="order-summary-title">Order Summary</th>
</tr> </tr>
<tr *ngFor="let item of cartItemsDetail"> <tr *ngFor="let item of cartItems | async">
<td class="item-name">{{item.shDescr}}</td> <td class="item-name">{{item.shDescr}}</td>
<td class="item-cost">Rs. {{item.costRate}}</td> <td class="item-cost">Rs. {{item.costRate}}</td>
</tr> </tr>
......
...@@ -2,6 +2,9 @@ import { Component, OnInit, ViewChild, ElementRef, Input, Output, EventEmitter } ...@@ -2,6 +2,9 @@ import { Component, OnInit, ViewChild, ElementRef, Input, Output, EventEmitter }
import { FormBuilder, Validators,NgForm } from '@angular/forms'; import { FormBuilder, Validators,NgForm } from '@angular/forms';
import { EcmCartService } from '../ecm-cart/ecm-cart.service'; import { EcmCartService } from '../ecm-cart/ecm-cart.service';
import { Item } from '../../ecm-model/product-model'; import { Item } from '../../ecm-model/product-model';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
@Component( { @Component( {
selector: 'ecm-checkout', selector: 'ecm-checkout',
...@@ -19,8 +22,9 @@ export class EcmCheckoutComponent implements OnInit { ...@@ -19,8 +22,9 @@ export class EcmCheckoutComponent implements OnInit {
countries; countries;
months; months;
years; years;
cartItems: Observable<Item[]>;
constructor(private formBuilder: FormBuilder, public cartService: EcmCartService) {
constructor(private formBuilder: FormBuilder, public cartService: EcmCartService, private store: Store<EcmStoreModel>) {
this.countries = [ this.countries = [
{ viewValue: 'India' }, { viewValue: 'India' },
{ viewValue: 'UAE' }, { viewValue: 'UAE' },
...@@ -61,25 +65,15 @@ export class EcmCheckoutComponent implements OnInit { ...@@ -61,25 +65,15 @@ export class EcmCheckoutComponent implements OnInit {
} }
getCartItems() { getCartItems() {
this.cartService.getCartItems().subscribe( this.cartItems = this.store.select('cart');
cartItemsDetail => {
this.cartItemsDetail = cartItemsDetail; this.cartItems.subscribe( cartItems => {
console.log( 'comp cartItemsDetail[' + JSON.stringify( cartItemsDetail ) + '] \n this.cartItemsDetail[' + this.cartItemsDetail.length + ']' ); this.totalPrice = 0;
if ( this.cartItemsDetail ) { cartItems.forEach(
this.getTotalPrice(); item => {
console.log( "the total Price is" + this.totalPrice ); this.totalPrice = this.totalPrice + (parseFloat( item.costRate ) * item.itemQuantity);
} }
}, );
error => {
let errorMessage = <any>error;
console.log( 'comp errorMessage[' + errorMessage + ']' );
});
}
getTotalPrice() {
this.cartItemsDetail.forEach(( item, i ) => {
this.totalPrice = this.totalPrice + parseFloat( item.costRate );
console.log('Total Price Is'+item.costRate);
}); });
} }
} }
......
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