diff --git a/src/client/components/ActivityFeed/activities/Omis.jsx b/src/client/components/ActivityFeed/activities/Omis.jsx deleted file mode 100644 index 774bf6aca0..0000000000 --- a/src/client/components/ActivityFeed/activities/Omis.jsx +++ /dev/null @@ -1,92 +0,0 @@ -import React from 'react' -import { get } from 'lodash' -import PropTypes from 'prop-types' -import Link from '@govuk-react/link' - -import { AdviserItemRenderer, ContactItemRenderer } from './card/item-renderers' -import { ACTIVITY_TYPE } from '../constants' - -import CardUtils from './card/CardUtils' -import ActivityCardLabels from './card/ActivityCardLabels' -import ActivityCardWrapper from './card/ActivityCardWrapper' -import ActivityCardSubject from './card/ActivityCardSubject' -import ActivityCardMetadata from './card/ActivityCardMetadata' -import ActivityOverviewSummary from './card/item-renderers/ActivityOverviewSummary' -import OverviewActivityCardWrapper from './card/OverviewActivityCardWrapper' - -const { format } = require('../../../utils/date') - -export default class Omis extends React.PureComponent { - static propTypes = { - activity: PropTypes.object.isRequired, - showDetails: PropTypes.bool.isRequired, - } - - static canRender(activity) { - return CardUtils.canRenderByTypes(activity, ACTIVITY_TYPE.Omis) - } - - render() { - const { activity, isOverview } = this.props - - const published = get(activity, 'published') - const reference = get(activity, 'object.name') - const country = get(activity, 'object.dit:country.name') - const ukRegion = get(activity, 'object.dit:ukRegion.name') - const url = get(activity, 'object.url') - const adviser = CardUtils.getAdviser(activity) - const contacts = CardUtils.getContacts(activity) - const date = format(published) - - const metadata = [ - { label: 'Date', value: date }, - { label: 'Country', value: country }, - { label: 'UK region', value: ukRegion }, - { - label: 'Added by', - value: adviser - ? [adviser].map((adviser, index) => ( - - {AdviserItemRenderer(adviser, index)} - - )) - : null, - }, - { - label: 'Company contact', - value: contacts.map((contact, index) => ( - {ContactItemRenderer(contact, index)} - )), - }, - ] - - const href = `${url}/work-order` - const kind = 'New Order' - const subject = {reference} - - let summary = [] - if (country) summary.push('Export to ', country) - if (adviser) summary.push(' added by ', adviser.name) - - return isOverview ? ( - - - - ) : ( - - - {subject} - - - - - ) - } -} diff --git a/src/client/components/ActivityFeed/activities/card/CardDetails.jsx b/src/client/components/ActivityFeed/activities/card/CardDetails.jsx deleted file mode 100644 index 98dab342b0..0000000000 --- a/src/client/components/ActivityFeed/activities/card/CardDetails.jsx +++ /dev/null @@ -1,95 +0,0 @@ -import React from 'react' -import Details from '@govuk-react/details' -import Link from '@govuk-react/link' -import styled from 'styled-components' -import { SPACING, MEDIA_QUERIES, FONT_SIZE } from '@govuk-react/constants' -import { VisuallyHidden } from 'govuk-react' -import PropTypes from 'prop-types' - -import Analytics from '../../../Analytics' - -const GovUkDetails = styled(Details)` - font-size: ${FONT_SIZE.SIZE_16}; - margin: ${SPACING.SCALE_2} 0 0; - - & > div { - padding: ${SPACING.SCALE_1}; - padding-bottom: ${SPACING.SCALE_3}; - margin: ${SPACING.SCALE_1} 0 ${SPACING.SCALE_1} 4px; - - & > a { - padding: ${SPACING.SCALE_4} 0 ${SPACING.SCALE_2} ${SPACING.SCALE_2}; - } - } - - ${MEDIA_QUERIES.TABLET} { - margin-top: -${SPACING.SCALE_3}; - } -` - -export default class CardDetails extends React.PureComponent { - static propTypes = { - summary: PropTypes.string.isRequired, - summaryVisuallyHidden: PropTypes.string, - showDetails: PropTypes.bool.isRequired, - link: PropTypes.shape({ - url: PropTypes.string, - text: PropTypes.string, - }), - children: PropTypes.node.isRequired, - analyticsAccordionType: PropTypes.string, - } - - static defaultProps = { - link: null, - } - - renderLink = (link) => { - if (!link) { - return null - } - - return {link.text} - } - - render() { - const { - summary, - showDetails, - link, - children, - summaryVisuallyHidden, - analyticsAccordionType, - } = this.props - - const SummaryWithHiddenContent = ( - <> - {summary} - {summaryVisuallyHidden} - - ) - - return ( - - {(pushAnalytics) => ( - { - pushAnalytics({ - event: 'viewInteractionEngagement', - extra: { - accordionEngagement: 'clicked', - accordionType: analyticsAccordionType, - }, - }) - }} - > - {children} - {this.renderLink(link)} - - )} - - ) - } -} diff --git a/src/client/components/ActivityFeed/activities/card/CardDetailsList.jsx b/src/client/components/ActivityFeed/activities/card/CardDetailsList.jsx deleted file mode 100644 index 199e2d9c35..0000000000 --- a/src/client/components/ActivityFeed/activities/card/CardDetailsList.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import styled from 'styled-components' -import { MEDIA_QUERIES } from '@govuk-react/constants' -import UnorderedList from '@govuk-react/unordered-list' -import ListItem from '@govuk-react/list-item' - -const StyledUnorderedList = styled(UnorderedList)` - margin-bottom: 0; -` - -const StyledListItem = styled(ListItem)` - ${MEDIA_QUERIES.TABLET} { - font-size: 16px; - } -` - -const CardDetailsList = ({ items, itemRenderer, itemPropName }) => { - return ( - - {items.map((item, index) => ( - - {itemRenderer(item, index, itemPropName)} - - ))} - - ) -} - -CardDetailsList.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - itemRenderer: PropTypes.any.isRequired, - itemPropName: PropTypes.string, -} - -export default CardDetailsList diff --git a/src/client/components/ActivityFeed/activities/card/CardTable.jsx b/src/client/components/ActivityFeed/activities/card/CardTable.jsx deleted file mode 100644 index a26a41ab44..0000000000 --- a/src/client/components/ActivityFeed/activities/card/CardTable.jsx +++ /dev/null @@ -1,86 +0,0 @@ -/* eslint-disable react/no-array-index-key */ -import React from 'react' -import PropTypes from 'prop-types' -import Table from '@govuk-react/table' -import styled from 'styled-components' -import { SPACING, MEDIA_QUERIES } from '@govuk-react/constants' - -import { ReadMore } from '../../../../components' - -const GovUkTable = styled(Table)` - ${MEDIA_QUERIES.TABLET} { - margin-bottom: ${({ isNotWrappedInDetails }) => - isNotWrappedInDetails ? '0' : SPACING.SCALE_2}; - } - - th { - width: ${({ isNotWrappedInDetails }) => - isNotWrappedInDetails ? '284px' : '270px'}; - } - - th, - td { - font-weight: normal; - border: 0; - padding: ${SPACING.SCALE_2}; - font-size: 16px; - vertical-align: top; - } -` - -class DetailsRow extends React.PureComponent { - static propTypes = { - header: PropTypes.string.isRequired, - children: PropTypes.node, - } - - static defaultProps = { - children: null, - } - - render() { - const { header, children } = this.props - - if (!children) { - return null - } - - return ( - - - {header} - - {children} - - ) - } -} - -export default class CardTable extends React.Component { - static propTypes = { - isNotWrappedInDetails: PropTypes.bool, - rows: PropTypes.arrayOf( - PropTypes.shape({ - header: PropTypes.string, - content: PropTypes.node, - }) - ).isRequired, - } - - static defaultProps = { - isNotWrappedInDetails: false, - } - - render() { - const { rows, isNotWrappedInDetails } = this.props - return ( - - {rows.map(({ header, content, hasReadmore }) => ( - - {hasReadmore ? : content} - - ))} - - ) - } -} diff --git a/src/client/components/ActivityFeed/activities/card/CardUtils.jsx b/src/client/components/ActivityFeed/activities/card/CardUtils.jsx index 07e8672241..dc51834e63 100644 --- a/src/client/components/ActivityFeed/activities/card/CardUtils.jsx +++ b/src/client/components/ActivityFeed/activities/card/CardUtils.jsx @@ -57,59 +57,15 @@ const getStatusByLatest = (contactsList) => { return status } -const getCompany = (activity) => { - return get(activity, 'object.attributedTo', []) - .filter(({ type }) => type !== 'dit:Company') - .map(({ name }) => ({ name })) - .shift() -} - -const getAdvisers = (activity) => { - return mapPeople( - activity, - 'dit:Adviser', - ({ id, name, 'dit:emailAddress': emailAddress, 'dit:team': team }) => { - return pickBy({ - id, - name, - emailAddress, - team: get(team, 'name'), // Only available for Interactions - type: 'Adviser', - }) - } - ) -} - const canRenderByTypes = (activity, types) => { const activityTypes = get(activity, 'object.type') return some(types, (type) => includes(activityTypes, type)) } -const getAdviser = (activity) => { - const adviser = { - id: get(activity, 'actor.id'), - name: get(activity, 'actor.name'), - emailAddress: get(activity, 'actor.dit:emailAddress'), - } - - return adviser.name && adviser.emailAddress ? adviser : null -} - -const transform = (activity) => ({ - url: get(activity, 'object.url'), - subject: get(activity, 'object.dit:subject'), - service: get(activity, 'object.dit:service.name'), - startTime: get(activity, 'object.startTime'), -}) - export default { canRenderByTypes, - getAdvisers, getContacts, - getCompany, - getAdviser, - transform, getContactsGroupedByRegistrationStatus, getStatusByLatest, } diff --git a/src/client/components/ActivityFeed/activities/card/index.js b/src/client/components/ActivityFeed/activities/card/index.js index 7bc264c2be..05f6fde669 100644 --- a/src/client/components/ActivityFeed/activities/card/index.js +++ b/src/client/components/ActivityFeed/activities/card/index.js @@ -1,5 +1,2 @@ export { default as Card } from './Card' -export { default as CardDetails } from './CardDetails' export { default as CardHeader } from './CardHeader' -export { default as CardTable } from './CardTable' -export { default as CardDetailsList } from './CardDetailsList' diff --git a/src/client/components/ActivityFeed/activities/card/item-renderers/AdviserItemRenderer.jsx b/src/client/components/ActivityFeed/activities/card/item-renderers/AdviserItemRenderer.jsx deleted file mode 100644 index 8e0d1d5c46..0000000000 --- a/src/client/components/ActivityFeed/activities/card/item-renderers/AdviserItemRenderer.jsx +++ /dev/null @@ -1,28 +0,0 @@ -import Link from '@govuk-react/link' -import PropTypes from 'prop-types' -import React from 'react' - -const AdviserItemRenderer = (item) => { - const name = {item?.name} - const emailAddress = ( - {item.emailAddress} - ) - const team = item.team ? `, (${item.team})` : null - - return ( - <> - {name}, {emailAddress} - {team} - - ) -} - -AdviserItemRenderer.propTypes = { - adviser: PropTypes.shape({ - name: PropTypes.string.isRequired, - emailAddress: PropTypes.string.isRequired, - team: PropTypes.string, // Only available for Interactions - }).isRequired, -} - -export default AdviserItemRenderer diff --git a/src/client/components/ActivityFeed/activities/card/item-renderers/BooleanItemRenderer.jsx b/src/client/components/ActivityFeed/activities/card/item-renderers/BooleanItemRenderer.jsx deleted file mode 100644 index 62f7ef29b4..0000000000 --- a/src/client/components/ActivityFeed/activities/card/item-renderers/BooleanItemRenderer.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import PropTypes from 'prop-types' - -const BooleanItemRenderer = (item, index, property) => { - return item[property].toString() -} - -BooleanItemRenderer.propTypes = { - item: PropTypes.shape.isRequired, - index: PropTypes.number.isRequired, - property: PropTypes.string.isRequired, -} - -export default BooleanItemRenderer diff --git a/src/client/components/ActivityFeed/activities/card/item-renderers/ContactItemRenderer.jsx b/src/client/components/ActivityFeed/activities/card/item-renderers/ContactItemRenderer.jsx deleted file mode 100644 index 0ca914515d..0000000000 --- a/src/client/components/ActivityFeed/activities/card/item-renderers/ContactItemRenderer.jsx +++ /dev/null @@ -1,24 +0,0 @@ -import Link from '@govuk-react/link' -import PropTypes from 'prop-types' -import React from 'react' - -const ContactItemRenderer = (item) => { - const name = {item.name} - const jobTitle = item.jobTitle ? ({item.jobTitle}) : null - - return ( - <> - {name} {jobTitle} - - ) -} - -ContactItemRenderer.propTypes = { - contact: PropTypes.shape({ - name: PropTypes.string.isRequired, - url: PropTypes.string, // Can't set this as 'isRequired' - jobTitle: PropTypes.string, - }).isRequired, -} - -export default ContactItemRenderer diff --git a/src/client/components/ActivityFeed/activities/card/item-renderers/DefaultItemRenderer.jsx b/src/client/components/ActivityFeed/activities/card/item-renderers/DefaultItemRenderer.jsx deleted file mode 100644 index 19fe63c14a..0000000000 --- a/src/client/components/ActivityFeed/activities/card/item-renderers/DefaultItemRenderer.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import PropTypes from 'prop-types' - -// String and number -const DefaultItemRenderer = (item, index, property) => { - return item[property] -} - -DefaultItemRenderer.propTypes = { - item: PropTypes.shape.isRequired, - index: PropTypes.number.isRequired, - property: PropTypes.string.isRequired, -} - -export default DefaultItemRenderer diff --git a/src/client/components/ActivityFeed/activities/card/item-renderers/index.js b/src/client/components/ActivityFeed/activities/card/item-renderers/index.js deleted file mode 100644 index 0f11c2bdaf..0000000000 --- a/src/client/components/ActivityFeed/activities/card/item-renderers/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export { default as AdviserItemRenderer } from './AdviserItemRenderer' -export { default as ContactItemRenderer } from './ContactItemRenderer' -export { default as DefaultItemRenderer } from './DefaultItemRenderer' -export { default as BooleanItemRenderer } from './BooleanItemRenderer' diff --git a/src/client/components/ActivityFeed/activities/index.js b/src/client/components/ActivityFeed/activities/index.js index 4aa18b48c6..39832c71fa 100644 --- a/src/client/components/ActivityFeed/activities/index.js +++ b/src/client/components/ActivityFeed/activities/index.js @@ -3,7 +3,6 @@ import CompaniesHouseCompany from './CompaniesHouseCompany' import DirectoryFormsApi from './DirectoryFormsApi' import MaxemailCampaign from './MaxemailCampaign' import HmrcExporter from './HmrcExporter' -import Omis from './Omis' import AventriAttendee from './AventriAttendee' import DataHubEvent from './DataHubEvent' import AventriEvent from './AventriEvent' @@ -18,6 +17,5 @@ export default [ DirectoryFormsApi, MaxemailCampaign, HmrcExporter, - Omis, AventriEventSyncWarning, ]