File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
static/gsApp/components/billingDetails Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -194,13 +194,7 @@ function BillingDetailsForm({
194
194
} ;
195
195
196
196
useEffect ( ( ) => {
197
- const requiredFields = [
198
- 'addressLine1' ,
199
- 'city' ,
200
- 'region' ,
201
- 'countryCode' ,
202
- 'postalCode' ,
203
- ] ;
197
+ const requiredFields = [ 'addressLine1' , 'city' , 'countryCode' ] ;
204
198
requiredFields . forEach ( field => {
205
199
form . setFieldDescriptor ( field , {
206
200
required : true ,
@@ -214,6 +208,18 @@ function BillingDetailsForm({
214
208
} ;
215
209
} , [ form ] ) ;
216
210
211
+ useEffect ( ( ) => {
212
+ if ( countryHasRegionChoices ( state . countryCode ) ) {
213
+ form . setFieldDescriptor ( 'region' , { required : true } ) ;
214
+ } else {
215
+ form . setFieldDescriptor ( 'region' , { required : false } ) ;
216
+ }
217
+
218
+ return ( ) => {
219
+ form . removeField ( 'region' ) ;
220
+ } ;
221
+ } , [ state . countryCode , form ] ) ;
222
+
217
223
if ( ! organization . access . includes ( 'org:billing' ) ) {
218
224
return null ;
219
225
}
You can’t perform that action at this time.
0 commit comments