/** * External dependencies */ 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'; const Form = ( { formRef, values, setValues, }: { formRef: React.RefObject< HTMLFormElement >; 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 setLocationField = ( field: keyof PickupLocation ) => ( newValue: string | boolean ) => { setValues( ( prevValue: PickupLocation ) => ( { ...prevValue, [ field ]: newValue, } ) ); }; const setLocationAddressField = ( field: keyof PickupLocation[ 'address' ] ) => ( newValue: string | boolean ) => { setValues( ( prevValue ) => ( { ...prevValue, address: { ...prevValue.address, [ field ]: newValue, }, } ) ); }; return (
); }; export default Form;