Provide new hook with sanitized merchant data

This commit is contained in:
Philipp Stracker 2025-02-10 18:53:42 +01:00
parent c0bbd2a6f8
commit acdf109ca8
No known key found for this signature in database

View file

@ -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 };