From fca35994c94dfac35f830f0166e61ab7c4ad08b9 Mon Sep 17 00:00:00 2001 From: Paul Kilmurray Date: Wed, 5 Jul 2023 13:33:38 +0100 Subject: [PATCH] update settings --- assets/img/wcpos-icon-b&w.svg | 11 + assets/img/wcpos-icon-transparent.svg | 26 + assets/img/wcpos-icon.svg | 57 +- assets/img/wp-menu-icon.svg | 17 + includes/API/Settings.php | 130 +- includes/Admin/Menu.php | 4 +- packages/analytics/package.json | 20 +- packages/eslint/package.json | 6 +- packages/settings/package.json | 20 +- packages/settings/src/components/combobox.tsx | 24 +- .../src/screens/checkout/gateways.tsx | 2 + .../screens/checkout/order-status-select.tsx | 33 +- .../src/screens/general/barcode-select.tsx | 15 +- templates/pos.php | 2 +- yarn.lock | 1156 ++++++++++------- 15 files changed, 947 insertions(+), 576 deletions(-) create mode 100644 assets/img/wcpos-icon-b&w.svg create mode 100644 assets/img/wcpos-icon-transparent.svg create mode 100644 assets/img/wp-menu-icon.svg diff --git a/assets/img/wcpos-icon-b&w.svg b/assets/img/wcpos-icon-b&w.svg new file mode 100644 index 0000000..05178f9 --- /dev/null +++ b/assets/img/wcpos-icon-b&w.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/assets/img/wcpos-icon-transparent.svg b/assets/img/wcpos-icon-transparent.svg new file mode 100644 index 0000000..08ec71a --- /dev/null +++ b/assets/img/wcpos-icon-transparent.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/assets/img/wcpos-icon.svg b/assets/img/wcpos-icon.svg index 8be5d4a..c21ef0f 100644 --- a/assets/img/wcpos-icon.svg +++ b/assets/img/wcpos-icon.svg @@ -1,44 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + diff --git a/assets/img/wp-menu-icon.svg b/assets/img/wp-menu-icon.svg new file mode 100644 index 0000000..a4dee02 --- /dev/null +++ b/assets/img/wp-menu-icon.svg @@ -0,0 +1,17 @@ + + + + + + diff --git a/includes/API/Settings.php b/includes/API/Settings.php index 95a89bd..b1e6221 100644 --- a/includes/API/Settings.php +++ b/includes/API/Settings.php @@ -5,6 +5,7 @@ use Closure; use WP_Error; use WP_REST_Request; +use WP_REST_Response; use WP_REST_Server; use function in_array; use function is_array; @@ -38,10 +39,10 @@ public function __construct() { /** * BACKWARD COMPATIBILITY: Remove this method in the future */ -// public function get_settings( $id ) { -// $settings = $this->settings_service->get_settings( $id ); -// return $settings; -// } + // public function get_settings( $id ) { + // $settings = $this->settings_service->get_settings( $id ); + // return $settings; + // } /** * @return void @@ -67,15 +68,15 @@ public function register_routes(): void { ) ); - register_rest_route( - $this->namespace, - '/' . $this->rest_base . '/general/barcodes', - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_barcodes' ), - 'permission_callback' => array( $this, 'read_permission_check' ), - ) - ); + // register_rest_route( + // $this->namespace, + // '/' . $this->rest_base . '/general/barcodes', + // array( + // 'methods' => WP_REST_Server::READABLE, + // 'callback' => array( $this, 'get_barcodes' ), + // 'permission_callback' => array( $this, 'read_permission_check' ), + // ) + // ); register_rest_route( $this->namespace, @@ -252,6 +253,105 @@ public function get_checkout_endpoint_args(): array { ); } + /** + * @param WP_REST_Request $request + * @return array|WP_REST_Response + */ + public function get_general_settings( WP_REST_Request $request ) { + $general_settings = $this->settings_service->get_general_settings(); + + if ( is_wp_error( $general_settings ) ) { + return $general_settings; + } + + // Create the response object + $response = new WP_REST_Response( $general_settings ); + + // Set the status code of the response + $response->set_status( 200 ); + + return $response; + } + + /** + * @param WP_REST_Request $request + * @return array|WP_REST_Response + */ + public function get_checkout_settings( WP_REST_Request $request ) { + $checkout_settings = $this->settings_service->get_checkout_settings(); + + if ( is_wp_error( $checkout_settings ) ) { + return $checkout_settings; + } + + // Create the response object + $response = new WP_REST_Response( $checkout_settings ); + + // Set the status code of the response + $response->set_status( 200 ); + + return $response; + } + + /** + * @param WP_REST_Request $request + * @return array|WP_REST_Response + */ + public function get_payment_gateways_settings( WP_REST_Request $request ) { + $payment_gateways_settings = $this->settings_service->get_payment_gateways_settings(); + + if ( is_wp_error( $payment_gateways_settings ) ) { + return $payment_gateways_settings; + } + + // Create the response object + $response = new WP_REST_Response( $payment_gateways_settings ); + + // Set the status code of the response + $response->set_status( 200 ); + + return $response; + } + + /** + * @param WP_REST_Request $request + * @return array|WP_REST_Response + */ + public function get_access_settings( WP_REST_Request $request ) { + $access_settings = $this->settings_service->get_access_settings(); + + if ( is_wp_error( $access_settings ) ) { + return $access_settings; + } + + // Create the response object + $response = new WP_REST_Response( $access_settings ); + + // Set the status code of the response + $response->set_status( 200 ); + + return $response; + } + + /** + * @param WP_REST_Request $request + * @return array|WP_REST_Response + */ + public function get_license_settings( WP_REST_Request $request ) { + $license_settings = $this->settings_service->get_license_settings(); + + if ( is_wp_error( $license_settings ) ) { + return $license_settings; + } + + // Create the response object + $response = new WP_REST_Response( $license_settings ); + + // Set the status code of the response + $response->set_status( 200 ); + + return $response; + } /** @@ -272,7 +372,7 @@ public function update_payment_gateways_settings( WP_REST_Request $request ) { * @return array|WP_Error */ public function update_general_settings( WP_REST_Request $request ) { - $settings = array_replace_recursive( $this->get_general_settings(), $request->get_json_params() ); + $settings = array_replace_recursive( $this->settings_service->get_general_settings(), $request->get_json_params() ); return $this->settings_service->save_settings( 'general', $settings ); } @@ -284,7 +384,7 @@ public function update_general_settings( WP_REST_Request $request ) { * @return array|WP_Error */ public function update_checkout_settings( WP_REST_Request $request ) { - $settings = array_replace_recursive( $this->get_checkout_settings(), $request->get_json_params() ); + $settings = array_replace_recursive( $this->settings_service->get_checkout_settings(), $request->get_json_params() ); return $this->settings_service->save_settings( 'checkout', $settings ); } diff --git a/includes/Admin/Menu.php b/includes/Admin/Menu.php index 8747bef..9ba858a 100644 --- a/includes/Admin/Menu.php +++ b/includes/Admin/Menu.php @@ -47,8 +47,8 @@ private function register_pos_admin() { 'manage_woocommerce_pos', PLUGIN_NAME, array( $this, 'display_upgrade_page' ), - 'data:image/svg+xml;base64,P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ZmlsbD0iI2E3YWFhZCIgY3g9IjYzMCIgY3k9IjY2MiIgcj0iOTYiLz4KPGNpcmNsZSBmaWxsPSIjYTdhYWFkIiBjeD0iMjYwLjUiIGN5PSI2NjIuNSIgcj0iOTUuNSIvPgo8L3N2Zz4K' + ); add_submenu_page( PLUGIN_NAME, diff --git a/packages/analytics/package.json b/packages/analytics/package.json index bb0a520..b4a47d5 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -6,8 +6,8 @@ }, "dependencies": { "@tanstack/react-query": "^4.29.19", - "@transifex/native": "^5.3.0", - "@transifex/react": "^5.3.0", + "@transifex/native": "^5.4.0", + "@transifex/react": "^5.4.0", "@woocommerce/components": "^12.0.0", "@wordpress/api-fetch": "6.33.0", "@wordpress/components": "^25.2.0", @@ -21,23 +21,23 @@ "react-error-boundary": "4.0.10" }, "devDependencies": { - "@babel/core": "7.22.5", - "@babel/plugin-transform-runtime": "7.22.5", - "@babel/preset-env": "7.22.5", + "@babel/core": "7.22.6", + "@babel/plugin-transform-runtime": "7.22.6", + "@babel/preset-env": "7.22.6", "@babel/preset-react": "7.22.5", "@babel/preset-typescript": "7.22.5", - "@babel/runtime": "7.22.5", + "@babel/runtime": "7.22.6", "@svgr/webpack": "8.0.1", "@tanstack/react-query-devtools": "^4.29.19", - "@transifex/cli": "^5.3.0", + "@transifex/cli": "^5.4.0", "@types/jest": "29.5.2", "@types/lodash": "4.14.195", "@types/react": "18.2.14", "@types/react-beautiful-dnd": "13.1.4", "@types/react-dom": "18.2.6", "@types/wordpress__components": "^23.0.1", - "@typescript-eslint/eslint-plugin": "5.60.1", - "@typescript-eslint/parser": "5.60.1", + "@typescript-eslint/eslint-plugin": "5.61.0", + "@typescript-eslint/parser": "5.61.0", "@wcpos/eslint-config": "*", "@wordpress/env": "8.2.0", "autoprefixer": "10.4.14", @@ -48,7 +48,7 @@ "fork-ts-checker-webpack-plugin": "8.0.0", "html-webpack-plugin": "5.5.3", "husky": "8.0.3", - "jest": "29.5.0", + "jest": "29.6.0", "jsdoc": "4.0.2", "mini-css-extract-plugin": "2.7.6", "node-sass": "9.0.0", diff --git a/packages/eslint/package.json b/packages/eslint/package.json index 5855621..c64259a 100644 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@rushstack/eslint-patch": "^1.3.2", - "@typescript-eslint/eslint-plugin": "^5.60.1", - "@typescript-eslint/parser": "5.60.1", + "@typescript-eslint/eslint-plugin": "^5.61.0", + "@typescript-eslint/parser": "5.61.0", "@wcpos/tsconfig": "*", - "eslint": "8.43.0", + "eslint": "8.44.0", "eslint-config-airbnb": "19.0.4", "eslint-config-prettier": "8.8.0", "eslint-config-universe": "^11.3.0", diff --git a/packages/settings/package.json b/packages/settings/package.json index 14412f3..2d84a88 100644 --- a/packages/settings/package.json +++ b/packages/settings/package.json @@ -8,8 +8,8 @@ "@headlessui/react": "^1.7.15", "@headlessui/tailwindcss": "^0.1.3", "@tanstack/react-query": "^4.29.19", - "@transifex/native": "^5.3.0", - "@transifex/react": "^5.3.0", + "@transifex/native": "^5.4.0", + "@transifex/react": "^5.4.0", "@wordpress/api-fetch": "6.33.0", "@wordpress/components": "^25.2.0", "@wordpress/element": "5.13.0", @@ -22,23 +22,23 @@ "react-error-boundary": "4.0.10" }, "devDependencies": { - "@babel/core": "7.22.5", - "@babel/plugin-transform-runtime": "7.22.5", - "@babel/preset-env": "7.22.5", + "@babel/core": "7.22.6", + "@babel/plugin-transform-runtime": "7.22.6", + "@babel/preset-env": "7.22.6", "@babel/preset-react": "7.22.5", "@babel/preset-typescript": "7.22.5", - "@babel/runtime": "7.22.5", + "@babel/runtime": "7.22.6", "@svgr/webpack": "8.0.1", "@tanstack/react-query-devtools": "^4.29.19", - "@transifex/cli": "^5.3.0", + "@transifex/cli": "^5.4.0", "@types/jest": "29.5.2", "@types/lodash": "4.14.195", "@types/react": "18.2.14", "@types/react-beautiful-dnd": "13.1.4", "@types/react-dom": "18.2.6", "@types/wordpress__components": "^23.0.1", - "@typescript-eslint/eslint-plugin": "5.60.1", - "@typescript-eslint/parser": "5.60.1", + "@typescript-eslint/eslint-plugin": "5.61.0", + "@typescript-eslint/parser": "5.61.0", "@wcpos/eslint-config": "*", "@wordpress/env": "8.2.0", "autoprefixer": "10.4.14", @@ -49,7 +49,7 @@ "fork-ts-checker-webpack-plugin": "8.0.0", "html-webpack-plugin": "5.5.3", "husky": "8.0.3", - "jest": "29.5.0", + "jest": "29.6.0", "jsdoc": "4.0.2", "mini-css-extract-plugin": "2.7.6", "node-sass": "9.0.0", diff --git a/packages/settings/src/components/combobox.tsx b/packages/settings/src/components/combobox.tsx index 19238e8..f808892 100644 --- a/packages/settings/src/components/combobox.tsx +++ b/packages/settings/src/components/combobox.tsx @@ -40,12 +40,22 @@ const Combobox = ({ options, onSearch, onChange, value, placeholder, loading }: onSearch(event.target.value); }; + /** + * + */ + const handleChange = (option) => { + onSearch(''); + onChange(option); + }; + /** * */ React.useEffect(() => { const handleFocus = () => { - inputRef.current.select(); + if (inputRef.current) { + inputRef.current.select(); + } }; const node = inputRef.current; @@ -61,9 +71,10 @@ const Combobox = ({ options, onSearch, onChange, value, placeholder, loading }: * */ return ( - +
-
option.label} onChange={handleSearch} placeholder={placeholder} + data-1p-ignore /> - -
+ + { }, }); }} + disabled={!proEnabled && !['pos_cash', 'pos_card'].includes(item.id)} /> @@ -202,6 +203,7 @@ const Gateways = () => { modalGateway.current = item; setOpen(true); }} + disabled={!proEnabled && !['pos_cash', 'pos_card'].includes(item.id)} > {t('Settings', { _tags: 'wp-admin-settings' })} diff --git a/packages/settings/src/screens/checkout/order-status-select.tsx b/packages/settings/src/screens/checkout/order-status-select.tsx index 9e90732..63c65ac 100644 --- a/packages/settings/src/screens/checkout/order-status-select.tsx +++ b/packages/settings/src/screens/checkout/order-status-select.tsx @@ -1,11 +1,6 @@ import * as React from 'react'; -import { useQuery } from '@tanstack/react-query'; -import apiFetch from '@wordpress/api-fetch'; -import { map } from 'lodash'; - import Select from '../../components/select'; -import useNotices from '../../hooks/use-notices'; interface OrderStatusSelectProps { selectedStatus: string; @@ -13,31 +8,11 @@ interface OrderStatusSelectProps { } const OrderStatusSelect = ({ selectedStatus, mutate }: OrderStatusSelectProps) => { - const { setNotice } = useNotices(); - - const { data: options } = useQuery({ - queryKey: ['order-statuses'], - queryFn: async () => { - const response = await apiFetch>({ - path: `wcpos/v1/settings/checkout/order-statuses?wcpos=1`, - method: 'GET', - }).catch((err) => { - console.error(err); - return err; - }); - - // if we have an error response, set the notice - if (response?.code && response?.message) { - setNotice({ type: 'error', message: response?.message }); - } + const order_statuses = window?.wcpos?.settings?.order_statuses; - return map(response, (label, value) => ({ - label, - value, - })); - }, - placeholderData: [], - }); + const options = React.useMemo(() => { + return Object.entries(order_statuses).map(([value, label]) => ({ value, label })); + }, [order_statuses]); return (