Skip to content

Commit 39ab01e

Browse files
committed
Squashed commit of the following:
commit a26f209 Author: Alex Nuttall <[email protected]> Date: Tue Apr 22 12:50:14 2025 +0100 tfdocs commit 7dd95d8 Author: Alex Nuttall <[email protected]> Date: Tue Apr 22 12:34:36 2025 +0100 unit tests pass commit 335ff8c Author: Alex Nuttall <[email protected]> Date: Tue Apr 22 09:56:10 2025 +0100 updating openapi spec to try and improve template dto type commit 6a29ab2 Author: Alex Nuttall <[email protected]> Date: Tue Apr 22 09:11:30 2025 +0100 updating openapi spec to try and improve template dto type commit db8b764 Author: Alex Nuttall <[email protected]> Date: Fri Apr 18 11:52:08 2025 +0100 backend curl readme commit ac5490a Author: Alex Nuttall <[email protected]> Date: Thu Apr 17 19:48:48 2025 +0100 fix apig iam policy commit 6c8d46d Author: Alex Nuttall <[email protected]> Date: Thu Apr 17 10:39:58 2025 +0100 init commit b93ac03 Author: Alex Nuttall <[email protected]> Date: Thu Apr 17 09:13:10 2025 +0100 init commit bbecabc Author: Alex Nuttall <[email protected]> Date: Thu Apr 17 07:27:15 2025 +0100 entity builder refactor commit 8aeccb7 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 14:16:47 2025 +0100 fix test title commit 24cdf28 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 13:54:49 2025 +0100 fix lambda vpc opt commit 6e781b3 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 13:07:58 2025 +0100 rm stray file commit 7962187 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 12:53:39 2025 +0100 tf validator fix commit 3bd5b9f Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 12:52:46 2025 +0100 replace DatabaseTemplate commit 235a70c Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 12:43:31 2025 +0100 move mergedTemplate to utils commit 4fbbfce Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 12:22:45 2025 +0100 move supplier to the event commit 4440197 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 10:25:25 2025 +0100 move sg list inside vpc object on lambda vars commit 85da2b8 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 09:17:42 2025 +0100 tfdocs commit 41be015 Author: Alex Nuttall <[email protected]> Date: Wed Apr 16 09:03:47 2025 +0100 set lock for one month to "finalise" commit 322bb7e Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 16:43:43 2025 +0100 retain locks commit b99bad1 Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 14:38:43 2025 +0100 tfdocs commit e5eb655 Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 14:35:09 2025 +0100 descriptions - rm not relevant dns refs commit 13f8e99 Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 14:32:32 2025 +0100 add parent_acct_environment commit c6ddfe8 Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 11:17:52 2025 +0100 tfdocs commit 88f9465 Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 11:06:04 2025 +0100 add acct local to conditionally create mock config param commit 9462d46 Author: Alex Nuttall <[email protected]> Date: Tue Apr 15 08:52:44 2025 +0100 link to confluence commit 347bc65 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 18:16:05 2025 +0100 add try to default_letter_supplier commit fb5db15 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 18:14:41 2025 +0100 add try to default_letter_supplier commit f8f2ce9 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 17:04:40 2025 +0100 review comments commit 52eacb5 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 16:40:29 2025 +0100 rename batch data commit c52b360 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 16:08:50 2025 +0100 rm @debug from test name commit e791f01 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 13:20:47 2025 +0100 rename TemplateRepository commit d0611f3 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 13:09:58 2025 +0100 rename personalisationFields to ...Parameters commit adf5814 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 12:38:30 2025 +0100 fix queue ref commit 711424f Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 12:24:15 2025 +0100 tfdocs commit 7772d0f Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 12:21:19 2025 +0100 rm update to status commit 7dd82c4 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 12:02:39 2025 +0100 rm update to status commit b2cf3f9 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 11:43:43 2025 +0100 tfdocs commit 199fa5a Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 11:41:36 2025 +0100 whitespace commit 0019c01 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 11:17:00 2025 +0100 remove vpc changes commit 7c7ec2d Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 10:47:56 2025 +0100 add event mapping option commit e762dec Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 08:57:18 2025 +0100 add lambda timeout commit a640c4a Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 08:45:47 2025 +0100 cleanup commit 0d16b77 Author: Alex Nuttall <[email protected]> Date: Mon Apr 14 08:24:47 2025 +0100 add automated tests commit 4a1d776 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 16:47:37 2025 +0100 tfdocs commit efc6511 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 16:45:31 2025 +0100 ignore coverage dir commit 3f30d0e Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 16:44:27 2025 +0100 entity update builder tests commit b8499f6 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 16:00:15 2025 +0100 jest config changes commit f7c8cb9 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 15:30:58 2025 +0100 use nullable vpc opt commit 3705363 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 15:20:21 2025 +0100 add sg commit 5488128 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 15:17:19 2025 +0100 add sg commit 89fc09e Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 14:41:35 2025 +0100 adding vpc commit 9fe1b15 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 14:23:08 2025 +0100 fix duplicate module var commit 2722a93 Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 14:12:18 2025 +0100 docs commit 2bf5b2d Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 14:11:42 2025 +0100 cleanup commit 385ef8f Author: Alex Nuttall <[email protected]> Date: Fri Apr 11 14:02:59 2025 +0100 finish unit tests commit dc67954 Author: Alex Nuttall <[email protected]> Date: Thu Apr 10 17:24:11 2025 +0100 tfdocs commit 26a6545 Author: Alex Nuttall <[email protected]> Date: Thu Apr 10 17:11:00 2025 +0100 add tfscaffold changes commit 89e17aa Author: Alex Nuttall <[email protected]> Date: Thu Apr 10 16:18:59 2025 +0100 upgrade SQS commit e82a524 Author: Alex Nuttall <[email protected]> Date: Thu Apr 10 11:57:25 2025 +0100 use commit hash sqs mod temporarily commit 87ff83d Author: Alex Nuttall <[email protected]> Date: Thu Apr 10 10:22:25 2025 +0100 adding batch test commit c21834f Author: Alex Nuttall <[email protected]> Date: Wed Apr 9 14:18:44 2025 +0100 finish send test commit cf3cb4c Author: Alex Nuttall <[email protected]> Date: Wed Apr 9 14:17:45 2025 +0100 finish send test commit 6cd981b Author: Alex Nuttall <[email protected]> Date: Wed Apr 9 12:21:49 2025 +0100 more unit tests commit d1d8466 Author: Alex Nuttall <[email protected]> Date: Wed Apr 9 09:49:54 2025 +0100 adding unit tests commit c7a582b Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 15:17:01 2025 +0100 adding statuses commit fad3b96 Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 14:42:53 2025 +0100 upgrade shared sqs commit afc0fe9 Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 14:25:35 2025 +0100 fix logger exports commit d6f5842 Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 13:47:15 2025 +0100 re-add utils dependency in backend-client commit 59ed4e4 Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 13:35:58 2025 +0100 ignore tests not running for now commit e66d65f Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 08:57:20 2025 +0100 whitespace commit 0ad2bbf Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 08:31:07 2025 +0100 whitespace commit 291ba6f Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 08:28:07 2025 +0100 tfdocs commit b1be7b6 Author: Alex Nuttall <[email protected]> Date: Tue Apr 8 08:06:25 2025 +0100 adding unit test commit 5268eb4 Author: Alex Nuttall <[email protected]> Date: Mon Apr 7 17:42:08 2025 +0100 adding update builder commit 405efb6 Author: Alex Nuttall <[email protected]> Date: Fri Apr 4 11:58:23 2025 +0100 adding sftp send commit 191b622 Author: Alex Nuttall <[email protected]> Date: Fri Apr 4 11:05:31 2025 +0100 adding handler commit 26cb098 Author: Alex Nuttall <[email protected]> Date: Fri Apr 4 08:38:29 2025 +0100 CCM-8637: add sftp utils commit 8fd12f6 Author: Alex Nuttall <[email protected]> Date: Thu Apr 3 16:37:38 2025 +0100 CCM-8637: tfdocs commit 55b55aa Author: Alex Nuttall <[email protected]> Date: Thu Apr 3 16:33:54 2025 +0100 CCM-8637: init
1 parent f289868 commit 39ab01e

File tree

45 files changed

+1187
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1187
-173
lines changed

frontend/src/__tests__/app/submit-email-template/page.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('SubmitEmailTemplatePage', () => {
5353
templateName={state.name}
5454
templateId={state.id}
5555
goBackPath='preview-email-template'
56-
submitPath='email-template-submitted'
56+
confirmPath='email-template-submitted'
5757
/>
5858
);
5959
});

frontend/src/__tests__/app/submit-nhs-app-template/page.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('SubmitNhsAppTemplatePage', () => {
5757
templateName={state.name}
5858
templateId={state.id}
5959
goBackPath='preview-nhs-app-template'
60-
submitPath='nhs-app-template-submitted'
60+
confirmPath='nhs-app-template-submitted'
6161
/>
6262
);
6363
});

frontend/src/__tests__/app/submit-text-message-template/page.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('SubmitSmsTemplatePage', () => {
5757
templateName={state.name}
5858
templateId={state.id}
5959
goBackPath='preview-text-message-template'
60-
submitPath='text-message-template-submitted'
60+
confirmPath='text-message-template-submitted'
6161
/>
6262
);
6363
});

frontend/src/__tests__/components/forms/SubmitTemplate/SubmitTemplate.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('SubmitTemplate component', () => {
2525
templateId='template-id'
2626
templateName='template-name'
2727
goBackPath='example'
28-
submitPath='example-submit'
28+
confirmPath='example-submit'
2929
/>
3030
);
3131

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
createLetterTemplate,
1515
setTemplateToDeleted,
1616
setTemplateToSubmitted,
17+
requestTemplateProof,
1718
} from '@utils/form-actions';
1819
import { getAccessTokenServer } from '@utils/amplify-utils';
1920
import { TemplateDto } from 'nhs-notify-backend-client';
@@ -583,4 +584,66 @@ describe('form-actions', () => {
583584
);
584585
});
585586
});
587+
588+
describe('requestTemplateProof', () => {
589+
test('sends proof request successfully', async () => {
590+
const responseData = {
591+
templateType: 'LETTER',
592+
id: 'new-template-id',
593+
templateStatus: 'NOT_YET_SUBMITTED',
594+
name: 'template-name',
595+
letterType: 'q1',
596+
language: 'ar',
597+
files: {
598+
pdfTemplate: {
599+
fileName: 'template.pdf',
600+
currentVersion: 'pdf-version',
601+
virusScanStatus: 'PASSED',
602+
},
603+
},
604+
createdAt: '2025-01-13T10:19:25.579Z',
605+
updatedAt: '2025-01-13T10:19:25.579Z',
606+
} satisfies TemplateDto;
607+
608+
mockedTemplateClient.requestProof.mockResolvedValueOnce({
609+
data: responseData,
610+
});
611+
612+
const response = await requestTemplateProof('id');
613+
614+
expect(mockedTemplateClient.requestProof).toHaveBeenCalledWith(
615+
'id',
616+
'token'
617+
);
618+
619+
expect(response).toEqual(responseData);
620+
});
621+
622+
test('requestTemplateProof - should throw error when saving unexpectedly fails', async () => {
623+
mockedTemplateClient.requestProof.mockResolvedValueOnce({
624+
error: {
625+
code: 400,
626+
message: 'Bad request',
627+
},
628+
});
629+
630+
await expect(requestTemplateProof('id')).rejects.toThrow(
631+
'Failed to request proof'
632+
);
633+
634+
expect(mockedTemplateClient.requestProof).toHaveBeenCalledWith(
635+
'id',
636+
'token'
637+
);
638+
});
639+
640+
test('deleteTemplate - should throw error when no token', async () => {
641+
authIdTokenServerMock.mockReset();
642+
authIdTokenServerMock.mockResolvedValueOnce(undefined);
643+
644+
await expect(requestTemplateProof('id')).rejects.toThrow(
645+
'Failed to get access token'
646+
);
647+
});
648+
});
586649
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use server';
2+
3+
import { Metadata } from 'next';
4+
import { redirect, RedirectType } from 'next/navigation';
5+
import { RequestProof } from '@forms/RequestProof/RequestProof';
6+
import {
7+
PageProps,
8+
validateLetterTemplate,
9+
} from 'nhs-notify-web-template-management-utils';
10+
import { getTemplate } from '@utils/form-actions';
11+
import content from '@content/content';
12+
13+
const { pageTitle } = content.components.submitTemplate;
14+
15+
export async function generateMetadata(): Promise<Metadata> {
16+
return {
17+
title: pageTitle.EMAIL,
18+
};
19+
}
20+
21+
const RequestProofPage = async (props: PageProps) => {
22+
const { templateId } = await props.params;
23+
24+
const template = await getTemplate(templateId);
25+
26+
const validatedTemplate = validateLetterTemplate(template);
27+
28+
if (!validatedTemplate) {
29+
return redirect('/invalid-template', RedirectType.replace);
30+
}
31+
32+
return (
33+
<RequestProof
34+
templateName={validatedTemplate.name}
35+
templateId={validatedTemplate.id}
36+
goBackPath='preview-letter-template'
37+
confirmPath='preview-letter-template'
38+
/>
39+
);
40+
};
41+
42+
export default RequestProofPage;

frontend/src/app/submit-email-template/[templateId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const SubmitEmailTemplatePage = async (props: PageProps) => {
3434
templateName={validatedTemplate.name}
3535
templateId={validatedTemplate.id}
3636
goBackPath='preview-email-template'
37-
submitPath='email-template-submitted'
37+
confirmPath='email-template-submitted'
3838
/>
3939
);
4040
};

frontend/src/app/submit-nhs-app-template/[templateId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const SubmitNhsAppTemplatePage = async (props: PageProps) => {
3434
templateName={validatedTemplate.name}
3535
templateId={validatedTemplate.id}
3636
goBackPath='preview-nhs-app-template'
37-
submitPath='nhs-app-template-submitted'
37+
confirmPath='nhs-app-template-submitted'
3838
/>
3939
);
4040
};

frontend/src/app/submit-text-message-template/[templateId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const SubmitSmsTemplatePage = async (props: PageProps) => {
3434
templateName={validatedTemplate.name}
3535
templateId={validatedTemplate.id}
3636
goBackPath='preview-text-message-template'
37-
submitPath='text-message-template-submitted'
37+
confirmPath='text-message-template-submitted'
3838
/>
3939
);
4040
};
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
'use client';
2+
3+
import { ConfirmCancelProps } from 'nhs-notify-web-template-management-utils';
4+
import content from '@content/content';
5+
import { NHSNotifyMain } from '@atoms/NHSNotifyMain/NHSNotifyMain';
6+
import concatClassNames from '@utils/concat-class-names';
7+
import { NHSNotifyFormWrapper } from '@molecules/NHSNotifyFormWrapper/NHSNotifyFormWrapper';
8+
import { NHSNotifyButton } from '@atoms/NHSNotifyButton/NHSNotifyButton';
9+
import { getBasePath } from '@utils/get-base-path';
10+
import { useActionState } from 'react';
11+
import { requestProof } from './server-action';
12+
13+
export function RequestProof({
14+
templateName,
15+
templateId,
16+
goBackPath,
17+
confirmPath,
18+
}: ConfirmCancelProps) {
19+
const {
20+
buttons,
21+
checkTestData,
22+
requirementsIntro,
23+
requirementsList,
24+
subHeading,
25+
waitTime,
26+
} = content.components.requestProof;
27+
28+
const goBackHref = `${getBasePath()}/${goBackPath}/${templateId}`;
29+
30+
const [_, action] = useActionState(requestProof, confirmPath);
31+
32+
return (
33+
<NHSNotifyMain>
34+
<h1
35+
id='request-proof'
36+
className={concatClassNames(
37+
'nhsuk-heading-l',
38+
'nhsuk-u-margin-bottom-0'
39+
)}
40+
>
41+
Request a proof of &apos;{templateName}&apos;
42+
</h1>
43+
<h2
44+
className={concatClassNames(
45+
'nhsuk-heading-xs',
46+
'nhsuk-u-margin-bottom-1'
47+
)}
48+
>
49+
{subHeading}
50+
</h2>
51+
<p>{requirementsIntro}</p>
52+
<ul>
53+
{requirementsList.map((text, i) => (
54+
<li key={i}>{text}</li>
55+
))}
56+
</ul>
57+
<p>{checkTestData}</p>
58+
<p>{waitTime}</p>
59+
<NHSNotifyFormWrapper formId='submit-template-form' action={action}>
60+
<input type='hidden' name='templateId' value={templateId} readOnly />
61+
<NHSNotifyButton
62+
secondary
63+
id='go-back-button'
64+
className='nhsuk-u-margin-right-3'
65+
href={goBackHref}
66+
>
67+
{buttons.back}
68+
</NHSNotifyButton>
69+
<NHSNotifyButton id='request-proof-button'>
70+
{buttons.confirm}
71+
</NHSNotifyButton>
72+
</NHSNotifyFormWrapper>
73+
</NHSNotifyMain>
74+
);
75+
}

0 commit comments

Comments
 (0)