diff --git a/backend.dockerfile b/backend.dockerfile index 177094a..285710c 100644 --- a/backend.dockerfile +++ b/backend.dockerfile @@ -65,4 +65,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/.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 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/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/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/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/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 +} diff --git a/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-rest-delivery-process-api.php b/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-rest-delivery-process-api.php index 72a0976..c2cf204 100644 --- a/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-rest-delivery-process-api.php +++ b/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-rest-delivery-process-api.php @@ -42,14 +42,14 @@ class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case { $this->assertTrue(is_array($pending_step)); - $this->assertArrayHasKey('idOrder', $pending_step); - $this->assertArrayHasKey('orderNumber', $pending_step); + $this->assertArrayHasKey('order_id', $pending_step); + $this->assertArrayHasKey('order_number', $pending_step); $this->assertArrayHasKey('status', $pending_step); - $this->assertArrayHasKey('stepAction', $pending_step); + $this->assertArrayHasKey('step_action', $pending_step); - $this->assertEquals($pending_step['idOrder'], $this->order_id); - $this->assertEquals($pending_step['orderNumber'], $this->order_id); + $this->assertEquals($pending_step['order_id'], $this->order_id); + $this->assertEquals($pending_step['order_number'], $this->order_id); $this->assertEquals($pending_step['status'], 'pending'); - $this->assertNotEmpty($pending_step['stepAction']); + $this->assertNotEmpty($pending_step['step_action']); } } diff --git a/backend/composer.json b/backend/composer.json index 5900c23..58f623a 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,6 +76,7 @@ "wp plugin activate jwt-authentication-for-wp-rest-api", "wp plugin activate gravityforms", "wp plugin activate gravityflow", + "wp plugin activate capability-manager-enhanced", "wp plugin activate wiaas" ], "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", 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'; 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 @@ - ({ 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..cfaff25 100644 --- a/frontend/src/actions/dashboard/nextActionsActions.js +++ b/frontend/src/actions/dashboard/nextActionsActions.js @@ -1,6 +1,7 @@ -import {API_SERVER} from '../../config'; -import HtmlClient from '../../helpers/HtmlClient'; 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 = () => ({ @@ -18,11 +19,11 @@ export const fetchNextActions = () => { return dispatch => { dispatch(requestNextActions()); 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); - }); + }); } } diff --git a/frontend/src/actions/dashboard/ordersActions.js b/frontend/src/actions/dashboard/ordersActions.js index d4a1371..c7245a5 100644 --- a/frontend/src/actions/dashboard/ordersActions.js +++ b/frontend/src/actions/dashboard/ordersActions.js @@ -4,6 +4,8 @@ import { REQUEST_ORDERS, RECEIVE_ORDERS } from '../../constants/dashboardConstants'; +import {fromWCOrder} from '../../helpers/OrderHelper'; +import { MAX_ORDER_COUNT } from '../../constants/ordersConstants'; const htmlClient = new HtmlClient(); export const requestOrders = () => ({ @@ -21,13 +23,12 @@ 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?per_page=${MAX_ORDER_COUNT}`, + method: 'get', + }) + .then(response => { + dispatch(recieveOrders(response.data.map(wcOrder => fromWCOrder(wcOrder)))); }) - .then(response => dispatch(recieveOrders(response.data))) .catch(error => { htmlClient.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); }); + */ } } 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} 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!', 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/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; 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; } } 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 {