diff --git a/src/apps/companies/apps/add-company/client/CompanySearchStep.jsx b/src/apps/companies/apps/add-company/client/CompanySearchStep.jsx index efb24638e57..85e2e046bd9 100644 --- a/src/apps/companies/apps/add-company/client/CompanySearchStep.jsx +++ b/src/apps/companies/apps/add-company/client/CompanySearchStep.jsx @@ -88,8 +88,8 @@ function CompanySearchStep({ } CompanySearchStep.propTypes = { - countryName: PropTypes.string.isRequired, - countryIsoCode: PropTypes.string.isRequired, + countryName: PropTypes.string, + countryIsoCode: PropTypes.string, csrfToken: PropTypes.string.isRequired, } diff --git a/src/apps/companies/apps/business-details/client/SectionAbout.jsx b/src/apps/companies/apps/business-details/client/SectionAbout.jsx index 5e33778bf78..d442f0bbb60 100644 --- a/src/apps/companies/apps/business-details/client/SectionAbout.jsx +++ b/src/apps/companies/apps/business-details/client/SectionAbout.jsx @@ -36,7 +36,11 @@ const SectionAbout = ({ company, isDnbCompany, isArchived }) => ( caption={`About ${company.name}`} data-test="aboutDetailsContainer" actions={ - !isArchived && Edit + !isArchived && ( + + Edit + + ) } > diff --git a/src/apps/companies/apps/business-details/client/SectionAddresses.jsx b/src/apps/companies/apps/business-details/client/SectionAddresses.jsx index 011724bd742..de633a1cdac 100644 --- a/src/apps/companies/apps/business-details/client/SectionAddresses.jsx +++ b/src/apps/companies/apps/business-details/client/SectionAddresses.jsx @@ -54,7 +54,10 @@ const SectionAddresses = ({ company, isDnbCompany, isArchived }) => { actions={ !isDnbCompany && !isArchived && ( - + Edit ) diff --git a/src/apps/companies/apps/business-details/client/SectionHierarchy.jsx b/src/apps/companies/apps/business-details/client/SectionHierarchy.jsx index 85af6764d2d..55e320d746c 100644 --- a/src/apps/companies/apps/business-details/client/SectionHierarchy.jsx +++ b/src/apps/companies/apps/business-details/client/SectionHierarchy.jsx @@ -210,7 +210,10 @@ const SectionHierarchy = ({ actions={ !isArchived && showDataHubHierarchy && ( - + Edit ) diff --git a/src/apps/companies/apps/business-details/client/SectionOneList.jsx b/src/apps/companies/apps/business-details/client/SectionOneList.jsx index ed4291e01a0..a88c148ee71 100644 --- a/src/apps/companies/apps/business-details/client/SectionOneList.jsx +++ b/src/apps/companies/apps/business-details/client/SectionOneList.jsx @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import React from 'react' import PropTypes from 'prop-types' import Link from '@govuk-react/link' @@ -20,8 +21,8 @@ const getLocation = (manager) => { return manager.ditTeam.ukRegion ? manager.ditTeam.ukRegion.name : manager.ditTeam.country - ? manager.ditTeam.country.name - : '-' + ? manager.ditTeam.country.name + : '-' } const SectionOneList = ({ company, isArchived, isDnbCompany }) => @@ -33,7 +34,9 @@ const SectionOneList = ({ company, isArchived, isDnbCompany }) => actions={ !isArchived && !isDnbCompany && ( - Edit + + Edit + ) } > diff --git a/src/apps/companies/apps/business-details/client/SectionRegion.jsx b/src/apps/companies/apps/business-details/client/SectionRegion.jsx index 8fd9b0f6eab..8cb70a2031f 100644 --- a/src/apps/companies/apps/business-details/client/SectionRegion.jsx +++ b/src/apps/companies/apps/business-details/client/SectionRegion.jsx @@ -12,7 +12,10 @@ const SectionRegion = ({ company, isArchived }) => data-test="regionDetailsContainer" actions={ !isArchived && ( - + Edit ) diff --git a/src/apps/companies/apps/business-details/client/SectionSector.jsx b/src/apps/companies/apps/business-details/client/SectionSector.jsx index bbcd054570e..768b57d1428 100644 --- a/src/apps/companies/apps/business-details/client/SectionSector.jsx +++ b/src/apps/companies/apps/business-details/client/SectionSector.jsx @@ -11,7 +11,12 @@ const SectionSector = ({ company, isArchived }) => ( data-test="sectorDetailsContainer" actions={ !isArchived && ( - Edit + + Edit + ) } > diff --git a/src/apps/companies/apps/company-overview/overview-table-cards/AccountManagementCard.jsx b/src/apps/companies/apps/company-overview/overview-table-cards/AccountManagementCard.jsx index d7a90ab8bf6..98881c50285 100644 --- a/src/apps/companies/apps/company-overview/overview-table-cards/AccountManagementCard.jsx +++ b/src/apps/companies/apps/company-overview/overview-table-cards/AccountManagementCard.jsx @@ -94,8 +94,8 @@ const AccountManagementCard = ({ company }) => { {buildCellContents( viewablePrimaryContacts.length > 0, - {viewablePrimaryContacts.map((contact) => ( - + {viewablePrimaryContacts.map((contact, index) => ( + ( const ActiveInvestmentList = ({ upcomingActiveInvestments, companyId }) => upcomingActiveInvestments.map((activeInvestment) => ( - <> + @@ -175,7 +175,7 @@ const ActiveInvestmentList = ({ upcomingActiveInvestments, companyId }) => )} - > + )) const ActiveInvestmentProjectsCard = ({ diff --git a/src/apps/companies/apps/company-overview/overview-table-cards/ActivityCard.jsx b/src/apps/companies/apps/company-overview/overview-table-cards/ActivityCard.jsx index 89889bf46df..73bd6dd3798 100644 --- a/src/apps/companies/apps/company-overview/overview-table-cards/ActivityCard.jsx +++ b/src/apps/companies/apps/company-overview/overview-table-cards/ActivityCard.jsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Fragment } from 'react' import { Link } from 'govuk-react' import PropTypes from 'prop-types' import camelCase from 'camelcase' @@ -31,47 +31,43 @@ const ActivityCard = (props) => { const feedTypeText = camelCase(feedType, { pascalCase: true }) return ( - - - {feedTypeText} activity - - Add interaction - - > - } - data-test={`${feedTypeText} activityCardContainer`} - > - - - - - - - - - View all activities - - - - - + + {feedTypeText} activity + + Add interaction + + + } + data-test={`${feedTypeText} activityCardContainer`} + > + + + + + + + + + View all activities + + + + ) } diff --git a/src/apps/companies/apps/exports/client/ExportsIndex.jsx b/src/apps/companies/apps/exports/client/ExportsIndex.jsx index 7d5aa097d0d..a3b88a9b43e 100644 --- a/src/apps/companies/apps/exports/client/ExportsIndex.jsx +++ b/src/apps/companies/apps/exports/client/ExportsIndex.jsx @@ -38,7 +38,12 @@ const ExportsIndex = ({ companyId, returnUrl }) => { caption="Exports" actions={ !company.archived && ( - Edit + + Edit + ) } > @@ -87,8 +92,8 @@ const ExportsIndex = ({ companyId, returnUrl }) => { repeatedly tested their model against a subset of known-good data to improve it. The scores are as follows: - {Object.values(exportPotentialLabels).map((category) => ( - + {Object.values(exportPotentialLabels).map((category, index) => ( + {category.text} - {category.description} ))} @@ -106,6 +111,7 @@ const ExportsIndex = ({ companyId, returnUrl }) => { Edit diff --git a/src/apps/interactions/apps/details-form/client/InteractionDetailsForm.jsx b/src/apps/interactions/apps/details-form/client/InteractionDetailsForm.jsx index 85b17d97c0d..f9e52c012b1 100644 --- a/src/apps/interactions/apps/details-form/client/InteractionDetailsForm.jsx +++ b/src/apps/interactions/apps/details-form/client/InteractionDetailsForm.jsx @@ -194,7 +194,6 @@ InteractionDetailsForm.propTypes = { contactId: PropTypes.string, interactionId: PropTypes.string, user: PropTypes.object, - ...StepInteractionDetails.propTypes, } export default connect(({ values, ...state }) => ({ diff --git a/src/client/components/ActivityFeed/CollectionList/filters.js b/src/client/components/ActivityFeed/CollectionList/filters.js index e724cacc335..e09532a1d15 100644 --- a/src/client/components/ActivityFeed/CollectionList/filters.js +++ b/src/client/components/ActivityFeed/CollectionList/filters.js @@ -26,7 +26,7 @@ export const buildSelectedFilters = ( })), }, createdByOthers: { - queryParams: 'createdByOthers', + queryParam: 'createdByOthers', options: buildOptionsFilter({ options: [ { diff --git a/src/client/components/ActivityFeed/activities/card/item-renderers/ActivityOverviewSummary.jsx b/src/client/components/ActivityFeed/activities/card/item-renderers/ActivityOverviewSummary.jsx index 9a89b61f28c..ffc6aae0265 100644 --- a/src/client/components/ActivityFeed/activities/card/item-renderers/ActivityOverviewSummary.jsx +++ b/src/client/components/ActivityFeed/activities/card/item-renderers/ActivityOverviewSummary.jsx @@ -10,7 +10,10 @@ export default class ActivityOverviewSummary extends React.PureComponent { date: PropTypes.string, kind: PropTypes.string, subject: PropTypes.node, - summary: PropTypes.string, + summary: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.arrayOf(PropTypes.any), + ]), } render() { diff --git a/src/client/components/CollectionList/CollectionItem.jsx b/src/client/components/CollectionList/CollectionItem.jsx index 7bbbc9160fc..1fa82ec0bd2 100644 --- a/src/client/components/CollectionList/CollectionItem.jsx +++ b/src/client/components/CollectionList/CollectionItem.jsx @@ -138,7 +138,7 @@ const CollectionItem = ({ CollectionItem.propTypes = { headingUrl: PropTypes.string, headingText: PropTypes.string.isRequired, - subheading: PropTypes.string, + subheading: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), badges: PropTypes.arrayOf( PropTypes.shape({ text: PropTypes.string, diff --git a/src/client/components/CollectionList/index.jsx b/src/client/components/CollectionList/index.jsx index 648c3d00a1b..d2161ad712e 100644 --- a/src/client/components/CollectionList/index.jsx +++ b/src/client/components/CollectionList/index.jsx @@ -142,7 +142,7 @@ CollectionList.propTypes = { }), maxItemsToPaginate: PropTypes.number, maxItemsToDownload: PropTypes.number, - onPageClick: PropTypes.func.isRequired, + onPageClick: PropTypes.func, addItemUrl: PropTypes.string, metadataRenderer: PropTypes.func, footerRenderer: PropTypes.func, diff --git a/src/client/components/CompanyTabbedLocalNavigation/CompanyInvestmentTab.jsx b/src/client/components/CompanyTabbedLocalNavigation/CompanyInvestmentTab.jsx index ba6b63f2265..a1512c023dc 100644 --- a/src/client/components/CompanyTabbedLocalNavigation/CompanyInvestmentTab.jsx +++ b/src/client/components/CompanyTabbedLocalNavigation/CompanyInvestmentTab.jsx @@ -66,9 +66,9 @@ const investmentNavItems = (companyId, isLCP) => [ }, ] -const CompanyInvestmentTab = ({ navItem, index }) => +const CompanyInvestmentTab = ({ navItem }) => navItem && ( - + ( > {investmentNavItems(companyId, isLCP).map((t, index) => ( - + ))} diff --git a/src/client/components/EntityList/EntityListItem.jsx b/src/client/components/EntityList/EntityListItem.jsx index cae2b133d78..71edb0e0f6f 100644 --- a/src/client/components/EntityList/EntityListItem.jsx +++ b/src/client/components/EntityList/EntityListItem.jsx @@ -64,8 +64,8 @@ const EntityListItem = ({ id, onEntityClick, data, text, heading, meta }) => { return ( isClickable && onEntityClick(data)} onKeyDown={(e) => isClickable && e.keyCode === KEY_ENTER && onEntityClick(data) diff --git a/src/client/components/FilteredCollectionList/index.jsx b/src/client/components/FilteredCollectionList/index.jsx index fe18ab9d834..55d0621d509 100644 --- a/src/client/components/FilteredCollectionList/index.jsx +++ b/src/client/components/FilteredCollectionList/index.jsx @@ -1,9 +1,9 @@ /* eslint-disable react/no-array-index-key */ // this is because there isn't necessarily a unique id to use as the key -import React from 'react' +import React, { useEffect } from 'react' import PropTypes from 'prop-types' -import { Route } from 'react-router-dom' +import { Route, useHistory, useLocation } from 'react-router-dom' import { GridRow, GridCol } from 'govuk-react' import { isEmpty } from 'lodash' import qs from 'qs' @@ -93,21 +93,28 @@ const FilteredCollectionList = ({ useReactRouter = false, collectionItemTemplate = collectionItemTemplateDefault, }) => { + const history = useHistory() + const location = useLocation() + const totalPages = Math.ceil( Math.min(count, maxItemsToPaginate) / itemsPerPage ) + const qsParams = qs.parse(location.search.slice(1)) + + useEffect(() => { + if (defaultQueryParams && isEmpty(qsParams)) { + history.push({ + search: qs.stringify({ + ...defaultQueryParams, + }), + }) + } + }, []) + return ( - {({ history, location }) => { - const qsParams = qs.parse(location.search.slice(1)) + {() => { const initialPage = getPageNumber(qsParams) - if (defaultQueryParams && isEmpty(qsParams)) { - history.push({ - search: qs.stringify({ - ...defaultQueryParams, - }), - }) - } return ( {children} @@ -144,8 +151,8 @@ const FilteredCollectionList = ({ {() => isComplete && ( - {results.map((item) => ( - + {results.map((item, index) => ( + {(pushAnalytics) => collectionItemTemplate( item, diff --git a/src/client/components/Form/elements/FieldAdvisersTypeahead/index.jsx b/src/client/components/Form/elements/FieldAdvisersTypeahead/index.jsx index 8a3f05a282c..707cee40c90 100644 --- a/src/client/components/Form/elements/FieldAdvisersTypeahead/index.jsx +++ b/src/client/components/Form/elements/FieldAdvisersTypeahead/index.jsx @@ -47,5 +47,7 @@ FieldAdvisersTypeahead.propTypes = { isMulti: PropTypes.bool, placeholder: PropTypes.string, } - +FieldAdvisersTypeahead.defaultProps = { + label: '', +} export default FieldAdvisersTypeahead diff --git a/src/client/components/Form/elements/FieldCheckboxes/index.jsx b/src/client/components/Form/elements/FieldCheckboxes/index.jsx index 087dd0402c8..297c3447604 100644 --- a/src/client/components/Form/elements/FieldCheckboxes/index.jsx +++ b/src/client/components/Form/elements/FieldCheckboxes/index.jsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Fragment } from 'react' import PropTypes from 'prop-types' import MultiChoice from '@govuk-react/multi-choice' import styled from 'styled-components' @@ -96,12 +96,11 @@ const FieldCheckboxes = ({ }, index ) => ( - <> + {exclusive && index === options.length - 1 && ( or )} {value.includes(optionValue) && !!children ? children : null} - > + ) )} diff --git a/src/client/components/Form/elements/FieldCurrency/index.jsx b/src/client/components/Form/elements/FieldCurrency/index.jsx index 93789a66b02..8f54ae4d77a 100644 --- a/src/client/components/Form/elements/FieldCurrency/index.jsx +++ b/src/client/components/Form/elements/FieldCurrency/index.jsx @@ -98,8 +98,8 @@ const FieldCurrency = ({ initialValue, }) - const [displayValue, setDisplayValue] = useState() - const [rawValue, setRawValue] = useState() + const [displayValue, setDisplayValue] = useState('') + const [rawValue, setRawValue] = useState('') const [editing, setEditing] = useState(false) useEffect(() => { diff --git a/src/client/components/Form/elements/FieldUneditable/index.jsx b/src/client/components/Form/elements/FieldUneditable/index.jsx index 9e6d1ebdf52..eeab92c1eff 100644 --- a/src/client/components/Form/elements/FieldUneditable/index.jsx +++ b/src/client/components/Form/elements/FieldUneditable/index.jsx @@ -17,7 +17,7 @@ const FieldUneditable = ({ {children}{' '} {onChangeClick && ( - + Change {label || legend} )} diff --git a/src/client/components/Form/index.jsx b/src/client/components/Form/index.jsx index 3362277d81d..7cbd79fac43 100644 --- a/src/client/components/Form/index.jsx +++ b/src/client/components/Form/index.jsx @@ -571,7 +571,7 @@ Form.propTypes = { id: PropTypes.string.isRequired, analyticsFormName: PropTypes.string.isRequired, analyticsData: PropTypes.func, - cancelRedirectTo: PropTypes.func.isRequired, + cancelRedirectTo: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), cancelButtonLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), submissionTaskName: PropTypes.string.isRequired, submitButtonLabel: PropTypes.string, diff --git a/src/client/components/Layout/CompanyLayout.jsx b/src/client/components/Layout/CompanyLayout.jsx index 03f2d07b338..26566bb2eb4 100644 --- a/src/client/components/Layout/CompanyLayout.jsx +++ b/src/client/components/Layout/CompanyLayout.jsx @@ -36,7 +36,10 @@ const CompanyLayout = ({ CompanyLayout.propTypes = { company: PropTypes.object.isRequired, - children: PropTypes.element.isRequired, + children: PropTypes.oneOfType([ + PropTypes.element, + PropTypes.arrayOf(PropTypes.element), + ]).isRequired, isInvestment: PropTypes.bool, isLCP: PropTypes.bool, } diff --git a/src/client/components/Layout/ContactLayout.jsx b/src/client/components/Layout/ContactLayout.jsx index 41ae473df9f..56801eed8e1 100644 --- a/src/client/components/Layout/ContactLayout.jsx +++ b/src/client/components/Layout/ContactLayout.jsx @@ -62,7 +62,10 @@ const ContactLayout = ({ contact, flashMessages, permissions, children }) => { ContactLayout.propTypes = { contact: PropTypes.object.isRequired, permissions: PropTypes.array.isRequired, - children: PropTypes.element.isRequired, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.element), + PropTypes.element, + ]).isRequired, } export default ContactLayout diff --git a/src/client/components/Layout/DefaultLayout.jsx b/src/client/components/Layout/DefaultLayout.jsx index a6c6c3f028a..e7113cb1a5f 100644 --- a/src/client/components/Layout/DefaultLayout.jsx +++ b/src/client/components/Layout/DefaultLayout.jsx @@ -60,7 +60,7 @@ const DefaultLayout = ({ } DefaultLayout.propTypes = { - heading: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, + heading: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), headingLink: PropTypes.shape({ url: PropTypes.string.isRequired, text: PropTypes.string.isRequired, diff --git a/src/client/components/Layout/FormLayout.jsx b/src/client/components/Layout/FormLayout.jsx index 8f21d08815e..b6283a90664 100644 --- a/src/client/components/Layout/FormLayout.jsx +++ b/src/client/components/Layout/FormLayout.jsx @@ -10,8 +10,11 @@ const FormLayout = ({ setWidth, children }) => ( ) FormLayout.propTypes = { - setWidth: PropTypes.string, - children: PropTypes.element.isRequired, + setWidth: PropTypes.string.isRequired, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.element), + PropTypes.element, + ]).isRequired, } export default FormLayout diff --git a/src/client/components/Layout/ProjectLayout.jsx b/src/client/components/Layout/ProjectLayout.jsx index d54c586832c..cce2d6049dc 100644 --- a/src/client/components/Layout/ProjectLayout.jsx +++ b/src/client/components/Layout/ProjectLayout.jsx @@ -152,10 +152,13 @@ export const ProjectLayout = ({ ) ProjectLayout.propTypes = { - project: PropTypes.object.isRequired, + project: PropTypes.object, breadcrumbs: PropTypes.array.isRequired, pageTitle: PropTypes.string.isRequired, - children: PropTypes.array.isRequired, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.element), + PropTypes.element, + ]).isRequired, userPermissions: PropTypes.array.isRequired, flashMessages: PropTypes.shape({ type: PropTypes.oneOfType([ diff --git a/src/client/components/LocalNav/index.jsx b/src/client/components/LocalNav/index.jsx index 53e3bd27a31..d15b649bf5f 100644 --- a/src/client/components/LocalNav/index.jsx +++ b/src/client/components/LocalNav/index.jsx @@ -43,8 +43,8 @@ export const LocalNav = ({ children, dataTest = 'local-nav' }) => { return ( - {children.map((link) => ( - {link} + {children.map((link, index) => ( + {link} ))} diff --git a/src/client/components/NewWindowLink/index.jsx b/src/client/components/NewWindowLink/index.jsx index 84c8764827e..68c1c20ff33 100644 --- a/src/client/components/NewWindowLink/index.jsx +++ b/src/client/components/NewWindowLink/index.jsx @@ -37,7 +37,7 @@ const NewWindowLink = ({ href, children, showWarning = true, ...rest }) => ( NewWindowLink.propTypes = { href: PropTypes.string.isRequired, - children: PropTypes.node.isRequired, + children: PropTypes.node, showWarning: PropTypes.bool, } diff --git a/src/client/components/RoutedCheckboxGroupField/index.jsx b/src/client/components/RoutedCheckboxGroupField/index.jsx index 3c9b409c402..183f79ddd91 100644 --- a/src/client/components/RoutedCheckboxGroupField/index.jsx +++ b/src/client/components/RoutedCheckboxGroupField/index.jsx @@ -5,27 +5,34 @@ import qs from 'qs' import CheckboxGroupField from '../CheckboxGroupField' -const RoutedCheckboxGroupField = ({ qsParam, ...props }) => ( - - {({ history, location }) => { - const qsParams = qs.parse(location.search.slice(1)) - return ( - - history.push({ - search: qs.stringify({ - ...qsParams, - [qsParam]: pickedOptions.map(({ value }) => value), - page: 1, - }), - }) - } - /> - ) - }} - -) +const RoutedCheckboxGroupField = ({ qsParam, ...props }) => { + // Don't render component if there are no options. + if (props.options === undefined) { + return null + } + + return ( + + {({ history, location }) => { + const qsParams = qs.parse(location.search.slice(1)) + return ( + + history.push({ + search: qs.stringify({ + ...qsParams, + [qsParam]: pickedOptions.map(({ value }) => value), + page: 1, + }), + }) + } + /> + ) + }} + + ) +} RoutedCheckboxGroupField.propTypes = { name: PropTypes.string.isRequired, diff --git a/src/client/components/RoutedRelatedCompaniesCheckboxGroup/Filter.jsx b/src/client/components/RoutedRelatedCompaniesCheckboxGroup/Filter.jsx index de835b388ff..2dd4f1081a4 100644 --- a/src/client/components/RoutedRelatedCompaniesCheckboxGroup/Filter.jsx +++ b/src/client/components/RoutedRelatedCompaniesCheckboxGroup/Filter.jsx @@ -48,7 +48,7 @@ const RoutedRelatedCompaniesCheckboxGroup = ({ company, selectedOptions }) => ( } selectedOptions={selectedOptions} data-test="include-related-companies-filter" - aria-description={ + aria-describedby={ relatedCompaniesCountResponse.reducedTree ? SUBSIDIARIES_LIMITED_LABEL : undefined diff --git a/src/client/components/SkeletonPlaceholder/CollectionListPlaceholder.jsx b/src/client/components/SkeletonPlaceholder/CollectionListPlaceholder.jsx index d5d60dc6d28..c825e94af72 100644 --- a/src/client/components/SkeletonPlaceholder/CollectionListPlaceholder.jsx +++ b/src/client/components/SkeletonPlaceholder/CollectionListPlaceholder.jsx @@ -26,9 +26,10 @@ const collectionList = () => ( {Array.from(Array(listItems).keys()).map((i) => ( - + {Array.from(Array(listItemFields).keys()).map((j) => ( { {children .filter((c) => c) - .map((c) => ( - {c} + .map((c, index) => ( + {c} ))} ) @@ -122,7 +122,7 @@ SummaryTable.ListRow = ({ heading, value, emptyValue, ...rest }) => ( ) SummaryTable.propTypes = { - caption: PropTypes.string, + caption: PropTypes.oneOfType([PropTypes.string, PropTypes.element]), actions: PropTypes.node, children: PropTypes.node, } @@ -145,7 +145,11 @@ SummaryTable.Row.defaultProps = { SummaryTable.TextRow.propTypes = { heading: PropTypes.string, - value: PropTypes.string, + value: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.element, + PropTypes.arrayOf(PropTypes.element), + ]), } SummaryTable.TextRow.defaultProps = { diff --git a/src/client/components/Typeahead/index.jsx b/src/client/components/Typeahead/index.jsx index 1ea32487b80..10b20732db6 100644 --- a/src/client/components/Typeahead/index.jsx +++ b/src/client/components/Typeahead/index.jsx @@ -2,12 +2,14 @@ import React from 'react' import MultiInstanceTypeahead from './Typeahead' -const Typeahead = ({ id, name, ...props }) => ( - -) +const Typeahead = ({ id, name, ...props }) => { + return ( + + ) +} export default Typeahead diff --git a/src/client/modules/Companies/CoreTeam/CoreTeam.jsx b/src/client/modules/Companies/CoreTeam/CoreTeam.jsx index 6a827bf05e6..6dccd8e0370 100644 --- a/src/client/modules/Companies/CoreTeam/CoreTeam.jsx +++ b/src/client/modules/Companies/CoreTeam/CoreTeam.jsx @@ -19,7 +19,7 @@ const getSubheadingText = (company) => { const buildRow = (transformedAdvisers) => transformedAdvisers.map(({ team, location, name, email }) => ( - + {team} {location} {name} diff --git a/src/client/modules/Contacts/CollectionList/CompanyContactsCollection.jsx b/src/client/modules/Contacts/CollectionList/CompanyContactsCollection.jsx index 992258f605b..1d04ab20cf4 100644 --- a/src/client/modules/Contacts/CollectionList/CompanyContactsCollection.jsx +++ b/src/client/modules/Contacts/CollectionList/CompanyContactsCollection.jsx @@ -42,7 +42,7 @@ const CompanyContactsCollection = ({ breadcrumbs={[{ text: 'Contacts' }]} returnUrl={returnUrl} > - {company.archived && ( + {company.archived ? ( - )} + ) : null} ( <> - Audit history - - {contactAuditHistory.count > 0 && ( - + Audit history + - )} + {contactAuditHistory.count > 0 ? ( + + ) : null} - - + {}} + /> + + > > )} diff --git a/src/client/modules/Contacts/ContactDetails/ContactDetails.jsx b/src/client/modules/Contacts/ContactDetails/ContactDetails.jsx index 63141ddfc08..370267917c6 100644 --- a/src/client/modules/Contacts/ContactDetails/ContactDetails.jsx +++ b/src/client/modules/Contacts/ContactDetails/ContactDetails.jsx @@ -51,13 +51,13 @@ const ContactDetails = ({ contactId, companyAddress, permissions }) => ( {(contact) => ( <> - {contact.validEmail === false && ( + {contact.validEmail === false ? ( - )} + ) : null} ( children={contact.email} flag={contact.validEmail === false} /> - {contact.notes && ( + {contact.notes ? ( - )} + ) : null} ( } /> - {!contact.archived && ( + {!contact.archived ? ( ( > Edit Contact - )} + ) : null} { heading="Contact(s)" children={transformContacts(interaction.contacts)} /> - {interaction.service && ( + {interaction.service ? ( - )} - {interaction.serviceDeliveryStatus && ( + ) : null} + {interaction.serviceDeliveryStatus ? ( - )} - {interaction.grantAmountOffered && ( + ) : null} + {interaction.grantAmountOffered ? ( - )} - {interaction.netCompanyReceipt && ( + ) : null} + {interaction.netCompanyReceipt ? ( - )} - {interaction.notes && ( + ) : null} + {interaction.notes ? ( - )} + ) : null} - {interaction.ditParticipants && ( + {interaction.ditParticipants ? ( - )} - {interaction.investmentProject && ( + ) : null} + {interaction.investmentProject ? ( { } /> - )} - {interaction.kind === 'service_delivery' && ( + ) : null} + {interaction.kind === 'service_delivery' ? ( { ) } /> - )} - {interaction.communicationChannel && ( + ) : null} + {interaction.communicationChannel ? ( - )} - {interaction.policyFeedbackNotes && ( + ) : null} + {interaction.policyFeedbackNotes ? ( - )} + ) : null} {interaction.exportCountries?.length > 0 && transformExportCountries(interaction.exportCountries)} - {interaction.relatedTradeAgreements?.length > 0 && ( + {interaction.relatedTradeAgreements?.length > 0 ? ( - )} - {interaction.largeCapitalOpportunity && ( + ) : null} + {interaction.largeCapitalOpportunity ? ( { } /> - )} - {interaction.theme === EXPORT && ( + ) : null} + {interaction.theme === EXPORT ? ( <> { /> )} > - )} + ) : null} { If you think the information is incomplete or incorrect,{' '} - + get in touch using the support form. diff --git a/src/client/modules/Investments/Opportunities/Opportunity.jsx b/src/client/modules/Investments/Opportunities/Opportunity.jsx index 01465e35823..1ca5e611c82 100644 --- a/src/client/modules/Investments/Opportunities/Opportunity.jsx +++ b/src/client/modules/Investments/Opportunities/Opportunity.jsx @@ -95,7 +95,6 @@ const Opportunity = ({ opportunity }) => { } Opportunity.propTypes = { - opportunityId: PropTypes.string.isRequired, opportunity: PropTypes.object.isRequired, } diff --git a/src/client/modules/Investments/Opportunities/OpportunityDetailsHeader.jsx b/src/client/modules/Investments/Opportunities/OpportunityDetailsHeader.jsx index 205438a4538..0591aef2038 100644 --- a/src/client/modules/Investments/Opportunities/OpportunityDetailsHeader.jsx +++ b/src/client/modules/Investments/Opportunities/OpportunityDetailsHeader.jsx @@ -80,7 +80,7 @@ OpportunityDetailsHeader.propTypes = { ).isRequired, opportunityValue: PropTypes.shape({ label: PropTypes.string, - value: PropTypes.string, + value: PropTypes.number, }).isRequired, }), }), diff --git a/src/client/modules/Investments/Profiles/transformers.js b/src/client/modules/Investments/Profiles/transformers.js index 80ea9f3b2fc..3be9c68abea 100644 --- a/src/client/modules/Investments/Profiles/transformers.js +++ b/src/client/modules/Investments/Profiles/transformers.js @@ -6,7 +6,7 @@ const { format } = require('../../../utils/date') const transformLargeCapitalProfiles = ({ investor_company, created_on }) => ({ headingText: investor_company.name, headingUrl: companies.investments.largeCapitalProfile(investor_company.id), - itemId: investor_company.id, + id: investor_company.id, metadata: [ { label: 'Updated on', diff --git a/src/client/modules/Investments/Projects/Details/EditProjectRequirements.jsx b/src/client/modules/Investments/Projects/Details/EditProjectRequirements.jsx index a24c46c766c..27fea848a19 100644 --- a/src/client/modules/Investments/Projects/Details/EditProjectRequirements.jsx +++ b/src/client/modules/Investments/Projects/Details/EditProjectRequirements.jsx @@ -88,7 +88,7 @@ const EditProjectRequirements = () => { type="text" name="client_requirements" label="Client requirements" - initialValue={project.clientRequirements} + initialValue={project.clientRequirements || ''} /> { hideCountyField={true} useStaticPostcodeField={true} initialValue={{ - address1: project.address1, - address2: project.address2, - town: project.addressTown, - postcode: project.addressPostcode, + address1: project.address1 || '', + address2: project.address2 || '', + town: project.addressTown || '', + postcode: project.addressPostcode || '', }} /> { label="Other business activity (if not on list)" name="other_business_activity" type="text" - initialValue={project.otherBusinessActivity} + initialValue={project.otherBusinessActivity || ''} placeholder="e.g. meet and greet dinner" /> diff --git a/src/client/modules/Investments/Projects/Details/EditProjectValue.jsx b/src/client/modules/Investments/Projects/Details/EditProjectValue.jsx index b7c7acedde1..e4e8d1a690f 100644 --- a/src/client/modules/Investments/Projects/Details/EditProjectValue.jsx +++ b/src/client/modules/Investments/Projects/Details/EditProjectValue.jsx @@ -118,9 +118,11 @@ const EditProjectValue = () => { label="Gross value added (GVA)" name="gross_value_added" > - {project.grossValueAdded - ? currencyGBP(project.grossValueAdded) - : setGVAMessage(project)} + <> + {project.grossValueAdded + ? currencyGBP(project.grossValueAdded) + : setGVAMessage(project)} + > )} > diff --git a/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx b/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx index 7686cd5ec4f..1980109aa2d 100644 --- a/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx +++ b/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx @@ -68,7 +68,7 @@ const ProjectDetails = ({ currentAdviserId }) => { {(project) => ( @@ -131,6 +131,7 @@ const ProjectDetails = ({ currentAdviserId }) => { heading="Client contacts" value={project.clientContacts.map((contact, i) => ( @@ -139,54 +140,54 @@ const ProjectDetails = ({ currentAdviserId }) => { ))} /> )} - {project.description && ( + {project.description ? ( - )} - {project.anonymousDescription && ( + ) : null} + {project.anonymousDescription ? ( - )} - {project.estimatedLandDate && ( + ) : null} + {project.estimatedLandDate ? ( - )} - {project.likelihoodToLand && ( + ) : null} + {project.likelihoodToLand ? ( - )} - {project.actualLandDate && ( + ) : null} + {project.actualLandDate ? ( - )} - {project.investorType && ( + ) : null} + {project.investorType ? ( - )} - {project.levelOfInvolvement && ( + ) : null} + {project.levelOfInvolvement ? ( - )} - {project.specificProgramme && ( + ) : null} + {project.specificProgramme ? ( - )} + ) : null} { value={transformArray(project.strategicDrivers)} /> )} - {project.clientRequirements && ( + {project.clientRequirements ? ( - )} + ) : null} {project.competitorCountries && project.competitorCountries.length > 0 && ( { {project.grossValueAdded && ( )} {project.governmentAssistance != null && ( diff --git a/src/client/modules/Investments/Projects/Evidence/ProjectEvidence.jsx b/src/client/modules/Investments/Projects/Evidence/ProjectEvidence.jsx index b272ae5c0a2..9ac39ea0a27 100644 --- a/src/client/modules/Investments/Projects/Evidence/ProjectEvidence.jsx +++ b/src/client/modules/Investments/Projects/Evidence/ProjectEvidence.jsx @@ -37,7 +37,7 @@ const ProjectEvidence = () => { Evidence - {evidence.count > 0 && ( + {evidence.count > 0 ? ( @@ -48,11 +48,11 @@ const ProjectEvidence = () => { {evidence.results.map((document) => ( - + - {document.tags.map((tag, i) => ( - - {tag.name} + {document.tags.map((tag) => ( + + {tag.name} ))} @@ -96,7 +96,7 @@ const ProjectEvidence = () => { ))} - )} + ) : null} ( /> ) -export const FieldProjectName = ({ - initialValue = null, - placeholder = null, -}) => ( +export const FieldProjectName = ({ initialValue = '', placeholder = null }) => ( ) -export const FieldProjectDescription = ({ - initialValue = null, - hint = null, -}) => ( +export const FieldProjectDescription = ({ initialValue = '', hint = null }) => ( ) -export const FieldAnonDescription = ({ initialValue = null }) => ( +export const FieldAnonDescription = ({ initialValue = '' }) => ( ) @@ -236,7 +230,7 @@ export const FieldReferralSourceHierarchy = ({ label="Event" name="referral_source_activity_event" type="text" - initialValue={eventInitialValue} + initialValue={eventInitialValue || ''} placeholder={eventPlaceholder} required="Enter the event details" /> diff --git a/src/client/modules/Investments/Projects/ProjectInteractions.jsx b/src/client/modules/Investments/Projects/ProjectInteractions.jsx index d6c83824a26..34c1879e965 100644 --- a/src/client/modules/Investments/Projects/ProjectInteractions.jsx +++ b/src/client/modules/Investments/Projects/ProjectInteractions.jsx @@ -12,6 +12,8 @@ import { } from '../../../components/Resource' import urls from '../../../../lib/urls' import ProjectLayout from '../../../components/Layout/ProjectLayout' +import { INTERACTIONS__LOADED } from '../../../actions' +import { TASK_GET_INTERACTIONS_LIST } from '../../Interactions/CollectionList/state' const ProjectInteractions = () => { const history = useHistory() @@ -20,15 +22,25 @@ const ProjectInteractions = () => { const activePage = parseInt(parsedQueryString.page, 10) || 1 const { projectId } = useParams() + + const payload = { + investment_project_id: projectId, + limit: 10, + offset: activePage * 10 - 10, + sortby: parsedQueryString.sortby, + } + + const collectionListTask = { + name: TASK_GET_INTERACTIONS_LIST, + id: projectId, + progressMessage: 'Loading interactions', + startOnRender: { + payload: payload, + onSuccessDispatch: INTERACTIONS__LOADED, + }, + } return ( - + {(_, count, rawData) => { const interactions = rawData.results.map(transformInteractionToListItem) const sortOptions = [ @@ -74,6 +86,7 @@ const ProjectInteractions = () => { }), }) } + taskProps={collectionListTask} activePage={activePage} sortOptions={count ? sortOptions : null} addItemUrl={urls.investments.projects.interactions.createType( diff --git a/src/client/modules/Investments/Projects/Team/ProjectTeam.jsx b/src/client/modules/Investments/Projects/Team/ProjectTeam.jsx index 40146718518..135cc6217c5 100644 --- a/src/client/modules/Investments/Projects/Team/ProjectTeam.jsx +++ b/src/client/modules/Investments/Projects/Team/ProjectTeam.jsx @@ -111,7 +111,7 @@ const ProjectTeam = () => { project.projectAssuranceAdviser ) ? ( <> - + Role Adviser @@ -185,7 +185,7 @@ const ProjectTeam = () => { {project.teamMembers?.length > 0 ? ( <> - + Role Adviser @@ -194,7 +194,7 @@ const ProjectTeam = () => { {project.teamMembers.map((member) => { const adviserTeam = getTeamMemberTeam(member.adviser.id) return ( - + {member.role} {member.adviser.name} {adviserTeam} diff --git a/src/client/modules/Investments/Projects/transformers.js b/src/client/modules/Investments/Projects/transformers.js index 020726bf9da..ba5190b0931 100644 --- a/src/client/modules/Investments/Projects/transformers.js +++ b/src/client/modules/Investments/Projects/transformers.js @@ -48,7 +48,10 @@ export const transformObjectForTypeahead = (object) => label: object.name, value: object.id, } - : null + : { + label: '', + value: '', + } export const transformBoolToRadioOption = (boolean) => boolean ? OPTION_YES : OPTION_NO @@ -266,10 +269,12 @@ export const transformInvestmentProjectToListItem = ({ } const getTaskSubheading = (archived) => - archived && ( + archived ? ( COMPLETED + ) : ( + '' ) export const transformTaskToListItem = ({ diff --git a/src/client/modules/Omis/AssigneeTime.jsx b/src/client/modules/Omis/AssigneeTime.jsx index a04c74aa498..0cfe685c22c 100644 --- a/src/client/modules/Omis/AssigneeTime.jsx +++ b/src/client/modules/Omis/AssigneeTime.jsx @@ -22,9 +22,13 @@ const StyledLink = styled(Link)` margin-bottom: ${SPACING.SCALE_5}; ` +const getEstimatedTime = (estimatedTime) => { + return estimatedTime > 0 ? (estimatedTime / 60).toString() : '' +} + const buildRows = (assignees) => assignees.map(({ adviser, estimatedTime }, index) => ( - + {adviser.name} @@ -32,7 +36,7 @@ const buildRows = (assignees) => name={`${adviser.id}`} dataTest={`adviser-${index}`} type="text" - initialValue={estimatedTime > 0 ? estimatedTime / 60 : null} + initialValue={getEstimatedTime(estimatedTime)} validate={validateNumber} /> diff --git a/src/client/modules/Omis/CollectionList/CompanyOrdersCollection.jsx b/src/client/modules/Omis/CollectionList/CompanyOrdersCollection.jsx index c090649e002..aa84e93adc3 100644 --- a/src/client/modules/Omis/CollectionList/CompanyOrdersCollection.jsx +++ b/src/client/modules/Omis/CollectionList/CompanyOrdersCollection.jsx @@ -71,7 +71,7 @@ const CompanyOrdersCollection = ({ breadcrumbs={[{ text: 'Orders (OMIS)' }]} returnUrl={returnUrl} > - {company.archived && ( + {company.archived ? ( - )} + ) : null} assignees.map(({ adviser, estimatedTime }, index) => ( - + {adviser.name} {transformEstimatedTime(estimatedTime)} diff --git a/src/client/modules/Omis/CreateOrder/CreateOrder.jsx b/src/client/modules/Omis/CreateOrder/CreateOrder.jsx index 5f5676aa364..b84c1d6a718 100644 --- a/src/client/modules/Omis/CreateOrder/CreateOrder.jsx +++ b/src/client/modules/Omis/CreateOrder/CreateOrder.jsx @@ -41,7 +41,7 @@ const StyledInsetText = styled(InsetText)` ` export const CompanyDetails = ({ company }) => ( - + Company {company.name} @@ -62,7 +62,7 @@ export const CompanyDetails = ({ company }) => ( ) export const WhatHappensNext = ({ ukRegion }) => ( - + What happens next? diff --git a/src/client/modules/Omis/EditInvoiceDetails.jsx b/src/client/modules/Omis/EditInvoiceDetails.jsx index 3d776e227e9..bb708e2bcd8 100644 --- a/src/client/modules/Omis/EditInvoiceDetails.jsx +++ b/src/client/modules/Omis/EditInvoiceDetails.jsx @@ -35,7 +35,7 @@ export const BillingAddress = ({ company, order }) => { {transformedAddress.map((addressPart) => ( - {addressPart} + {addressPart} ))} @@ -98,7 +98,7 @@ export const FieldVATStatus = ({ order }) => ( Validate the EU VAT number } - initialValue={order ? order.vatNumber : null} + initialValue={order ? order.vatNumber : ''} validate={validateVATNumber} /> diff --git a/src/client/modules/Omis/OMISLocalHeader.jsx b/src/client/modules/Omis/OMISLocalHeader.jsx index ed21d4d9864..74bc8b05259 100644 --- a/src/client/modules/Omis/OMISLocalHeader.jsx +++ b/src/client/modules/Omis/OMISLocalHeader.jsx @@ -73,7 +73,7 @@ const setHeaderItems = (order, quote) => { return order.ukRegion ? secondItems.unshift({ label: 'UK region', - value: order.ukRegion?.name, + value: order.ukRegion?.name || '', }) && items.concat(secondItems) : items.concat(secondItems) } diff --git a/src/client/modules/Omis/WorkOrderTables/AssigneesTable.jsx b/src/client/modules/Omis/WorkOrderTables/AssigneesTable.jsx index eee9a5d050a..e2ddf69ef93 100644 --- a/src/client/modules/Omis/WorkOrderTables/AssigneesTable.jsx +++ b/src/client/modules/Omis/WorkOrderTables/AssigneesTable.jsx @@ -58,7 +58,7 @@ const calculateTotalEstimatedHours = (assignees) => { const buildAssigneeRows = (assignees, order) => assignees.map(({ adviser, estimatedTime, isLead }) => ( - + {setAssigneeNameText(adviser, isLead)} @@ -91,6 +91,7 @@ const AssigneesTable = ({ assignees, order }) => ( [ isOrderActive(order) && ( ( ), canEditOrder(order) && ( ( actions={ (canEditOrder(order) || isOrderActive(order)) && ( ( actions={ canEditOrder(order) && ( ( actions={ (canEditOrder(order) || isOrderActive(order)) && ( ( actions={ canEditOrder(order) && ( subscribers.map(({ name, ditTeam }) => ( - + {name} {ditTeam?.ukRegion ? ', ' + ditTeam.ukRegion.name : ''} @@ -21,6 +21,7 @@ const SubscribersTable = ({ subscribers, order }) => ( actions={ isOrderActive(order) && ( ( ( const InvestmentItemRenderer = (item, onDeleteReminder, disableDelete) => ( ( headerLinkHref={urls.tasks.details(item.task.id)} headerLinkTitle={item.event} itemContent={} + key={item.id} /> ) diff --git a/src/client/modules/Tasks/TaskForm/TaskFormFields.jsx b/src/client/modules/Tasks/TaskForm/TaskFormFields.jsx index 345159992b7..b005fd092c8 100644 --- a/src/client/modules/Tasks/TaskForm/TaskFormFields.jsx +++ b/src/client/modules/Tasks/TaskForm/TaskFormFields.jsx @@ -145,7 +145,6 @@ const TaskFormFields = ({ Data Hub reminder - ({ status: investmentProjectStatusFaker(), project_code: investmentProjectCodeFaker(), incomplete_fields: [], + investment_type: { + name: faker.company.name(), + id: faker.string.uuid(), + }, ...overrides, }) diff --git a/test/functional/cypress/specs/investments/project-edit-project-management-spec.js b/test/functional/cypress/specs/investments/project-edit-project-management-spec.js index a187b9cda98..c80dd255eb8 100644 --- a/test/functional/cypress/specs/investments/project-edit-project-management-spec.js +++ b/test/functional/cypress/specs/investments/project-edit-project-management-spec.js @@ -84,7 +84,7 @@ describe('Edit the management advisers for a project', () => { const expectedBody = { id: incompleteProject.id, project_assurance_adviser: '2c42c516-9898-e211-a939-e4115bead28a', - project_manager: null, + project_manager: '', } selectFirstMockedTypeaheadOption({ element: '#field-project_assurance_adviser', @@ -101,7 +101,7 @@ describe('Edit the management advisers for a project', () => { it('should submit the form with only PM typeahead filled in and redirect', () => { const expectedBody = { id: incompleteProject.id, - project_assurance_adviser: null, + project_assurance_adviser: '', project_manager: '2c42c516-9898-e211-a939-e4115bead28a', } selectFirstMockedTypeaheadOption({ diff --git a/test/sandbox/fixtures/v3/investment/projects.json b/test/sandbox/fixtures/v3/investment/projects.json index c9fa0fc49e5..8689c194715 100644 --- a/test/sandbox/fixtures/v3/investment/projects.json +++ b/test/sandbox/fixtures/v3/investment/projects.json @@ -2865,7 +2865,8 @@ "id": "ac4b1006-56af-40e0-8615-7aba53e0e4bf", "name": "A nice investment", "investor_company": { - "id": "ba3h7106-56af-40e0-8615-7aba53e0e4bf" + "id": "ba3h7106-56af-40e0-8615-7aba53e0e4bf", + "name": "Some company" }, "stage": { "name": "Active",