Skip to content

Commit

Permalink
Use relative path for the actions in feature-announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
harriswong committed Jun 13, 2024
1 parent 0888735 commit d370fdf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions client/components/migration/feature-announcement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useState } from '@wordpress/element';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { localize } from 'i18n-calypso';
import { getNonce } from 'api/request'; // client/api/request.js
import { getNonce, getBaseURL } from 'api/request'; // client/api/request.js

/**
* Internal dependencies
Expand Down Expand Up @@ -36,9 +36,10 @@ const FeatureAnnouncement = ({ translate, isEligable }) => {
"Content-Type": "application/json",
'X-WP-Nonce': getNonce()
};
console.log('getBaseURL', getBaseURL());

const installPluginAPICall = () =>
fetch( '/wp-json/wc-admin/plugins/install', {
fetch( getBaseURL() + 'wc-admin/plugins/install', {
method: 'POST',
headers,
body: JSON.stringify({
Expand All @@ -47,7 +48,7 @@ const FeatureAnnouncement = ({ translate, isEligable }) => {
} );

const activatePluginAPICall = () =>
fetch( '/wp-json/wc-admin/plugins/activate', {
fetch( getBaseURL() + 'wc-admin/plugins/activate', {
method: 'POST',
headers,
body: JSON.stringify({
Expand All @@ -56,7 +57,7 @@ const FeatureAnnouncement = ({ translate, isEligable }) => {
} );

const deactivateWCSTPluginAPICall = () =>
fetch( '/wp-json/wp/v2/plugins/woocommerce-services/woocommerce-services', {
fetch( getBaseURL() + 'wp/v2/plugins/woocommerce-services/woocommerce-services', {
method: 'POST',
headers,
body: JSON.stringify({
Expand All @@ -72,7 +73,7 @@ const FeatureAnnouncement = ({ translate, isEligable }) => {
await activatePluginAPICall();
await deactivateWCSTPluginAPICall();
setIsUpdating(false);
window.location = '/wp-admin/plugins.php';
window.location = global.wcsPluginData.adminPluginPath;
} catch (e) {
//TODO: error handling.
// console.log('Failed to install or activate.', e);
Expand Down

0 comments on commit d370fdf

Please sign in to comment.