mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
✨ New Redux properties for manual connection data
This commit is contained in:
parent
d4fbde1b13
commit
ac68aa7968
3 changed files with 52 additions and 0 deletions
|
@ -47,6 +47,28 @@ export const setIsReady = ( isReady ) => ( {
|
||||||
payload: { isReady },
|
payload: { isReady },
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transient. Sets the "manualClientId" value.
|
||||||
|
*
|
||||||
|
* @param {string} manualClientId
|
||||||
|
* @return {Action} The action.
|
||||||
|
*/
|
||||||
|
export const setManualClientId = ( manualClientId ) => ( {
|
||||||
|
type: ACTION_TYPES.SET_TRANSIENT,
|
||||||
|
payload: { manualClientId },
|
||||||
|
} );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transient. Sets the "manualClientSecret" value.
|
||||||
|
*
|
||||||
|
* @param {string} manualClientSecret
|
||||||
|
* @return {Action} The action.
|
||||||
|
*/
|
||||||
|
export const setManualClientSecret = ( manualClientSecret ) => ( {
|
||||||
|
type: ACTION_TYPES.SET_TRANSIENT,
|
||||||
|
payload: { manualClientSecret },
|
||||||
|
} );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persistent.Set the "onboarding completed" flag which shows or hides the wizard.
|
* Persistent.Set the "onboarding completed" flag which shows or hides the wizard.
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,6 +30,8 @@ const useHooks = () => {
|
||||||
setStep,
|
setStep,
|
||||||
setCompleted,
|
setCompleted,
|
||||||
setIsCasualSeller,
|
setIsCasualSeller,
|
||||||
|
setManualClientId,
|
||||||
|
setManualClientSecret,
|
||||||
setAreOptionalPaymentMethodsEnabled,
|
setAreOptionalPaymentMethodsEnabled,
|
||||||
setProducts,
|
setProducts,
|
||||||
} = useDispatch( STORE_NAME );
|
} = useDispatch( STORE_NAME );
|
||||||
|
@ -43,6 +45,8 @@ const useHooks = () => {
|
||||||
|
|
||||||
// Transient accessors.
|
// Transient accessors.
|
||||||
const isReady = useTransient( 'isReady' );
|
const isReady = useTransient( 'isReady' );
|
||||||
|
const manualClientId = useTransient( 'manualClientId' );
|
||||||
|
const manualClientSecret = useTransient( 'manualClientSecret' );
|
||||||
|
|
||||||
// Persistent accessors.
|
// Persistent accessors.
|
||||||
const step = usePersistent( 'step' );
|
const step = usePersistent( 'step' );
|
||||||
|
@ -73,6 +77,14 @@ const useHooks = () => {
|
||||||
setIsCasualSeller: ( value ) => {
|
setIsCasualSeller: ( value ) => {
|
||||||
return savePersistent( setIsCasualSeller, value );
|
return savePersistent( setIsCasualSeller, value );
|
||||||
},
|
},
|
||||||
|
manualClientId,
|
||||||
|
setManualClientId: ( value ) => {
|
||||||
|
return savePersistent( setManualClientId, value );
|
||||||
|
},
|
||||||
|
manualClientSecret,
|
||||||
|
setManualClientSecret: ( value ) => {
|
||||||
|
return savePersistent( setManualClientSecret, value );
|
||||||
|
},
|
||||||
areOptionalPaymentMethodsEnabled,
|
areOptionalPaymentMethodsEnabled,
|
||||||
setAreOptionalPaymentMethodsEnabled: ( value ) => {
|
setAreOptionalPaymentMethodsEnabled: ( value ) => {
|
||||||
return savePersistent( setAreOptionalPaymentMethodsEnabled, value );
|
return savePersistent( setAreOptionalPaymentMethodsEnabled, value );
|
||||||
|
@ -88,6 +100,22 @@ const useHooks = () => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useManualConnectionForm = () => {
|
||||||
|
const {
|
||||||
|
manualClientId,
|
||||||
|
setManualClientId,
|
||||||
|
manualClientSecret,
|
||||||
|
setManualClientSecret,
|
||||||
|
} = useHooks();
|
||||||
|
|
||||||
|
return {
|
||||||
|
manualClientId,
|
||||||
|
setManualClientId,
|
||||||
|
manualClientSecret,
|
||||||
|
setManualClientSecret,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const useBusiness = () => {
|
export const useBusiness = () => {
|
||||||
const { isCasualSeller, setIsCasualSeller } = useHooks();
|
const { isCasualSeller, setIsCasualSeller } = useHooks();
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import ACTION_TYPES from './action-types';
|
||||||
|
|
||||||
const defaultTransient = Object.freeze( {
|
const defaultTransient = Object.freeze( {
|
||||||
isReady: false,
|
isReady: false,
|
||||||
|
manualClientId: '',
|
||||||
|
manualClientSecret: '',
|
||||||
|
|
||||||
// Read only values, provided by the server.
|
// Read only values, provided by the server.
|
||||||
flags: Object.freeze( {
|
flags: Object.freeze( {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue