Skip to content

Commit b5f86a6

Browse files
committed
CCM-8588 Add tag colour mapping for new status
1 parent 7dffdba commit b5f86a6

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

frontend/src/components/molecules/PreviewTemplateDetails/PreviewTemplateDetails.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
NHSAppTemplate,
99
templateStatusToDisplayMappings,
1010
templateTypeDisplayMappings,
11+
templateStatusToColourMappings,
1112
} from 'nhs-notify-web-template-management-utils';
1213
import styles from './PreviewTemplateDetails.module.scss';
1314
import { PreviewTemplateDetailsProps } from './preview-template-details.types';
@@ -53,9 +54,7 @@ export function PreviewTemplateDetails({
5354
<SummaryList.Key>{rowHeadings.templateStatus}</SummaryList.Key>
5455
<SummaryList.Value>
5556
<Tag
56-
color={
57-
template.templateStatus === 'SUBMITTED' ? 'grey' : undefined
58-
}
57+
color={templateStatusToColourMappings(template.templateStatus)}
5958
>
6059
{templateStatusToDisplayMappings(template.templateStatus)}
6160
</Tag>

utils/utils/src/__tests__/enum.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
import { Language, LetterType } from 'nhs-notify-backend-client';
1+
import {
2+
Language,
3+
LetterType,
4+
TemplateStatus,
5+
} from 'nhs-notify-backend-client';
26
import {
37
alphabeticalLanguageList,
48
alphabeticalLetterTypeList,
59
letterTypeDisplayMappings,
610
previewTemplatePages,
11+
templateStatusToColourMappings,
712
templateStatusToDisplayMappings,
813
templateTypeDisplayMappings,
914
templateTypeToUrlTextMappings,
1015
viewSubmittedTemplatePages,
1116
} from '../enum';
17+
import { TEMPLATE_STATUS_LIST } from 'nhs-notify-backend-client';
1218

1319
describe('templateTypeDisplayMappings', () => {
1420
test('NHS_APP', () => {
@@ -115,6 +121,24 @@ describe('templateStatusToDisplayMappings', () => {
115121
});
116122
});
117123

124+
describe('templateStatusToColourMappings', () => {
125+
it.each(TEMPLATE_STATUS_LIST)(
126+
'should give the expected colour when templateType is %s',
127+
(templateStatus) => {
128+
const expectedColours: { [key in TemplateStatus]?: string } = {
129+
SUBMITTED: 'grey',
130+
PENDING_PROOF_REQUEST: 'blue',
131+
VIRUS_SCAN_FAILED: 'red',
132+
VALIDATION_FAILED: 'red',
133+
};
134+
135+
expect(templateStatusToColourMappings(templateStatus)).toEqual(
136+
expectedColours[templateStatus]
137+
);
138+
}
139+
);
140+
});
141+
118142
describe('templateTypeToUrlTextMappings', () => {
119143
test('NHS_APP', () => {
120144
expect(templateTypeToUrlTextMappings('NHS_APP')).toEqual('nhs-app');

utils/utils/src/enum.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ export const templateStatusToDisplayMappings = (status: TemplateStatus) =>
8484
VALIDATION_FAILED: 'Validation Failed',
8585
})[status];
8686

87+
export const templateStatusToColourMappings = (status: TemplateStatus) =>
88+
(
89+
({
90+
NOT_YET_SUBMITTED: undefined,
91+
SUBMITTED: 'grey',
92+
DELETED: undefined,
93+
PENDING_UPLOAD: undefined,
94+
PENDING_PROOF_REQUEST: 'blue',
95+
PENDING_VALIDATION: undefined,
96+
VIRUS_SCAN_FAILED: 'red',
97+
VALIDATION_FAILED: 'red',
98+
}) as const
99+
)[status];
100+
87101
export const templateTypeToUrlTextMappings = (type: TemplateType) =>
88102
({
89103
NHS_APP: 'nhs-app',

0 commit comments

Comments
 (0)