From 0b899c09af5dd096d7f9fcdf096f3dc111d84c94 Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Wed, 8 Aug 2018 14:40:00 +0200 Subject: [PATCH] Connected and enabled co-maket --- .gitignore | 3 +- frontend/package-lock.json | 180 ++++++++---------- frontend/src/actions/cart/cartActions.js | 12 ++ .../coMarket/coMarketPackagesActions.js | 50 ++--- frontend/src/actions/login/authActions.js | 73 +++++++ .../coMarket/CoMarketPackagesContainer.jsx | 4 +- .../coMarket/components/ShopItem.jsx | 6 +- 7 files changed, 202 insertions(+), 126 deletions(-) diff --git a/.gitignore b/.gitignore index 00258e0..2109039 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /log *.env -!environment.env \ No newline at end of file +!environment.env +.idea \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b59180b..44a93bb 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -4300,21 +4300,19 @@ "bundled": true, "optional": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -4325,18 +4323,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -4371,7 +4366,7 @@ "bundled": true, "optional": true, "requires": { - "minipass": "2.2.4" + "minipass": "^2.2.1" } }, "fs.realpath": { @@ -4384,14 +4379,14 @@ "bundled": true, "optional": true, "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "glob": { @@ -4399,12 +4394,12 @@ "bundled": true, "optional": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "has-unicode": { @@ -4417,7 +4412,7 @@ "bundled": true, "optional": true, "requires": { - "safer-buffer": "2.1.2" + "safer-buffer": "^2.1.0" } }, "ignore-walk": { @@ -4425,7 +4420,7 @@ "bundled": true, "optional": true, "requires": { - "minimatch": "3.0.4" + "minimatch": "^3.0.4" } }, "inflight": { @@ -4433,14 +4428,13 @@ "bundled": true, "optional": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -4450,9 +4444,8 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { - "number-is-nan": "1.0.1" + "number-is-nan": "^1.0.0" } }, "isarray": { @@ -4463,23 +4456,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" + "safe-buffer": "^5.1.1", + "yallist": "^3.0.0" } }, "minizlib": { @@ -4487,13 +4477,12 @@ "bundled": true, "optional": true, "requires": { - "minipass": "2.2.4" + "minipass": "^2.2.1" } }, "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4508,9 +4497,9 @@ "bundled": true, "optional": true, "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.21", - "sax": "1.2.4" + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" } }, "node-pre-gyp": { @@ -4518,16 +4507,16 @@ "bundled": true, "optional": true, "requires": { - "detect-libc": "1.0.3", - "mkdirp": "0.5.1", - "needle": "2.2.0", - "nopt": "4.0.1", - "npm-packlist": "1.1.10", - "npmlog": "4.1.2", - "rc": "1.2.7", - "rimraf": "2.6.2", - "semver": "5.5.0", - "tar": "4.4.1" + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.0", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.1.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" } }, "nopt": { @@ -4535,8 +4524,8 @@ "bundled": true, "optional": true, "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" + "abbrev": "1", + "osenv": "^0.1.4" } }, "npm-bundled": { @@ -4549,8 +4538,8 @@ "bundled": true, "optional": true, "requires": { - "ignore-walk": "3.0.1", - "npm-bundled": "1.0.3" + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" } }, "npmlog": { @@ -4558,16 +4547,15 @@ "bundled": true, "optional": true, "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -4577,9 +4565,8 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -4597,8 +4584,8 @@ "bundled": true, "optional": true, "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" } }, "path-is-absolute": { @@ -4616,10 +4603,10 @@ "bundled": true, "optional": true, "requires": { - "deep-extend": "0.5.1", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "^0.5.1", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -4634,13 +4621,13 @@ "bundled": true, "optional": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "rimraf": { @@ -4648,7 +4635,7 @@ "bundled": true, "optional": true, "requires": { - "glob": "7.1.2" + "glob": "^7.0.5" } }, "safe-buffer": { @@ -4683,11 +4670,10 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -4695,14 +4681,14 @@ "bundled": true, "optional": true, "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "~5.1.0" } }, "strip-ansi": { "version": "3.0.1", "bundled": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "strip-json-comments": { @@ -4715,13 +4701,13 @@ "bundled": true, "optional": true, "requires": { - "chownr": "1.0.1", - "fs-minipass": "1.2.5", - "minipass": "2.2.4", - "minizlib": "1.1.0", - "mkdirp": "0.5.1", - "safe-buffer": "5.1.1", - "yallist": "3.0.2" + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", + "yallist": "^3.0.2" } }, "util-deprecate": { @@ -4734,7 +4720,7 @@ "bundled": true, "optional": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2" } }, "wrappy": { diff --git a/frontend/src/actions/cart/cartActions.js b/frontend/src/actions/cart/cartActions.js index 6f071db..fcfbf5f 100644 --- a/frontend/src/actions/cart/cartActions.js +++ b/frontend/src/actions/cart/cartActions.js @@ -56,6 +56,7 @@ export const receiveCustomerDetails = (json) => ({ export const fetchCartCount = () => { return dispatch => { +<<<<<<< HEAD dispatch(requestShopCartCount()); //TODO : fetch cart count from woocommerce (requires plugin) dispatch(receiveShopCartCount(0)); @@ -68,6 +69,17 @@ export const fetchCartCount = () => { client.onError(error, dispatch); }); */ +======= + // TODO Fetch correct cart count after adding support to cart on API + // dispatch(requestShopCartCount()); + // return client.fetch({url: `${API_SERVER}/cart/api/getCartCount`}).then(response => { + // if (typeof response.data !== 'undefined' && 'cartItemsCount' in response.data) { + dispatch(receiveShopCartCount(0)); + // } + // }).catch(error => { + // client.onError(error, dispatch); + // }); +>>>>>>> 6e0c26d... Connected and enabled co-maket } } diff --git a/frontend/src/actions/coMarket/coMarketPackagesActions.js b/frontend/src/actions/coMarket/coMarketPackagesActions.js index 343e030..ec55aee 100644 --- a/frontend/src/actions/coMarket/coMarketPackagesActions.js +++ b/frontend/src/actions/coMarket/coMarketPackagesActions.js @@ -24,17 +24,20 @@ const recieveShopPackages = (json) => ({ export const fetchShopPackages = (cl, search) => { return dispatch => { dispatch(requestShopPackages()); + let searchParam = search ? '?search=' +search : '' return client.fetch({ - url: `${API_SERVER}/coMarket/api/getShopPackages`, - method: 'post', - data: { - idCommercialLead: (cl && cl.value) || 0, - search - } - }) + url: `${API_SERVER}/wp-json/wc/v2/products` + searchParam, + // TODO: Add comercialLead parameter after the support for it is added on backend + + // method: 'post', + // data: { + // idCommercialLead: (cl && cl.value) || 0, + // search + // } + }) .then(response => { - if(response.data && response.data.packages){ - dispatch(recieveShopPackages(response.data.packages)) + if (response.data) { + dispatch(recieveShopPackages(response.data)) } }) .catch(error => { @@ -63,22 +66,23 @@ const generateClOptions = (commercialLeads) => { export const fetchShopCommercialLeads = () => { return dispatch => { dispatch(requestShopCommercialLeads()); - return client.fetch({url: `${API_SERVER}/coMarket/api/getAllCommercialLeads`}) - .then(response => { - if(response.data && response.data.commercialLeads){ - const clOptions = generateClOptions(response.data.commercialLeads); - dispatch(recieveShopCommercialLeads(clOptions)); - if (clOptions.length) { - dispatch(selectCommercialLead(clOptions[0])); - dispatch(fetchShopPackages(clOptions[0])); - } - } - }) - .catch(error => { - client.onError(error, dispatch); - }); + // TODO: FetchcomercialLead after the support for it is added on backend + // return client.fetch({url: `${API_SERVER}/coMarket/api/getAllCommercialLeads`}) + // .then(response => { + // if(response.data && response.data.commercialLeads){ + const clOptions = generateClOptions([{ "idCommercialLead": 14, "commercialLeadName": "Coor Service Management", "mail": "rikard@co-ideation.com" }]); + dispatch(recieveShopCommercialLeads(clOptions)); + if (clOptions.length) { + dispatch(selectCommercialLead(clOptions[0])); + dispatch(fetchShopPackages(clOptions[0])); + } } + // }) + // .catch(error => { + // client.onError(error, dispatch); + // }); } +// } export const selectCommercialLead = (cl) => ({ type: SELECT_SHOP_COMMERCIAL_LEAD, diff --git a/frontend/src/actions/login/authActions.js b/frontend/src/actions/login/authActions.js index fc2a41d..f3e8dab 100644 --- a/frontend/src/actions/login/authActions.js +++ b/frontend/src/actions/login/authActions.js @@ -62,6 +62,7 @@ export const validateAccessToken = (token) => { }) .catch(error => { + localStorage.removeItem('accessToken'); htmlClient.onError(error, dispatch); }); } @@ -161,6 +162,7 @@ const validateRefreshToken = () => { export const getModules = () => { return dispatch => { dispatch(requestModules()); +<<<<<<< HEAD //TODO : check how to solve modules, don't hardocde values const modules={ modules:{ @@ -233,6 +235,77 @@ export const getModules = () => { htmlClient.onError(error, dispatch); }); */ +======= + let appModules = { + modules: { + modules: [ + { + id: '15', + name: 'Terms', + menuName: 'Terms', + url: 'terms', + isInMenu: '0' + }, + { + id: '19', + name: 'Cart', + menuName: 'Cart', + url: 'cart', + isInMenu: '0' + }, + { + id: '14', + name: 'ProfileSettings', + menuName: 'ProfileSettings', + url: 'profileSettings', + isInMenu: '0' + }, + { + id: '23', + name: 'OrderProjects', + menuName: 'OrderProjects', + url: 'orderProjects', + isInMenu: '0' + }, + { + id: '1', + name: 'Dashboards', + menuName: 'Overview', + url: 'dashboards', + isInMenu: '1' + }, + { + id: '18', + name: 'CoMarket', + menuName: 'Co-Market', + url: 'co-market', + isInMenu: '1' + } + ], + subModules: { + 'co-market': [ + { + moduleUrl: 'co-market', + menuName: 'Orders', + name: 'Orders', + url: 'orders' + } + ] + } + } + } + return dispatch(recieveModules(appModules)); + // return htmlClient.fetch({ + // url: `${API_SERVER}/login/api/getModules`, + // }) + // .then(response => { + // dispatch(recieveModules(response.data)); + // }) + // .catch(error => { + // htmlClient.onError(error, dispatch); + // }); + // return {activeModule : ""} +>>>>>>> 6e0c26d... Connected and enabled co-maket } } diff --git a/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx b/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx index 76c05ee..eedc0b8 100644 --- a/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx +++ b/frontend/src/containers/coMarket/CoMarketPackagesContainer.jsx @@ -40,13 +40,13 @@ class CoMarketPackagesContainer extends Component { } { (shopPackages && !isLoading) && - shopPackages.map((shopPackage, mapKey) => ) } - + a ); diff --git a/frontend/src/containers/coMarket/components/ShopItem.jsx b/frontend/src/containers/coMarket/components/ShopItem.jsx index d277f9c..5f74f39 100644 --- a/frontend/src/containers/coMarket/components/ShopItem.jsx +++ b/frontend/src/containers/coMarket/components/ShopItem.jsx @@ -14,10 +14,10 @@ class ShopItem extends Component { return ( -
+
- + {this.getShopItemPackageTitle(shopPackage.name)} @@ -30,7 +30,7 @@ class ShopItem extends Component {
- +