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:
Albert Juhé Lluveras 2020-03-24 11:28:19 +01:00 committed by GitHub
parent 2ba75fdc25
commit c7e20c29d9
2 changed files with 11 additions and 5 deletions

View File

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

View File

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