diff --git a/src/main/assets/locales/cy/respondToClaim/exceptionalHardship.json b/src/main/assets/locales/cy/respondToClaim/exceptionalHardship.json new file mode 100644 index 000000000..cab2c95a7 --- /dev/null +++ b/src/main/assets/locales/cy/respondToClaim/exceptionalHardship.json @@ -0,0 +1,22 @@ +{ + "caption": "cyRespond to a property possession claim", + "pageTitle": "cyExceptional hardship", + "introParagraph1": "cyExceptional hardship means experiencing serious difficulties that go beyond the normal difficulty of losing your home.", + "introParagraph2": "cyIf this applies to you, a judge might allow you to stay in your home for longer.", + "introParagraph3": "cyAny details you provide will be considered by a judge when making their decision, but it is up to them to decide if exceptional hardship applies in your case.", + "forExample": "cyFor example, you might have:", + "bullet1": "cygone through a divorce or separation", + "bullet2": "cylost your job or been made redundant", + "bullet3": "cyexperienced a bereavement or long-term illness", + "bullet4": "cybeen declared bankrupt", + "question": "cyWould you experience exceptional hardship if you were asked to leave your home?", + "options": { + "yes": "cyYes", + "no": "cyNo" + }, + "textAreaLabel": "cyGive details about the exceptional hardship you’d experience", + "errors": { + "exceptionalHardship": "cyChoose yes or no", + "exceptionalHardshipDetails": "cyEnter details about the exceptional hardship you’d experience" + } +} diff --git a/src/main/assets/locales/cy/respondToClaim/yourCircumstances.json b/src/main/assets/locales/cy/respondToClaim/yourCircumstances.json new file mode 100644 index 000000000..55ccaf295 --- /dev/null +++ b/src/main/assets/locales/cy/respondToClaim/yourCircumstances.json @@ -0,0 +1,19 @@ +{ + "caption": "cyRespond to a property possession claim", + "pageTitle": "cyYour circumstances", + "introParagraph": "cyYou can use this section to give details about any events or circumstances that have impacted your case that you think a judge should know about.", + "forExample": "cyFor example:", + "bullet1": "cysomeone in your household has an illness or disability", + "bullet2": "cychildren in your household attend a local school", + "bullet3": "cyyou work irregular hours, making it hard to find a new place to live", + "question": "cyWould you like to share anything about your circumstances?", + "options": { + "yes": "cyYes", + "no": "cyNo" + }, + "textAreaLabel": "cyGive details about your circumstances", + "errors": { + "shareCircumstances": "cyChoose yes or no", + "circumstancesDetails": "cyEnter details about your circumstances" + } +} diff --git a/src/main/assets/locales/en/respondToClaim/exceptionalHardship.json b/src/main/assets/locales/en/respondToClaim/exceptionalHardship.json new file mode 100644 index 000000000..3426844e0 --- /dev/null +++ b/src/main/assets/locales/en/respondToClaim/exceptionalHardship.json @@ -0,0 +1,22 @@ +{ + "caption": "Respond to a property possession claim", + "pageTitle": "Exceptional hardship", + "introParagraph1": "Exceptional hardship means experiencing serious difficulties that go beyond the normal difficulty of losing your home.", + "introParagraph2": "If this applies to you, a judge might allow you to stay in your home for longer.", + "introParagraph3": "Any details you provide will be considered by a judge when making their decision, but it is up to them to decide if exceptional hardship applies in your case.", + "forExample": "For example, you might have:", + "bullet1": "gone through a divorce or separation", + "bullet2": "lost your job or been made redundant", + "bullet3": "experienced a bereavement or long-term illness", + "bullet4": "been declared bankrupt", + "question": "Would you experience exceptional hardship if you were asked to leave your home?", + "options": { + "yes": "Yes", + "no": "No" + }, + "textAreaLabel": "Give details about the exceptional hardship you’d experience", + "errors": { + "exceptionalHardship": "Choose yes or no", + "exceptionalHardshipDetails": "Enter details about the exceptional hardship you’d experience" + } +} diff --git a/src/main/assets/locales/en/respondToClaim/yourCircumstances.json b/src/main/assets/locales/en/respondToClaim/yourCircumstances.json new file mode 100644 index 000000000..e525468da --- /dev/null +++ b/src/main/assets/locales/en/respondToClaim/yourCircumstances.json @@ -0,0 +1,19 @@ +{ + "caption": "Respond to a property possession claim", + "pageTitle": "Your circumstances", + "introParagraph": "You can use this section to give details about any events or circumstances that have impacted your case that you think a judge should know about.", + "forExample": "For example:", + "bullet1": "someone in your household has an illness or disability", + "bullet2": "children in your household attend a local school", + "bullet3": "you work irregular hours, making it hard to find a new place to live", + "question": "Would you like to share anything about your circumstances?", + "options": { + "yes": "Yes", + "no": "No" + }, + "textAreaLabel": "Give details about your circumstances", + "errors": { + "shareCircumstances": "Choose yes or no", + "circumstancesDetails": "Enter details about your circumstances" + } +} diff --git a/src/main/interfaces/ccdCase.interface.ts b/src/main/interfaces/ccdCase.interface.ts index 5b7ea2b63..bcc0167cb 100644 --- a/src/main/interfaces/ccdCase.interface.ts +++ b/src/main/interfaces/ccdCase.interface.ts @@ -3,8 +3,9 @@ export enum CaseState { SUBMITTED = 'Submitted', } -export type YesNoValue = 'YES' | 'NO' | null; -export type TenancyTypeCorrectValue = YesNoValue | 'NOT_SURE'; +export type VerticalYesNoValue = 'YES' | 'NO' | null; +export type YesNoValue = 'Yes' | 'No'; +export type TenancyTypeCorrectValue = VerticalYesNoValue | 'NOT_SURE'; export type ContactPreference = 'EMAIL' | 'POST' | null; export type YesNoNotSureValue = 'YES' | 'NO' | 'NOT_SURE'; @@ -43,7 +44,7 @@ export interface PossessionClaimResponse { firstName?: string; lastName?: string; address?: Address; - phoneNumberProvided?: YesNoValue; + phoneNumberProvided?: VerticalYesNoValue; phoneNumber?: string; emailAddress?: string; }; @@ -53,13 +54,19 @@ export interface PossessionClaimResponse { tenancyType?: string; tenancyStartDateCorrect?: string; tenancyStartDate?: string; - contactByPhone?: YesNoValue; - contactByText?: YesNoValue; + contactByPhone?: VerticalYesNoValue; + contactByText?: VerticalYesNoValue; preferenceType?: ContactPreference; freeLegalAdvice?: string; defendantNameConfirmation?: string; dateOfBirth?: string; landlordRegistered?: YesNoNotSureValue; + householdCircumstances?: { + shareAdditionalCircumstances?: YesNoValue; + additionalCircumstancesDetails?: string; + exceptionalHardship?: YesNoValue; + exceptionalHardshipDetails?: string; + }; writtenTerms?: YesNoNotSureValue; }; } diff --git a/src/main/steps/respond-to-claim/current-circumstances/currentCircumstances.njk b/src/main/steps/respond-to-claim/current-circumstances/currentCircumstances.njk index 7b686d7b7..7eed60f2c 100644 --- a/src/main/steps/respond-to-claim/current-circumstances/currentCircumstances.njk +++ b/src/main/steps/respond-to-claim/current-circumstances/currentCircumstances.njk @@ -1,15 +1,41 @@ {% extends "stepsTemplate.njk" %} {% from "macros/stepButtons.njk" import stepButtons %} +{% from "govuk/components/button/macro.njk" import govukButton %} +{% from "govuk/components/radios/macro.njk" import govukRadios %} {% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %} {% from "macros/csrf.njk" import csrfProtection %} +{% block pageTitle %} + {{ pageTitle }} – HM Courts & Tribunals Service – GOV.UK +{% endblock %} {% block mainContent %} {% if errorSummary %} {{ govukErrorSummary(errorSummary) }} {% endif %} -
This is a placeholder for Your Circumstances step.
- {% endblock %} diff --git a/src/main/steps/respond-to-claim/current-circumstances/index.ts b/src/main/steps/respond-to-claim/current-circumstances/index.ts index 4da773d72..c66cd8c9f 100644 --- a/src/main/steps/respond-to-claim/current-circumstances/index.ts +++ b/src/main/steps/respond-to-claim/current-circumstances/index.ts @@ -1,13 +1,106 @@ +import type { PossessionClaimResponse, YesNoValue } from '../../../interfaces/ccdCase.interface'; import type { StepDefinition } from '../../../interfaces/stepFormData.interface'; +import { buildCcdCaseForPossessionClaimResponse } from '../../utils/populateResponseToClaimPayloadmap'; import { flowConfig } from '../flow.config'; -import { createFormStep } from '@modules/steps'; +import { createFormStep, getTranslationFunction } from '@modules/steps'; export const step: StepDefinition = createFormStep({ stepName: 'your-circumstances', journeyFolder: 'respondToClaim', stepDir: __dirname, flowConfig, - fields: [], + translationKeys: { + pageTitle: 'pageTitle', + caption: 'caption', + }, + fields: [ + { + name: 'shareCircumstances', + type: 'radio', + required: true, + legendClasses: 'govuk-fieldset__legend--m', + translationKey: { label: 'question' }, + errorMessage: 'errors.shareCircumstances', + options: [ + { + value: 'yes', + translationKey: 'options.yes', + subFields: { + circumstancesDetails: { + name: 'circumstancesDetails', + type: 'character-count', + required: true, + maxLength: 500, + errorMessage: 'errors.circumstancesDetails', + translationKey: { label: 'textAreaLabel' }, + attributes: { + rows: 5, + }, + }, + }, + }, + { + value: 'no', + translationKey: 'options.no', + }, + ], + }, + ], customTemplate: `${__dirname}/currentCircumstances.njk`, + extendGetContent: req => { + const t = getTranslationFunction(req, 'your-circumstances', ['common']); + + return { + introParagraph: t('introParagraph'), + forExample: t('forExample'), + bullet1: t('bullet1'), + bullet2: t('bullet2'), + bullet3: t('bullet3'), + }; + }, + beforeRedirect: async req => { + const shareCircumstances = req.body?.shareCircumstances as string | undefined; + + if (!shareCircumstances || (shareCircumstances !== 'yes' && shareCircumstances !== 'no')) { + return; + } + + const ccdMapping: Record<'yes' | 'no', YesNoValue> = { yes: 'Yes', no: 'No' }; + const shareAdditionalCircumstances = ccdMapping[shareCircumstances]; + const additionalCircumstancesDetails = + shareCircumstances === 'yes' + ? (req.body?.['shareCircumstances.circumstancesDetails'] as string | undefined) + : undefined; + + const possessionClaimResponse: PossessionClaimResponse = { + defendantResponses: { + householdCircumstances: { + shareAdditionalCircumstances, + additionalCircumstancesDetails, + }, + }, + }; + + await buildCcdCaseForPossessionClaimResponse(req, possessionClaimResponse); + }, + getInitialFormData: req => { + const caseData = req.res?.locals?.validatedCase?.data; + const circumstances = caseData?.possessionClaimResponse?.defendantResponses?.householdCircumstances; + const existingAnswer = circumstances?.shareAdditionalCircumstances as string | undefined; + + const mapping: RecordThis is a placeholder for Exceptional Hardship step.
- {% endblock %} diff --git a/src/main/steps/respond-to-claim/exceptional-hardship/index.ts b/src/main/steps/respond-to-claim/exceptional-hardship/index.ts index 490e9f6a5..e115b6be8 100644 --- a/src/main/steps/respond-to-claim/exceptional-hardship/index.ts +++ b/src/main/steps/respond-to-claim/exceptional-hardship/index.ts @@ -1,13 +1,111 @@ +import type { PossessionClaimResponse, YesNoValue } from '../../../interfaces/ccdCase.interface'; import type { StepDefinition } from '../../../interfaces/stepFormData.interface'; +import { buildCcdCaseForPossessionClaimResponse } from '../../utils/populateResponseToClaimPayloadmap'; import { flowConfig } from '../flow.config'; -import { createFormStep } from '@modules/steps'; +import { createFormStep, getTranslationFunction } from '@modules/steps'; export const step: StepDefinition = createFormStep({ stepName: 'exceptional-hardship', journeyFolder: 'respondToClaim', stepDir: __dirname, flowConfig, - fields: [], + translationKeys: { + pageTitle: 'pageTitle', + caption: 'caption', + }, + fields: [ + { + name: 'exceptionalHardship', + type: 'radio', + required: true, + legendClasses: 'govuk-fieldset__legend--m', + translationKey: { label: 'question' }, + errorMessage: 'errors.exceptionalHardship', + options: [ + { + value: 'yes', + translationKey: 'options.yes', + subFields: { + exceptionalHardshipDetails: { + name: 'exceptionalHardshipDetails', + type: 'character-count', + required: true, + maxLength: 500, + errorMessage: 'errors.exceptionalHardshipDetails', + translationKey: { label: 'textAreaLabel' }, + attributes: { + rows: 5, + }, + }, + }, + }, + { + value: 'no', + translationKey: 'options.no', + }, + ], + }, + ], customTemplate: `${__dirname}/exceptionalHardship.njk`, + extendGetContent: req => { + const t = getTranslationFunction(req, 'exceptional-hardship', ['common']); + + return { + introParagraph1: t('introParagraph1'), + introParagraph2: t('introParagraph2'), + introParagraph3: t('introParagraph3'), + forExample: t('forExample'), + bullet1: t('bullet1'), + bullet2: t('bullet2'), + bullet3: t('bullet3'), + bullet4: t('bullet4'), + }; + }, + beforeRedirect: async req => { + const exceptionalHardshipValue = req.body?.exceptionalHardship as string | undefined; + + if (!exceptionalHardshipValue || (exceptionalHardshipValue !== 'yes' && exceptionalHardshipValue !== 'no')) { + return; + } + + const ccdMapping: Record<'yes' | 'no', YesNoValue> = { yes: 'Yes', no: 'No' }; + const exceptionalHardship = ccdMapping[exceptionalHardshipValue]; + const exceptionalHardshipDetails = + exceptionalHardshipValue === 'yes' + ? (req.body?.['exceptionalHardship.exceptionalHardshipDetails'] as string | undefined) + : undefined; + + const possessionClaimResponse: PossessionClaimResponse = { + defendantResponses: { + householdCircumstances: { + exceptionalHardship, + exceptionalHardshipDetails, + }, + }, + }; + + await buildCcdCaseForPossessionClaimResponse(req, possessionClaimResponse); + }, + getInitialFormData: req => { + const caseData = req.res?.locals?.validatedCase?.data; + const householdCircumstances = caseData?.possessionClaimResponse?.defendantResponses?.householdCircumstances; + const existingAnswer = householdCircumstances?.exceptionalHardship as string | undefined; + + const mapping: Record