From 724b2d659ff43cc13e98169c688b114df72f843a Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Mon, 16 Dec 2024 12:37:05 +0000 Subject: [PATCH 1/9] Remove format function and replace with formatDate --- .../details/client/ReferralDetails.jsx | 9 ++++-- src/apps/interactions/client/transformers.js | 7 +++-- .../activities/CompaniesHouseAccount.jsx | 19 +++++++++---- .../activities/CompaniesHouseCompany.jsx | 28 +++++++++++-------- .../activities/DirectoryFormsApi.jsx | 10 +++---- .../ActivityFeed/activities/HmrcExporter.jsx | 4 +-- .../activities/MaxemailCampaign.jsx | 4 +-- .../activities/card/CardHeader.jsx | 9 ++++-- src/client/components/ArchivePanel/index.jsx | 9 +++--- src/client/components/CompanyLists/Table.jsx | 6 ++-- .../InvestmentDetails.jsx | 6 ++-- .../components/ReferralList/Referral.jsx | 4 +-- .../AccountManagement/ArchivedObjectives.jsx | 8 +++--- .../Companies/AccountManagement/index.jsx | 14 ++++++---- .../Companies/CollectionList/transformers.js | 5 ++-- .../CompanyBusinessDetails.jsx | 7 +++-- .../LinkGlobalHQ/transformers.js | 4 +-- .../LinkSubsidiary/transformers.js | 4 +-- .../CompanyHierarchy/CompanyTree.jsx | 7 +++-- .../ProfileDetailsTable.jsx | 6 ++-- .../TableCards/ExportStatusCard.jsx | 4 +-- .../TableCards/InvestmentStatusCard.jsx | 7 +++-- .../ExportPipeline/ExportDetails/index.jsx | 10 +++++-- .../CollectionList/transformers.js | 7 +++-- .../InteractionReferralDetails.jsx | 4 +-- .../Investments/EYBLeads/EYBLeadDetails.jsx | 7 +++-- .../Investments/EYBLeads/transformers.js | 4 +-- .../Investments/Profiles/transformers.js | 4 +-- .../EditAssociatedProject/transformers.js | 9 ++++-- .../EditRecipientCompany/transformers.js | 4 +-- .../Projects/Details/ProjectDetails.jsx | 14 +++++++--- .../Projects/ProjectEvaluation.jsx | 7 +++-- .../Projects/Team/EditProjectManagement.jsx | 10 +++++-- .../Investments/Projects/transformers.js | 28 +++++++++++++++---- .../Omis/CollectionList/transformers.js | 6 ++-- .../CreateOrder/CompanySelect/transformers.js | 4 +-- src/client/modules/Omis/PaymentReceipt.jsx | 7 ++--- .../modules/Omis/PaymentReconciliation.jsx | 7 +++-- .../InvestmentOPListItemRenderer.jsx | 5 ++-- .../Tasks/MyTasksItemRenderer.jsx | 5 ++-- .../CompanyHierarchy/Hierarchy.cy.jsx | 10 +++++-- .../WorkOrder/OrderIncompleteFields.cy.jsx | 10 +++++-- ...ount-management-add-edit-objective-spec.js | 10 ++++--- .../companies/account-management-spec.js | 11 ++++---- .../companies/archived-objectives-spec.js | 15 ++++++++-- .../export-pipeline/export-details-spec.js | 11 +++++--- .../specs/investments/eyb-leads-spec.js | 7 +++-- .../opportunity-interactions-spec.js | 7 +++-- .../investments/project-interactions-spec.js | 10 +++++-- .../specs/investments/project-tasks-spec.js | 9 ++++-- .../specs/tasks/create-similar-task-spec.js | 8 ++++-- .../cypress/specs/tasks/edit-task-spec.js | 12 ++++---- 52 files changed, 286 insertions(+), 157 deletions(-) diff --git a/src/apps/companies/apps/referrals/details/client/ReferralDetails.jsx b/src/apps/companies/apps/referrals/details/client/ReferralDetails.jsx index 918a2bfeae8..59b115d2cfd 100644 --- a/src/apps/companies/apps/referrals/details/client/ReferralDetails.jsx +++ b/src/apps/companies/apps/referrals/details/client/ReferralDetails.jsx @@ -15,7 +15,10 @@ import Task from '../../../../../../client/components/Task' import { REFERRAL_DETAILS } from '../../../../../../client/actions' -const { format } = require('../../../../../../client/utils/date') +const { + formatDate, + DATE_FORMAT_COMPACT, +} = require('../../../../../../client/utils/date-utils') export const AdviserDetails = ({ name, email, team }) => ( <> @@ -87,14 +90,14 @@ export default connect(({ referrerUrl, ...state }) => ({ {receivingAdviser && } - {format(date)} + {formatDate(date, DATE_FORMAT_COMPACT)} {notes} {completed ? ( - {format(completed.on)} + {formatDate(completed.on, DATE_FORMAT_COMPACT)} diff --git a/src/apps/interactions/client/transformers.js b/src/apps/interactions/client/transformers.js index e9cb3a150cf..f89b8a70045 100644 --- a/src/apps/interactions/client/transformers.js +++ b/src/apps/interactions/client/transformers.js @@ -1,6 +1,9 @@ import { get } from 'lodash' -import { format } from '../../../client/utils/date' +import { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} from '../../../client/utils/date-utils' import urls from '../../../lib/urls' import { LABELS } from './constants' @@ -52,7 +55,7 @@ export const transformInteractionToListItem = ({ } = {}) => ({ id, metadata: [ - { label: 'Date', value: format(date, 'dd MMMM yyyy') }, + { label: 'Date', value: formatDate(date, DATE_FORMAT_DAY_MONTH_YEAR) }, { label: 'Contact(s)', value: contacts && formatContacts(contacts), diff --git a/src/client/components/ActivityFeed/activities/CompaniesHouseAccount.jsx b/src/client/components/ActivityFeed/activities/CompaniesHouseAccount.jsx index c22820bc842..db4b1d69ebd 100644 --- a/src/client/components/ActivityFeed/activities/CompaniesHouseAccount.jsx +++ b/src/client/components/ActivityFeed/activities/CompaniesHouseAccount.jsx @@ -13,7 +13,7 @@ import ActivityCardSubject from './card/ActivityCardSubject' import ActivityOverviewSummary from './card/item-renderers/ActivityOverviewSummary' import OverviewActivityCardWrapper from './card/OverviewActivityCardWrapper' -const { format } = require('../../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../../utils/date-utils') export default class CompaniesHouseAccount extends React.PureComponent { static propTypes = { @@ -32,8 +32,9 @@ export default class CompaniesHouseAccount extends React.PureComponent { const { activity, isOverview } = this.props const startTime = get(activity, 'object.startTime') const summary = get(activity, 'summary') - const balanceSheetDate = format( - get(activity, 'object.dit:balanceSheetDate') + const balanceSheetDate = formatDate( + get(activity, 'object.dit:balanceSheetDate'), + DATE_FORMAT_COMPACT ) const netAssetsLiabilities = currencyGBP( get( @@ -41,12 +42,18 @@ export default class CompaniesHouseAccount extends React.PureComponent { 'object.dit:netAssetsLiabilitiesIncludingPensionAssetLiability' ) ) - const periodEnd = format(get(activity, 'object.dit:periodEnd')) - const periodStart = format(get(activity, 'object.dit:periodStart')) + const periodEnd = formatDate( + get(activity, 'object.dit:periodEnd'), + DATE_FORMAT_COMPACT + ) + const periodStart = formatDate( + get(activity, 'object.dit:periodStart'), + DATE_FORMAT_COMPACT + ) const shareholderFunds = currencyGBP( get(activity, 'object.dit:shareholderFunds') ) - const date = format(startTime) + const date = formatDate(startTime, DATE_FORMAT_COMPACT) const metadata = [ { label: 'Date', value: date }, { label: 'Balance sheet date', value: balanceSheetDate }, diff --git a/src/client/components/ActivityFeed/activities/CompaniesHouseCompany.jsx b/src/client/components/ActivityFeed/activities/CompaniesHouseCompany.jsx index cef6bb4c83a..9a35b89ff6b 100644 --- a/src/client/components/ActivityFeed/activities/CompaniesHouseCompany.jsx +++ b/src/client/components/ActivityFeed/activities/CompaniesHouseCompany.jsx @@ -11,7 +11,7 @@ import ActivityCardSubject from './card/ActivityCardSubject' import ActivityOverviewSummary from './card/item-renderers/ActivityOverviewSummary' import OverviewActivityCardWrapper from './card/OverviewActivityCardWrapper' -const { format } = require('../../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../../utils/date-utils') export default class CompaniesHouseCompany extends React.PureComponent { static propTypes = { @@ -35,21 +35,27 @@ export default class CompaniesHouseCompany extends React.PureComponent { const subject = get(activity, 'summary') const address = get(activity, 'object.location:dit:address') const postcode = get(activity, 'object.location:dit:postcode') - const confStmtLastMadeUpDate = format( + const confStmtLastMadeUpDate = formatDate( get(activity, 'object.dit:confStmtLastMadeUpDate') ) - const confStmtNextDueDate = format( - get(activity, 'object.dit:confStmtNextDueDate') + const confStmtNextDueDate = formatDate( + get(activity, 'object.dit:confStmtNextDueDate'), + DATE_FORMAT_COMPACT ) - const incorporationDate = format( + const incorporationDate = formatDate( get(activity, 'object.dit:incorporationDate') ) - const nextDueDate = format(get(activity, 'object.dit:nextDueDate')) - const returnsLastMadeUpDate = format( - get(activity, 'object.dit:returnsLastMadeUpDate') + const nextDueDate = formatDate( + get(activity, 'object.dit:nextDueDate'), + DATE_FORMAT_COMPACT ) - const returnsNextDueDate = format( - get(activity, 'object.dit:returnsNextDueDate') + const returnsLastMadeUpDate = formatDate( + get(activity, 'object.dit:returnsLastMadeUpDate'), + DATE_FORMAT_COMPACT + ) + const returnsNextDueDate = formatDate( + get(activity, 'object.dit:returnsNextDueDate'), + DATE_FORMAT_COMPACT ) const sicCodes = get(activity, 'object.dit:sicCodes') @@ -60,7 +66,7 @@ export default class CompaniesHouseCompany extends React.PureComponent { )) - const date = format(startTime) + const date = formatDate(startTime, DATE_FORMAT_COMPACT) const metadata = [ { label: 'Date', value: date }, diff --git a/src/client/components/ActivityFeed/activities/DirectoryFormsApi.jsx b/src/client/components/ActivityFeed/activities/DirectoryFormsApi.jsx index 2f740f3ea3a..1daa0bf5117 100644 --- a/src/client/components/ActivityFeed/activities/DirectoryFormsApi.jsx +++ b/src/client/components/ActivityFeed/activities/DirectoryFormsApi.jsx @@ -12,7 +12,7 @@ import ActivityCardNotes from './card/ActivityCardNotes' import ActivityCardMetadata from './card/ActivityCardMetadata' import ActivityOverviewSummary from './card/item-renderers/ActivityOverviewSummary' -import { format } from '../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../utils/date-utils' import OverviewActivityCardWrapper from './card/OverviewActivityCardWrapper' export default class DirectoryFormsApi extends React.PureComponent { @@ -68,7 +68,7 @@ export default class DirectoryFormsApi extends React.PureComponent { ) ) const metadata = [ - { label: 'Date', value: format(sentDate) }, + { label: 'Date', value: formatDate(sentDate, DATE_FORMAT_COMPACT) }, { label: 'Contact(s)', value: formattedContacts(), @@ -84,7 +84,7 @@ export default class DirectoryFormsApi extends React.PureComponent { ) ) - const date = format(startTime) + const date = formatDate(startTime, DATE_FORMAT_COMPACT) const metadata = [ { label: 'Date', value: date }, { label: 'Export item code(s)', value: exportItemCodesList }, diff --git a/src/client/components/ActivityFeed/activities/MaxemailCampaign.jsx b/src/client/components/ActivityFeed/activities/MaxemailCampaign.jsx index e1fa773e47e..6759158867f 100644 --- a/src/client/components/ActivityFeed/activities/MaxemailCampaign.jsx +++ b/src/client/components/ActivityFeed/activities/MaxemailCampaign.jsx @@ -11,7 +11,7 @@ import ActivityCardLabels from './card/ActivityCardLabels' import ActivityCardSubject from './card/ActivityCardSubject' import ActivityCardMetadata from './card/ActivityCardMetadata' -const { format } = require('../../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../../utils/date-utils') export default class MaxemailCampaign extends React.PureComponent { static propTypes = { @@ -39,7 +39,7 @@ export default class MaxemailCampaign extends React.PureComponent { )) const metadata = [ - { label: 'Date', value: format(published) }, + { label: 'Date', value: formatDate(published, DATE_FORMAT_COMPACT) }, { label: 'Senders name', value: name }, { label: 'Senders email', value: from }, { label: 'Content', value: content }, diff --git a/src/client/components/ActivityFeed/activities/card/CardHeader.jsx b/src/client/components/ActivityFeed/activities/card/CardHeader.jsx index 446726ff0c6..989c80c9059 100644 --- a/src/client/components/ActivityFeed/activities/card/CardHeader.jsx +++ b/src/client/components/ActivityFeed/activities/card/CardHeader.jsx @@ -16,7 +16,10 @@ import { BLUE, GREY_1, GREY_4 } from '../../../../utils/colours' import Badge from '../../../Badge' import { SOURCE_TYPES } from '../../constants' -const { format } = require('../../../../utils/date') +const { + formatDate, + DATE_FORMAT_COMPACT, +} = require('../../../../utils/date-utils') const StyledBlockText = styled(H3)` display: inline-block; @@ -118,7 +121,9 @@ const CardHeader = ({ - {startTime && {format(startTime)}} + {startTime && ( + {formatDate(startTime, DATE_FORMAT_COMPACT)} + )} {badge && ( diff --git a/src/client/components/ArchivePanel/index.jsx b/src/client/components/ArchivePanel/index.jsx index ac9f1d95d11..f935a952968 100644 --- a/src/client/components/ArchivePanel/index.jsx +++ b/src/client/components/ArchivePanel/index.jsx @@ -6,7 +6,7 @@ import { SPACING, FONT_SIZE, FONT_WEIGHTS } from '@govuk-react/constants' import Link from '@govuk-react/link' import StatusMessage from '../../../client/components/StatusMessage' -import { format } from '../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../utils/date-utils' const negativeSpacing = '-' + SPACING.SCALE_4 @@ -48,10 +48,11 @@ const ArchivePanel = ({ {archivedBy - ? `This ${type} was ${archiveMessage} on ${format( - archivedOn + ? `This ${type} was ${archiveMessage} on ${formatDate( + archivedOn, + DATE_FORMAT_COMPACT )} by ${checkArchiverFormat(archivedBy)}.` - : `This ${type} was automatically archived on ${format(archivedOn)}.`} + : `This ${type} was automatically archived on ${formatDate(archivedOn, DATE_FORMAT_COMPACT)}.`} {`Reason: ${archiveReason}`} {unarchiveUrl && ( diff --git a/src/client/components/CompanyLists/Table.jsx b/src/client/components/CompanyLists/Table.jsx index 0dd94f234c4..8cb344fa9d7 100644 --- a/src/client/components/CompanyLists/Table.jsx +++ b/src/client/components/CompanyLists/Table.jsx @@ -18,7 +18,7 @@ import urls from '../../../lib/urls' import { MEDIA_QUERIES } from '../../utils/responsive' import SecondaryButton from '../SecondaryButton' -const { format } = require('../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../utils/date-utils') const StyledButtonLink = styled.a({ marginBottom: 0, @@ -159,7 +159,9 @@ const CompaniesTable = ({ companies }) => ( /> - {date ? format(date) : '-'} + + {date ? formatDate(date, DATE_FORMAT_COMPACT) : '-'} + {interactionId ? ( diff --git a/src/client/components/MyInvestmentProjects/InvestmentDetails.jsx b/src/client/components/MyInvestmentProjects/InvestmentDetails.jsx index bd38c5ebebc..3552922e4c6 100644 --- a/src/client/components/MyInvestmentProjects/InvestmentDetails.jsx +++ b/src/client/components/MyInvestmentProjects/InvestmentDetails.jsx @@ -6,7 +6,7 @@ import { SPACING, FONT_SIZE, FONT_WEIGHTS } from '@govuk-react/constants' import { companies, interactions } from '../../../lib/urls' import { GREY_3, DARK_GREY } from '../../utils/colours' -const { format } = require('../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../utils/date-utils') const StyledDiv = styled('div')({ height: '100%', @@ -75,7 +75,9 @@ const InvestmentDetails = ({ {latestInteraction && ( <> Last interaction: - {format(latestInteraction.date)} + + {formatDate(latestInteraction.date, DATE_FORMAT_COMPACT)} + Interaction subject: diff --git a/src/client/components/ReferralList/Referral.jsx b/src/client/components/ReferralList/Referral.jsx index 692d91f4eee..ad89d861f89 100644 --- a/src/client/components/ReferralList/Referral.jsx +++ b/src/client/components/ReferralList/Referral.jsx @@ -9,7 +9,7 @@ import { AdviserDetails } from '../../../apps/companies/apps/referrals/details/c import { Card, CardHeader } from '../ActivityFeed/activities/card' import SummaryList from '../../components/SummaryList' import urls from '../../../lib/urls' -import { format } from '../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../utils/date-utils' const StyledSummaryListWrapper = styled.div({ flexGrow: 1, @@ -75,7 +75,7 @@ const Referral = ({ ? [ { label: 'Accepted on', - value: format(dateAccepted), + value: formatDate(dateAccepted, DATE_FORMAT_COMPACT), }, ] : []), diff --git a/src/client/modules/Companies/AccountManagement/ArchivedObjectives.jsx b/src/client/modules/Companies/AccountManagement/ArchivedObjectives.jsx index be7c8140d5b..dc9beab4823 100644 --- a/src/client/modules/Companies/AccountManagement/ArchivedObjectives.jsx +++ b/src/client/modules/Companies/AccountManagement/ArchivedObjectives.jsx @@ -11,7 +11,7 @@ import { } from '../../../components/Resource' import { buildCompanyBreadcrumbs } from '../utils' import { DARK_GREY, GREY_2 } from '../../../utils/colours' -import { format } from '../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../utils/date-utils' import urls from '../../../../lib/urls' const BorderContainer = styled('div')` @@ -42,7 +42,7 @@ const objectiveMetadata = (objective) => { }, { label: 'Due date', - value: format(objective.targetDate), + value: formatDate(objective.targetDate, DATE_FORMAT_COMPACT), }, { label: 'Progress', @@ -102,13 +102,13 @@ const ArchivedObjectives = () => { {`Objective complete. Updated by ${ objective?.modifiedBy?.name - }: ${format(objective.modifiedOn)}`} + }: ${formatDate(objective.modifiedOn, DATE_FORMAT_COMPACT)}`} ) : ( {`Objective incomplete. Archived by ${ objective?.modifiedBy?.name - }: ${format(objective.modifiedOn)}`} + }: ${formatDate(objective.modifiedOn, DATE_FORMAT_COMPACT)}`} )} diff --git a/src/client/modules/Companies/AccountManagement/index.jsx b/src/client/modules/Companies/AccountManagement/index.jsx index 36826aec9ec..da3e6d97945 100644 --- a/src/client/modules/Companies/AccountManagement/index.jsx +++ b/src/client/modules/Companies/AccountManagement/index.jsx @@ -15,7 +15,10 @@ import { CompanyResource, } from '../../../components/Resource' import urls from '../../../../lib/urls' -import { format } from '../../../../client/utils/date' +import { + formatDate, + DATE_FORMAT_COMPACT, +} from '../../../../client/utils/date-utils' import { DARK_GREY, GREY_2, GREY_3, TEXT_COLOUR } from '../../../utils/colours' import { LeadITA } from './LeadAdvisers' import { CoreTeamAdvisers } from '../CoreTeam/CoreTeam' @@ -113,8 +116,9 @@ const Strategy = ({ company }) => ( - {`Last updated by ${company?.modifiedBy?.name}: ${format( - company.modifiedOn + {`Last updated by ${company?.modifiedBy?.name}: ${formatDate( + company.modifiedOn, + DATE_FORMAT_COMPACT )}. `} View changes in{' '} @@ -181,7 +185,7 @@ const Objectives = ({ company }) => ( {`Last updated by ${ objective?.modifiedBy?.name - }: ${format(objective.modifiedOn)}`} + }: ${formatDate(objective.modifiedOn, DATE_FORMAT_COMPACT)}`} @@ -234,7 +238,7 @@ const objectiveMetadata = (objective) => { }, { label: 'Due date', - value: format(objective.targetDate), + value: formatDate(objective.targetDate, DATE_FORMAT_COMPACT), }, { label: 'Progress', diff --git a/src/client/modules/Companies/CollectionList/transformers.js b/src/client/modules/Companies/CollectionList/transformers.js index c7587d72260..8d4f776c20b 100644 --- a/src/client/modules/Companies/CollectionList/transformers.js +++ b/src/client/modules/Companies/CollectionList/transformers.js @@ -2,12 +2,11 @@ import { get } from 'lodash' import labels from './labels' import urls from '../../../../lib/urls' - import { addressToString } from '../../../utils/addresses' -const { format } = require('../../../utils/date') const { formatDate, + DATE_FORMAT_COMPACT, DATE_FORMAT_MEDIUM_WITH_TIME, } = require('../../../utils/date-utils') @@ -58,7 +57,7 @@ const transformCompanyToListItem = ({ if (latest_interaction_date) { metadata.push({ label: 'Last interaction date', - value: format(latest_interaction_date), + value: formatDate(latest_interaction_date, DATE_FORMAT_COMPACT), }) } diff --git a/src/client/modules/Companies/CompanyBusinessDetails/CompanyBusinessDetails.jsx b/src/client/modules/Companies/CompanyBusinessDetails/CompanyBusinessDetails.jsx index b8ffb56e7b2..9d876438fa1 100644 --- a/src/client/modules/Companies/CompanyBusinessDetails/CompanyBusinessDetails.jsx +++ b/src/client/modules/Companies/CompanyBusinessDetails/CompanyBusinessDetails.jsx @@ -23,7 +23,7 @@ import { import CompanyLayout from '../../../components/Layout/CompanyLayout' import Task from '../../../components/Task' import urls from '../../../../lib/urls' -import { format } from '../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../utils/date-utils' import { ID, @@ -90,7 +90,10 @@ const CompanyBusinessDetails = ({ . {lastUpdated(company) && ( -
Last updated on: {format(lastUpdated(company))}
+
+ Last updated on:{' '} + {formatDate(lastUpdated(company), DATE_FORMAT_COMPACT)} +
)} (company) => { if (latest_interaction_date) { metadata.push({ label: 'Last interaction date', - value: format(latest_interaction_date), + value: formatDate(latest_interaction_date, DATE_FORMAT_COMPACT), }) } diff --git a/src/client/modules/Companies/CompanyBusinessDetails/LinkSubsidiary/transformers.js b/src/client/modules/Companies/CompanyBusinessDetails/LinkSubsidiary/transformers.js index 0d550dc6ee1..2c0fd1233cf 100644 --- a/src/client/modules/Companies/CompanyBusinessDetails/LinkSubsidiary/transformers.js +++ b/src/client/modules/Companies/CompanyBusinessDetails/LinkSubsidiary/transformers.js @@ -5,9 +5,9 @@ import urls from '../../../../../lib/urls' import { addressToString } from '../../../../utils/addresses' -const { format } = require('../../../../utils/date') const { formatDate, + DATE_FORMAT_COMPACT, DATE_FORMAT_MEDIUM_WITH_TIME, } = require('../../../../utils/date-utils') @@ -54,7 +54,7 @@ const transformSubsidiaryToListItem = (parentCompanyId) => (company) => { if (latest_interaction_date) { metadata.push({ label: 'Last interaction date', - value: format(latest_interaction_date), + value: formatDate(latest_interaction_date, DATE_FORMAT_COMPACT), }) } diff --git a/src/client/modules/Companies/CompanyHierarchy/CompanyTree.jsx b/src/client/modules/Companies/CompanyHierarchy/CompanyTree.jsx index 2c241cb6f03..5c0fa08e681 100644 --- a/src/client/modules/Companies/CompanyHierarchy/CompanyTree.jsx +++ b/src/client/modules/Companies/CompanyHierarchy/CompanyTree.jsx @@ -39,7 +39,7 @@ import { } from './styled' import { addressToString } from '../../../utils/addresses' import { GREY_4, BLACK, WHITE, BLUE } from '../../../utils/colours' -import { format } from '../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../utils/date-utils' import { hqLabels } from '../../../../apps/companies/labels' const ToggleSubsidiariesButton = ({ @@ -405,7 +405,10 @@ const HierarchyItem = ({
Last interaction date
{company.latest_interaction_date - ? format(company.latest_interaction_date) + ? formatDate( + company.latest_interaction_date, + DATE_FORMAT_COMPACT + ) : 'Not set'}
diff --git a/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx b/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx index 046b9a27ab3..9f0d5843f0e 100644 --- a/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx +++ b/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx @@ -2,7 +2,7 @@ import React from 'react' import { SummaryTable } from '../../../../components' import { requiredCheckTypes } from './constants' -import { format } from '../../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../../utils/date-utils' const buildRequiredCheckField = ( requiredChecks, @@ -16,9 +16,9 @@ const buildRequiredCheckField = ( return ( requiredChecks.name + `\n` + - `Date of most recent background checks: ${format( + `Date of most recent background checks: ${formatDate( requiredChecksConductedOn, - 'dd MM yyyy' + DATE_FORMAT_COMPACT )}` + `\n` + `Person responsible for most recent background checks: ${requiredChecksConductedBy?.name}` diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/ExportStatusCard.jsx b/src/client/modules/Companies/CompanyOverview/TableCards/ExportStatusCard.jsx index 8fc23672d92..f814477cf2a 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/ExportStatusCard.jsx +++ b/src/client/modules/Companies/CompanyOverview/TableCards/ExportStatusCard.jsx @@ -13,7 +13,7 @@ import { exportWinsState2props, } from './state' import { OVERVIEW__EXPORT_WINS_SUMMARY } from '../../../../actions' -import { format } from '../../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../../utils/date-utils' import { transformExportCountries } from '../../CompanyExports/transformers' import { companies } from '../../../../../lib/urls' import { buildCellContents } from './transformers' @@ -185,7 +185,7 @@ export const ExportStatusDetails = ({ latestExportWin.error ? ( {latestExportWin.error} ) : ( - `${format(latestExportWin.date)}, ${latestExportWin.country}` + `${formatDate(latestExportWin.date, DATE_FORMAT_COMPACT)}, ${latestExportWin.country}` ) ) : ( 'No export wins recorded' diff --git a/src/client/modules/Companies/CompanyOverview/TableCards/InvestmentStatusCard.jsx b/src/client/modules/Companies/CompanyOverview/TableCards/InvestmentStatusCard.jsx index 9ede240db0d..0ddd59d56fa 100644 --- a/src/client/modules/Companies/CompanyOverview/TableCards/InvestmentStatusCard.jsx +++ b/src/client/modules/Companies/CompanyOverview/TableCards/InvestmentStatusCard.jsx @@ -19,7 +19,10 @@ import { StyledTableRow, } from './components' -const { format } = require('../../../../utils/date') +const { + formatDate, + DATE_FORMAT_COMPACT, +} = require('../../../../utils/date-utils') const buildProjectStatusUrl = (companyId, param) => urls.companies.investments.companyInvestmentProjects(companyId) + param @@ -74,7 +77,7 @@ const InvestmentStatusCard = ({ )} data-test="latest-won-project-link" > - {`${format(summary.won.last_won_project.last_changed)} - ${ + {`${formatDate(summary.won.last_won_project.last_changed, DATE_FORMAT_COMPACT)} - ${ summary.won.last_won_project.name }`} diff --git a/src/client/modules/ExportPipeline/ExportDetails/index.jsx b/src/client/modules/ExportPipeline/ExportDetails/index.jsx index 41579013e1e..949199eba8a 100644 --- a/src/client/modules/ExportPipeline/ExportDetails/index.jsx +++ b/src/client/modules/ExportPipeline/ExportDetails/index.jsx @@ -12,7 +12,10 @@ import { EXPORT_LOADED } from '../../../actions' import { DefaultLayout, SummaryTable } from '../../../components' import Task from '../../../components/Task' import { ID, state2props, TASK_GET_EXPORT_DETAIL } from './state' -import { format } from '../../../../client/utils/date' +import { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} from '../../../../client/utils/date-utils' import { currencyGBP } from '../../../../client/utils/number-utils' import { BLACK, GREY_3 } from '../../../utils/colours' import { transformIdNameToValueLabel } from '../../../transformers' @@ -136,7 +139,10 @@ const ExportDetailsForm = ({ exportItem }) => { > {isEmpty(exportItem.estimated_win_date) ? 'Not set' - : format(exportItem.estimated_win_date, 'MMMM yyyy')} + : formatDate( + exportItem.estimated_win_date, + DATE_FORMAT_DAY_MONTH_YEAR + )}
{isEmpty(exportItem.status) diff --git a/src/client/modules/Interactions/CollectionList/transformers.js b/src/client/modules/Interactions/CollectionList/transformers.js index 293d4d2dbef..84b37daacf3 100644 --- a/src/client/modules/Interactions/CollectionList/transformers.js +++ b/src/client/modules/Interactions/CollectionList/transformers.js @@ -1,7 +1,10 @@ /* eslint-disable camelcase */ import { get } from 'lodash' -import { format } from '../../../utils/date' +import { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} from '../../../utils/date-utils' import urls from '../../../../lib/urls' @@ -55,7 +58,7 @@ export const transformInteractionToListItem = ({ } = {}) => ({ id, metadata: [ - { label: 'Date', value: format(date, 'dd MMMM yyyy') }, + { label: 'Date', value: formatDate(date, DATE_FORMAT_DAY_MONTH_YEAR) }, { label: 'Contact(s)', value: contacts && formatContacts(contacts), diff --git a/src/client/modules/Interactions/InteractionDetails/InteractionReferralDetails.jsx b/src/client/modules/Interactions/InteractionDetails/InteractionReferralDetails.jsx index 50f5a4ca81d..1f934e6fa4b 100644 --- a/src/client/modules/Interactions/InteractionDetails/InteractionReferralDetails.jsx +++ b/src/client/modules/Interactions/InteractionDetails/InteractionReferralDetails.jsx @@ -6,7 +6,7 @@ import styled from 'styled-components' import { SummaryTable } from '../../../components' import urls from '../../../../lib/urls' -const { format } = require('../../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../../utils/date-utils') const StyledSummaryTable = styled(SummaryTable)({ 'margin-top': SPACING_POINTS[8], @@ -24,7 +24,7 @@ const InteractionReferralDetails = ({ referral, companyId }) => { - {format(referral.createdOn)} + {formatDate(referral.createdOn, DATE_FORMAT_COMPACT)} {referral.createdBy.name} diff --git a/src/client/modules/Investments/EYBLeads/EYBLeadDetails.jsx b/src/client/modules/Investments/EYBLeads/EYBLeadDetails.jsx index 9e316e61ee5..28d2f2a5815 100644 --- a/src/client/modules/Investments/EYBLeads/EYBLeadDetails.jsx +++ b/src/client/modules/Investments/EYBLeads/EYBLeadDetails.jsx @@ -2,7 +2,7 @@ import React from 'react' import { useParams } from 'react-router-dom' import { Link } from 'govuk-react' -import { format } from '../../../utils/date' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../utils/date-utils' import urls from '../../../../lib/urls' import { EYBLeadResource } from '../../../components/Resource' import { EYBLeadLayout, NewWindowLink, SummaryTable } from '../../../components' @@ -49,7 +49,10 @@ const EYBLeadDetails = () => { /> {eybLead.companyWebsite ? ( diff --git a/src/client/modules/Investments/EYBLeads/transformers.js b/src/client/modules/Investments/EYBLeads/transformers.js index e1c3e381a9f..77f6270b7f4 100644 --- a/src/client/modules/Investments/EYBLeads/transformers.js +++ b/src/client/modules/Investments/EYBLeads/transformers.js @@ -1,7 +1,7 @@ import urls from '../../../../lib/urls' import { TAG_COLOURS } from '../../../components/Tag' -import { format } from '../../../utils/date' import { VALUES_VALUE_TO_LABEL_MAP } from './constants' +import { formatDate, DATE_FORMAT_COMPACT } from '../../../utils/date-utils' export const transformLeadToListItem = ({ id, @@ -29,7 +29,7 @@ export const transformLeadToListItem = ({ const metadata = [ { label: 'Submitted to EYB', - value: format(triage_created, 'dd MMM yyyy'), + value: formatDate(triage_created, DATE_FORMAT_COMPACT), }, { label: 'Estimated spend', value: spend }, { label: 'Sector', value: sector ? sector.name : '' }, diff --git a/src/client/modules/Investments/Profiles/transformers.js b/src/client/modules/Investments/Profiles/transformers.js index 3be9c68abea..781b1f280ef 100644 --- a/src/client/modules/Investments/Profiles/transformers.js +++ b/src/client/modules/Investments/Profiles/transformers.js @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ import { companies } from '../../../../lib/urls' -const { format } = require('../../../utils/date') +const { formatDate, DATE_FORMAT_COMPACT } = require('../../../utils/date-utils') const transformLargeCapitalProfiles = ({ investor_company, created_on }) => ({ headingText: investor_company.name, @@ -10,7 +10,7 @@ const transformLargeCapitalProfiles = ({ investor_company, created_on }) => ({ metadata: [ { label: 'Updated on', - value: format(created_on), + value: formatDate(created_on, DATE_FORMAT_COMPACT), }, ], }) diff --git a/src/client/modules/Investments/Projects/Details/EditAssociatedProject/transformers.js b/src/client/modules/Investments/Projects/Details/EditAssociatedProject/transformers.js index d2221b6d0f8..2f27b3221ec 100644 --- a/src/client/modules/Investments/Projects/Details/EditAssociatedProject/transformers.js +++ b/src/client/modules/Investments/Projects/Details/EditAssociatedProject/transformers.js @@ -1,5 +1,8 @@ import urls from '../../../../../../lib/urls' -import { format } from '../../../../../utils/date' +import { + formatDate, + DATE_FORMAT_MONTH_YEAR, +} from '../../../../../utils/date-utils' export const checkIfAssociatedProjectExists = (hasAssociatedProject) => hasAssociatedProject ? 'Update associated project' : 'Add associated project' @@ -28,7 +31,9 @@ const transformNonFdiProjectToListItem = (projectId) => (project) => { { label: 'Sector', value: sector ? sector.name : '' }, { label: 'Estimated land date', - value: estimated_land_date && format(estimated_land_date, 'MMMM yyyy'), + value: + estimated_land_date && + formatDate(estimated_land_date, DATE_FORMAT_MONTH_YEAR), }, ].filter((metadata) => metadata.value) diff --git a/src/client/modules/Investments/Projects/Details/EditRecipientCompany/transformers.js b/src/client/modules/Investments/Projects/Details/EditRecipientCompany/transformers.js index fa4c610678e..1a80c7930e5 100644 --- a/src/client/modules/Investments/Projects/Details/EditRecipientCompany/transformers.js +++ b/src/client/modules/Investments/Projects/Details/EditRecipientCompany/transformers.js @@ -3,9 +3,9 @@ import { get } from 'lodash' import urls from '../../../../../../lib/urls' import labels from '../../../../Companies/CollectionList/labels' import { addressToString } from '../../../../../utils/addresses' -import { format } from '../../../../../utils/date' import { formatDate, + DATE_FORMAT_COMPACT, DATE_FORMAT_MEDIUM_WITH_TIME, } from '../../../../../utils/date-utils' @@ -51,7 +51,7 @@ const transformCompanyToListItem = if (latest_interaction_date) { metadata.push({ label: 'Last interaction date', - value: format(latest_interaction_date), + value: formatDate(latest_interaction_date, DATE_FORMAT_COMPACT), }) } diff --git a/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx b/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx index b92a56f761f..c0d19a60117 100644 --- a/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx +++ b/src/client/modules/Investments/Projects/Details/ProjectDetails.jsx @@ -23,8 +23,11 @@ import { transformBusinessActivity } from './transformers' import urls from '../../../../../lib/urls' import { state2props } from './state' import { transformArray } from '../../../Companies/CompanyInvestments/LargeCapitalProfile/transformers' -import { format } from '../../../../utils/date' -import { DATE_LONG_FORMAT_1 } from '../../../../../common/constants' +import { + formatDate, + DATE_FORMAT_FULL, + DATE_FORMAT_MONTH_YEAR, +} from '../../../../utils/date-utils' import { GREY_3, BLACK } from '../../../../utils/colours' import { currencyGBP } from '../../../../utils/number-utils' import InvestmentName from '../InvestmentName' @@ -157,7 +160,10 @@ const ProjectDetails = ({ currentAdviserId }) => { {project.estimatedLandDate ? ( ) : null} {project.likelihoodToLand ? ( @@ -169,7 +175,7 @@ const ProjectDetails = ({ currentAdviserId }) => { {project.actualLandDate ? ( ) : null} {project.investorType ? ( diff --git a/src/client/modules/Investments/Projects/ProjectEvaluation.jsx b/src/client/modules/Investments/Projects/ProjectEvaluation.jsx index c3a28233553..c0fa7461c4f 100644 --- a/src/client/modules/Investments/Projects/ProjectEvaluation.jsx +++ b/src/client/modules/Investments/Projects/ProjectEvaluation.jsx @@ -17,8 +17,7 @@ import { transformFdiType, } from './transformers' import urls from '../../../../lib/urls' -import { format } from '../../../utils/date' -import { DATE_LONG_FORMAT_1 } from '../../../../common/constants' +import { formatDate, DATE_FORMAT_FULL } from '../../../utils/date-utils' import ProjectLayoutNew from '../../../components/Layout/ProjectLayoutNew' import InvestmentName from './InvestmentName' @@ -92,7 +91,9 @@ const landingTable = (ukCompany = null, actualLandDate) => (
diff --git a/src/client/modules/Investments/Projects/Team/EditProjectManagement.jsx b/src/client/modules/Investments/Projects/Team/EditProjectManagement.jsx index 92201a5ce46..539bc3d1497 100644 --- a/src/client/modules/Investments/Projects/Team/EditProjectManagement.jsx +++ b/src/client/modules/Investments/Projects/Team/EditProjectManagement.jsx @@ -21,7 +21,10 @@ import { InvestmentResource, } from '../../../../components/Resource' import ProjectLayout from '../../../../components/Layout/ProjectLayout' -import { format } from '../../../../utils/date' +import { + formatDate, + DATE_FORMAT_MONTH_YEAR, +} from '../../../../utils/date-utils' import { currencyGBP } from '../../../../utils/number-utils' const EditProjectManagement = () => { @@ -125,7 +128,10 @@ const EditProjectManagement = () => { /> ({ id, metadata: [ - { label: 'Deadline', value: format(deadline, 'dd MMMM yyyy') }, - { label: 'Created on', value: format(created_on, 'dd MMMM yyyy') }, + { + label: 'Deadline', + value: formatDate(deadline, DATE_FORMAT_DAY_MONTH_YEAR), + }, + { + label: 'Created on', + value: formatDate(created_on, DATE_FORMAT_DAY_MONTH_YEAR), + }, { label: 'Adviser', value: adviser.name, @@ -266,7 +275,9 @@ export const transformInvestmentProjectToListItem = ({ { label: 'Sector', value: sector ? sector.name : '' }, { label: 'Estimated land date', - value: estimated_land_date && format(estimated_land_date, 'MMMM yyyy'), + value: + estimated_land_date && + formatDate(estimated_land_date, DATE_FORMAT_DAY_MONTH_YEAR), }, ].filter((metadata) => metadata.value) @@ -303,10 +314,15 @@ export const transformTaskToListItem = ({ headingText: title, subheading: getTaskSubheading(archived), metadata: [ - { label: 'Date created', value: format(createdOn, 'dd MMMM yyyy') }, + { + label: 'Date created', + value: formatDate(createdOn, DATE_FORMAT_DAY_MONTH_YEAR), + }, { label: 'Due date', - value: dueDate ? format(dueDate, 'dd MMMM yyyy') : NOT_SET_TEXT, + value: dueDate + ? formatDate(dueDate, DATE_FORMAT_DAY_MONTH_YEAR) + : NOT_SET_TEXT, }, { label: 'Assigned to', value: advisers.map((a) => a.name).join(', ') }, ], diff --git a/src/client/modules/Omis/CollectionList/transformers.js b/src/client/modules/Omis/CollectionList/transformers.js index 27a506a4cc0..6abfd4e9518 100644 --- a/src/client/modules/Omis/CollectionList/transformers.js +++ b/src/client/modules/Omis/CollectionList/transformers.js @@ -4,10 +4,10 @@ import { STATUSES } from './constants' import { omis } from '../../../../lib/urls' import { currencyGBP } from '../../../utils/number-utils' -const { format } = require('../../../utils/date') const { formatDate, DATE_FORMAT_MEDIUM, + DATE_FORMAT_COMPACT, DATE_FORMAT_MEDIUM_WITH_TIME, } = require('../../../utils/date-utils') @@ -51,7 +51,9 @@ export const transformOrderToListItem = ({ }, { label: 'Delivery date', - value: delivery_date ? format(delivery_date) : null, + value: delivery_date + ? formatDate(delivery_date, DATE_FORMAT_COMPACT) + : null, }, ].filter((item) => item.value) diff --git a/src/client/modules/Omis/CreateOrder/CompanySelect/transformers.js b/src/client/modules/Omis/CreateOrder/CompanySelect/transformers.js index 49c3f1bc148..57d40ce9093 100644 --- a/src/client/modules/Omis/CreateOrder/CompanySelect/transformers.js +++ b/src/client/modules/Omis/CreateOrder/CompanySelect/transformers.js @@ -5,9 +5,9 @@ import urls from '../../../../../lib/urls' import { addressToString } from '../../../../utils/addresses' -const { format } = require('../../../../utils/date') const { formatDate, + DATE_FORMAT_COMPACT, DATE_FORMAT_MEDIUM_WITH_TIME, } = require('../../../../utils/date-utils') @@ -48,7 +48,7 @@ const transformCompanyToListItem = ({ if (latest_interaction_date) { metadata.push({ label: 'Last interaction date', - value: format(latest_interaction_date), + value: formatDate(latest_interaction_date, DATE_FORMAT_COMPACT), }) } diff --git a/src/client/modules/Omis/PaymentReceipt.jsx b/src/client/modules/Omis/PaymentReceipt.jsx index 5527848d661..5dc0ce22ec2 100644 --- a/src/client/modules/Omis/PaymentReceipt.jsx +++ b/src/client/modules/Omis/PaymentReceipt.jsx @@ -12,8 +12,7 @@ import { } from '../../components/Resource' import OMISLayout from './OMISLayout' import { DARK_GREY } from '../../utils/colours' -import { format } from '../../utils/date' -import { DATE_LONG_FORMAT_1 } from '../../../common/constants' +import { formatDate, DATE_FORMAT_FULL } from '../../utils/date-utils' import { currencyGBP } from '../../utils/number-utils' import { ButtonLink } from '../../components' import urls from '../../../lib/urls' @@ -78,7 +77,7 @@ export const AddressSection = ({ invoice, paymentDate }) => ( Receipt date

- {format(paymentDate, DATE_LONG_FORMAT_1)} + {formatDate(paymentDate, DATE_FORMAT_FULL)}

@@ -169,7 +168,7 @@ export const PaymentSection = ({ Amount received

{currencyGBP(payment[0].amount / 100)}

Received on -

{format(payment[0].receivedOn, DATE_LONG_FORMAT_1)}

+

{formatDate(payment[0].receivedOn, DATE_FORMAT_FULL)}

{payment[0].transactionReference && ( <> Transaction reference diff --git a/src/client/modules/Omis/PaymentReconciliation.jsx b/src/client/modules/Omis/PaymentReconciliation.jsx index 855348349ff..f49566966c8 100644 --- a/src/client/modules/Omis/PaymentReconciliation.jsx +++ b/src/client/modules/Omis/PaymentReconciliation.jsx @@ -18,8 +18,9 @@ import { } from '../../components/Resource' import urls from '../../../lib/urls' import { currencyGBP } from '../../utils/number-utils' -import { format, getDifferenceInWords } from '../../utils/date' -import { DATE_LONG_FORMAT_1, FORM_LAYOUT } from '../../../common/constants' +import { getDifferenceInWords } from '../../utils/date' +import { formatDate, DATE_FORMAT_FULL } from '../../utils/date-utils' +import { FORM_LAYOUT } from '../../../common/constants' import { validateAmountRecieved, validateIfDateInPast } from './validators' import { TASK_RECONCILE_OMIS_PAYMENT } from './state' import { @@ -106,7 +107,7 @@ export const InvoiceDetails = ({ invoice, reference }) => ( Payment due date - {format(invoice.paymentDueDate, DATE_LONG_FORMAT_1) + + {formatDate(invoice.paymentDueDate, DATE_FORMAT_FULL) + ' (' + getDifferenceInWords(invoice.paymentDueDate) + ')'} diff --git a/src/client/modules/Reminders/ItemRenderers/Investments/InvestmentOPListItemRenderer.jsx b/src/client/modules/Reminders/ItemRenderers/Investments/InvestmentOPListItemRenderer.jsx index d20eb2b2f6b..d7871139eec 100644 --- a/src/client/modules/Reminders/ItemRenderers/Investments/InvestmentOPListItemRenderer.jsx +++ b/src/client/modules/Reminders/ItemRenderers/Investments/InvestmentOPListItemRenderer.jsx @@ -6,8 +6,7 @@ import { Link } from 'govuk-react' import styled from 'styled-components' import { ListItem, ItemHeader, ItemFooter } from '../styled' -import { DATE_DAY_LONG_FORMAT } from '../../../../../common/constants' -import { format } from '../../../../utils/date' +import { formatDate, DATE_FORMAT_FULL_DAY } from '../../../../utils/date-utils' import urls from '../../../../../lib/urls' const ItemContent = styled('div')({ @@ -20,7 +19,7 @@ const InvestmentOPListItemRenderer = (item) => ( - Due {format(item.deadline, DATE_DAY_LONG_FORMAT)} + Due {formatDate(item.deadline, DATE_FORMAT_FULL_DAY)} (
  • Date due: - {format(item.task.due_date, DATE_LONG_FORMAT_1)} + {formatDate(item.task.due_date, DATE_FORMAT_FULL)}
  • ) diff --git a/test/component/cypress/specs/Companies/CompanyHierarchy/Hierarchy.cy.jsx b/test/component/cypress/specs/Companies/CompanyHierarchy/Hierarchy.cy.jsx index 54630f5970a..102f8aa8f47 100644 --- a/test/component/cypress/specs/Companies/CompanyHierarchy/Hierarchy.cy.jsx +++ b/test/component/cypress/specs/Companies/CompanyHierarchy/Hierarchy.cy.jsx @@ -14,7 +14,10 @@ import { rgb, DARK_BLUE_LEGACY, } from '../../../../../../src/client/utils/colours' -import { format } from '../../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_COMPACT, +} from '../../../../../../src/client/utils/date-utils' const { company: { dnbGlobalUltimate, allOverviewDetails }, @@ -490,9 +493,10 @@ describe('D&B Company Tree Hierarchy component', () => { }) context('When a company has a mix of known and unknown subsidiaries', () => { - const formattedDate = format( + const formattedDate = formatDate( companyManuallyLinkedSubsidiaries.ultimate_global_company.subsidiaries[0] - .latest_interaction_date + .latest_interaction_date, + DATE_FORMAT_COMPACT ) beforeEach(() => { diff --git a/test/component/cypress/specs/Omis/WorkOrder/OrderIncompleteFields.cy.jsx b/test/component/cypress/specs/Omis/WorkOrder/OrderIncompleteFields.cy.jsx index 067a3994d5e..9917b59e137 100644 --- a/test/component/cypress/specs/Omis/WorkOrder/OrderIncompleteFields.cy.jsx +++ b/test/component/cypress/specs/Omis/WorkOrder/OrderIncompleteFields.cy.jsx @@ -7,7 +7,10 @@ import { VAT_STATUS, } from '../../../../../../src/client/modules/Omis/constants' import urls from '../../../../../../src/lib/urls' -import { format } from '../../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_COMPACT, +} from '../../../../../../src/client/utils/date-utils' const quoteAwaitingOrder = { id: '123', @@ -83,8 +86,9 @@ describe('OrderIncompleteFields', () => { .should('exist') .should( 'have.text', - `This order was cancelled on ${format( - cancelledOrder.cancelledOn + `This order was cancelled on ${formatDate( + cancelledOrder.cancelledOn, + DATE_FORMAT_COMPACT )} by ${cancelledOrder.cancelledBy.name}.` ) cy.get('[data-test="archive-reason"]') diff --git a/test/functional/cypress/specs/companies/account-management-add-edit-objective-spec.js b/test/functional/cypress/specs/companies/account-management-add-edit-objective-spec.js index 368f6499ceb..8bf851dd428 100644 --- a/test/functional/cypress/specs/companies/account-management-add-edit-objective-spec.js +++ b/test/functional/cypress/specs/companies/account-management-add-edit-objective-spec.js @@ -1,5 +1,7 @@ -import { format } from '../../../../../src/client/utils/date' -import { DATE_LONG_FORMAT_3 } from '../../../../../src/common/constants' +import { + formatDate, + DATE_FORMAT_ISO, +} from '../../../../../src/client/utils/date-utils' import { companyFaker } from '../../fakers/companies' import { objectiveFaker } from '../../fakers/objective' import { clickButton } from '../../support/actions' @@ -120,9 +122,9 @@ describe('Company account management', () => { has_blocker: withBlockersObjective.has_blocker, progress: withBlockersObjective.progress, subject: withBlockersObjective.subject, - target_date: format( + target_date: formatDate( withBlockersObjective.target_date, - DATE_LONG_FORMAT_3 + DATE_FORMAT_ISO ), }) }) diff --git a/test/functional/cypress/specs/companies/account-management-spec.js b/test/functional/cypress/specs/companies/account-management-spec.js index fcabcbe6dd3..b6d1795116b 100644 --- a/test/functional/cypress/specs/companies/account-management-spec.js +++ b/test/functional/cypress/specs/companies/account-management-spec.js @@ -1,11 +1,12 @@ -import { format } from 'date-fns' - import { faker } from '../../../../sandbox/utils/random' - import { companyFaker } from '../../fakers/companies' import { userFaker } from '../../fakers/users' import objectiveListFaker, { objectiveFaker } from '../../fakers/objective' import { adviserFaker } from '../../fakers/advisers' +import { + formatDate, + DATE_FORMAT_COMPACT, +} from '../../../../../src/client/utils/date-utils' import { assertCompanyBreadcrumbs, assertGovReactTable, @@ -88,9 +89,9 @@ describe('Company account management', () => { cy.get('[data-test="last-updated-strategy-details"] > span') .eq(0) .contains( - `Last updated by ${companyWithStrategy.modifiedBy.name}: ${format( + `Last updated by ${companyWithStrategy.modifiedBy.name}: ${formatDate( companyWithStrategy.modifiedOn, - 'dd MMM yyyy' + DATE_FORMAT_COMPACT )}. ` ) }) diff --git a/test/functional/cypress/specs/companies/archived-objectives-spec.js b/test/functional/cypress/specs/companies/archived-objectives-spec.js index f8c785e09e6..e9be8ab0120 100644 --- a/test/functional/cypress/specs/companies/archived-objectives-spec.js +++ b/test/functional/cypress/specs/companies/archived-objectives-spec.js @@ -1,4 +1,7 @@ -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_COMPACT, +} from '../../../../../src/client/utils/date-utils' import { objectiveFaker } from '../../fakers/objective' const fixtures = require('../../fixtures') @@ -32,12 +35,18 @@ context('When visiting the archived objective page with objectives', () => { it('should display 2 archived objectives with correct details', () => { cy.get('[data-test="objective-1"]') .should('contain.text', incompleteObjective.detail) - .should('contain.text', format(incompleteObjective.target_date)) + .should( + 'contain.text', + formatDate(incompleteObjective.target_date, DATE_FORMAT_COMPACT) + ) .should('contain.text', incompleteObjective.progress) .should('contain.text', incompleteObjective.modifiedBy.name) cy.get('[data-test="objective-2"]') .should('contain.text', completeObjective.detail) - .should('contain.text', format(completeObjective.target_date)) + .should( + 'contain.text', + formatDate(completeObjective.target_date, DATE_FORMAT_COMPACT) + ) .should('contain.text', completeObjective.progress) .should('contain.text', completeObjective.modifiedBy.name) }) diff --git a/test/functional/cypress/specs/export-pipeline/export-details-spec.js b/test/functional/cypress/specs/export-pipeline/export-details-spec.js index 043252883f9..bef20aeb9ae 100644 --- a/test/functional/cypress/specs/export-pipeline/export-details-spec.js +++ b/test/functional/cypress/specs/export-pipeline/export-details-spec.js @@ -2,7 +2,10 @@ import { capitalize } from 'lodash' import urls from '../../../../../src/lib/urls' import { currencyGBP } from '../../../../../src/client/utils/number-utils' -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_MONTH_YEAR, +} from '../../../../../src/client/utils/date-utils' import { exportFaker } from '../../fakers/export' const { @@ -33,9 +36,9 @@ describe('Export Details summary ', () => { exportItem.estimated_export_value_years?.name } / ${currencyGBP(exportItem.estimated_export_value_amount)}` - const estimatedWinDate = format( - exportItem.estimated_win_date.toISOString(), - 'MMMM yyyy' + const estimatedWinDate = formatDate( + exportItem.estimated_win_date, + DATE_FORMAT_MONTH_YEAR ) assertKeyValueTable('bodyMainContent', { 'Export title': exportItem.title, diff --git a/test/functional/cypress/specs/investments/eyb-leads-spec.js b/test/functional/cypress/specs/investments/eyb-leads-spec.js index c15bb51c39f..891578901cf 100644 --- a/test/functional/cypress/specs/investments/eyb-leads-spec.js +++ b/test/functional/cypress/specs/investments/eyb-leads-spec.js @@ -13,7 +13,10 @@ import { selectFirstTypeaheadOption, } from '../../support/actions' import { investments } from '../../../../../src/lib/urls' -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_COMPACT, +} from '../../../../../src/client/utils/date-utils' import { eybLeadFaker } from '../../fakers/eyb-leads' import { VALUES_VALUE_TO_LABEL_MAP } from '../../../../../src/client/modules/Investments/EYBLeads/constants' @@ -171,7 +174,7 @@ describe('EYB leads collection page', () => { .should('contain', eybLead.company.name) .should( 'contain', - `Submitted to EYB ${format(eybLead.triage_created, 'dd MMM yyyy')}` + `Submitted to EYB ${formatDate(eybLead.triage_created, DATE_FORMAT_COMPACT)}` ) .should('contain', `Estimated spend ${eybLead.spend}`) .should('contain', `Sector ${eybLead.sector.name}`) diff --git a/test/functional/cypress/specs/investments/opportunity-interactions-spec.js b/test/functional/cypress/specs/investments/opportunity-interactions-spec.js index b53c6445f2e..3211ddc1c45 100644 --- a/test/functional/cypress/specs/investments/opportunity-interactions-spec.js +++ b/test/functional/cypress/specs/investments/opportunity-interactions-spec.js @@ -9,7 +9,7 @@ const { assertBreadcrumbs, assertQueryParams, } = require('../../support/assertions') -const { format } = require('../../../../../src/client/utils/date') +const { formatDate } = require('../../../../../src/client/utils/date-utils') const interaction = interactionFaker() const interactionsList = interactionsListFaker(10) @@ -65,7 +65,10 @@ describe('The interactions tab on an opportunity page', () => { cy.get('[data-test="collection-item"]') .find('[data-test="metadata"]') - .should('contain', `Date ${format(interaction.date, 'dd MMMM yyyy')}`) + .should( + 'contain', + `Date ${formatDate(interaction.date, DATE_FORMAT_DAY_MONTH_YEAR)}` + ) .and('contain', `Contact(s) ${interaction.contacts[0].name}`) .and('contain', `Company ${interaction.companies[0].name}`) .and( diff --git a/test/functional/cypress/specs/investments/project-interactions-spec.js b/test/functional/cypress/specs/investments/project-interactions-spec.js index 976b41c892f..b016102c809 100644 --- a/test/functional/cypress/specs/investments/project-interactions-spec.js +++ b/test/functional/cypress/specs/investments/project-interactions-spec.js @@ -5,7 +5,10 @@ import { interactionFaker, } from '../../fakers/interactions' import { assertQueryParams } from '../../support/assertions' -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} from '../../../../../src/client/utils/date-utils' const interaction = interactionFaker() const interactionsList = interactionsListFaker(10) @@ -51,7 +54,10 @@ describe('Investment project interactions', () => { cy.get('[data-test="collection-item"]') .find('[data-test="metadata"]') - .should('contain', `Date ${format(interaction.date, 'dd MMMM yyyy')}`) + .should( + 'contain', + `Date ${formatDate(interaction.date, DATE_FORMAT_DAY_MONTH_YEAR)}` + ) .and('contain', `Contact(s) ${interaction.contacts[0].name}`) .and('contain', `Company ${interaction.companies[0].name}`) .and( diff --git a/test/functional/cypress/specs/investments/project-tasks-spec.js b/test/functional/cypress/specs/investments/project-tasks-spec.js index 3ff906eeb6f..74db935f64a 100644 --- a/test/functional/cypress/specs/investments/project-tasks-spec.js +++ b/test/functional/cypress/specs/investments/project-tasks-spec.js @@ -1,7 +1,10 @@ import fixtures from '../../fixtures' import urls from '../../../../../src/lib/urls' import { taskWithInvestmentProjectFaker } from '../../fakers/task' -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} from '../../../../../src/client/utils/date-utils' import { NOT_SET_TEXT } from '../../../../../src/apps/companies/constants' import { assertQueryParams } from '../../support/assertions' @@ -49,13 +52,13 @@ const assertTaskItem = (index, investmentTask) => { .find('[data-test="metadata"]') .should( 'contain', - `Date created ${format(investmentTask.createdOn, 'dd MMMM yyyy')}` + `Date created ${formatDate(investmentTask.createdOn, DATE_FORMAT_DAY_MONTH_YEAR)}` ) .and( 'contain', `Due date ${ investmentTask.dueDate - ? format(investmentTask.dueDate, 'dd MMMM yyyy') + ? formatDate(investmentTask.dueDate, DATE_FORMAT_DAY_MONTH_YEAR) : NOT_SET_TEXT }` ) diff --git a/test/functional/cypress/specs/tasks/create-similar-task-spec.js b/test/functional/cypress/specs/tasks/create-similar-task-spec.js index 09f02330193..1ca45216db0 100644 --- a/test/functional/cypress/specs/tasks/create-similar-task-spec.js +++ b/test/functional/cypress/specs/tasks/create-similar-task-spec.js @@ -10,8 +10,10 @@ import { assertPayload, assertFlashMessage, } from '../../../cypress/support/assertions' -import { DATE_LONG_FORMAT_3 } from '../../../../../src/common/constants' -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_ISO, +} from '../../../../../src/client/utils/date-utils' describe('Copy task from generic task task', () => { const genericTask = taskFaker() @@ -89,7 +91,7 @@ function assertTaskForm( interaction: interactionId, title: 'test copy task', description: 'test copy description', - due_date: format(task.dueDate, DATE_LONG_FORMAT_3), + due_date: formatDate(task.dueDate, DATE_FORMAT_ISO), email_reminders_enabled: task.emailRemindersEnabled, reminder_days: task.reminderDays, advisers: task.advisers.map((adviser) => adviser.id), diff --git a/test/functional/cypress/specs/tasks/edit-task-spec.js b/test/functional/cypress/specs/tasks/edit-task-spec.js index 2a7afe81cf1..6a071b71c3d 100644 --- a/test/functional/cypress/specs/tasks/edit-task-spec.js +++ b/test/functional/cypress/specs/tasks/edit-task-spec.js @@ -13,8 +13,10 @@ import { taskWithCompanyFaker, taskWithInvestmentProjectFaker, } from '../../fakers/task' -import { DATE_LONG_FORMAT_3 } from '../../../../../src/common/constants' -import { format } from '../../../../../src/client/utils/date' +import { + formatDate, + DATE_FORMAT_ISO, +} from '../../../../../src/client/utils/date-utils' import { companyFaker } from '../../fakers/companies' import { investmentProjectFaker } from '../../fakers/investment-projects' @@ -45,7 +47,7 @@ describe('Edit generic task', () => { assertPayload('@apiRequest', { title: 'new task', description: 'new description', - due_date: format(task.dueDate, DATE_LONG_FORMAT_3), + due_date: formatDate(task.dueDate, DATE_FORMAT_ISO), email_reminders_enabled: task.emailRemindersEnabled, investment_project: null, company: null, @@ -110,7 +112,7 @@ describe('Edit investment project task', () => { assertPayload('@apiRequest', { title: 'new task', description: 'new description', - due_date: format(investmentProjectTask.dueDate, DATE_LONG_FORMAT_3), + due_date: formatDate(investmentProjectTask.dueDate, DATE_FORMAT_ISO), email_reminders_enabled: investmentProjectTask.emailRemindersEnabled, company: null, investment_project: investmentProjectTask.investmentProject.id, @@ -252,7 +254,7 @@ describe('Edit company task', () => { assertPayload('@apiRequest', { title: 'new task', description: 'new description', - due_date: format(companyTask.dueDate, DATE_LONG_FORMAT_3), + due_date: formatDate(companyTask.dueDate, DATE_FORMAT_ISO), email_reminders_enabled: companyTask.emailRemindersEnabled, investment_project: null, company: companyTask.company.id, From b47ee4f1d443764a87dbbafb508581c14a4a2260 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Mon, 16 Dec 2024 13:02:45 +0000 Subject: [PATCH 2/9] Fix broken import --- test/end-to-end/cypress/specs/DIT/order-spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/end-to-end/cypress/specs/DIT/order-spec.js b/test/end-to-end/cypress/specs/DIT/order-spec.js index 26fc9b731f8..de9cc089acd 100644 --- a/test/end-to-end/cypress/specs/DIT/order-spec.js +++ b/test/end-to-end/cypress/specs/DIT/order-spec.js @@ -1,14 +1,14 @@ const fixtures = require('../../fixtures') const { formatDate, - DATE_MEDIUM_FORMAT, + DATE_FORMAT_MEDIUM, } = require('../../../../../src/client/utils/date-utils') const { omis } = require('../../../../../src/lib/urls') const { assertSummaryTable, } = require('../../../../functional/cypress/support/assertions') -const today = formatDate(new Date(), DATE_MEDIUM_FORMAT) +const today = formatDate(new Date(), DATE_FORMAT_MEDIUM) describe('Order', () => { const company = fixtures.company.create.defaultCompany('order testing') From 34829d39da12c33d5981f963e9103f0228dc5cdf Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Mon, 16 Dec 2024 13:04:05 +0000 Subject: [PATCH 3/9] Remove unused constants --- src/common/constants.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index 1e1b094914b..18150a951e1 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -1,14 +1,8 @@ // These are date-fns format codes - see https://date-fns.org/v2.23.0/docs/format -const DATE_LONG_FORMAT_1 = 'd MMMM yyyy' const DATE_LONG_FORMAT_2 = 'dd MMM yyyy' const DATE_LONG_FORMAT_3 = 'yyyy-MM-dd' -const DATE_DAY_LONG_FORMAT = 'E, dd MMM yyyy' -const DATE_MEDIUM_FORMAT = 'd MMM yyyy' -const DATE_TIME_MEDIUM_FORMAT = 'd MMM yyyy, h:mmaaa' const DATE_SHORT_FORMAT = 'yyyy-MM' -const DATE_SHORT_FORMAT_2 = 'MMMM yyyy' const DATE_DAY_MONTH = 'dd MMM' -const INTERACTION_TIMESTAMP_FORMAT = 'y-MM-d' const UNITED_KINGDOM_ID = '80756b9a-5d95-e211-a939-e4115bead28a' const UNITED_STATES_ID = '81756b9a-5d95-e211-a939-e4115bead28a' @@ -66,16 +60,10 @@ const EXPORT_INTEREST_STATUS = { } module.exports = { - DATE_DAY_LONG_FORMAT, DATE_DAY_MONTH, - DATE_LONG_FORMAT_1, DATE_LONG_FORMAT_2, DATE_LONG_FORMAT_3, - DATE_MEDIUM_FORMAT, - DATE_TIME_MEDIUM_FORMAT, DATE_SHORT_FORMAT, - DATE_SHORT_FORMAT_2, - INTERACTION_TIMESTAMP_FORMAT, UNITED_KINGDOM_ID, UNITED_STATES_ID, CANADA_ID, From 1db4426beae655708acac664d36d4a2a34812f2e Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Mon, 16 Dec 2024 15:50:41 +0000 Subject: [PATCH 4/9] Fix opportunity interactions functional tests --- .../specs/investments/opportunity-interactions-spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functional/cypress/specs/investments/opportunity-interactions-spec.js b/test/functional/cypress/specs/investments/opportunity-interactions-spec.js index 3211ddc1c45..f68414556dc 100644 --- a/test/functional/cypress/specs/investments/opportunity-interactions-spec.js +++ b/test/functional/cypress/specs/investments/opportunity-interactions-spec.js @@ -9,7 +9,10 @@ const { assertBreadcrumbs, assertQueryParams, } = require('../../support/assertions') -const { formatDate } = require('../../../../../src/client/utils/date-utils') +const { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} = require('../../../../../src/client/utils/date-utils') const interaction = interactionFaker() const interactionsList = interactionsListFaker(10) From 2c46ab9a9117b2f050362f556d491da2edd40cf0 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Mon, 16 Dec 2024 15:51:44 +0000 Subject: [PATCH 5/9] Fix export details functional tests --- src/client/modules/ExportPipeline/ExportDetails/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/modules/ExportPipeline/ExportDetails/index.jsx b/src/client/modules/ExportPipeline/ExportDetails/index.jsx index 949199eba8a..ed45c51af10 100644 --- a/src/client/modules/ExportPipeline/ExportDetails/index.jsx +++ b/src/client/modules/ExportPipeline/ExportDetails/index.jsx @@ -14,7 +14,7 @@ import Task from '../../../components/Task' import { ID, state2props, TASK_GET_EXPORT_DETAIL } from './state' import { formatDate, - DATE_FORMAT_DAY_MONTH_YEAR, + DATE_FORMAT_MONTH_YEAR, } from '../../../../client/utils/date-utils' import { currencyGBP } from '../../../../client/utils/number-utils' import { BLACK, GREY_3 } from '../../../utils/colours' @@ -141,7 +141,7 @@ const ExportDetailsForm = ({ exportItem }) => { ? 'Not set' : formatDate( exportItem.estimated_win_date, - DATE_FORMAT_DAY_MONTH_YEAR + DATE_FORMAT_MONTH_YEAR )}
    From d278390e006845def7c10a70bbd77f38cfaa8435 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Mon, 16 Dec 2024 19:13:00 +0000 Subject: [PATCH 6/9] Fix large capital profile functional tests --- .../LargeCapitalProfile/ProfileDetailsTable.jsx | 7 +++++-- .../companies/investments/large-capital-profile-spec.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx b/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx index 9f0d5843f0e..1cbf8489a90 100644 --- a/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx +++ b/src/client/modules/Companies/CompanyInvestments/LargeCapitalProfile/ProfileDetailsTable.jsx @@ -2,7 +2,10 @@ import React from 'react' import { SummaryTable } from '../../../../components' import { requiredCheckTypes } from './constants' -import { formatDate, DATE_FORMAT_COMPACT } from '../../../../utils/date-utils' +import { + formatDate, + DATE_FORMAT_DAY_MONTH_YEAR, +} from '../../../../utils/date-utils' const buildRequiredCheckField = ( requiredChecks, @@ -18,7 +21,7 @@ const buildRequiredCheckField = ( `\n` + `Date of most recent background checks: ${formatDate( requiredChecksConductedOn, - DATE_FORMAT_COMPACT + DATE_FORMAT_DAY_MONTH_YEAR )}` + `\n` + `Person responsible for most recent background checks: ${requiredChecksConductedBy?.name}` diff --git a/test/functional/cypress/specs/companies/investments/large-capital-profile-spec.js b/test/functional/cypress/specs/companies/investments/large-capital-profile-spec.js index 59b5d4c869f..0da1afd409b 100644 --- a/test/functional/cypress/specs/companies/investments/large-capital-profile-spec.js +++ b/test/functional/cypress/specs/companies/investments/large-capital-profile-spec.js @@ -92,7 +92,7 @@ describe('Company Investments and Large capital profile', () => { 'Investable capital': 30000, 'Investor description': 'incomplete', 'Has this investor cleared the required checks within the last 12 months?': - 'Cleared\nDate of most recent background checks: 29 04 2019\nPerson responsible for most recent background checks: Aaron Chan', + 'Cleared\nDate of most recent background checks: 29 April 2019\nPerson responsible for most recent background checks: Aaron Chan', }, }) }) From 07368df068295840238cc1ff3e19d3dfec36a7e4 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Tue, 17 Dec 2024 08:56:45 +0000 Subject: [PATCH 7/9] Fix investment project collection functional tests --- src/client/modules/Investments/Projects/transformers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/modules/Investments/Projects/transformers.js b/src/client/modules/Investments/Projects/transformers.js index 4fb0d447e98..aa31d645cfe 100644 --- a/src/client/modules/Investments/Projects/transformers.js +++ b/src/client/modules/Investments/Projects/transformers.js @@ -20,6 +20,7 @@ import { } from './constants' import { formatDate, + DATE_FORMAT_MONTH_YEAR, DATE_FORMAT_DAY_MONTH_YEAR, } from '../../../utils/date-utils' @@ -277,7 +278,7 @@ export const transformInvestmentProjectToListItem = ({ label: 'Estimated land date', value: estimated_land_date && - formatDate(estimated_land_date, DATE_FORMAT_DAY_MONTH_YEAR), + formatDate(estimated_land_date, DATE_FORMAT_MONTH_YEAR), }, ].filter((metadata) => metadata.value) From ae050e2de7b8c1c6facf7b274f0d14266ac1b8d3 Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Tue, 17 Dec 2024 11:00:04 +0000 Subject: [PATCH 8/9] Fix contact local header component tests --- src/client/components/ContactLocalHeader/index.jsx | 6 +++--- .../specs/Contacts/ContactLocalHeader.cy.jsx | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/client/components/ContactLocalHeader/index.jsx b/src/client/components/ContactLocalHeader/index.jsx index 3842598b91f..3132afa2ac4 100644 --- a/src/client/components/ContactLocalHeader/index.jsx +++ b/src/client/components/ContactLocalHeader/index.jsx @@ -100,9 +100,9 @@ const ContactLocalHeader = ({ contact, writeFlashMessage }) => { {contact.archived && ( { writeFlashMessage('Contact record updated') diff --git a/test/component/cypress/specs/Contacts/ContactLocalHeader.cy.jsx b/test/component/cypress/specs/Contacts/ContactLocalHeader.cy.jsx index 5726a08f457..f92665643ef 100644 --- a/test/component/cypress/specs/Contacts/ContactLocalHeader.cy.jsx +++ b/test/component/cypress/specs/Contacts/ContactLocalHeader.cy.jsx @@ -94,6 +94,20 @@ describe('ContactLocalHeader', () => { it('should render the archive panel', () => { cy.get('[data-test=archive-panel]').should('exist') }) + + it('should render an archived message', () => { + cy.get('[data-test="archive-message"]').should( + 'have.text', + 'This contact was archived on 04 Jul 2019 by Bernard Harris-Patel.' + ) + }) + + it('should render an archived reason', () => { + cy.get('[data-test="archive-reason"]').should( + 'have.text', + 'Reason: Left the company' + ) + }) }) }) From 7ff44b2dea2a15c61c76a3eaca7de9fa68b90f8f Mon Sep 17 00:00:00 2001 From: Paul Gain Date: Tue, 17 Dec 2024 11:30:28 +0000 Subject: [PATCH 9/9] Add a deprecation warning to the format function in date.js, recommending the use of formatDate instead --- src/client/utils/date.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/utils/date.js b/src/client/utils/date.js index 58ab504418c..69fed4dda32 100644 --- a/src/client/utils/date.js +++ b/src/client/utils/date.js @@ -120,13 +120,18 @@ function isShortDateValid(year, month) { } /** - * Date formatting and parsing functions + * @deprecated This function is deprecated. Use `formatDate` instead. + * + * This function will be removed in the near future. */ - function format(dateStr, dateFormat = DATE_LONG_FORMAT_2) { return isDateValid(dateStr) ? formatFns(parseISO(dateStr), dateFormat) : null } +/** + * Parsing functions + */ + const padZero = (value) => { const parsedValue = parseInt(value, 10) if (Number.isNaN(parsedValue)) {