Use updateOptions from @woocommerce/data OPTIONS_STORE_NAME to set wp options instead of using apiFetch
This commit is contained in:
parent
59478e391c
commit
b45d095e2d
|
@ -4,10 +4,9 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { createInterpolateElement, useState } from '@wordpress/element';
|
import { createInterpolateElement, useState } from '@wordpress/element';
|
||||||
import { Button, Card, CardBody, Notice } from '@wordpress/components';
|
import { Button, Card, CardBody, Notice } from '@wordpress/components';
|
||||||
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
|
import { PLUGINS_STORE_NAME, OPTIONS_STORE_NAME } from '@woocommerce/data';
|
||||||
import { useDispatch } from '@wordpress/data';
|
import { useDispatch } from '@wordpress/data';
|
||||||
import { recordEvent } from '@woocommerce/tracks';
|
import { recordEvent } from '@woocommerce/tracks';
|
||||||
import apiFetch from '@wordpress/api-fetch';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -69,6 +68,7 @@ const ErrorNotice = () => {
|
||||||
|
|
||||||
const NoThanksButton = () => {
|
const NoThanksButton = () => {
|
||||||
const [ isNoThanksClicked, setIsNoThanksClicked ] = useState( false );
|
const [ isNoThanksClicked, setIsNoThanksClicked ] = useState( false );
|
||||||
|
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
@ -80,12 +80,8 @@ const NoThanksButton = () => {
|
||||||
'wccore_subscriptions_empty_state_no_thanks_click',
|
'wccore_subscriptions_empty_state_no_thanks_click',
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
apiFetch( {
|
updateOptions( {
|
||||||
path: 'wc-admin/options',
|
[ dismissOptionKey ]: 'yes',
|
||||||
method: 'POST',
|
|
||||||
data: {
|
|
||||||
[ dismissOptionKey ]: 'yes',
|
|
||||||
},
|
|
||||||
} ).then( () => {
|
} ).then( () => {
|
||||||
window.location.href = noThanksUrl;
|
window.location.href = noThanksUrl;
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue