Add new settings-page navigation helper

This commit is contained in:
Philipp Stracker 2025-02-26 10:56:38 +01:00
parent 4534167dae
commit 5472ca580f
No known key found for this signature in database

View file

@ -5,6 +5,26 @@ const goToWooCommercePaymentsTab = () => {
window.location.href = window.ppcpSettings.wcPaymentsTabUrl;
};
export const useNavigation = () => {
return { goToWooCommercePaymentsTab };
/**
* Navigate to the main settings page, or to a defined tab (panel).
* Always initiates a browser navigation - if the user already is on the defined settings page,
* this function acts as a page-reload.
*
* @param {?string} [panel=null] Which settings tab to display.
*/
const goToPluginSettings = ( panel = null ) => {
let url = window.ppcpSettings.pluginSettingsUrl;
if ( panel ) {
url += '&panel=' + panel;
}
window.location.href = url;
};
export const useNavigation = () => {
return {
goToWooCommercePaymentsTab,
goToPluginSettings,
};
};