Decode address entities in shipping calculator (https://github.com/woocommerce/woocommerce-blocks/pull/2009)
* Fix wrong optional label for city * Decode all address entities in shipping calculator * Move decodeEntities to useShippingRates * Move decodeEntities to useShippingAddress
This commit is contained in:
parent
2ba75fdc25
commit
c7e20c29d9
|
@ -87,10 +87,7 @@ const AddressFields = {
|
|||
},
|
||||
city: {
|
||||
label: __( 'City', 'woo-gutenberg-products-block' ),
|
||||
optionalLabel: __(
|
||||
'Apartment, suite, etc. (optional)',
|
||||
'woo-gutenberg-products-block'
|
||||
),
|
||||
optionalLabel: __( 'City (optional)', 'woo-gutenberg-products-block' ),
|
||||
autocomplete: 'address-level2',
|
||||
required: true,
|
||||
hidden: false,
|
||||
|
|
|
@ -6,6 +6,7 @@ import { useEffect, useState } from '@wordpress/element';
|
|||
import isShallowEqual from '@wordpress/is-shallow-equal';
|
||||
import { useDebounce } from 'use-debounce';
|
||||
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
|
||||
import { decodeEntities } from '@wordpress/html-entities';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
|
@ -39,8 +40,16 @@ export const useShippingAddress = () => {
|
|||
);
|
||||
}
|
||||
}, [ debouncedShippingAddress ] );
|
||||
|
||||
const decodedShippingAddress = {};
|
||||
Object.keys( shippingAddress ).forEach( ( key ) => {
|
||||
decodedShippingAddress[ key ] = decodeEntities(
|
||||
shippingAddress[ key ]
|
||||
);
|
||||
} );
|
||||
|
||||
return {
|
||||
shippingAddress,
|
||||
shippingAddress: decodedShippingAddress,
|
||||
setShippingAddress,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue