diff --git a/plugins/woocommerce-blocks/assets/js/extensions/shipping-methods/pickup-location/edit-location/form.tsx b/plugins/woocommerce-blocks/assets/js/extensions/shipping-methods/pickup-location/edit-location/form.tsx index 4fe9675e286..4df31be4c05 100644 --- a/plugins/woocommerce-blocks/assets/js/extensions/shipping-methods/pickup-location/edit-location/form.tsx +++ b/plugins/woocommerce-blocks/assets/js/extensions/shipping-methods/pickup-location/edit-location/form.tsx @@ -3,13 +3,12 @@ */ import { __ } from '@wordpress/i18n'; import { SelectControl, TextControl } from '@wordpress/components'; -import { getSetting } from '@woocommerce/settings'; /** * Internal dependencies */ import type { PickupLocation } from '../types'; -import StateControl from './state-control'; +import { countryStateOptions, states } from '../utils'; const Form = ( { formRef, @@ -20,11 +19,7 @@ const Form = ( { values: PickupLocation; setValues: React.Dispatch< React.SetStateAction< PickupLocation > >; } ) => { - const countries = getSetting< Record< string, string > >( 'countries', [] ); - const states = getSetting< Record< string, Record< string, string > > >( - 'countryStates', - [] - ); + const { country: selectedCountry, state: selectedState } = values.address; const setLocationField = ( field: keyof PickupLocation ) => ( newValue: string | boolean ) => { setValues( ( prevValue: PickupLocation ) => ( { @@ -45,6 +40,10 @@ const Form = ( { } ) ); }; + const countryHasStates = + states[ selectedCountry ] && + Object.keys( states[ selectedCountry ] ).length > 0; + return (