@@ -85,7 +85,8 @@ const initialState = {
8585
8686const rootReducer = ( state = initialState , action ) => {
8787 const userUrl = `${ state . serverUrl } users/${ state . user . _id } ` , // get user data url
88- productsUrl = `${ state . serverUrl } products/` ; // get products data url
88+ productsUrl = `${ state . serverUrl } products/` , // get products data url
89+ payload = action . payload ;
8990
9091 switch ( action . type ) {
9192 case WISHLIST_GET_IDS :
@@ -95,38 +96,38 @@ const rootReducer = (state = initialState, action) => {
9596 return state ;
9697
9798 case WISHLIST_ADD_PRODUCT :
98- wishlistAddProductApiCall ( action . payload , userUrl ) . then ( wishlist => {
99+ wishlistAddProductApiCall ( payload , userUrl ) . then ( wishlist => {
99100 action . asyncDispatch ( { type : WISHLIST_SET_IDS , payload : wishlist } ) ;
100101 } ) . catch ( err => action . asyncDispatch ( { type : WISHLIST_ERROR , payload : err } )
101102 ) ;
102103 return state ;
103104
104105 case WISHLIST_REMOVE_PRODUCT :
105- wishlistRemoveProductApiCall ( action . payload , userUrl ) . then ( wishlist => {
106+ wishlistRemoveProductApiCall ( payload , userUrl ) . then ( wishlist => {
106107 action . asyncDispatch ( { type : WISHLIST_SET_IDS , payload : wishlist } ) ;
107108 } ) . catch ( err => console . warn ( err ) ) ;
108109 return state ;
109110
110111 case WISHLIST_SET_IDS :
111- action . asyncDispatch ( { type : WISHLIST_GET_PRODUCTS , payload : action . payload } ) ;
112+ action . asyncDispatch ( { type : WISHLIST_GET_PRODUCTS , payload : payload } ) ;
112113 return Object . assign ( { } , state , {
113- user : Object . assign ( { } , state . user , { wishlist : action . payload } )
114+ user : Object . assign ( { } , state . user , { wishlist : payload } )
114115 } ) ;
115116
116117 case WISHLIST_GET_PRODUCTS :
117- wishlistGetProductsApiCall ( action . payload , productsUrl ) . then ( wishlistProducts => {
118+ wishlistGetProductsApiCall ( payload , productsUrl ) . then ( wishlistProducts => {
118119 action . asyncDispatch ( { type : WISHLIST_SET_PRODUCTS , payload : wishlistProducts } ) ;
119120 } ) . catch ( err => console . warn ( err ) ) ;
120121 return state ;
121122
122123 case WISHLIST_SET_PRODUCTS :
123124 return Object . assign ( { } , state , {
124- user : Object . assign ( { } , state . user , { wishlistProducts : action . payload } )
125+ user : Object . assign ( { } , state . user , { wishlistProducts : payload } )
125126 } ) ;
126127
127128 case WISHLIST_ERROR :
128129 return Object . assign ( { } , state , {
129- user : Object . assign ( { } , state . user , { wishlistError : action . payload } ) ,
130+ user : Object . assign ( { } , state . user , { wishlistError : payload } ) ,
130131 modal : { status : true }
131132 } ) ;
132133
@@ -137,32 +138,32 @@ const rootReducer = (state = initialState, action) => {
137138 return state ;
138139
139140 case FEATUREDPRODUCTS_SET_SOURCE :
140- action . asyncDispatch ( { type : FEATUREDPRODUCTS_SET_VISIBLE , payload : action . payload } ) ;
141+ action . asyncDispatch ( { type : FEATUREDPRODUCTS_SET_VISIBLE , payload : payload } ) ;
141142 return Object . assign ( { } , state , {
142- featuredProducts : Object . assign ( { } , state . featuredProducts , { source : action . payload } )
143+ featuredProducts : Object . assign ( { } , state . featuredProducts , { source : payload } )
143144 } ) ;
144145
145146 case FEATUREDPRODUCTS_SET_VISIBLE :
146147 return Object . assign ( { } , state , {
147- featuredProducts : Object . assign ( { } , state . featuredProducts , { visible : action . payload } )
148+ featuredProducts : Object . assign ( { } , state . featuredProducts , { visible : payload } )
148149 } ) ;
149150
150151 case FEATUREDPRODUCTS_HANDLE_MODE :
151152 return Object . assign ( { } , state , {
152- featuredProducts : Object . assign ( { } , state . featuredProducts , { mode : action . payload } )
153+ featuredProducts : Object . assign ( { } , state . featuredProducts , { mode : payload } )
153154 } ) ;
154155
155156 case FEATUREDPRODUCTS_APPLY_FILTER :
156- action . asyncDispatch ( { type : FEATUREDPRODUCTS_SET_FILTERS , payload : action . payload } ) ;
157- featuredProductsApplyFilterReducer ( action . payload ) . then ( visible => {
157+ action . asyncDispatch ( { type : FEATUREDPRODUCTS_SET_FILTERS , payload : payload } ) ;
158+ featuredProductsApplyFilterReducer ( payload ) . then ( visible => {
158159 action . asyncDispatch ( { type : FEATUREDPRODUCTS_SET_VISIBLE , payload : visible } ) ;
159160 } ) ;
160161 return state ;
161162
162163 case FEATUREDPRODUCTS_SET_FILTERS :
163164 return Object . assign ( { } , state , {
164165 featuredProducts : Object . assign ( { } , state . featuredProducts , {
165- filters : Object . assign ( { } , state . featuredProducts . filters , { [ action . payload . task ] : action . payload . value } )
166+ filters : Object . assign ( { } , state . featuredProducts . filters , { [ payload . task ] : payload . value } )
166167 } )
167168 } ) ;
168169
@@ -177,7 +178,7 @@ const rootReducer = (state = initialState, action) => {
177178 } ) ;
178179
179180 case DEPARTMENTS_PRODUCTS_SEARCH :
180- autocompleteSearchApiCall ( productsUrl , action . payload ) . then ( products => {
181+ autocompleteSearchApiCall ( productsUrl , payload ) . then ( products => {
181182 action . asyncDispatch ( { type : DEPARTMENTS_PRODUCTS_SET , payload : products } ) ;
182183 } ) ;
183184 return state ;
@@ -186,17 +187,17 @@ const rootReducer = (state = initialState, action) => {
186187 return Object . assign ( { } , state , {
187188 departments : Object . assign ( { } , state . departments , {
188189 products : Object . assign ( { } , state . departments . products , {
189- items : action . payload
190+ items : payload
190191 } )
191192 } )
192193 } ) ;
193194
194195 case DEPARTMENTS_PRODUCTS_SELECTED_CHANGED :
195- console . log ( 'selected: ' , action . payload ) ;
196+ console . log ( 'selected: ' , payload ) ;
196197 return Object . assign ( { } , state , {
197198 departments : Object . assign ( { } , state . departments , {
198199 products : Object . assign ( { } , state . departments . products , {
199- selected : action . payload
200+ selected : payload ,
200201 } )
201202 } )
202203 } ) ;
0 commit comments