Labelled an opportunity's ID as an OCID only when it is one
This commit is contained in:
1 parent
64886a2f1e
commit
43f9ef3223
3 files changed
+17
-2
No files matched your search
@@ -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 {
|
||||
<dd>{yesNo(opportunity().has_documents)}</dd>
|
||||
<dt class="text-muted">Source</dt>
|
||||
<dd>{opportunity().source}</dd>
|
||||
<dt class="text-muted">OCID</dt>
|
||||
<dt class="text-muted">{uuidLabel(opportunity())}</dt>
|
||||
<dd class="break-all">{opportunity().uuid}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
@@ -83,3 +83,12 @@ const NOTICE_SITES: Record<string, NoticeSite> = {
|
||||
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-<tender id>, which the app makes up itself.
|
||||
*/
|
||||
export function uuidLabel(opportunity: Opportunity): string {
|
||||
return opportunity.uuid_type === 'ocid' ? 'OCID' : 'ID';
|
||||
}
|
||||
Reference in new issue
Block a user