From 7b95cb5ad63d31a2a6ee6428e98e49748024c9c9 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Tue, 19 May 2020 15:28:44 +0100 Subject: [PATCH] fix: only set the postcode when it's not an empty string --- src/forms/elements/FieldDnbCompany.jsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/forms/elements/FieldDnbCompany.jsx b/src/forms/elements/FieldDnbCompany.jsx index 07e9a41e..786a4809 100644 --- a/src/forms/elements/FieldDnbCompany.jsx +++ b/src/forms/elements/FieldDnbCompany.jsx @@ -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' @@ -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 }