New Settings UI: Map storeCountry and currency to WooCommerce settings

This commit is contained in:
Himad M 2024-12-02 18:15:07 -04:00
parent 4484386e49
commit a06a74004c
No known key found for this signature in database
GPG key ID: 5FC769E9888A7B98
11 changed files with 97 additions and 22 deletions

View file

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

View file

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