Skip to content

Commit bb39004

Browse files
CCM-12111: Display last edit time rather than creation time in templates table (#728)
1 parent a04a5cf commit bb39004

File tree

10 files changed

+72
-66
lines changed

10 files changed

+72
-66
lines changed

frontend/src/__tests__/components/molecules/MessageTemplates.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const messageTemplatesProps: {
2424
templateStatus: 'SUBMITTED',
2525
name: 'Template 2',
2626
message: 'Message',
27-
createdAt: '2021-02-01T00:00:00.000Z',
28-
updatedAt: '2021-02-01T00:00:00.000Z',
27+
createdAt: '2021-01-01T00:00:00.000Z',
28+
updatedAt: '2021-03-01T00:00:00.000Z',
2929
},
3030
{
3131
id: '3',
@@ -120,7 +120,7 @@ describe('MessageTemplates component', () => {
120120
).toBeInTheDocument();
121121
expect(
122122
screen.getByTestId('manage-template-table-header-template-date-created')
123-
).toHaveTextContent(messageTemplatesContent.tableHeadings.dateCreated);
123+
).toHaveTextContent(messageTemplatesContent.tableHeadings.lastEdited);
124124
expect(
125125
screen.getByTestId('manage-template-table-header-action')
126126
).toBeInTheDocument();

frontend/src/__tests__/components/molecules/__snapshots__/MessageTemplates.test.tsx.snap

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exports[`MessageTemplates component matches snapshot with not submitted status 1
5858
data-testid="manage-template-table-header-template-date-created"
5959
scope="col"
6060
>
61-
Date created
61+
Last edited
6262
</th>
6363
<th
6464
class="nhsuk-table__header"
@@ -139,7 +139,7 @@ exports[`MessageTemplates component matches snapshot with not submitted status 1
139139
aria-hidden="true"
140140
class="nhsuk-table-responsive__heading"
141141
>
142-
Date created
142+
Last edited
143143
</span>
144144
1st Jan 2021
145145
<br />
@@ -251,9 +251,9 @@ exports[`MessageTemplates component matches snapshot with not submitted status 1
251251
aria-hidden="true"
252252
class="nhsuk-table-responsive__heading"
253253
>
254-
Date created
254+
Last edited
255255
</span>
256-
1st Feb 2021
256+
1st Mar 2021
257257
<br />
258258
00:00
259259
</td>
@@ -352,7 +352,7 @@ exports[`MessageTemplates component matches snapshot with not submitted status 1
352352
aria-hidden="true"
353353
class="nhsuk-table-responsive__heading"
354354
>
355-
Date created
355+
Last edited
356356
</span>
357357
1st Feb 2021
358358
<br />
@@ -440,7 +440,7 @@ exports[`MessageTemplates component matches snapshot with not submitted status 1
440440
aria-hidden="true"
441441
class="nhsuk-table-responsive__heading"
442442
>
443-
Date created
443+
Last edited
444444
</span>
445445
1st Feb 2021
446446
<br />
@@ -538,7 +538,7 @@ exports[`MessageTemplates component matches snapshot with pending proof request
538538
data-testid="manage-template-table-header-template-date-created"
539539
scope="col"
540540
>
541-
Date created
541+
Last edited
542542
</th>
543543
<th
544544
class="nhsuk-table__header"
@@ -619,7 +619,7 @@ exports[`MessageTemplates component matches snapshot with pending proof request
619619
aria-hidden="true"
620620
class="nhsuk-table-responsive__heading"
621621
>
622-
Date created
622+
Last edited
623623
</span>
624624
1st Jan 2021
625625
<br />
@@ -731,9 +731,9 @@ exports[`MessageTemplates component matches snapshot with pending proof request
731731
aria-hidden="true"
732732
class="nhsuk-table-responsive__heading"
733733
>
734-
Date created
734+
Last edited
735735
</span>
736-
1st Feb 2021
736+
1st Mar 2021
737737
<br />
738738
00:00
739739
</td>
@@ -832,7 +832,7 @@ exports[`MessageTemplates component matches snapshot with pending proof request
832832
aria-hidden="true"
833833
class="nhsuk-table-responsive__heading"
834834
>
835-
Date created
835+
Last edited
836836
</span>
837837
1st Feb 2021
838838
<br />
@@ -920,7 +920,7 @@ exports[`MessageTemplates component matches snapshot with pending proof request
920920
aria-hidden="true"
921921
class="nhsuk-table-responsive__heading"
922922
>
923-
Date created
923+
Last edited
924924
</span>
925925
1st Feb 2021
926926
<br />
@@ -1018,7 +1018,7 @@ exports[`MessageTemplates component matches snapshot with submitted status 1`] =
10181018
data-testid="manage-template-table-header-template-date-created"
10191019
scope="col"
10201020
>
1021-
Date created
1021+
Last edited
10221022
</th>
10231023
<th
10241024
class="nhsuk-table__header"
@@ -1099,7 +1099,7 @@ exports[`MessageTemplates component matches snapshot with submitted status 1`] =
10991099
aria-hidden="true"
11001100
class="nhsuk-table-responsive__heading"
11011101
>
1102-
Date created
1102+
Last edited
11031103
</span>
11041104
1st Jan 2021
11051105
<br />
@@ -1200,9 +1200,9 @@ exports[`MessageTemplates component matches snapshot with submitted status 1`] =
12001200
aria-hidden="true"
12011201
class="nhsuk-table-responsive__heading"
12021202
>
1203-
Date created
1203+
Last edited
12041204
</span>
1205-
1st Feb 2021
1205+
1st Mar 2021
12061206
<br />
12071207
00:00
12081208
</td>
@@ -1301,7 +1301,7 @@ exports[`MessageTemplates component matches snapshot with submitted status 1`] =
13011301
aria-hidden="true"
13021302
class="nhsuk-table-responsive__heading"
13031303
>
1304-
Date created
1304+
Last edited
13051305
</span>
13061306
1st Feb 2021
13071307
<br />
@@ -1389,7 +1389,7 @@ exports[`MessageTemplates component matches snapshot with submitted status 1`] =
13891389
aria-hidden="true"
13901390
class="nhsuk-table-responsive__heading"
13911391
>
1392-
Date created
1392+
Last edited
13931393
</span>
13941394
1st Feb 2021
13951395
<br />
@@ -1487,7 +1487,7 @@ exports[`MessageTemplates component matches snapshot with waiting for proof stat
14871487
data-testid="manage-template-table-header-template-date-created"
14881488
scope="col"
14891489
>
1490-
Date created
1490+
Last edited
14911491
</th>
14921492
<th
14931493
class="nhsuk-table__header"
@@ -1568,7 +1568,7 @@ exports[`MessageTemplates component matches snapshot with waiting for proof stat
15681568
aria-hidden="true"
15691569
class="nhsuk-table-responsive__heading"
15701570
>
1571-
Date created
1571+
Last edited
15721572
</span>
15731573
1st Jan 2021
15741574
<br />
@@ -1656,9 +1656,9 @@ exports[`MessageTemplates component matches snapshot with waiting for proof stat
16561656
aria-hidden="true"
16571657
class="nhsuk-table-responsive__heading"
16581658
>
1659-
Date created
1659+
Last edited
16601660
</span>
1661-
1st Feb 2021
1661+
1st Mar 2021
16621662
<br />
16631663
00:00
16641664
</td>
@@ -1757,7 +1757,7 @@ exports[`MessageTemplates component matches snapshot with waiting for proof stat
17571757
aria-hidden="true"
17581758
class="nhsuk-table-responsive__heading"
17591759
>
1760-
Date created
1760+
Last edited
17611761
</span>
17621762
1st Feb 2021
17631763
<br />
@@ -1845,7 +1845,7 @@ exports[`MessageTemplates component matches snapshot with waiting for proof stat
18451845
aria-hidden="true"
18461846
class="nhsuk-table-responsive__heading"
18471847
>
1848-
Date created
1848+
Last edited
18491849
</span>
18501850
1st Feb 2021
18511851
<br />

frontend/src/__tests__/utils/form-actions.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,23 +490,23 @@ describe('form-actions', () => {
490490
await expect(getTemplates()).rejects.toThrow('Failed to get access token');
491491
});
492492

493-
test('getTemplates - order by createdAt and then id', async () => {
493+
test('getTemplates - order by updatedAt and then id', async () => {
494494
const baseTemplate = {
495495
templateType: 'SMS',
496496
templateStatus: 'NOT_YET_SUBMITTED',
497497
name: 'Template',
498498
message: 'Message',
499-
updatedAt: '2021-01-01T00:00:00.000Z',
499+
createdAt: '2020-01-01T00:00:00.000Z',
500500
} satisfies Partial<TemplateDto>;
501501

502502
const templates = [
503-
{ ...baseTemplate, id: '06', createdAt: '2022-01-01T00:00:00.000Z' },
504-
{ ...baseTemplate, id: '08', createdAt: '2020-01-01T00:00:00.000Z' },
505-
{ ...baseTemplate, id: '05', createdAt: '2021-01-01T00:00:00.000Z' },
506-
{ ...baseTemplate, id: '02', createdAt: '2021-01-01T00:00:00.000Z' },
507-
{ ...baseTemplate, id: '01', createdAt: '2021-01-01T00:00:00.000Z' },
508-
{ ...baseTemplate, id: '03', createdAt: '2021-01-01T00:00:00.000Z' },
509-
{ ...baseTemplate, id: '04', createdAt: '2021-01-01T00:00:00.000Z' },
503+
{ ...baseTemplate, id: '06', updatedAt: '2022-01-01T00:00:00.000Z' },
504+
{ ...baseTemplate, id: '08', updatedAt: '2020-01-01T00:00:00.000Z' },
505+
{ ...baseTemplate, id: '05', updatedAt: '2021-01-01T00:00:00.000Z' },
506+
{ ...baseTemplate, id: '02', updatedAt: '2021-01-01T00:00:00.000Z' },
507+
{ ...baseTemplate, id: '01', updatedAt: '2021-01-01T00:00:00.000Z' },
508+
{ ...baseTemplate, id: '03', updatedAt: '2021-01-01T00:00:00.000Z' },
509+
{ ...baseTemplate, id: '04', updatedAt: '2021-01-01T00:00:00.000Z' },
510510
];
511511

512512
// 06 is the newest, 08 is the oldest.

frontend/src/__tests__/utils/message-plans.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('Message plans actions', () => {
5353
const fields = {
5454
status: 'DRAFT',
5555
name: 'Routing config',
56-
updatedAt: '2021-01-01T00:00:00.000Z',
56+
createdAt: '2020-01-01T00:00:00.000Z',
5757
campaignId: 'campaignId',
5858
clientId: 'clientId',
5959
cascade: [
@@ -65,48 +65,48 @@ describe('Message plans actions', () => {
6565
},
6666
],
6767
cascadeGroupOverrides: [{ name: 'standard' }],
68-
} satisfies Omit<RoutingConfig, 'id' | 'createdAt'>;
68+
} satisfies Omit<RoutingConfig, 'id' | 'updatedAt'>;
6969

7070
const routingConfigs = [
7171
{
7272
...fields,
7373
id: 'a487ed49-e2f7-4871-ac8d-0c6c682c71f5',
74-
createdAt: '2022-01-01T00:00:00.000Z',
74+
updatedAt: '2022-01-01T00:00:00.000Z',
7575
},
7676
{
7777
...fields,
7878
id: '8f5157fe-72d7-4a9c-818f-77c128ec8197',
79-
createdAt: '2020-01-01T00:00:00.000Z',
79+
updatedAt: '2020-01-01T00:00:00.000Z',
8080
},
8181
{
8282
...fields,
8383
id: '9be9d25f-81d8-422a-a85c-2fa9019cde1e',
84-
createdAt: '2021-01-01T00:00:00.000Z',
84+
updatedAt: '2021-01-01T00:00:00.000Z',
8585
},
8686
{
8787
...fields,
8888
id: '1cfdd62d-9eca-4f15-9772-1937d4524c37',
89-
createdAt: '2021-01-01T00:00:00.000Z',
89+
updatedAt: '2021-01-01T00:00:00.000Z',
9090
},
9191
{
9292
...fields,
9393
id: '18da6158-07ef-455c-9c31-1a4d78a133cf',
94-
createdAt: '2021-01-01T00:00:00.000Z',
94+
updatedAt: '2021-01-01T00:00:00.000Z',
9595
},
9696
{
9797
...fields,
9898
id: '87fb5cbf-708d-49c3-9360-3e37efdc5278',
99-
createdAt: '2021-01-01T00:00:00.000Z',
99+
updatedAt: '2021-01-01T00:00:00.000Z',
100100
},
101101
{
102102
...fields,
103103
id: '0d6408fd-57ea-42f2-aae1-ed9614b67068',
104-
createdAt: '2021-01-01T00:00:00.000Z',
104+
updatedAt: '2021-01-01T00:00:00.000Z',
105105
},
106106
];
107107

108108
// a48... is the newest, 8f5... is the oldest.
109-
// the others all have the same createdAt.
109+
// the others all have the same updatedAt.
110110
const expectedOrder = [
111111
'a487ed49-e2f7-4871-ac8d-0c6c682c71f5',
112112
'0d6408fd-57ea-42f2-aae1-ed9614b67068',

frontend/src/components/molecules/MessageTemplates/MessageTemplates.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function MessageTemplates({
6767
{messageTemplatesContent.tableHeadings.status}
6868
</Table.Cell>
6969
<Table.Cell data-testid='manage-template-table-header-template-date-created'>
70-
{messageTemplatesContent.tableHeadings.dateCreated}
70+
{messageTemplatesContent.tableHeadings.lastEdited}
7171
</Table.Cell>
7272
<Table.Cell data-testid='manage-template-table-header-action'>
7373
{messageTemplatesContent.tableHeadings.action.text}
@@ -90,9 +90,9 @@ export function MessageTemplates({
9090
</Tag>
9191
</Table.Cell>
9292
<Table.Cell>
93-
{format(`${template.createdAt}`, 'do MMM yyyy')}
93+
{format(`${template.updatedAt}`, 'do MMM yyyy')}
9494
<br />
95-
{format(`${template.createdAt}`, 'HH:mm')}
95+
{format(`${template.updatedAt}`, 'HH:mm')}
9696
</Table.Cell>
9797
<Table.Cell>
9898
<div className={style.actionLinksWrapper}>

frontend/src/content/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ const messageTemplates = {
446446
id: 'ID',
447447
type: 'Type',
448448
status: 'Status',
449-
dateCreated: 'Date created',
449+
lastEdited: 'Last edited',
450450
action: { text: 'Action', copy: 'Copy', delete: 'Delete' },
451451
},
452452
createTemplateButton: {

frontend/src/utils/form-actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { logger } from 'nhs-notify-web-template-management-utils/logger';
1212
import { templateApiClient } from 'nhs-notify-backend-client/src/template-api-client';
1313
import { routingConfigurationApiClient } from 'nhs-notify-backend-client/src/routing-config-api-client';
14-
import { sortAscByCreatedAt } from './sort';
14+
import { sortAscByUpdatedAt } from './sort';
1515

1616
export async function createTemplate(
1717
template: CreateUpdateTemplate
@@ -188,7 +188,7 @@ export async function getTemplates(): Promise<TemplateDto[]> {
188188
(template): template is ValidatedTemplateDto => template !== undefined
189189
);
190190

191-
return sortAscByCreatedAt(sortedData);
191+
return sortAscByUpdatedAt(sortedData);
192192
}
193193

194194
export async function createRoutingConfig(

frontend/src/utils/message-plans.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { routingConfigurationApiClient } from 'nhs-notify-backend-client/src/routing-config-api-client';
77
import { logger } from 'nhs-notify-web-template-management-utils/logger';
88
import { getSessionServer } from './amplify-utils';
9-
import { sortAscByCreatedAt } from './sort';
9+
import { sortAscByUpdatedAt } from './sort';
1010

1111
export async function getRoutingConfigs(): Promise<RoutingConfig[]> {
1212
const { accessToken } = await getSessionServer();
@@ -32,7 +32,7 @@ export async function getRoutingConfigs(): Promise<RoutingConfig[]> {
3232
return success;
3333
});
3434

35-
return sortAscByCreatedAt(valid);
35+
return sortAscByUpdatedAt(valid);
3636
}
3737

3838
export async function countRoutingConfigs(

frontend/src/utils/sort.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export const sortAscByCreatedAt = <T>(
2-
items: T & { createdAt: string; id: string }[]
1+
export const sortAscByUpdatedAt = <T>(
2+
items: T & { updatedAt: string; id: string }[]
33
) =>
44
items.sort((a, b) => {
5-
const aCreatedAt = a.createdAt;
6-
const bCreatedAt = b.createdAt;
5+
const aUpdatedAt = a.updatedAt;
6+
const bUpdatedAt = b.updatedAt;
77

8-
if (aCreatedAt === bCreatedAt) {
8+
if (aUpdatedAt === bUpdatedAt) {
99
return a.id.localeCompare(b.id);
1010
}
11-
return aCreatedAt < bCreatedAt ? 1 : -1;
11+
return aUpdatedAt < bUpdatedAt ? 1 : -1;
1212
});

0 commit comments

Comments
 (0)