Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
fix: only set the postcode when it's not an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgain committed May 20, 2020
1 parent a427140 commit 7b95cb5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/forms/elements/FieldDnbCompany.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import { isEmpty } from 'lodash'
import { isEmpty, omitBy } from 'lodash'
import styled from 'styled-components'

import { WIDTHS, SPACING } from '@govuk-react/constants'
Expand Down Expand Up @@ -66,11 +66,16 @@ const FieldDnbCompany = ({
e.preventDefault()
const noValidationErrors = isEmpty(validateForm())
if (noValidationErrors) {
return onEntitySearch({
...queryParams,
search_term: values.dnbCompanyName,
postal_code: values.dnbPostalCode,
})
return onEntitySearch(
omitBy(
{
...queryParams,
search_term: values.dnbCompanyName,
postal_code: values.dnbPostalCode,
},
isEmpty
)
)
}
return null
}
Expand Down

0 comments on commit 7b95cb5

Please sign in to comment.