2024-03-11 23:50:22 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useSelect } from '@wordpress/data';
|
|
|
|
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
|
|
|
|
|
2024-06-11 05:28:05 +00:00
|
|
|
type Props = {
|
|
|
|
/** Set to false to disable this query, defaults to true to query the data */
|
|
|
|
enabled?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useLaunchYourStore = (
|
|
|
|
{ enabled }: Props = {
|
|
|
|
enabled: true,
|
|
|
|
}
|
|
|
|
) => {
|
2024-03-11 23:50:22 +00:00
|
|
|
const {
|
|
|
|
isLoading,
|
|
|
|
launchYourStoreEnabled,
|
|
|
|
comingSoon,
|
|
|
|
storePagesOnly,
|
|
|
|
privateLink,
|
|
|
|
shareKey,
|
|
|
|
} = useSelect( ( select ) => {
|
2024-06-11 05:28:05 +00:00
|
|
|
if ( ! enabled ) {
|
|
|
|
return {
|
|
|
|
isLoading: false,
|
|
|
|
comingSoon: null,
|
|
|
|
storePagesOnly: null,
|
|
|
|
privateLink: null,
|
|
|
|
shareKey: null,
|
|
|
|
launchYourStoreEnabled: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-03-11 23:50:22 +00:00
|
|
|
const { hasFinishedResolution, getOption } =
|
|
|
|
select( OPTIONS_STORE_NAME );
|
|
|
|
|
|
|
|
const allOptionResolutionsFinished =
|
|
|
|
! hasFinishedResolution( 'getOption', [
|
|
|
|
'woocommerce_coming_soon',
|
|
|
|
] ) &&
|
|
|
|
! hasFinishedResolution( 'getOption', [
|
|
|
|
'woocommerce_store_pages_only',
|
|
|
|
] ) &&
|
|
|
|
! hasFinishedResolution( 'getOption', [
|
|
|
|
'woocommerce_private_link',
|
|
|
|
] ) &&
|
|
|
|
! hasFinishedResolution( 'getOption', [ 'woocommerce_share_key' ] );
|
|
|
|
|
|
|
|
return {
|
|
|
|
isLoading: allOptionResolutionsFinished,
|
|
|
|
comingSoon: getOption( 'woocommerce_coming_soon' ),
|
|
|
|
storePagesOnly: getOption( 'woocommerce_store_pages_only' ),
|
|
|
|
privateLink: getOption( 'woocommerce_private_link' ),
|
|
|
|
shareKey: getOption( 'woocommerce_share_key' ),
|
|
|
|
launchYourStoreEnabled:
|
|
|
|
window.wcAdminFeatures[ 'launch-your-store' ],
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
|
|
|
|
return {
|
|
|
|
isLoading,
|
|
|
|
comingSoon,
|
|
|
|
storePagesOnly,
|
|
|
|
privateLink,
|
|
|
|
shareKey,
|
|
|
|
launchYourStoreEnabled,
|
|
|
|
};
|
|
|
|
};
|