diff --git a/modules/ppcp-settings/resources/js/data/common/hooks.js b/modules/ppcp-settings/resources/js/data/common/hooks.js index cd13e02e6..bac0b2959 100644 --- a/modules/ppcp-settings/resources/js/data/common/hooks.js +++ b/modules/ppcp-settings/resources/js/data/common/hooks.js @@ -144,7 +144,8 @@ export const useWebhooks = () => { }; export const useMerchantInfo = () => { - const { isReady, merchant, features } = useHooks(); + const { isReady, features } = useHooks(); + const merchant = useMerchant(); const { refreshMerchantData } = useDispatch( STORE_NAME ); const verifyLoginStatus = useCallback( async () => { @@ -166,6 +167,22 @@ export const useMerchantInfo = () => { }; }; +// Read-only access to the sanitized merchant details. +export const useMerchant = () => { + const { merchant } = useHooks(); + + return { + isConnected: merchant.isConnected ?? false, + isSandbox: merchant.isSandbox ?? true, + id: merchant.id ?? '', + email: merchant.email ?? '', + clientId: merchant.clientId ?? '', + clientSecret: merchant.clientSecret ?? '', + isBusinessSeller: 'business' === merchant.sellerType, + isCasualSeller: 'personal' === merchant.sellerType, + }; +}; + export const useActiveModal = () => { const { activeModal, setActiveModal } = useHooks(); return { activeModal, setActiveModal };