Update option name and value to make it more indicative.

This commit is contained in:
Gan Eng Chin 2023-03-19 20:16:04 +08:00
parent 49253425b2
commit 162d790a7a
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
1 changed files with 8 additions and 5 deletions

View File

@ -11,16 +11,16 @@ type UseIntroductionBanner = {
dismissIntroductionBanner: () => void;
};
const OPTION_NAME =
const OPTION_NAME_BANNER_DISMISSED =
'woocommerce_marketing_overview_multichannel_banner_dismissed';
const OPTION_VALUE = 'yes';
const OPTION_VALUE_YES = 'yes';
export const useIntroductionBanner = (): UseIntroductionBanner => {
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME );
const dismissIntroductionBanner = () => {
updateOptions( {
[ OPTION_NAME ]: OPTION_VALUE,
[ OPTION_NAME_BANNER_DISMISSED ]: OPTION_VALUE_YES,
} );
recordEvent( 'marketing_multichannel_banner_dismissed', {} );
};
@ -31,9 +31,12 @@ export const useIntroductionBanner = (): UseIntroductionBanner => {
const isUpdateRequesting = isOptionsUpdating();
return {
loading: ! hasFinishedResolution( 'getOption', [ OPTION_NAME ] ),
loading: ! hasFinishedResolution( 'getOption', [
OPTION_NAME_BANNER_DISMISSED,
] ),
isIntroductionBannerDismissed:
getOption( OPTION_NAME ) === OPTION_VALUE || isUpdateRequesting,
getOption( OPTION_NAME_BANNER_DISMISSED ) ===
OPTION_VALUE_YES || isUpdateRequesting,
dismissIntroductionBanner,
};
}, [] );