-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpage.tsx
More file actions
25 lines (18 loc) · 759 Bytes
/
page.tsx
File metadata and controls
25 lines (18 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use server';
import {
PageProps,
validateSubmittedEmailTemplate,
} from 'nhs-notify-web-template-management-utils';
import { getTemplate } from '@utils/form-actions';
import { redirect, RedirectType } from 'next/navigation';
import { ViewEmailTemplate } from '@molecules/ViewEmailTemplate/ViewEmailTemplate';
const ViewSubmittedEmailTemplatePage = async (props: PageProps) => {
const { templateId } = await props.params;
const template = await getTemplate(templateId);
const validatedTemplate = validateSubmittedEmailTemplate(template);
if (!validatedTemplate) {
redirect('/invalid-template', RedirectType.replace);
}
return <ViewEmailTemplate initialState={validatedTemplate} />;
};
export default ViewSubmittedEmailTemplatePage;