mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
New Settings UI: Map storeCountry and currency to WooCommerce settings
This commit is contained in:
parent
4484386e49
commit
a06a74004c
11 changed files with 97 additions and 22 deletions
|
@ -43,6 +43,7 @@ const useHooks = () => {
|
|||
const clientSecret = usePersistent( 'clientSecret' );
|
||||
const isSandboxMode = usePersistent( 'useSandbox' );
|
||||
const isManualConnectionMode = usePersistent( 'useManualConnection' );
|
||||
const flags = usePersistent( 'flags' );
|
||||
|
||||
const savePersistent = async ( setter, value ) => {
|
||||
setter( value );
|
||||
|
@ -69,6 +70,7 @@ const useHooks = () => {
|
|||
},
|
||||
connectViaSandbox,
|
||||
connectViaIdAndSecret,
|
||||
flags,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -109,3 +111,9 @@ export const useManualConnection = () => {
|
|||
connectViaIdAndSecret,
|
||||
};
|
||||
};
|
||||
|
||||
export const useWooSettings = () => {
|
||||
const { flags = {} } = useHooks();
|
||||
const { country, currency } = flags;
|
||||
return { storeCountry: country, storeCurrency: currency };
|
||||
};
|
||||
|
|
|
@ -22,6 +22,10 @@ const defaultPersistent = {
|
|||
useManualConnection: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
flags: {
|
||||
country: '',
|
||||
currency: '',
|
||||
},
|
||||
};
|
||||
|
||||
// Reducer logic.
|
||||
|
@ -39,7 +43,10 @@ const commonReducer = createReducer( defaultTransient, defaultPersistent, {
|
|||
setPersistent( state, action ),
|
||||
|
||||
[ ACTION_TYPES.HYDRATE ]: ( state, payload ) =>
|
||||
setPersistent( state, payload.data ),
|
||||
setPersistent( state, {
|
||||
...payload.data,
|
||||
flags: payload.flags,
|
||||
} ),
|
||||
} );
|
||||
|
||||
export default commonReducer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue