11import { push } from 'react-router-redux' ;
22import * as t from './actionTypes'
3+ import { PAGE , PRODUCT_CATEGORY , PRODUCT , RESERVED } from './pageTypes'
34import clientSettings from '../client/settings'
45import api from 'cezerin-client'
56api . initAjax ( clientSettings . ajaxBaseUrl ) ;
@@ -247,15 +248,15 @@ const getCategories = () => {
247248}
248249
249250const getProducts = ( currentPage , filter ) => {
250- if ( currentPage . type === 'product-category' ) {
251+ if ( currentPage . type === PRODUCT_CATEGORY ) {
251252 return api . ajax . products . list ( filter ) . then ( ( { status, json} ) => json )
252253 } else {
253254 return Promise . resolve ( [ ] ) ;
254255 }
255256}
256257
257258const getProduct = currentPage => {
258- if ( currentPage . type === 'product' ) {
259+ if ( currentPage . type === PRODUCT ) {
259260 return api . ajax . products . retrieve ( currentPage . resource ) . then ( ( { status, json} ) => json )
260261 } else {
261262 return Promise . resolve ( ) ;
@@ -267,7 +268,7 @@ const getCart = cookie => {
267268}
268269
269270const getPage = currentPage => {
270- if ( currentPage . type === 'page' ) {
271+ if ( currentPage . type === PAGE ) {
271272 return api . ajax . pages . retrieve ( currentPage . resource ) . then ( pageResponse => {
272273 return pageResponse . json ;
273274 } )
@@ -280,7 +281,7 @@ const getCommonData = (req, currentPage, productsFilter) => {
280281 const cookie = req . get ( 'cookie' ) ;
281282 return Promise . all ( [ getCategories ( ) , getProduct ( currentPage ) , getProducts ( currentPage , productsFilter ) , getCart ( cookie ) , getPage ( currentPage ) ] ) . then ( ( [ categories , product , products , cart , page ] ) => {
282283 let categoryDetails = null ;
283- if ( currentPage . type === 'product-category' ) {
284+ if ( currentPage . type === PRODUCT_CATEGORY ) {
284285 categoryDetails = categories . find ( c => c . id === currentPage . resource ) ;
285286 }
286287 return {
@@ -327,7 +328,7 @@ export const getInitialState = (req, checkoutFields, currentPage, settings) => {
327328 }
328329 }
329330
330- if ( currentPage . type === 'product-category' ) {
331+ if ( currentPage . type === PRODUCT_CATEGORY ) {
331332 initialState . app . productsFilter . category_id = currentPage . resource ;
332333 }
333334
0 commit comments