diff --git a/modules/settings/assets/js/api/index.js b/modules/settings/assets/js/api/index.js index 79f675b..ec0d785 100644 --- a/modules/settings/assets/js/api/index.js +++ b/modules/settings/assets/js/api/index.js @@ -127,6 +127,15 @@ class API { path: `${v1Prefix}/settings/get-settings`, }); } + + /** + * Go to connect service + * @return {Promise} redirect + */ + static async redirectToConnect() { + const link = await this.initConnect(); + window.open(link, '_self').focus(); + } } export default API; diff --git a/modules/settings/assets/js/components/my-account-menu/index.js b/modules/settings/assets/js/components/my-account-menu/index.js index 0995398..4a2a814 100644 --- a/modules/settings/assets/js/components/my-account-menu/index.js +++ b/modules/settings/assets/js/components/my-account-menu/index.js @@ -1,4 +1,4 @@ -import { ChevronDownIcon, UserIcon } from '@elementor/icons'; +import { ChevronDownIcon, UserIcon, ExternalLinkIcon } from '@elementor/icons'; import Avatar from '@elementor/ui/Avatar'; import Box from '@elementor/ui/Box'; import List from '@elementor/ui/List'; @@ -13,16 +13,34 @@ import { bindTrigger, usePopupState, } from '@elementor/ui/usePopupState'; -import { useSettings } from '@ea11y/hooks'; +import { useSettings, useToastNotification } from '@ea11y/hooks'; import { CreditCardIcon, UserArrowIcon } from '@ea11y/icons'; import { __ } from '@wordpress/i18n'; +import API from '../../api'; +import { BILLING_LINK } from '../../constants'; const MyAccountMenu = () => { const { openSidebar } = useSettings(); + const { error } = useToastNotification(); const accountMenuState = usePopupState({ variant: 'popover', popupId: 'myAccountMenu', }); + const onDeactivateAndDisconnect = async () => { + try { + await API.disconnect(); + await API.redirectToConnect(); + } catch (e) { + error( + __('Failed to switch account. Please try again.', 'pojo-accessibility'), + ); + console.error(e); + } + }; + + const redirectToBilling = () => { + window.open(BILLING_LINK, '_blank').focus(); + }; return ( <> @@ -72,17 +90,21 @@ const MyAccountMenu = () => { - + {__('Switch account', 'pojo-accessibility')} - + {__('Billing', 'pojo-accessibility')} + diff --git a/modules/settings/assets/js/constants/index.js b/modules/settings/assets/js/constants/index.js index c4169b4..3df3179 100644 --- a/modules/settings/assets/js/constants/index.js +++ b/modules/settings/assets/js/constants/index.js @@ -1,2 +1,3 @@ export const HELP_LINK = 'https://go.elementor.com/'; export const UPGRADE_LINK = 'https://go.elementor.com/'; +export const BILLING_LINK = 'https://my.elementor.com/'; diff --git a/modules/settings/module.php b/modules/settings/module.php index 588c004..c3b63c0 100644 --- a/modules/settings/module.php +++ b/modules/settings/module.php @@ -12,8 +12,8 @@ } class Module extends Module_Base { - const SETTING_PREFIX = 'a11y_'; - const SETTING_GROUP = 'a11y_settings'; + const SETTING_PREFIX = 'ea11y_'; + const SETTING_GROUP = 'ea11y_settings'; const SETTING_BASE_SLUG = 'accessibility-settings-2'; //TODO: Change this later const SETTING_CAPABILITY = 'manage_options'; diff --git a/package-lock.json b/package-lock.json index 70900e4..285cff0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "pojo-accessibility", "version": "2.1.0", "dependencies": { - "@elementor/icons": "^1.17.0", + "@elementor/icons": "^1.20.0", "@elementor/ui": "^1.21.2", "@wordpress/api-fetch": "^7.10.0", "@wordpress/core-data": "^7.10.0", @@ -2069,9 +2069,10 @@ } }, "node_modules/@elementor/icons": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/@elementor/icons/-/icons-1.18.1.tgz", - "integrity": "sha512-/69Adp/Q0ebKQOnNKekzX3ym7CQNotBq4JXO+pqtUXbqwbL0O7k56aR81yZSVns1TMOip5+Qxbgxemth0k0FlQ==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/@elementor/icons/-/icons-1.20.0.tgz", + "integrity": "sha512-1UgAIDO8qY7R7OjTZ+9cIMqgYtD7LAjIqVJiGmnkJMeb7sM65UebHvZiVVSZX7+jqJ1vuoLH+lmvAZlm8eqoGQ==", + "license": "GPL-3.0-or-later", "peerDependencies": { "@elementor/ui": "^1.4.61", "react": "^17.0.0 || ^18.0.0" diff --git a/package.json b/package.json index 23eb061..7604992 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "prettier": "^3.4.1" }, "dependencies": { - "@elementor/icons": "^1.17.0", + "@elementor/icons": "^1.20.0", "@elementor/ui": "^1.21.2", "@wordpress/api-fetch": "^7.10.0", "@wordpress/core-data": "^7.10.0",