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

Commit

Permalink
Merge pull request #300 from uktrade/searching-companies-by-postcode
Browse files Browse the repository at this point in the history
fix: Search DnB companies - only set the postcode if it's defined
  • Loading branch information
paulgain authored May 20, 2020
2 parents a427140 + 7b95cb5 commit 653c5d3
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 653c5d3

Please sign in to comment.