Skip to content

Commit

Permalink
Refactor AddressFields component to spread props correctly for child …
Browse files Browse the repository at this point in the history
…components (GCOM-1543)
  • Loading branch information
carlocarels90 committed Dec 20, 2024
1 parent 67bc2a1 commit 85037b7
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ export function AddressFields<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>(props: PluginProps<AddressFieldsProps<TFieldValues, TName>>) {
const { Prev } = props
const { Prev, ...rest } = props
const { control, name } = useAddressFieldsForm(props)
const country = useWatch({ control, name: name.countryCode })

return (
<>
{country === 'NL' ? (
<>
<AddressCountryRegion {...props} />
<AddressCountryRegion {...rest} />
<FormRow>
<AddressPostcode {...props} />
<AddressHousenumber {...props} />
<AddressAddition {...props} />
<AddressPostcode {...rest} />
<AddressHousenumber {...rest} />
<AddressAddition {...rest} />
</FormRow>
<FormRow>
<AddressStreet {...props} />
<AddressCity {...props} />
<AddressStreet {...rest} />
<AddressCity {...rest} />
</FormRow>
<PostcodeNLAutoFill {...props} />
<PostcodeNLAutoFill {...rest} />
</>
) : (
<Prev countryFirst {...props} />
<Prev countryFirst {...rest} />
)}
</>
)
Expand Down

0 comments on commit 85037b7

Please sign in to comment.