Skip to content

Commit b9b58e0

Browse files
committed
Refactoring
1 parent a01c6e9 commit b9b58e0

47 files changed

Lines changed: 1042 additions & 460 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"dependencies": {
4747
"babel-cli": "^6.24.0",
4848
"babel-core": "^6.24.0",
49-
"babel-loader": "^6.3.2",
49+
"babel-loader": "^6.4.1",
5050
"babel-plugin-transform-class-properties": "^6.23.0",
5151
"babel-polyfill": "^6.23.0",
5252
"babel-preset-latest": "^6.24.0",
@@ -59,7 +59,7 @@
5959
"express-jwt": "^5.1.0",
6060
"extract-text-webpack-plugin": "^2.1.0",
6161
"formidable": "^1.1.1",
62-
"fs-extra": "^2.0.0",
62+
"fs-extra": "^2.1.2",
6363
"handlebars": "^4.0.6",
6464
"helmet": "^3.4.1",
6565
"html-webpack-plugin": "^2.28.0",
@@ -68,7 +68,7 @@
6868
"lru-cache": "^4.0.2",
6969
"material-ui": "^0.17.1",
7070
"moment": "^2.16.0",
71-
"mongodb": "^2.2.24",
71+
"mongodb": "^2.2.25",
7272
"nodemailer": "^3.1.5",
7373
"nodemailer-smtp-transport": "^2.7.2",
7474
"react": "^15.4.2",

public/assets/js/polyfill.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

public/assets/js/require-shims.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/admin/client/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<title>Dashboard</title>
66
<meta charset="UTF-8" />
77
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<meta name="theme-color" content="#1976D2">
89
<link rel="manifest" href="/admin-assets/manifest.json">
910
<link rel="shortcut icon" href="/admin-assets/images/shortcut.png">
1011
</head>

src/api/server/services/products/products.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class ProductsService {
3535
aggregationPipeline.push({ $project: projectQuery });
3636
aggregationPipeline.push({ $match: matchQuery });
3737
aggregationPipeline.push({ $sort: sortQuery });
38-
aggregationPipeline.push({ $limit : limit });
3938
aggregationPipeline.push({ $skip : offset });
39+
aggregationPipeline.push({ $limit : limit });
4040

4141
return mongo.db.collection('products').aggregate(aggregationPipeline).toArray()
4242
.then(items => items.map(item => this.changeProperties(categories, item, thumbnail_width)))

src/store/server/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ storeRouter.get('*', (req, res, next) => {
7272
Promise.all([
7373
readIndexHtmlFile(),
7474
api.sitemap.retrieve({ path: req.path, enabled: true }),
75-
api.checkout_fields.list()
76-
]).then(([templateHtml, sitemapDetails, checkout_fields]) => {
75+
api.checkout_fields.list(),
76+
api.settings.retrieve()
77+
]).then(([templateHtml, sitemapDetails, checkout_fields, settings]) => {
7778
if (sitemapDetails.status === 200 || sitemapDetails.status === 404) {
7879
let currentPage = sitemapDetails.json;
7980
if(sitemapDetails.status === 404) {
@@ -83,7 +84,7 @@ storeRouter.get('*', (req, res, next) => {
8384
}
8485
}
8586

86-
getInitialState(req, checkout_fields.json, currentPage).then(initialState => {
87+
getInitialState(req, checkout_fields.json, currentPage, settings.json).then(initialState => {
8788
const store = createStore(reducers, initialState, applyMiddleware(thunkMiddleware));
8889
const routes = createRoutes(store);
8990

src/store/shared/actionTypes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export const PRODUCTS_REQUEST = 'PRODUCTS_REQUEST'
77
export const PRODUCTS_RECEIVE = 'PRODUCTS_RECEIVE'
88
export const PRODUCTS_FAILURE = 'PRODUCTS_FAILURE'
99

10+
export const PRODUCTS_MORE_REQUEST = 'PRODUCTS_MORE_REQUEST'
11+
export const PRODUCTS_MORE_RECEIVE = 'PRODUCTS_MORE_RECEIVE'
12+
1013
export const CHECKOUT_REQUEST = 'CHECKOUT_REQUEST'
1114
export const CHECKOUT_RECEIVE = 'CHECKOUT_RECEIVE'
1215
export const CHECKOUT_FAILURE = 'CHECKOUT_FAILURE'

src/store/shared/actions.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ function receiveProducts(products) {
1212
return {type: t.PRODUCTS_RECEIVE, products}
1313
}
1414

15+
function requestProducts() {
16+
return {type: t.PRODUCTS_REQUEST}
17+
}
18+
1519
function receiveProduct(product) {
1620
return {type: t.PRODUCT_RECEIVE, product}
1721
}
@@ -60,6 +64,19 @@ function requestCheckout() {
6064
return {type: t.CHECKOUT_REQUEST}
6165
}
6266

67+
function requestMoreProducts() {
68+
return {
69+
type: t.PRODUCTS_MORE_REQUEST
70+
}
71+
}
72+
73+
function receiveProductsMore(products) {
74+
return {
75+
type: t.PRODUCTS_MORE_RECEIVE,
76+
products
77+
}
78+
}
79+
6380
export function setCategory(category_id) {
6481
return (dispatch, getState) => {
6582
const state = getState();
@@ -259,19 +276,36 @@ export function fetchProduct(product_id) {
259276
export function fetchProducts() {
260277
return (dispatch, getState) => {
261278
const state = getState();
279+
dispatch(requestProducts());
262280

263281
let filter = state.app.productsFilter;
264-
filter.thumbnail_width = 320,
265-
filter.enabled = true;
266282
filter.category_id = state.app.currentCategory.id;
267-
filter.fields = 'path,id,name,category_id,category_name,sku,images,enabled,discontinued,stock_status,stock_quantity,price,on_sale,regular_price';
268-
283+
// filter.search =
269284
return api.ajax.products.list(filter).then(({status, json}) => {
270285
dispatch(receiveProducts(json))
271286
}).catch(error => {});
272287
}
273288
}
274289

290+
export function fetchMoreProducts() {
291+
return (dispatch, getState) => {
292+
const state = getState();
293+
if(state.app.loadingProducts) {
294+
return Promise.resolve();
295+
}
296+
dispatch(requestMoreProducts());
297+
298+
let filter = state.app.productsFilter;
299+
filter.limit = 15;
300+
filter.offset = state.app.products.length;
301+
filter.category_id = state.app.currentCategory.id;
302+
303+
return api.ajax.products.list(filter).then(({status, json}) => {
304+
dispatch(receiveProductsMore(json))
305+
}).catch(error => {});
306+
}
307+
}
308+
275309
export function fetchPage(pageId) {
276310
return (dispatch, getState) => {
277311
return api.ajax.pages.retrieve(pageId).then(({status, json}) => {
@@ -326,10 +360,10 @@ const getCommonData = (req, currentPage, productsFilter) => {
326360
});
327361
}
328362

329-
export const getInitialState = (req, checkout_fields, currentPage) => {
363+
export const getInitialState = (req, checkout_fields, currentPage, settings) => {
330364
let initialState = {
331365
app: {
332-
language: 'en',
366+
settings: settings,
333367
location: null,
334368
currentPage: currentPage,
335369
currentCategory: null,
@@ -339,14 +373,15 @@ export const getInitialState = (req, checkout_fields, currentPage) => {
339373
payment_methods: [],
340374
shipping_methods: [],
341375
page: {},
376+
loadingProducts: false,
377+
loadingMoreProducts: false,
342378
loadingShippingMethods: false,
343379
loadingPaymentMethods: false,
344380
processingCheckout: false,
345381
cart: null,
346382
order: null,
347383
productsFilter: {
348-
limit: 20,
349-
thumbnail_width: 320,
384+
limit: 30,
350385
enabled: true,
351386
fields: 'path,id,name,category_id,category_name,sku,images,enabled,discontinued,stock_status,stock_quantity,price,on_sale,regular_price'
352387
},

src/store/shared/components/checkoutForm/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
import { connect } from 'react-redux'
2-
import { reset, submit } from 'redux-form';
3-
import { fetchCart, updateCart, fetchShippingMethods, fetchPaymentMethods, checkout, updateCartShippingCountry, updateCartShippingState, updateCartShippingCity, updateCartShippingMethod, updateCartPaymentMethod} from '../../actions'
1+
import React from 'react'
2+
import {connect} from 'react-redux'
3+
import {reset, submit} from 'redux-form';
4+
import {
5+
checkout,
6+
updateCart,
7+
fetchShippingMethods,
8+
fetchPaymentMethods,
9+
updateCartShippingCountry,
10+
updateCartShippingState,
11+
updateCartShippingCity,
12+
updateCartShippingMethod,
13+
updateCartPaymentMethod
14+
} from '../../actions'
415
import Form from './form'
516

6-
const mapStateToProps = (state) => {
17+
const mapStateToProps = (state, ownProps) => {
718
return {
819
initialValues: state.app.cart,
920
payment_methods: state.app.payment_methods,
@@ -15,7 +26,7 @@ const mapStateToProps = (state) => {
1526
}
1627
}
1728

18-
const mapDispatchToProps = (dispatch) => {
29+
const mapDispatchToProps = (dispatch, ownProps) => {
1930
return {
2031
onSubmit: (values) => {
2132
dispatch(updateCart(values));

src/store/shared/components/checkoutSuccess/index.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)