mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
✨ Provide new hook with sanitized merchant data
This commit is contained in:
parent
c0bbd2a6f8
commit
acdf109ca8
1 changed files with 18 additions and 1 deletions
|
@ -144,7 +144,8 @@ export const useWebhooks = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useMerchantInfo = () => {
|
export const useMerchantInfo = () => {
|
||||||
const { isReady, merchant, features } = useHooks();
|
const { isReady, features } = useHooks();
|
||||||
|
const merchant = useMerchant();
|
||||||
const { refreshMerchantData } = useDispatch( STORE_NAME );
|
const { refreshMerchantData } = useDispatch( STORE_NAME );
|
||||||
|
|
||||||
const verifyLoginStatus = useCallback( async () => {
|
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 = () => {
|
export const useActiveModal = () => {
|
||||||
const { activeModal, setActiveModal } = useHooks();
|
const { activeModal, setActiveModal } = useHooks();
|
||||||
return { activeModal, setActiveModal };
|
return { activeModal, setActiveModal };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue