-
Notifications
You must be signed in to change notification settings - Fork 10.7k
/
use-launch-your-store.js
46 lines (42 loc) · 1.22 KB
/
use-launch-your-store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* External dependencies
*/
import { useSelect } from '@wordpress/data';
import { OPTIONS_STORE_NAME } from '@woocommerce/data';
export const useLaunchYourStore = () => {
const { isLoading, launchStatus, showLaunchYourStore } = useSelect(
( select ) => {
const { hasFinishedResolution, getOption } =
select( OPTIONS_STORE_NAME );
const isLoading =
! hasFinishedResolution( 'getOption', [ 'launch-status' ] ) &&
! hasFinishedResolution( 'getOption', [
'woocommerce_coming_soon',
] ) &&
! hasFinishedResolution( 'getOption', [
'woocommerce_store_pages_only',
] ) &&
! hasFinishedResolution( 'getOption', [
'woocommerce_private_link',
] ) &&
! hasFinishedResolution( 'getOption', [
'woocommerce_share_key',
] );
return {
isLoading,
launchStatus: getOption( 'launch-status' ),
comingSoon: getOption( 'woocommerce_coming_soon' ),
storePagesOnly: getOption( 'woocommerce_store_pages_only' ),
privateLink: getOption( 'woocommerce_private_link' ),
shareKey: getOption( 'woocommerce_share_key' ),
showLaunchYourStore:
window.wcAdminFeatures[ 'launch-your-store' ],
};
}
);
return {
isLoading,
launchStatus,
showLaunchYourStore,
};
};