Skip to content

Commit

Permalink
Fix for CA DA tech handover feedback items (#1704)
Browse files Browse the repository at this point in the history
* feat(PRL-6394): Add warning message when doc is generated from upload docs

* feat(PRL-6561): Update SOD notfication

* feat(PRL-6605): Update service of order notification

* feat(PRL-6605): Update service of order notification

* feat(PRL-6606): Update SOA DA dashboard notification

* audit supp

* feat(PRL-6607): Update SOA CA dashboard notification

* feat(PRL-6558): AOH update child field to be mandatory

* feat(PRL-6607): Update SOA CA dashboard notification

* Dummy update README.md to test build

* Fix failing test

* yarn audit supp

* fix CVE

---------

Co-authored-by: sealDebolina <[email protected]>
Co-authored-by: elizereyes123 <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 2e0b702 commit 03b4ac4
Show file tree
Hide file tree
Showing 19 changed files with 669 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## prl-citizen-frontend

Updated with Release 4.0
Updated with Release 4.0

## Getting Started

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@
"semver": "^7.5.4",
"send": "0.19.0",
"serve-static": "1.16.2",
"cross-spawn": "7.0.6"
"cross-spawn": "7.0.6",
"path-to-regexp": "8.2.0"
},
"packageManager": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import _ from 'lodash';

import { PartyType } from '../../../../../app/case/definition';
import { TranslationFn } from '../../../../../app/controller/GetController';
import { FormContent, FormFields, FormFieldsFn } from '../../../../../app/form/Form';
import { atLeastOneFieldIsChecked } from '../../../../../app/form/validation';
import { interpolate } from '../../../../../steps/common/string-parser';
import { applyParms } from '../../../../../steps/common/url-parser';
import { FETCH_CASE_DETAILS } from '../../../../../steps/urls';
import { UploadDocumentCategory } from '../../definitions';
import { getUploadDocumentCategoryDetails } from '../../upload/utils';

export * from './routeGuard';

const en = {
positionStatements: 'Position statement',
witnessStatements: 'Witness statement',
documentAvailableText: 'A new {docCategory} is generated/uploaded',
declaration: 'I believe that the facts stated in these documents are true',
consent: 'This confirms that the information you are submitting is true and accurate, to the best of your knowledge.',
submitButtonText: 'Submit',
Expand Down Expand Up @@ -50,6 +55,7 @@ const en = {
const cy: typeof en = {
positionStatements: 'Datganiadau safbwynt',
witnessStatements: 'Datganiadau tyst',
documentAvailableText: 'Mae {docCategory} newydd yn cael ei gynhyrchu/llwytho i fyny',
declaration: 'Credaf fod y ffeithiau a nodir yn y dogfennau hyn yn wir',
consent:
'Mae hyn yn cadarnhau bod yr wybodaeth yr ydych yn ei chyflwyno yn wir ac yn gywir, hyd eithaf eich gwybodaeth.',
Expand Down Expand Up @@ -136,7 +142,7 @@ export const generateContent: TranslationFn = content => {
const userCase = request.session.userCase;
const uploadedFilesDataReference =
partyType === PartyType.APPLICANT ? 'applicantUploadFiles' : 'respondentUploadFiles';
let title;
let title: string;

if (docCategory === UploadDocumentCategory.POSITION_STATEMENTS) {
title = translations.positionStatements;
Expand All @@ -154,6 +160,8 @@ export const generateContent: TranslationFn = content => {
caption: sectionTitle,
title,
...translations,
isDocumentGeneratedAndUploded: _.get(request.session, 'applicationSettings.isDocumentGeneratedAndUplaoded', false),
documentAvailableText: interpolate(translations.documentAvailableText, { docCategory: title.toLowerCase() }),
form: { ...form, fields: (form.fields as FormFieldsFn)(content.userCase || {}, request) },
filesUploaded:
content.userCase?.[uploadedFilesDataReference]?.map(file => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export default class UploadDocumentPostController extends PostController<AnyObje
return;
}
req.session.userCase?.[getUploadedFilesDataReference(partyType)]?.push(response.document);
req.session.applicationSettings = {
...req.session.applicationSettings,
isDocumentGeneratedAndUplaoded: true,
};
req.session.errors = removeUploadDocErrors(req.session.errors);
} catch (e) {
req.session.errors = handleError(req.session.errors, 'uploadError', true);
Expand Down Expand Up @@ -248,6 +252,7 @@ export default class UploadDocumentPostController extends PostController<AnyObje
}

req.session.errors = removeUploadDocErrors(req.session.errors);
delete req.session?.applicationSettings?.isDocumentGeneratedAndUplaoded;
} catch (error) {
req.session.errors = handleError(req.session.errors, 'uploadError', true);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% from "govuk/components/button/macro.njk" import govukButton %}
{% from "govuk/components/textarea/macro.njk" import govukTextarea %}
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}
{% from "govuk/components/warning-text/macro.njk" import govukWarningText %}

<div class="govuk-form-group">
{% block page_content %}
Expand All @@ -12,6 +13,14 @@
{{title}}
</h1>
{% if allowGenerateDocs %}

{% if isDocumentGeneratedAndUploded %}
{{ govukWarningText({
text: documentAvailableText,
iconFallbackText: "Warning"
}) }}
{% endif %}

<form
action="?docCategory={{ docCategory }}&_csrf={{ csrfToken }}"
method="post"
Expand Down
2 changes: 2 additions & 0 deletions src/main/steps/common/documents/upload/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const deleteDocument = async (req: AppRequest, res: Response): Promise<vo
);

if (req.session.userCase?.[uploadedFilesDataReference]?.length === 0) {
delete req.session?.applicationSettings?.isDocumentGeneratedAndUplaoded;
delete req.session.userCase[uploadedFilesDataReference];
}
}
Expand Down Expand Up @@ -106,4 +107,5 @@ export const resetUploadDocumentSessionData = (req: AppRequest): void => {
req.session.userCase.applicantUploadFiles = [];
req.session.userCase.respondentUploadFiles = [];
delete req.session.userCase.declarationCheck;
delete req.session?.applicationSettings?.isDocumentGeneratedAndUplaoded;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const en = {
<p class="govuk-body ">You can <a href="https://www.gov.uk/injunction-domestic-violence" class="govuk-link govuk-link a" rel="external" target="_blank">apply for a domestic abuse injunction</a> separately.</p>`,
warningText:
'We will share the information that you give in this section with the other person in the case so that they can respond to what you have said.',
childrenConcernedAboutLabel: 'Which children are you concerned about? (optional)',
childrenConcernedAboutLabel: 'Which children are you concerned about?',
behaviourDetailsLabel: 'Describe the behaviours you would like the court to be aware of. (optional)',
behaviourDetailsHintText:
'Keep your answer brief. You will have a chance to give more detail to the court later in the proceedings.',
Expand Down Expand Up @@ -55,7 +55,7 @@ const cy = () => ({
<p class="govuk-body ">Gallwch<a href="https://www.gov.uk/injunction-domestic-violence" class="govuk-link govuk-link a" rel="external" target="_blank"> wneud cais am waharddeb cam-drin domestig</a> ar wahân</p>`,
warningText:
"Byddwn yn rhannu'r wybodaeth y byddwch yn ei rhoi yn yr adran hon gyda'r unigolyn arall yn yr achos er mwyn iddo allu ymateb i'r hyn rydych chi wedi'i ddweud.",
childrenConcernedAboutLabel: "Pa blant ydych chi'n poeni amdanyn nhw? (dewisol)",
childrenConcernedAboutLabel: "Pa blant ydych chi'n poeni amdanyn nhw?",
behaviourDetailsLabel: "Disgrifiwch yr ymddygiadau yr hoffech i'r llys fod yn ymwybodol ohonynt. (dewisol)",
behaviourDetailsHintText:
"Cadwch eich ateb yn fyr. Bydd cyfle i chi roi mwy o fanylion i'r llys yn ddiweddarach yn yr achos.",
Expand Down
48 changes: 23 additions & 25 deletions src/main/steps/common/safety-concerns/child/report-abuse/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../../../../../app/case/definition';
import { TranslationFn } from '../../../../../app/controller/GetController';
import { FormContent, GenerateDynamicFormFields } from '../../../../../app/form/Form';
import { isTextAreaValid } from '../../../../../app/form/validation';
import { atLeastOneFieldIsChecked, isTextAreaValid } from '../../../../../app/form/validation';
import { C100_URL } from '../../../../../steps/urls';
import { getDataShape } from '../../util';
import { generateContent as commonContent } from '../content';
Expand All @@ -27,7 +27,7 @@ export const en = () => ({
<p class="govuk-body ">You can <a href="https://www.gov.uk/injunction-domestic-violence" class="govuk-link govuk-link a" rel="external" target="_blank">apply for a domestic abuse injunction</a> separately.</p>`,
warningText:
'We will share the information that you give in this section with the other person in the case so that they can respond to what you have said.',
childrenConcernedAboutLabel: 'Which children are you concerned about? (optional)',
childrenConcernedAboutLabel: 'Which children are you concerned about?',
behaviourDetailsLabel: 'Describe the behaviours you would like the court to be aware of. (optional)',
behaviourDetailsHintText:
'Keep your answer brief. You will have a chance to give more detail to the court later in the proceedings.',
Expand All @@ -47,6 +47,9 @@ export const en = () => ({
seekHelpDetailsNoHint:
'<p class="govuk-body">See the <a href="https://www.nspcc.org.uk/keeping-children-safe/reporting-abuse/dedicated-helplines/" class="govuk-link" rel="external" target="_blank">NSPCC guidance</a> if you are unsure how to get help.</p>',
errors: {
childrenConcernedAbout: {
required: 'You must select atleast one child you are concerned about.',
},
behaviourDetails: {
invalidCharacters: 'You have entered an invalid character. Special characters <,>,{,} are not allowed.',
invalid:
Expand Down Expand Up @@ -82,7 +85,7 @@ export const cy = () => ({
<p class="govuk-body ">Gallwch<a href="https://www.gov.uk/injunction-domestic-violence" class="govuk-link govuk-link a" rel="external" target="_blank"> wneud cais am waharddeb cam-drin domestig</a> ar wahân</p>`,
warningText:
"Byddwn yn rhannu'r wybodaeth y byddwch yn ei rhoi yn yr adran hon gyda'r unigolyn arall yn yr achos er mwyn iddo allu ymateb i'r hyn rydych chi wedi'i ddweud.",
childrenConcernedAboutLabel: "Pa blant ydych chi'n poeni amdanyn nhw? (dewisol)",
childrenConcernedAboutLabel: "Pa blant ydych chi'n poeni amdanyn nhw?",
behaviourDetailsLabel: "Disgrifiwch yr ymddygiadau yr hoffech i'r llys fod yn ymwybodol ohonynt. (dewisol)",
behaviourDetailsHintText:
"Cadwch eich ateb yn fyr. Bydd cyfle i chi roi mwy o fanylion i'r llys yn ddiweddarach yn yr achos.",
Expand All @@ -103,6 +106,9 @@ export const cy = () => ({
seekHelpDetailsNoHint:
'<p class="govuk-body">Gweler <a href="https://www.nspcc.org.uk/keeping-children-safe/reporting-abuse/dedicated-helplines/" class="govuk-link" rel="external" target="_blank">cyfarwyddyd NSPCC</a>os nad ydych yn siŵr sut i gael help.</p>',
errors: {
childrenConcernedAbout: {
required: 'Rhaid i chi ddewis o leiaf un plentyn yr ydych yn pryderu yn ei gylch.',
},
behaviourDetails: {
invalidCharacters: 'Rydych wedi defnyddio nod annilys. Ni chaniateir y nodau arbennig hyn <,>,{,}',
invalid:
Expand Down Expand Up @@ -150,15 +156,16 @@ export const generateFormFields = (
classes: 'govuk-checkboxes',
labelSize: 's',
label: l => l.childrenConcernedAboutLabel,
values: [
...childrenData.map(childObj => {
return {
validator: atLeastOneFieldIsChecked,
values: childrenData.length
? childrenData.map(childObj => ({
name: 'childrenConcernedAbout',
label: `${childObj.firstName} ${childObj.lastName}`,
value: `${childObj.id}`,
};
}),
],
value: childObj.id,
selected: childrenData.length === 1 || data.childrenConcernedAbout?.includes(childObj.id),
disabled: childrenData.length === 1,
}))
: [],
},
behaviourDetails: {
type: 'textarea',
Expand Down Expand Up @@ -192,10 +199,12 @@ export const generateFormFields = (
label: l => l.YesOptionLabel,
value: YesNoEmpty.YES,
conditionalText: l => l.isOngoingBehaviourHint,
selected: data.isOngoingBehaviour === YesNoEmpty.YES,
},
{
label: l => l.NoOptionLabel,
value: YesNoEmpty.NO,
selected: data.isOngoingBehaviour === YesNoEmpty.NO,
},
],
},
Expand All @@ -209,6 +218,7 @@ export const generateFormFields = (
{
label: l => l.YesOptionLabel1,
value: YesNoEmpty.YES,
selected: data.seekHelpFromPersonOrAgency === YesNoEmpty.YES,
subFields: {
seekHelpDetails: {
type: 'textarea',
Expand All @@ -221,6 +231,7 @@ export const generateFormFields = (
{
label: l => l.NoOptionLabel1,
value: YesNoEmpty.NO,
selected: data.seekHelpFromPersonOrAgency === YesNoEmpty.NO,
conditionalText: l => l.seekHelpDetailsNoHint,
},
],
Expand All @@ -232,21 +243,6 @@ export const generateFormFields = (
cy: {},
};

// mark the selection for the radio buttons based on the option chosen

fields.isOngoingBehaviour.values = fields.isOngoingBehaviour.values.map(config =>
config.value === data.isOngoingBehaviour ? { ...config, selected: true } : config
);
fields.seekHelpFromPersonOrAgency.values = fields.seekHelpFromPersonOrAgency.values.map(config =>
config.value === data.seekHelpFromPersonOrAgency ? { ...config, selected: true } : config
);

// mark the selection for the children checkboxes based on the option chosen
fields.childrenConcernedAbout.values = fields.childrenConcernedAbout.values.map(config =>
// Checking if the data.childrenConcernedAbout has been prefilled, if YES, data will be fetched from userCase. If NOT, checkboxes are made fresh and untouched
data.childrenConcernedAbout?.includes(config.value) ? { ...config, selected: true } : config
);

return { fields, errors };
};

Expand Down Expand Up @@ -321,13 +317,15 @@ export const generateContent: TranslationFn = content => {
C100RebuildJourney ? c100ChildrenDetails : CARespChildrenDetails
);

delete form.saveAndComeLater;
if (C100RebuildJourney) {
Object.assign(form, {
saveAndComeLater: {
text: l => l.saveAndComeLater,
},
});
}

return {
...translations,
...commonContent(content),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ export default class SafteyConcernsAbusePostController extends PostController<An
public async post(req: AppRequest<AnyObject>, res: Response): Promise<void> {
const abuseType = req.params.abuseType as C1AAbuseTypes;
const C100RebuildJourney = req.originalUrl.startsWith(C100_URL);
const form = new Form(getFormFields(req.session.userCase, abuseType, C100RebuildJourney).fields as FormFields);
const caseData = req.session.userCase;
const form = new Form(getFormFields(caseData, abuseType, C100RebuildJourney).fields as FormFields);
const { onlycontinue, saveAndComeLater, ...formFields } = req.body;
const childDetails = C100RebuildJourney ? caseData?.cd_children : caseData?.newChildDetails;

if (childDetails?.length === 1) {
Object.assign(formFields, { childrenConcernedAbout: [childDetails[0].id] });
}

const { _csrf, ...formData } = form.getParsedBody(formFields);
const childAbuseData: Partial<Case> = {
c1A_safteyConcerns: {
Expand All @@ -33,6 +40,7 @@ export default class SafteyConcernsAbusePostController extends PostController<An
},
};

req.session.errors = form.getErrors(formData);
req.session.userCase = {
...(req.session?.userCase ?? {}),
...childAbuseData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const keys = {
childDrugAbuse: 'Have the children been impacted by drug, alcohol or substance abuse?',
childLocation: 'Why do you think the children may be abducted or kept outside the UK without your consent?',
children: 'The children in this application',
childrenConcernedAboutLabel: 'Which children are you concerned about? (optional)',
childrenConcernedAboutLabel: 'Which children are you concerned about?',
childrenMoreThanOnePassport: 'Do the children have more than one passport?',
childsCurrentLocationText: 'Where are the children now?',
concerns: 'concerns',
Expand Down
Loading

0 comments on commit 03b4ac4

Please sign in to comment.