From e3765f7b09131d745e192d2d7771e7f939c50e30 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 26 Jul 2018 15:34:02 +0200 Subject: [PATCH 01/19] improve environment handling --- environment.env | 2 +- frontend/src/constants/authConstants.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment.env b/environment.env index 0b2a9cb..c459f64 100644 --- a/environment.env +++ b/environment.env @@ -24,4 +24,4 @@ WP_SECURE_AUTH_SALT=generate_me WP_LOGGED_IN_SALT=generate_me WP_NONCE_SALT=generate_me -WP_JWT_AUTH_SECRET_KEY=generate_me \ No newline at end of file +WP_JWT_AUTH_SECRET_KEY=generate_me diff --git a/frontend/src/constants/authConstants.js b/frontend/src/constants/authConstants.js index d70bd8f..f02b48a 100644 --- a/frontend/src/constants/authConstants.js +++ b/frontend/src/constants/authConstants.js @@ -1,4 +1,4 @@ -import {API_SERVER_BASE} from '../config.js'; +import {API_SERVER_LOGIN} from '../config.js'; const MODULE = 'AUTH_'; @@ -36,7 +36,7 @@ export const loginMessages = { CHANGE_LATER: 'You can change your password in 5 minutes!', INVALID_REFRESH_TOKEN: 'Your session has expired!', EXPIRED_SESSION : 'Your session has expired!', - INVALID_USER_TYPE: 'Users with other roles than "customer" must use this url for login: ' + API_SERVER_BASE, + INVALID_USER_TYPE: 'Users with other roles than "customer" must use this url for login: ' + API_SERVER_LOGIN, INVALID_CHANGE_TOKEN: 'Invalid change token value!', PASSWORDS_MISSING: 'Password can not be empty', WRONG_USERNAME: 'Invalid username!', From 688cb1ad594e257502a001e481bd6c5579c32e45 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 26 Jul 2018 19:30:32 +0200 Subject: [PATCH 02/19] add htaccess --- backend/.htaccess | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 backend/.htaccess diff --git a/backend/.htaccess b/backend/.htaccess new file mode 100644 index 0000000..9308912 --- /dev/null +++ b/backend/.htaccess @@ -0,0 +1,13 @@ +# BEGIN WordPress + +RewriteEngine On +RewriteBase / +RewriteRule ^index\.php$ - [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . /index.php [L] +RewriteCond %{HTTP:Authorization} ^(.*) +RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1] + +SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 +# END WordPress From 09a2be6be8b4071404c44acbd4bb23dab24c9658 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 26 Jul 2018 19:55:40 +0200 Subject: [PATCH 03/19] environment fix --- backend.dockerfile | 14 +++++++++++++- backend/wp-config.php | 18 +++++++++--------- environment.env => dev.env | 0 frontend.dockerfile | 1 + 4 files changed, 23 insertions(+), 10 deletions(-) rename environment.env => dev.env (100%) diff --git a/backend.dockerfile b/backend.dockerfile index 177094a..54603c8 100644 --- a/backend.dockerfile +++ b/backend.dockerfile @@ -1,5 +1,6 @@ FROM php:7.0-apache +<<<<<<< HEAD ARG API_URL ARG MYSQL_DATABASE @@ -45,6 +46,17 @@ RUN chmod +x /usr/local/bin/wp COPY docker/php/setup.sh /init-scripts/ RUN chmod +x /init-scripts/setup.sh +======= +ARG WP_DB_NAME +ARG WP_DB_USER +ARG WP_DB_PASSWORD +ARG WP_DB_HOST + +ENV WP_DB_NAME=${WP_DB_NAME} \ + WP_DB_USER=${WP_DB_USER} \ + WP_DB_PASSWORD=${WP_DB_PASSWORD} \ + WP_DB_HOST=${WP_DB_HOST} +>>>>>>> environment fix RUN docker-php-ext-install pdo pdo_mysql mysqli RUN a2enmod rewrite ssl @@ -65,4 +77,4 @@ COPY docker/php/.htaccess /var/www/html/ RUN chown -R www-data:www-data /var/www/html -CMD /init-scripts/setup.sh \ No newline at end of file +CMD /init-scripts/setup.sh diff --git a/backend/wp-config.php b/backend/wp-config.php index e557ed4..5e5ec6b 100644 --- a/backend/wp-config.php +++ b/backend/wp-config.php @@ -1,9 +1,9 @@ - Date: Sun, 29 Jul 2018 02:28:44 +0200 Subject: [PATCH 04/19] override missing modules using hardcoded values --- frontend/src/actions/cart/cartActions.js | 4 ++ .../src/actions/dashboard/dashboardActions.js | 17 ++++- .../actions/dashboard/nextActionsActions.js | 7 ++- frontend/src/actions/login/authActions.js | 63 +++++++++++++++++++ 4 files changed, 85 insertions(+), 6 deletions(-) diff --git a/frontend/src/actions/cart/cartActions.js b/frontend/src/actions/cart/cartActions.js index 8005745..6f071db 100644 --- a/frontend/src/actions/cart/cartActions.js +++ b/frontend/src/actions/cart/cartActions.js @@ -57,6 +57,9 @@ export const receiveCustomerDetails = (json) => ({ export const fetchCartCount = () => { return dispatch => { dispatch(requestShopCartCount()); + //TODO : fetch cart count from woocommerce (requires plugin) + dispatch(receiveShopCartCount(0)); + /* return client.fetch({url: `${API_SERVER}/cart/api/getCartCount`}).then(response => { if (typeof response.data !== 'undefined' && 'cartItemsCount' in response.data) { dispatch(receiveShopCartCount(response.data.cartItemsCount)); @@ -64,6 +67,7 @@ export const fetchCartCount = () => { }).catch(error => { client.onError(error, dispatch); }); + */ } } diff --git a/frontend/src/actions/dashboard/dashboardActions.js b/frontend/src/actions/dashboard/dashboardActions.js index 14aaad5..18330a4 100644 --- a/frontend/src/actions/dashboard/dashboardActions.js +++ b/frontend/src/actions/dashboard/dashboardActions.js @@ -1,7 +1,4 @@ -import {API_SERVER} from '../../config'; -import HtmlClient from '../../helpers/HtmlClient'; import {REQUEST_GADGETS, RECIEVE_GADGETS} from '../../constants/dashboardConstants'; -const htmlClient = new HtmlClient(); const requestGadgets = () => ({type: REQUEST_GADGETS}); const recieveGadgets = (json) => ({ @@ -12,6 +9,19 @@ const recieveGadgets = (json) => ({ export const fetchGadgets = () => { return dispatch => { dispatch(requestGadgets()); + //TODO : check how to solve gadgets, don't use hardcoded values + const gadgets = [ + { + name: 'CustomerOrderCentral', + idGadget: 0, + }, + { + name: 'CustomerNextActions', + idGadget: 1, + } + ] + dispatch(recieveGadgets(gadgets)); + /* return htmlClient.fetch({ url: `${API_SERVER}/dashboards/api/getMyDashboard` }) @@ -23,5 +33,6 @@ export const fetchGadgets = () => { .catch(error => { htmlClient.onError(error, dispatch); }); + */ } } diff --git a/frontend/src/actions/dashboard/nextActionsActions.js b/frontend/src/actions/dashboard/nextActionsActions.js index 5716e97..ad9960f 100644 --- a/frontend/src/actions/dashboard/nextActionsActions.js +++ b/frontend/src/actions/dashboard/nextActionsActions.js @@ -1,7 +1,4 @@ -import {API_SERVER} from '../../config'; -import HtmlClient from '../../helpers/HtmlClient'; import {REQUEST_NEXT_ACTIONS, RECIEVE_NEXT_ACTIONS} from '../../constants/dashboardConstants'; -const client = new HtmlClient(); export const requestNextActions = () => ({ type: REQUEST_NEXT_ACTIONS, @@ -17,6 +14,9 @@ export const recieveNextActions = (json) => ({ export const fetchNextActions = () => { return dispatch => { dispatch(requestNextActions()); + //TODO : fetch next actions from gravity flow api + dispatch(recieveNextActions({})); + /* return client.fetch({ url: `${API_SERVER}/dashboards/api/getNextActionsInfo` }) @@ -24,5 +24,6 @@ export const fetchNextActions = () => { .catch(error => { client.onError(error, dispatch); }); + */ } } diff --git a/frontend/src/actions/login/authActions.js b/frontend/src/actions/login/authActions.js index 18867ad..fc2a41d 100644 --- a/frontend/src/actions/login/authActions.js +++ b/frontend/src/actions/login/authActions.js @@ -161,6 +161,68 @@ const validateRefreshToken = () => { export const getModules = () => { return dispatch => { dispatch(requestModules()); + //TODO : check how to solve modules, don't hardocde values + const modules={ + modules:{ + modules:[ + { + id:"19", + isInMenu:"0", + menuName:"Cart", + name:"Cart", + url:"cart", + + }, + { + id:"14", + isInMenu:"0", + menuName:"ProfileSettings", + name:"ProfileSettings", + url:"profileSettings", + }, + { + id:"23", + isInMenu:"0", + menuName:"OrderProjects", + name:"OrderProjects", + url:"orderProjects", + }, + { + id:"15", + isInMenu:"0", + menuName:"Terms", + name:"Terms", + url:"terms", + }, + { + id:"1", + isInMenu:"1", + menuName:"Overview", + name:"Dashboards", + url:"dashboards", + }, + { + id:"18", + isInMenu:"1", + menuName:"Co-Market", + name:"CoMarket", + url:"co-market", + } + ], + subModules:{ + "co-market":[ + { + menuName:"Orders", + name:"Orders", + url:"orders", + moduleUrl:"co-market", + } + ] + } + } + } + dispatch(recieveModules(modules)); + /* return htmlClient.fetch({ url: `${API_SERVER}/login/api/getModules`, }) @@ -170,6 +232,7 @@ export const getModules = () => { .catch(error => { htmlClient.onError(error, dispatch); }); + */ } } From 9d24fd86492f3315db028e22aeb49a3dc544ede0 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Sun, 29 Jul 2018 02:41:22 +0200 Subject: [PATCH 05/19] create adapter for orders object and use it to accomodate for displaying --- .../src/actions/dashboard/ordersActions.js | 14 ++++++---- frontend/src/helpers/SaburlyAdapter.js | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 frontend/src/helpers/SaburlyAdapter.js diff --git a/frontend/src/actions/dashboard/ordersActions.js b/frontend/src/actions/dashboard/ordersActions.js index d4a1371..15d3592 100644 --- a/frontend/src/actions/dashboard/ordersActions.js +++ b/frontend/src/actions/dashboard/ordersActions.js @@ -4,7 +4,9 @@ import { REQUEST_ORDERS, RECEIVE_ORDERS } from '../../constants/dashboardConstants'; +import SaburlyAdapter from '../../helpers/SaburlyAdapter'; const htmlClient = new HtmlClient(); +const saburlyAdapter = new SaburlyAdapter(); export const requestOrders = () => ({ type: REQUEST_ORDERS, @@ -21,13 +23,13 @@ export const fetchOrders = (viewAllOrders) => { return dispatch => { dispatch(requestOrders()); return htmlClient.fetch({ - url: `${API_SERVER}/dashboards/api/getOrderCentralInfo`, - method: 'post', - data: { - viewAllOrders - } + url: `${API_SERVER}/wp-json/wc/v2/orders`, + method: 'get' + }) + .then(response => { + const transformedOrdersArray = saburlyAdapter.transformOrdersArray(response.data); + dispatch(recieveOrders(transformedOrdersArray)); }) - .then(response => dispatch(recieveOrders(response.data))) .catch(error => { htmlClient.onError(error, dispatch); }); diff --git a/frontend/src/helpers/SaburlyAdapter.js b/frontend/src/helpers/SaburlyAdapter.js new file mode 100644 index 0000000..e1a0d13 --- /dev/null +++ b/frontend/src/helpers/SaburlyAdapter.js @@ -0,0 +1,28 @@ +import moment from 'moment'; + +const transformOrderInArray = (order) => { + let newOrderObject = { + idOrder: order.id, + orderNumber: order.number, + orderDate: moment(order.date_created).format("Do MMM, YYYY"), + reference: 'reference field', + assignedTo: 'assigned to', + fixedPrice: order.total, + recurringPrice: 0, + status: order.status, + currency: order.currency + } + return newOrderObject; +} + +class SaburlyAdapter { + + transformOrdersArray(orders) { + return orders.map(order => { + return transformOrderInArray(order); + }); + }; + +} + +export default SaburlyAdapter; \ No newline at end of file From a35fd40e3a707c10951bef7b1645be6b0da5faba Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 2 Aug 2018 14:28:42 +0200 Subject: [PATCH 06/19] fix docker file --- backend.dockerfile | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/backend.dockerfile b/backend.dockerfile index 54603c8..285710c 100644 --- a/backend.dockerfile +++ b/backend.dockerfile @@ -1,6 +1,5 @@ FROM php:7.0-apache -<<<<<<< HEAD ARG API_URL ARG MYSQL_DATABASE @@ -46,17 +45,6 @@ RUN chmod +x /usr/local/bin/wp COPY docker/php/setup.sh /init-scripts/ RUN chmod +x /init-scripts/setup.sh -======= -ARG WP_DB_NAME -ARG WP_DB_USER -ARG WP_DB_PASSWORD -ARG WP_DB_HOST - -ENV WP_DB_NAME=${WP_DB_NAME} \ - WP_DB_USER=${WP_DB_USER} \ - WP_DB_PASSWORD=${WP_DB_PASSWORD} \ - WP_DB_HOST=${WP_DB_HOST} ->>>>>>> environment fix RUN docker-php-ext-install pdo pdo_mysql mysqli RUN a2enmod rewrite ssl From dcbb47425fe57418f9446e3805fd4419d4a4c39c Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 2 Aug 2018 14:29:28 +0200 Subject: [PATCH 07/19] include wiaas plugin for fetching delivery steps --- .../app/plugins/wiaas/includes/class-wiaas-delivery-process.php | 2 +- .../delivery-process/class-wiaas-delivery-process-step.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php index 7c4c9e3..c3a526c 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-delivery-process.php @@ -159,4 +159,4 @@ class Wiaas_Delivery_Process { } } -add_action( 'gravityflow_loaded', array('Wiaas_Delivery_Process', 'init') ); \ No newline at end of file +add_action( 'gravityflow_loaded', array('Wiaas_Delivery_Process', 'init') ); diff --git a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php index ce887a1..e4497c7 100644 --- a/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php +++ b/backend/app/plugins/wiaas/includes/delivery-process/class-wiaas-delivery-process-step.php @@ -246,4 +246,4 @@ class Wiaas_Delivery_Process_Step extends Gravity_Flow_Step { return absint($value); } -} \ No newline at end of file +} From ce9f0799ed2aedc0526b4f0d0e424598a1dab374 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 2 Aug 2018 14:31:03 +0200 Subject: [PATCH 08/19] stop forcing https locally --- backend/config/application.php | 10 ---------- backend/config/environments/production.php | 10 ++++++++++ backend/config/environments/staging.php | 10 ++++++++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/backend/config/application.php b/backend/config/application.php index 3903cf3..e12625e 100644 --- a/backend/config/application.php +++ b/backend/config/application.php @@ -23,16 +23,6 @@ if (file_exists($env_config)) { require_once $env_config; } -/** - * Stops redirect loop on login page - */ -define('FORCE_SSL_ADMIN', true); -// in some setups HTTP_X_FORWARDED_PROTO might contain -// a comma-separated list e.g. http,https -// so check for https existence -if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) - $_SERVER['HTTPS']='on'; - /** * URLs */ diff --git a/backend/config/environments/production.php b/backend/config/environments/production.php index 162c71c..5c39f79 100644 --- a/backend/config/environments/production.php +++ b/backend/config/environments/production.php @@ -5,3 +5,13 @@ define('WP_DEBUG_DISPLAY', false); define('SCRIPT_DEBUG', false); /** Disable all file modifications including updates and update notifications */ define('DISALLOW_FILE_MODS', true); + +/** + * Stops redirect loop on login page + */ +define('FORCE_SSL_ADMIN', true); +// in some setups HTTP_X_FORWARDED_PROTO might contain +// a comma-separated list e.g. http,https +// so check for https existence +if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) + $_SERVER['HTTPS']='on'; \ No newline at end of file diff --git a/backend/config/environments/staging.php b/backend/config/environments/staging.php index 528be4a..55fa1c7 100644 --- a/backend/config/environments/staging.php +++ b/backend/config/environments/staging.php @@ -5,3 +5,13 @@ define('WP_DEBUG_DISPLAY', false); define('SCRIPT_DEBUG', false); /** Disable all file modifications including updates and update notifications */ define('DISALLOW_FILE_MODS', true); + +/** + * Stops redirect loop on login page + */ +define('FORCE_SSL_ADMIN', true); +// in some setups HTTP_X_FORWARDED_PROTO might contain +// a comma-separated list e.g. http,https +// so check for https existence +if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) + $_SERVER['HTTPS']='on'; From ce7e864c1d52cd535ec09150603ffc4ccc85e86e Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 2 Aug 2018 14:31:59 +0200 Subject: [PATCH 09/19] add missing variable to config --- frontend/src/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/config.js b/frontend/src/config.js index 3bca27e..efbfbe8 100644 --- a/frontend/src/config.js +++ b/frontend/src/config.js @@ -3,5 +3,6 @@ const API_VERSION = 'v2'; const API_SERVER_BASE = process.env.REACT_APP_API_URL; const API_SERVER = API_SERVER_BASE; +const API_SERVER_LOGIN = API_SERVER + "/wp-admin"; -export {API_SERVER_BASE, API_SERVER, APPLICATION_NAME} +export {API_SERVER_BASE, API_SERVER, APPLICATION_NAME, API_SERVER_LOGIN} From 5ceb376f8f5730ab254732babb9bde26cab6b03f Mon Sep 17 00:00:00 2001 From: GotPPay Date: Thu, 2 Aug 2018 14:32:15 +0200 Subject: [PATCH 10/19] fetch next actions from wiaas plugin --- frontend/src/actions/dashboard/nextActionsActions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/actions/dashboard/nextActionsActions.js b/frontend/src/actions/dashboard/nextActionsActions.js index ad9960f..cfaff25 100644 --- a/frontend/src/actions/dashboard/nextActionsActions.js +++ b/frontend/src/actions/dashboard/nextActionsActions.js @@ -1,4 +1,8 @@ import {REQUEST_NEXT_ACTIONS, RECIEVE_NEXT_ACTIONS} from '../../constants/dashboardConstants'; +import { API_SERVER } from '../../config'; +import HtmlClient from '../../helpers/HtmlClient'; + +const client = new HtmlClient(); export const requestNextActions = () => ({ type: REQUEST_NEXT_ACTIONS, @@ -14,16 +18,12 @@ export const recieveNextActions = (json) => ({ export const fetchNextActions = () => { return dispatch => { dispatch(requestNextActions()); - //TODO : fetch next actions from gravity flow api - dispatch(recieveNextActions({})); - /* return client.fetch({ - url: `${API_SERVER}/dashboards/api/getNextActionsInfo` + url: `${API_SERVER}/wp-json/wiaas/next-delivery-steps` }) .then(response => dispatch(recieveNextActions(response.data))) .catch(error => { client.onError(error, dispatch); - }); - */ + }); } } From 7725556f38ffa944ac844403bad6ccb561c7052b Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 7 Aug 2018 13:55:59 +0200 Subject: [PATCH 11/19] enhance customer role capability --- .../wiaas/includes/class-wiaas-db-update.php | 3 ++- .../db-updates/wiaas-db-update-functions.php | 7 ++++++ backend/composer.json | 4 +++- backend/composer.lock | 24 +++++++++++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php index 4f54fe4..bc89b8c 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-db-update.php @@ -7,7 +7,8 @@ class Wiaas_DB_Update { private static $db_updates = array( '20180728222206' => 'wiaas_db_update_enable_product_by_user_role', '20180801222206' => 'wiaas_db_update_setup_gravity', - '20180802222206' => 'wiaas_db_update_add_delivery_process_forms' + '20180802222206' => 'wiaas_db_update_add_delivery_process_forms', + '20180807222206' => 'wiaas_db_update_setup_customer_capabilities' ); public static function execute() { diff --git a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-functions.php b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-functions.php index c537822..5f0fca2 100644 --- a/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-functions.php +++ b/backend/app/plugins/wiaas/includes/db-updates/wiaas-db-update-functions.php @@ -76,4 +76,11 @@ function wiaas_db_update_add_delivery_process_forms() { } do_action('gform_forms_post_import', $created_forms); +} + +function wiaas_db_update_setup_customer_capabilities() { + $customer_role = get_role('customer'); + + $customer_role->add_cap('read_private_shop_orders'); + $customer_role->add_cap('read_shop_order'); } \ No newline at end of file diff --git a/backend/composer.json b/backend/composer.json index 5900c23..72fff13 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -47,6 +47,7 @@ "wpackagist-plugin/mailchimp-for-woocommerce": "2.1.7", "wpackagist-plugin/woocommerce-gateway-paypal-express-checkout": "1.5.6", "wpackagist-plugin/jwt-authentication-for-wp-rest-api": "1.2.4", + "wpackagist-plugin/capability-manager-enhanced": "1.5.9", "3rdparty/gravityforms": "*", "3rdparty/gravityflow": "*" @@ -75,7 +76,8 @@ "wp plugin activate jwt-authentication-for-wp-rest-api", "wp plugin activate gravityforms", "wp plugin activate gravityflow", - "wp plugin activate wiaas" + "wp plugin activate wiaas", + "wp plugin activate capability-manager-enhanced" ], "update-db": [ "wp core update-db", diff --git a/backend/composer.lock b/backend/composer.lock index cda3cd2..3273dd6 100644 --- a/backend/composer.lock +++ b/backend/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "16aac868dbf84d6c3cf7c41703e9085f", + "content-hash": "dca54e67b0185da192f5260baa4c162e", "packages": [ { "name": "3rdparty/gravityflow", @@ -437,6 +437,26 @@ "type": "wordpress-plugin", "homepage": "https://wordpress.org/plugins/akismet/" }, + { + "name": "wpackagist-plugin/capability-manager-enhanced", + "version": "1.5.9", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/capability-manager-enhanced/", + "reference": "trunk" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/capability-manager-enhanced.zip?timestamp=1532180189", + "reference": null, + "shasum": null + }, + "require": { + "composer/installers": "~1.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/capability-manager-enhanced/" + }, { "name": "wpackagist-plugin/groups", "version": "2.3.1", From 5a0664940633015a4f981bcc9f852fd97e48c6c9 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 7 Aug 2018 14:13:58 +0200 Subject: [PATCH 12/19] limit number of orders --- frontend/src/actions/dashboard/ordersActions.js | 5 +++-- frontend/src/constants/ordersConstants.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/actions/dashboard/ordersActions.js b/frontend/src/actions/dashboard/ordersActions.js index 15d3592..c9315c1 100644 --- a/frontend/src/actions/dashboard/ordersActions.js +++ b/frontend/src/actions/dashboard/ordersActions.js @@ -5,6 +5,7 @@ import { RECEIVE_ORDERS } from '../../constants/dashboardConstants'; import SaburlyAdapter from '../../helpers/SaburlyAdapter'; +import { MAX_ORDER_COUNT } from '../../constants/ordersConstants'; const htmlClient = new HtmlClient(); const saburlyAdapter = new SaburlyAdapter(); @@ -23,8 +24,8 @@ export const fetchOrders = (viewAllOrders) => { return dispatch => { dispatch(requestOrders()); return htmlClient.fetch({ - url: `${API_SERVER}/wp-json/wc/v2/orders`, - method: 'get' + url: `${API_SERVER}/wp-json/wc/v2/orders?per_page=${MAX_ORDER_COUNT}`, + method: 'get', }) .then(response => { const transformedOrdersArray = saburlyAdapter.transformOrdersArray(response.data); diff --git a/frontend/src/constants/ordersConstants.js b/frontend/src/constants/ordersConstants.js index 6b1f69d..91a2e42 100644 --- a/frontend/src/constants/ordersConstants.js +++ b/frontend/src/constants/ordersConstants.js @@ -207,3 +207,5 @@ export const orderTexts = { PLACED_BY: 'Placed by' } }; + +export const MAX_ORDER_COUNT = 5; From a2022f3b078d443709aeaa7e44e2dcb9b77460e3 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 8 Aug 2018 14:15:57 +0200 Subject: [PATCH 13/19] change order of plugins activation --- backend/composer.json | 4 ++-- dev.env => environment.env | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename dev.env => environment.env (100%) diff --git a/backend/composer.json b/backend/composer.json index 72fff13..58f623a 100644 --- a/backend/composer.json +++ b/backend/composer.json @@ -76,8 +76,8 @@ "wp plugin activate jwt-authentication-for-wp-rest-api", "wp plugin activate gravityforms", "wp plugin activate gravityflow", - "wp plugin activate wiaas", - "wp plugin activate capability-manager-enhanced" + "wp plugin activate capability-manager-enhanced", + "wp plugin activate wiaas" ], "update-db": [ "wp core update-db", diff --git a/dev.env b/environment.env similarity index 100% rename from dev.env rename to environment.env From 375fcb80a7e24aa2b2cd2a50aa6b26650dcdba13 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 8 Aug 2018 16:46:14 +0200 Subject: [PATCH 14/19] change object properties to more readable ones --- .../class-wiaas-rest-delivery-process-api.php | 6 ++-- frontend/src/helpers/OrderHelper.js | 15 ++++++++++ frontend/src/helpers/SaburlyAdapter.js | 28 ------------------- 3 files changed, 18 insertions(+), 31 deletions(-) create mode 100644 frontend/src/helpers/OrderHelper.js delete mode 100644 frontend/src/helpers/SaburlyAdapter.js diff --git a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-delivery-process-api.php b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-delivery-process-api.php index 461a51d..5a8d493 100644 --- a/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-delivery-process-api.php +++ b/backend/app/plugins/wiaas/includes/api/class-wiaas-rest-delivery-process-api.php @@ -51,10 +51,10 @@ class Wiass_REST_Delivery_Process_API { foreach ($entries as $entry) { $step = gravity_flow()->get_step( $entry['workflow_step'] ); $data[] = array( - 'idOrder' => $entry['wiaas_delivery_order_id'], - 'orderNumber' => $entry['wiaas_delivery_order_id'], + 'order_id' => $entry['wiaas_delivery_order_id'], + 'order_number' => $entry['wiaas_delivery_order_id'], 'status' => $entry['workflow_final_status'], - 'stepAction' => $step->get_name(), + 'step_action' => $step->get_name(), ); } diff --git a/frontend/src/helpers/OrderHelper.js b/frontend/src/helpers/OrderHelper.js new file mode 100644 index 0000000..862c8ec --- /dev/null +++ b/frontend/src/helpers/OrderHelper.js @@ -0,0 +1,15 @@ +import moment from 'moment'; + +export const fromWCOrder = (order) => { + return { + id: order.id, + number: order.number, + dateCreated: moment(order.date_created).format("Do MMM, YYYY"), + reference: 'reference field', + assignedTo: 'assigned to', + fixedPrice: order.total, + recurringPrice: 0, + status: order.status, + currency: order.currency + } +} \ No newline at end of file diff --git a/frontend/src/helpers/SaburlyAdapter.js b/frontend/src/helpers/SaburlyAdapter.js deleted file mode 100644 index e1a0d13..0000000 --- a/frontend/src/helpers/SaburlyAdapter.js +++ /dev/null @@ -1,28 +0,0 @@ -import moment from 'moment'; - -const transformOrderInArray = (order) => { - let newOrderObject = { - idOrder: order.id, - orderNumber: order.number, - orderDate: moment(order.date_created).format("Do MMM, YYYY"), - reference: 'reference field', - assignedTo: 'assigned to', - fixedPrice: order.total, - recurringPrice: 0, - status: order.status, - currency: order.currency - } - return newOrderObject; -} - -class SaburlyAdapter { - - transformOrdersArray(orders) { - return orders.map(order => { - return transformOrderInArray(order); - }); - }; - -} - -export default SaburlyAdapter; \ No newline at end of file From 2a0726d256008681921c8a51a0c760bc185d5011 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 8 Aug 2018 16:46:59 +0200 Subject: [PATCH 15/19] apply changes from order helper --- frontend/src/actions/dashboard/ordersActions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/actions/dashboard/ordersActions.js b/frontend/src/actions/dashboard/ordersActions.js index c9315c1..856a655 100644 --- a/frontend/src/actions/dashboard/ordersActions.js +++ b/frontend/src/actions/dashboard/ordersActions.js @@ -4,10 +4,9 @@ import { REQUEST_ORDERS, RECEIVE_ORDERS } from '../../constants/dashboardConstants'; -import SaburlyAdapter from '../../helpers/SaburlyAdapter'; +import {fromWCOrder} from '../../helpers/OrderHelper'; import { MAX_ORDER_COUNT } from '../../constants/ordersConstants'; const htmlClient = new HtmlClient(); -const saburlyAdapter = new SaburlyAdapter(); export const requestOrders = () => ({ type: REQUEST_ORDERS, @@ -28,8 +27,10 @@ export const fetchOrders = (viewAllOrders) => { method: 'get', }) .then(response => { - const transformedOrdersArray = saburlyAdapter.transformOrdersArray(response.data); - dispatch(recieveOrders(transformedOrdersArray)); + const transformedFromWCOrders = response.data.map(order=>{ + return fromWCOrder(order); + }); + dispatch(recieveOrders(transformedFromWCOrders)); }) .catch(error => { htmlClient.onError(error, dispatch); From 0f515172feab04f3874207ae82b3b53a382879b7 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 8 Aug 2018 16:47:45 +0200 Subject: [PATCH 16/19] change statuses to adapt to woocommerce statuses --- frontend/src/constants/dashboardConstants.js | 6 +++--- frontend/src/containers/dashboard/NextActions.scss | 4 ++-- frontend/src/containers/dashboard/OrderCentral.scss | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/constants/dashboardConstants.js b/frontend/src/constants/dashboardConstants.js index 36fea0b..aaff788 100644 --- a/frontend/src/constants/dashboardConstants.js +++ b/frontend/src/constants/dashboardConstants.js @@ -30,10 +30,10 @@ export const dashboardTexts = { }, statuses: { open: 'Open', - 'in-progress': 'In Progress', - production: 'Production', + processing: 'In Progress', + completed: 'Production', 'end-of-life': 'End Of Life', - canceled: 'Canceled', + cancelled: 'Cancelled', 'not-accepted': 'Not Accepted', invalid: 'Invalid', pending: 'Pending' diff --git a/frontend/src/containers/dashboard/NextActions.scss b/frontend/src/containers/dashboard/NextActions.scss index f3c8ff4..16e4b70 100644 --- a/frontend/src/containers/dashboard/NextActions.scss +++ b/frontend/src/containers/dashboard/NextActions.scss @@ -36,8 +36,8 @@ background: $not-accepted-status-color; } - .in-progress { - background: $in-progress-status-color; + .processing { + background: $processing-status-color; } .next-action-details{ diff --git a/frontend/src/containers/dashboard/OrderCentral.scss b/frontend/src/containers/dashboard/OrderCentral.scss index d24da32..639d8c1 100644 --- a/frontend/src/containers/dashboard/OrderCentral.scss +++ b/frontend/src/containers/dashboard/OrderCentral.scss @@ -31,15 +31,15 @@ background: $open-status-color; } - .in-progress { - background: $in-progress-status-color; + .processing { + background: $processing-status-color; } .line-open { border-left: 3px $open-status-color solid; } - .line-in-progress { - border-left: 3px $in-progress-status-color solid; + .line-processing { + border-left: 3px $processing-status-color solid; } } From 190d139f5aa6b9e634967c701f197a551b4a24f6 Mon Sep 17 00:00:00 2001 From: GotPPay Date: Wed, 8 Aug 2018 16:48:17 +0200 Subject: [PATCH 17/19] use new names from order and process properties --- .../src/containers/dashboard/components/NextActionItem.jsx | 4 ++-- .../src/containers/dashboard/components/NextActionsList.jsx | 2 +- frontend/src/containers/dashboard/components/OrderItem.jsx | 6 +++--- frontend/src/containers/dashboard/components/OrdersList.jsx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/containers/dashboard/components/NextActionItem.jsx b/frontend/src/containers/dashboard/components/NextActionItem.jsx index f307a46..3d0a455 100644 --- a/frontend/src/containers/dashboard/components/NextActionItem.jsx +++ b/frontend/src/containers/dashboard/components/NextActionItem.jsx @@ -10,10 +10,10 @@ class NextActionItem extends Component { return ( - {nextAction.stepAction} + {nextAction.step_action} - +
{dashboardTexts.statuses[nextAction.status]}
diff --git a/frontend/src/containers/dashboard/components/NextActionsList.jsx b/frontend/src/containers/dashboard/components/NextActionsList.jsx index e5ed86b..7995a9a 100644 --- a/frontend/src/containers/dashboard/components/NextActionsList.jsx +++ b/frontend/src/containers/dashboard/components/NextActionsList.jsx @@ -14,7 +14,7 @@ class NextActionsList extends Component { { nextActions && nextActions.map((nextAction, index) => - + ) } diff --git a/frontend/src/containers/dashboard/components/OrderItem.jsx b/frontend/src/containers/dashboard/components/OrderItem.jsx index 072df85..5eed5f9 100644 --- a/frontend/src/containers/dashboard/components/OrderItem.jsx +++ b/frontend/src/containers/dashboard/components/OrderItem.jsx @@ -12,9 +12,9 @@ class OrderItem extends Component {