From 43f9ef3223115ea99c06f6e7ee435ad44bca9bb0 Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Wed, 21 Oct 2026 14:15:04 +0100 Subject: [PATCH] Labelled an opportunity's ID as an OCID only when it is one --- web/src/components/OpportunityDialog.tsx | 4 ++-- web/src/lib/opportunities.test.ts | 6 ++++++ web/src/lib/opportunities.ts | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/web/src/components/OpportunityDialog.tsx b/web/src/components/OpportunityDialog.tsx index 78f36f3..a9d65d2 100644 --- a/web/src/components/OpportunityDialog.tsx +++ b/web/src/components/OpportunityDialog.tsx @@ -15,7 +15,7 @@ import { api } from '@/api/client'; import { errorText } from '@/lib/errors'; import { statusLabel } from '@/lib/filterOpportunities'; import { formatDate, formatMoney } from '@/lib/format'; -import { noticeSite } from '@/lib/opportunities'; +import { noticeSite, uuidLabel } from '@/lib/opportunities'; import type { Opportunity } from '@/types/Opportunities'; import { ReleaseTabs } from './ReleaseTabs'; import { buttonPrimary, statusBadge } from './styles'; @@ -134,7 +134,7 @@ export function OpportunityDialog(props: Props): JSX.Element {
{yesNo(opportunity().has_documents)}
Source
{opportunity().source}
-
OCID
+
{uuidLabel(opportunity())}
{opportunity().uuid}
diff --git a/web/src/lib/opportunities.test.ts b/web/src/lib/opportunities.test.ts index b5efe80..88eeabb 100644 --- a/web/src/lib/opportunities.test.ts +++ b/web/src/lib/opportunities.test.ts @@ -7,6 +7,7 @@ import { latestRelease, mergeOpportunities, noticeSite, + uuidLabel, } from './opportunities'; import { testOpportunity } from './testOpportunity'; @@ -96,3 +97,8 @@ test('a Find a Tender release’s page is its notice', () => { 'https://www.find-tender.service.gov.uk/notice/095868-2026', ); }); + +test('an OCID is labelled as one, and other kinds of UUID as an ID', () => { + expect(uuidLabel(testOpportunity('ocds-h6vhtk-05a1b2'))).toBe('OCID'); + expect(uuidLabel(testOpportunity('eusupply-uk-100114954', { uuid_type: 'eusupply' }))).toBe('ID'); +}); diff --git a/web/src/lib/opportunities.ts b/web/src/lib/opportunities.ts index 648f1d4..496541c 100644 --- a/web/src/lib/opportunities.ts +++ b/web/src/lib/opportunities.ts @@ -83,3 +83,12 @@ const NOTICE_SITES: Record = { export function noticeSite(opportunity: Opportunity): NoticeSite | undefined { return NOTICE_SITES[opportunity.source]; } + +/** + * What the opportunity's UUID is called on screen: "OCID" for an OCDS + * contracting process's id, and "ID" for the other kinds, such as + * eusupply-uk-, which the app makes up itself. + */ +export function uuidLabel(opportunity: Opportunity): string { + return opportunity.uuid_type === 'ocid' ? 'OCID' : 'ID'; +}