Remove unnecessary wpDataselect & WCDataSelector types from react client
This commit is contained in:
parent
672ba17a80
commit
d94c1dc7bd
|
@ -8,7 +8,7 @@ import { escapeRegExp, has } from 'lodash';
|
|||
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
|
||||
import { SelectControl, TextControl } from '@woocommerce/components';
|
||||
import { Spinner } from '@wordpress/components';
|
||||
import { useSelect, select as wpDataSelect } from '@wordpress/data';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -28,8 +28,8 @@ type Option = { key: string; label: string };
|
|||
/**
|
||||
* Type guard to ensure that the specified locale object has a .required property
|
||||
*
|
||||
* @param fieldName field of Locale
|
||||
* @param locale unknown object to be checked
|
||||
* @param fieldName field of Locale
|
||||
* @param locale unknown object to be checked
|
||||
* @return Boolean indicating if locale has a .required property
|
||||
*/
|
||||
const isLocaleRecord = (
|
||||
|
@ -353,7 +353,7 @@ export function StoreAddress( {
|
|||
hasFinishedResolution,
|
||||
countries,
|
||||
loadingCountries,
|
||||
} = useSelect( ( select: typeof wpDataSelect ) => {
|
||||
} = useSelect( ( select ) => {
|
||||
const {
|
||||
getLocale,
|
||||
getCountries,
|
||||
|
|
|
@ -7,7 +7,6 @@ import { identity } from 'lodash';
|
|||
import {
|
||||
ONBOARDING_STORE_NAME,
|
||||
withOnboardingHydration,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { getHistory, getNewPath } from '@woocommerce/navigation';
|
||||
import type { History } from 'history';
|
||||
|
|
|
@ -10,11 +10,7 @@ import {
|
|||
} from '@wordpress/components';
|
||||
import { useState, useEffect } from '@wordpress/element';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import {
|
||||
useDispatch,
|
||||
useSelect,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { OPTIONS_STORE_NAME, PluginsStoreActions } from '@woocommerce/data';
|
||||
import apiFetch from '@wordpress/api-fetch';
|
||||
|
||||
|
@ -228,7 +224,7 @@ const ConnectAccountPage = () => {
|
|||
const [ errorMessage, setErrorMessage ] = useState( '' );
|
||||
|
||||
const { isJetpackConnected, connectUrl, hasViewedWelcomePage } = useSelect(
|
||||
( select: typeof wpDataSelect ) => {
|
||||
( select ) => {
|
||||
const { getOption } = select( OPTIONS_STORE_NAME );
|
||||
let pageViewTimestamp = getOption(
|
||||
'wc_pay_welcome_page_viewed_timestamp'
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
PAYMENT_GATEWAYS_STORE_NAME,
|
||||
PLUGINS_STORE_NAME,
|
||||
Plugin,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import ExternalIcon from 'gridicons/dist/external';
|
||||
|
@ -50,7 +49,7 @@ const PaymentRecommendations: React.FC = () => {
|
|||
paymentGatewaySuggestions,
|
||||
isResolving,
|
||||
} = useSelect(
|
||||
( select: WCDataSelector ) => {
|
||||
( select ) => {
|
||||
const installingGatewayId =
|
||||
isInstalled && getPluginSlug( installingPlugin );
|
||||
return {
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import {
|
||||
useDispatch,
|
||||
useSelect,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { Button, Card, CardHeader } from '@wordpress/components';
|
||||
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
|
||||
import { EllipsisMenu } from '@woocommerce/components';
|
||||
|
@ -59,7 +55,7 @@ export const DismissableList: React.FC< {
|
|||
dismissOptionName: string;
|
||||
className?: string;
|
||||
} > = ( { children, className, dismissOptionName } ) => {
|
||||
const isVisible = useSelect( ( select: typeof wpDataSelect ) => {
|
||||
const isVisible = useSelect( ( select ) => {
|
||||
const { getOption, hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { useSelect, select as wpDataSelect } from '@wordpress/data';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { useUser, OPTIONS_STORE_NAME } from '@woocommerce/data';
|
||||
|
||||
const SHOW_MARKETPLACE_SUGGESTION_OPTION =
|
||||
|
@ -10,21 +10,19 @@ const SHOW_MARKETPLACE_SUGGESTION_OPTION =
|
|||
const RecommendationsEligibilityWrapper: React.FC = ( { children } ) => {
|
||||
const { currentUserCan } = useUser();
|
||||
|
||||
const isMarketplaceSuggestionsEnabled = useSelect(
|
||||
( select: typeof wpDataSelect ) => {
|
||||
const { getOption, hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
);
|
||||
const isMarketplaceSuggestionsEnabled = useSelect( ( select ) => {
|
||||
const { getOption, hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
);
|
||||
|
||||
const hasFinishedResolving = hasFinishedResolution( 'getOption', [
|
||||
SHOW_MARKETPLACE_SUGGESTION_OPTION,
|
||||
] );
|
||||
const canShowMarketplaceSuggestions =
|
||||
getOption( SHOW_MARKETPLACE_SUGGESTION_OPTION ) !== 'no';
|
||||
const hasFinishedResolving = hasFinishedResolution( 'getOption', [
|
||||
SHOW_MARKETPLACE_SUGGESTION_OPTION,
|
||||
] );
|
||||
const canShowMarketplaceSuggestions =
|
||||
getOption( SHOW_MARKETPLACE_SUGGESTION_OPTION ) !== 'no';
|
||||
|
||||
return hasFinishedResolving && canShowMarketplaceSuggestions;
|
||||
}
|
||||
);
|
||||
return hasFinishedResolving && canShowMarketplaceSuggestions;
|
||||
} );
|
||||
|
||||
if ( ! currentUserCan( 'install_plugins' ) ) {
|
||||
return null;
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import {
|
||||
useSelect,
|
||||
useDispatch,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useSelect, useDispatch } from '@wordpress/data';
|
||||
import { useState, Children } from '@wordpress/element';
|
||||
import { Text } from '@woocommerce/experimental';
|
||||
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
|
||||
|
@ -103,7 +99,7 @@ const ShippingRecommendationsList: React.FC = ( { children } ) => (
|
|||
const ShippingRecommendations: React.FC = () => {
|
||||
const [ pluginsBeingSetup, setupPlugin ] = useInstallPlugin();
|
||||
|
||||
const activePlugins = useSelect( ( select: typeof wpDataSelect ) =>
|
||||
const activePlugins = useSelect( ( select ) =>
|
||||
select( PLUGINS_STORE_NAME ).getActivePlugins()
|
||||
);
|
||||
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import {
|
||||
useSelect,
|
||||
useDispatch,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useSelect, useDispatch } from '@wordpress/data';
|
||||
import { Button, ExternalLink } from '@wordpress/components';
|
||||
import { Pill } from '@woocommerce/components';
|
||||
import { PLUGINS_STORE_NAME } from '@woocommerce/data';
|
||||
|
@ -26,9 +22,8 @@ const WooCommerceServicesItem: React.FC< {
|
|||
const wcAdminAssetUrl = getAdminSetting( 'wcAdminAssetUrl', '' );
|
||||
const { createSuccessNotice } = useDispatch( 'core/notices' );
|
||||
|
||||
const isSiteConnectedToJetpack = useSelect(
|
||||
( select: typeof wpDataSelect ) =>
|
||||
select( PLUGINS_STORE_NAME ).isJetpackConnected()
|
||||
const isSiteConnectedToJetpack = useSelect( ( select ) =>
|
||||
select( PLUGINS_STORE_NAME ).isJetpackConnected()
|
||||
);
|
||||
|
||||
const handleSetupClick = () => {
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useMemo } from '@wordpress/element';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import {
|
||||
getVisibleTasks,
|
||||
ONBOARDING_STORE_NAME,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { getVisibleTasks, ONBOARDING_STORE_NAME } from '@woocommerce/data';
|
||||
import { getSetting } from '@woocommerce/settings';
|
||||
|
||||
/**
|
||||
|
@ -30,7 +26,7 @@ export const ProgressHeader: React.FC< ProgressHeaderProps > = ( {
|
|||
completedCount,
|
||||
hasVisitedTasks,
|
||||
disabledCompletedCount,
|
||||
} = useSelect( ( select: WCDataSelector ) => {
|
||||
} = useSelect( ( select ) => {
|
||||
const taskList = select( ONBOARDING_STORE_NAME ).getTaskList(
|
||||
taskListId
|
||||
);
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
import { registerPlugin } from '@wordpress/plugins';
|
||||
import { WooOnboardingTask } from '@woocommerce/onboarding';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import {
|
||||
ONBOARDING_STORE_NAME,
|
||||
TaskType,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { ONBOARDING_STORE_NAME, TaskType } from '@woocommerce/data';
|
||||
import { useEffect, useState } from '@wordpress/element';
|
||||
|
||||
type DeprecatedTask = TaskType & {
|
||||
|
@ -19,16 +15,14 @@ const DeprecatedWooOnboardingTaskFills = () => {
|
|||
const [ deprecatedTasks, setDeprecatedTasks ] = useState<
|
||||
DeprecatedTask[]
|
||||
>( [] );
|
||||
const { isResolving, taskLists } = useSelect(
|
||||
( select: WCDataSelector ) => {
|
||||
return {
|
||||
isResolving: select( ONBOARDING_STORE_NAME ).isResolving(
|
||||
'getTaskLists'
|
||||
),
|
||||
taskLists: select( ONBOARDING_STORE_NAME ).getTaskLists(),
|
||||
};
|
||||
}
|
||||
);
|
||||
const { isResolving, taskLists } = useSelect( ( select ) => {
|
||||
return {
|
||||
isResolving: select( ONBOARDING_STORE_NAME ).isResolving(
|
||||
'getTaskLists'
|
||||
),
|
||||
taskLists: select( ONBOARDING_STORE_NAME ).getTaskLists(),
|
||||
};
|
||||
} );
|
||||
|
||||
useEffect( () => {
|
||||
if ( taskLists && taskLists.length > 0 ) {
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Card, CardHeader, Spinner } from '@wordpress/components';
|
||||
import {
|
||||
ONBOARDING_STORE_NAME,
|
||||
PLUGINS_STORE_NAME,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { ONBOARDING_STORE_NAME, PLUGINS_STORE_NAME } from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import { Text } from '@woocommerce/experimental';
|
||||
import { useMemo, useState } from '@wordpress/element';
|
||||
|
@ -122,7 +118,7 @@ const Marketing: React.FC< MarketingProps > = ( { onComplete } ) => {
|
|||
freeExtensions,
|
||||
installedPlugins,
|
||||
isResolving,
|
||||
} = useSelect( ( select: WCDataSelector ) => {
|
||||
} = useSelect( ( select ) => {
|
||||
const { getActivePlugins, getInstalledPlugins } = select(
|
||||
PLUGINS_STORE_NAME
|
||||
);
|
||||
|
|
|
@ -21,20 +21,18 @@ export const StoreLocation: React.FC< {
|
|||
const { updateAndPersistSettingsForGroup } = useDispatch(
|
||||
SETTINGS_STORE_NAME
|
||||
);
|
||||
const { generalSettings, isResolving } = useSelect(
|
||||
( select: WCDataSelector ) => {
|
||||
const { getSettings, hasFinishedResolution } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
const { generalSettings, isResolving } = useSelect( ( select ) => {
|
||||
const { getSettings, hasFinishedResolution } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
|
||||
return {
|
||||
generalSettings: getSettings( 'general' )?.general,
|
||||
isResolving: ! hasFinishedResolution( 'getSettings', [
|
||||
'general',
|
||||
] ),
|
||||
};
|
||||
}
|
||||
);
|
||||
return {
|
||||
generalSettings: getSettings( 'general' )?.general,
|
||||
isResolving: ! hasFinishedResolution( 'getSettings', [
|
||||
'general',
|
||||
] ),
|
||||
};
|
||||
} );
|
||||
|
||||
useEffect( () => {
|
||||
if ( isResolving || ! hasCompleteAddress( generalSettings ) ) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import { getAdminLink } from '@woocommerce/settings';
|
|||
import {
|
||||
OPTIONS_STORE_NAME,
|
||||
SETTINGS_STORE_NAME,
|
||||
WCDataSelector,
|
||||
TaskType,
|
||||
} from '@woocommerce/data';
|
||||
import { queueRecordEvent, recordEvent } from '@woocommerce/tracks';
|
||||
|
@ -60,7 +59,7 @@ const Tax: React.FC< TaxProps > = ( { onComplete, query, task } ) => {
|
|||
SETTINGS_STORE_NAME
|
||||
);
|
||||
const { generalSettings, isResolving, taxSettings } = useSelect(
|
||||
( select: WCDataSelector ) => {
|
||||
( select ) => {
|
||||
const { getSettings, hasFinishedResolution } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
|
|
|
@ -17,7 +17,7 @@ import { SettingsSelector, TaxChildProps } from '../utils';
|
|||
export const Configure: React.FC<
|
||||
Pick< TaxChildProps, 'isPending' | 'onManual' >
|
||||
> = ( { isPending, onManual } ) => {
|
||||
const { generalSettings } = useSelect( ( select: WCDataSelector ) => {
|
||||
const { generalSettings } = useSelect( ( select ) => {
|
||||
const { getSettings } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
|
|
|
@ -5,11 +5,7 @@ import { __ } from '@wordpress/i18n';
|
|||
import { difference } from 'lodash';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { Spinner } from '@woocommerce/components';
|
||||
import {
|
||||
PLUGINS_STORE_NAME,
|
||||
SETTINGS_STORE_NAME,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { PLUGINS_STORE_NAME, SETTINGS_STORE_NAME } from '@woocommerce/data';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -34,7 +30,7 @@ export const WooCommerceTax: React.FC< TaxChildProps > = ( {
|
|||
isJetpackConnected,
|
||||
isResolving,
|
||||
pluginsToActivate,
|
||||
} = useSelect( ( select: WCDataSelector ) => {
|
||||
} = useSelect( ( select ) => {
|
||||
const { getSettings } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
|
|
|
@ -7,11 +7,7 @@ import { Link, Plugins as PluginInstaller } from '@woocommerce/components';
|
|||
import { OPTIONS_STORE_NAME, InstallPluginsResponse } from '@woocommerce/data';
|
||||
import { recordEvent, queueRecordEvent } from '@woocommerce/tracks';
|
||||
import { Text } from '@woocommerce/experimental';
|
||||
import {
|
||||
useDispatch,
|
||||
useSelect,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { useEffect } from '@wordpress/element';
|
||||
|
||||
/**
|
||||
|
@ -27,26 +23,24 @@ export const Plugins: React.FC< SetupStepProps > = ( {
|
|||
pluginsToActivate,
|
||||
} ) => {
|
||||
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
|
||||
const { isResolving, tosAccepted } = useSelect(
|
||||
( select: typeof wpDataSelect ) => {
|
||||
const { getOption, hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
);
|
||||
const { isResolving, tosAccepted } = useSelect( ( select ) => {
|
||||
const { getOption, hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
);
|
||||
|
||||
return {
|
||||
isResolving:
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'woocommerce_setup_jetpack_opted_in',
|
||||
] ) ||
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'wc_connect_options',
|
||||
] ),
|
||||
tosAccepted:
|
||||
getOption( 'wc_connect_options' )?.tos_accepted ||
|
||||
getOption( 'woocommerce_setup_jetpack_opted_in' ) === '1',
|
||||
};
|
||||
}
|
||||
);
|
||||
return {
|
||||
isResolving:
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'woocommerce_setup_jetpack_opted_in',
|
||||
] ) ||
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'wc_connect_options',
|
||||
] ),
|
||||
tosAccepted:
|
||||
getOption( 'wc_connect_options' )?.tos_accepted ||
|
||||
getOption( 'woocommerce_setup_jetpack_opted_in' ) === '1',
|
||||
};
|
||||
} );
|
||||
|
||||
useEffect( () => {
|
||||
if ( ! tosAccepted || pluginsToActivate.length ) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
PLUGINS_STORE_NAME,
|
||||
SETTINGS_STORE_NAME,
|
||||
} from '@woocommerce/data';
|
||||
import { useSelect, select as wpDataSelect } from '@wordpress/data';
|
||||
import { useSelect } from '@wordpress/data';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -47,29 +47,27 @@ export const Setup: React.FC< SetupProps > = ( {
|
|||
const [ pluginsToActivate, setPluginsToActivate ] = useState< string[] >(
|
||||
[]
|
||||
);
|
||||
const { activePlugins, isResolving } = useSelect(
|
||||
( select: typeof wpDataSelect ) => {
|
||||
const { getSettings } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
const { hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
const { getActivePlugins } = select( PLUGINS_STORE_NAME );
|
||||
const { activePlugins, isResolving } = useSelect( ( select ) => {
|
||||
const { getSettings } = select(
|
||||
SETTINGS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
const { hasFinishedResolution } = select(
|
||||
OPTIONS_STORE_NAME
|
||||
) as SettingsSelector;
|
||||
const { getActivePlugins } = select( PLUGINS_STORE_NAME );
|
||||
|
||||
return {
|
||||
activePlugins: getActivePlugins(),
|
||||
generalSettings: getSettings( 'general' )?.general,
|
||||
isResolving:
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'woocommerce_setup_jetpack_opted_in',
|
||||
] ) ||
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'wc_connect_options',
|
||||
] ),
|
||||
};
|
||||
}
|
||||
);
|
||||
return {
|
||||
activePlugins: getActivePlugins(),
|
||||
generalSettings: getSettings( 'general' )?.general,
|
||||
isResolving:
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'woocommerce_setup_jetpack_opted_in',
|
||||
] ) ||
|
||||
! hasFinishedResolution( 'getOption', [
|
||||
'wc_connect_options',
|
||||
] ),
|
||||
};
|
||||
} );
|
||||
const [ stepIndex, setStepIndex ] = useState( 0 );
|
||||
|
||||
useEffect( () => {
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
* External dependencies
|
||||
*/
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import {
|
||||
useSelect,
|
||||
useDispatch,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useSelect, useDispatch } from '@wordpress/data';
|
||||
import {
|
||||
ONBOARDING_STORE_NAME,
|
||||
OPTIONS_STORE_NAME,
|
||||
|
@ -98,7 +94,7 @@ export const TasksReminderBar: React.FC< ReminderBarProps > = ( {
|
|||
taskListComplete,
|
||||
reminderBarHidden,
|
||||
completedTasksCount,
|
||||
} = useSelect( ( select: typeof wpDataSelect ) => {
|
||||
} = useSelect( ( select ) => {
|
||||
const {
|
||||
getTaskList,
|
||||
hasFinishedResolution: onboardingHasFinishedResolution,
|
||||
|
|
|
@ -10,7 +10,6 @@ import {
|
|||
getVisibleTasks,
|
||||
ONBOARDING_STORE_NAME,
|
||||
TaskListType,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import { Text, List, CollapsibleList } from '@woocommerce/experimental';
|
||||
|
@ -39,7 +38,7 @@ export const TaskList: React.FC< TaskListProps > = ( {
|
|||
displayProgressHeader = false,
|
||||
query,
|
||||
} ) => {
|
||||
const { profileItems } = useSelect( ( select: WCDataSelector ) => {
|
||||
const { profileItems } = useSelect( ( select ) => {
|
||||
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
||||
|
||||
return {
|
||||
|
|
|
@ -9,7 +9,6 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|||
import {
|
||||
ONBOARDING_STORE_NAME,
|
||||
OPTIONS_STORE_NAME,
|
||||
WCDataSelector,
|
||||
TaskListType,
|
||||
TaskType,
|
||||
} from '@woocommerce/data';
|
||||
|
@ -67,16 +66,14 @@ export const Tasks: React.FC< TasksProps > = ( { query } ) => {
|
|||
'woocommerce_tasklist_progression'
|
||||
);
|
||||
|
||||
const { isResolving, taskLists } = useSelect(
|
||||
( select: WCDataSelector ) => {
|
||||
return {
|
||||
isResolving: ! select(
|
||||
ONBOARDING_STORE_NAME
|
||||
).hasFinishedResolution( 'getTaskLists' ),
|
||||
taskLists: select( ONBOARDING_STORE_NAME ).getTaskLists(),
|
||||
};
|
||||
}
|
||||
);
|
||||
const { isResolving, taskLists } = useSelect( ( select ) => {
|
||||
return {
|
||||
isResolving: ! select(
|
||||
ONBOARDING_STORE_NAME
|
||||
).hasFinishedResolution( 'getTaskLists' ),
|
||||
taskLists: select( ONBOARDING_STORE_NAME ).getTaskLists(),
|
||||
};
|
||||
} );
|
||||
|
||||
const getCurrentTask = () => {
|
||||
if ( ! task ) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|||
import {
|
||||
ONBOARDING_STORE_NAME,
|
||||
OPTIONS_STORE_NAME,
|
||||
WCDataSelector,
|
||||
TaskListType,
|
||||
TaskType,
|
||||
} from '@woocommerce/data';
|
||||
|
@ -38,7 +37,7 @@ const ExtendedTask: React.FC< TasksProps > = ( { query } ) => {
|
|||
}: {
|
||||
isResolving: boolean;
|
||||
taskLists: TaskListType[];
|
||||
} = useSelect( ( select: WCDataSelector ) => {
|
||||
} = useSelect( ( select ) => {
|
||||
return {
|
||||
isResolving: select( ONBOARDING_STORE_NAME ).isResolving(
|
||||
'getTaskListsByIds'
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
OPTIONS_STORE_NAME,
|
||||
ONBOARDING_STORE_NAME,
|
||||
getVisibleTasks,
|
||||
WCDataSelector,
|
||||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import { List } from '@woocommerce/experimental';
|
||||
|
@ -43,7 +42,7 @@ export const SectionedTaskList: React.FC< TaskListProps > = ( {
|
|||
displayProgressHeader,
|
||||
} ) => {
|
||||
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
|
||||
const { profileItems } = useSelect( ( select: WCDataSelector ) => {
|
||||
const { profileItems } = useSelect( ( select ) => {
|
||||
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
||||
return {
|
||||
profileItems: getProfileItems(),
|
||||
|
|
|
@ -17,7 +17,6 @@ import {
|
|||
TaskType,
|
||||
useUserPreferences,
|
||||
getVisibleTasks,
|
||||
WCDataSelector,
|
||||
TaskListType,
|
||||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
|
@ -56,7 +55,7 @@ export const TaskList: React.FC< TaskListProps > = ( {
|
|||
const { updateOptions, dismissTask, undoDismissTask } = useDispatch(
|
||||
OPTIONS_STORE_NAME
|
||||
);
|
||||
const { profileItems } = useSelect( ( select: WCDataSelector ) => {
|
||||
const { profileItems } = useSelect( ( select ) => {
|
||||
const { getProfileItems } = select( ONBOARDING_STORE_NAME );
|
||||
return {
|
||||
profileItems: getProfileItems(),
|
||||
|
|
|
@ -10,11 +10,7 @@ import {
|
|||
PluginsStoreActions,
|
||||
} from '@woocommerce/data';
|
||||
import { recordEvent } from '@woocommerce/tracks';
|
||||
import {
|
||||
useDispatch,
|
||||
useSelect,
|
||||
select as wpDataSelect,
|
||||
} from '@wordpress/data';
|
||||
import { useDispatch, useSelect } from '@wordpress/data';
|
||||
import { sanitize } from 'dompurify';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
|
@ -59,27 +55,24 @@ export const PaymentPromotionRow: React.FC< PaymentPromotionRowProps > = ( {
|
|||
const { installAndActivatePlugins } = useDispatch( PLUGINS_STORE_NAME );
|
||||
const { createNotice } = useDispatch( 'core/notices' );
|
||||
const { updatePaymentGateway } = useDispatch( PAYMENT_GATEWAYS_STORE_NAME );
|
||||
const { gatewayIsActive, paymentGateway } = useSelect(
|
||||
( select: typeof wpDataSelect ) => {
|
||||
const { getPaymentGateway } = select( PAYMENT_GATEWAYS_STORE_NAME );
|
||||
const activePlugins: string[] = select(
|
||||
PLUGINS_STORE_NAME
|
||||
).getActivePlugins();
|
||||
const isActive =
|
||||
activePlugins && activePlugins.includes( pluginSlug );
|
||||
let paymentGatewayData;
|
||||
if ( isActive ) {
|
||||
paymentGatewayData = getPaymentGateway(
|
||||
pluginSlug.replace( /\-/g, '_' )
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
gatewayIsActive: isActive,
|
||||
paymentGateway: paymentGatewayData,
|
||||
};
|
||||
const { gatewayIsActive, paymentGateway } = useSelect( ( select ) => {
|
||||
const { getPaymentGateway } = select( PAYMENT_GATEWAYS_STORE_NAME );
|
||||
const activePlugins: string[] = select(
|
||||
PLUGINS_STORE_NAME
|
||||
).getActivePlugins();
|
||||
const isActive = activePlugins && activePlugins.includes( pluginSlug );
|
||||
let paymentGatewayData;
|
||||
if ( isActive ) {
|
||||
paymentGatewayData = getPaymentGateway(
|
||||
pluginSlug.replace( /\-/g, '_' )
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
gatewayIsActive: isActive,
|
||||
paymentGateway: paymentGatewayData,
|
||||
};
|
||||
} );
|
||||
|
||||
useEffect( () => {
|
||||
if (
|
||||
|
|
Loading…
Reference in New Issue