-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontent.ts
More file actions
152 lines (146 loc) · 7 KB
/
Copy pathcontent.ts
File metadata and controls
152 lines (146 loc) · 7 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import config from 'config';
import { isObject } from 'lodash';
import { Checkbox } from '../../../../../app/case/case';
import { getFilename } from '../../../../../app/case/formatter/uploaded-files';
import { TranslationFn } from '../../../../../app/controller/GetController';
import { UPPY_FILE_INPUT_BUTTON_ID } from '../../../../../app/document/DocumentManagementConstants';
import { FormContent, FormFieldsFn } from '../../../../../app/form/Form';
import { generateContent as uploadDocumentGenerateContent } from '../../../../applicant1/upload-your-documents/content';
import { CommonContent } from '../../../../common/common.content';
const en = ({ partner }: CommonContent, applicant1UploadDocumentContent) => ({
title: 'Upload your evidence',
statement: '',
certifiedTranslation: `If your evidence is a conversation in a language other than English, you'll need to provide a <a class="govuk-link" target="_blank" href="${config.get(
'govukUrls.certifiedTranslation'
)}">certified translation</a>.`,
toInclude: {
header:
"If you're uploading images or screenshots of a recent conversation by text, email or social media, make sure they include:",
options: {
bulletOne: `your ${partner}'s name`,
bulletTwo: 'the date the messages were sent',
bulletThree: `your ${partner}'s email address, phone number or social media username as appropriate`,
},
},
line4: 'You may need to upload multiple documents.',
line5: 'The court cannot accept video or audio recordings as evidence.',
uploadAFile: 'Upload a file',
chooseFileButtonText: 'Choose file',
noFileChosen: 'No file chosen',
uploadedFiles: 'Uploaded files',
noFilesUploaded: 'No files uploaded',
cannotUpload: 'I cannot upload some or all of my documents',
cannotUploadInfo:
'You can send your documents to the court by post or webform. You must send your evidence and any certified translations if you need them. You’ll receive details of how to send them after you’ve submitted this application.',
errors: {
applicant1InterimAppsEvidenceUploadedFiles: {
notUploaded: "Upload your documents, or select 'I cannot upload some or all of my documents'.",
errorUploading: applicant1UploadDocumentContent.errors.applicant1UploadedFiles.errorUploading,
fileSizeTooBig: applicant1UploadDocumentContent.errors.applicant1UploadedFiles.fileSizeTooBig,
fileWrongFormat: applicant1UploadDocumentContent.errors.applicant1UploadedFiles.fileWrongFormat,
},
applicant1InterimAppsCannotUploadDocs: {
notUploaded: "Upload your documents, or select 'I cannot upload some or all of my documents'.",
},
},
});
const cy: typeof en = ({ partner }: CommonContent, applicant1UploadDocumentContent) => ({
title: 'Uwchlwytho eich tystiolaeth',
statement: '',
certifiedTranslation: `Os yw eich tystiolaeth mewn iaith nad yw’n Saesneg, bydd arnoch angen darparu <a class="govuk-link" target="_blank" href="${config.get(
'govukUrls.certifiedTranslation'
)}">cyfieithiad ardystiedig</a>.`,
toInclude: {
header:
'Os ydych yn uwchlwytho delweddau o sgwrs ddiweddar trwy neges destun, e-bost neu’r cyfryngau cymdeithasol, gwnewch yn siŵr eu bod yn cynnwys:',
options: {
bulletOne: `enw eich ${partner}`,
bulletTwo: 'y dyddiadau pan anfonwyd y negeseuon',
bulletThree: `cyfeiriad e-bost, rhif ffôn neu enw defnyddiwr cyfryngau cymdeithasol eich ${partner}, fel sy’n briodol`,
},
},
line4: 'Efallai bydd arnoch angen uwchlwytho sawl dogfen.',
line5: 'Ni all y llys dderbyn recordiadau fideo neu sain fel tystiolaeth.',
uploadAFile: 'Llwytho ffeil',
chooseFileButtonText: 'Dewis ffeil',
noFileChosen: "Dim ffeil wedi'i dewis",
uploadedFiles: 'Ffeiliau sydd wedi cael eu llwytho',
noFilesUploaded: 'Nid oes ffeiliau wedi cael eu llwytho',
cannotUpload: 'Ni allaf lwytho rhai o fy nogfennau / fy holl ddogfennau.',
cannotUploadInfo:
'Gallwch anfon eich dogfen i’r llys drwy’r post neu drwy ffurflen ar-lein. Dylech anfon eich tystiolaeth ac unrhyw gyfieithiadau ardystiedig os oes arnoch eu hangen. Fe gewch fanylion am sut i’w hanfon ar ôl i chi gyflwyno’r cais hwn.',
errors: {
applicant1InterimAppsEvidenceUploadedFiles: {
notUploaded: 'Uwchlwythwch eich dogfennau, neu dewiswch ‘Ni allaf uwchlwytho rhai neu’r cyfan o’m dogfennau’.',
errorUploading: applicant1UploadDocumentContent.errors.applicant1UploadedFiles.errorUploading,
fileSizeTooBig: applicant1UploadDocumentContent.errors.applicant1UploadedFiles.fileSizeTooBig,
fileWrongFormat: applicant1UploadDocumentContent.errors.applicant1UploadedFiles.fileWrongFormat,
},
applicant1InterimAppsCannotUploadDocs: {
notUploaded: 'Uwchlwythwch eich dogfennau, neu dewiswch ‘Ni allaf uwchlwytho rhai neu’r cyfan o’m dogfennau’.',
},
},
});
export const form: FormContent = {
fields: userCase => ({
applicant1InterimAppsEvidenceUploadedFiles: {
type: 'hidden',
label: l => l.uploadFiles,
labelHidden: true,
errorId: UPPY_FILE_INPUT_BUTTON_ID,
value:
(isObject(userCase.applicant1InterimAppsEvidenceUploadedFiles)
? JSON.stringify(userCase.applicant1InterimAppsEvidenceUploadedFiles)
: userCase.applicant1InterimAppsEvidenceUploadedFiles) || '[]',
parser: data => JSON.parse((data as Record<string, string>).applicant1InterimAppsEvidenceUploadedFiles || '[]'),
validator: (value, formData) => {
const hasUploadedFiles = (value as string[])?.length && (value as string) !== '[]';
const selectedCannotUploadDocuments = !!formData.applicant1InterimAppsCannotUploadDocs?.length;
if (!hasUploadedFiles && !selectedCannotUploadDocuments) {
return 'notUploaded';
}
},
},
applicant1InterimAppsCannotUploadDocs: {
type: 'checkboxes',
label: l => l.cannotUpload,
labelHidden: true,
errorId: UPPY_FILE_INPUT_BUTTON_ID,
values: [
{
name: 'applicant1InterimAppsCannotUploadDocs',
label: l => l.cannotUpload,
value: Checkbox.Checked,
conditionalText: l => `<p class="govuk-body govuk-!-margin-top-5">${l.cannotUploadInfo}</p>`,
},
],
},
}),
submit: {
text: l => l.continue,
},
};
const languages = {
en,
cy,
};
export const generateContent: TranslationFn = content => {
const applicant1UploadDocumentContent = uploadDocumentGenerateContent(content);
const translations = languages[content.language](content, applicant1UploadDocumentContent);
const uploadedDocsFilenames = content.userCase.applicant1InterimAppsEvidenceDocs?.map(item =>
getFilename(item.value)
);
const amendable = content.isAmendableStates;
const uploadContentScript = `{
"isAmendableStates": ${content.isAmendableStates},
"delete": "${content.delete}"
}`;
return {
...applicant1UploadDocumentContent,
...translations,
form: { ...form, fields: (form.fields as FormFieldsFn)(content.userCase || {}) },
amendable,
uploadedDocsFilenames,
uploadContentScript,
};
};