generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 2
HDPI 3571 Current Circumstances Exceptional Hardship Frontend #972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sdmiddletonSolirius
wants to merge
21
commits into
master
Choose a base branch
from
HDPI-3571-current-circumstances-exceptional-hardship-FE
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
17c9366
initial setup for 3571 FE
sdmiddletonSolirius c5f4176
Merge branch 'master' into HDPI-3571-current-circumstances-exceptiona…
sdmiddletonSolirius 70ff797
Initial commit for additional circumstances views and data persistence
sdmiddletonSolirius c54045f
prettier fixes
sdmiddletonSolirius 71440d4
data persistence and heading fix
sdmiddletonSolirius 554ec70
initial hardship page setup
sdmiddletonSolirius e5cfb73
comment removal
sdmiddletonSolirius d1bf328
update curly apostrophe
sdmiddletonSolirius 46207a0
Merge branch 'master' into HDPI-3571-current-circumstances-exceptiona…
sdmiddletonSolirius 79ba227
minor blank space
sdmiddletonSolirius 7443aef
refactoring
sdmiddletonSolirius 5838406
refactoring index to match implementation across codebase
sdmiddletonSolirius 0842578
fixing linting errors
sdmiddletonSolirius 817a89f
Merge branch 'master' into HDPI-3571-current-circumstances-exceptiona…
sdmiddletonSolirius 0550ad7
Align yes/no typing with backend enums and updating stepButtons macros
sdmiddletonSolirius 8a7c70b
Merge branch 'master' into HDPI-3571-current-circumstances-exceptiona…
sdmiddletonSolirius 4c4be18
quick dash amend on page title
sdmiddletonSolirius d4ebae3
updating enums again
sdmiddletonSolirius c4a93ee
updating enum values and casing
sdmiddletonSolirius 5b1a4c2
Merge branch 'master' into HDPI-3571-current-circumstances-exceptiona…
sdmiddletonSolirius b338bb6
Merge branch 'master' into HDPI-3571-current-circumstances-exceptiona…
sdmiddletonSolirius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/main/assets/locales/cy/respondToClaim/exceptionalHardship.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/assets/locales/cy/respondToClaim/yourCircumstances.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/assets/locales/en/respondToClaim/exceptionalHardship.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/main/assets/locales/en/respondToClaim/yourCircumstances.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 30 additions & 4 deletions
34
src/main/steps/respond-to-claim/current-circumstances/currentCircumstances.njk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 %} | ||
| <h1 class="govuk-heading-l">Your circumstances (placeholder)</h1> | ||
| <p class="govuk-body">This is a placeholder for Your Circumstances step.</p> | ||
| <form method="post" action="{{ url }}"> | ||
| {{ stepButtons(continue, saveForLater) }} | ||
|
|
||
| {% if caption %} | ||
| <span class="govuk-caption-l">{{ caption }}</span> | ||
| {% endif %} | ||
|
|
||
| <h1 class="govuk-heading-l">{{ pageTitle }}</h1> | ||
|
|
||
| <p class="govuk-body">{{ introParagraph }}</p> | ||
|
|
||
| <p class="govuk-body"> {{ forExample }}</p> | ||
|
|
||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li>{{ bullet1 }}</li> | ||
| <li>{{ bullet2 }}</li> | ||
| <li>{{ bullet3 }}</li> | ||
| </ul> | ||
|
|
||
| <form method="post" action="{{ url }}" novalidate> | ||
| {% for field in fields %} | ||
| {% if field.componentType == 'radios' %} | ||
| {{ govukRadios(field.component) }} | ||
| {% endif %} | ||
| {% endfor %} | ||
|
|
||
| {{ stepButtons(saveAndContinue, saveForLater) }} | ||
| {{ csrfProtection(csrfToken) }} | ||
| </form> | ||
| {% endblock %} |
97 changes: 95 additions & 2 deletions
97
src/main/steps/respond-to-claim/current-circumstances/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: Record<string, string> = { Yes: 'yes', No: 'no' }; | ||
| const shareCircumstances = existingAnswer ? mapping[existingAnswer] : undefined; | ||
|
|
||
| if (!shareCircumstances) { | ||
| return {}; | ||
| } | ||
|
|
||
| return { | ||
| shareCircumstances, | ||
| ...(shareCircumstances === 'yes' && circumstances?.additionalCircumstancesDetails | ||
| ? { 'shareCircumstances.circumstancesDetails': circumstances.additionalCircumstancesDetails } | ||
| : {}), | ||
| }; | ||
| }, | ||
| }); |
36 changes: 32 additions & 4 deletions
36
src/main/steps/respond-to-claim/exceptional-hardship/exceptionalHardship.njk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,43 @@ | ||
| {% 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 %} | ||
| <h1 class="govuk-heading-l">Exceptional hardship (placeholder)</h1> | ||
| <p class="govuk-body">This is a placeholder for Exceptional Hardship step.</p> | ||
| <form method="post" action="{{ url }}"> | ||
| {{ stepButtons(continue, saveForLater) }} | ||
|
|
||
| {% if caption %} | ||
| <span class="govuk-caption-l">{{ caption }}</span> | ||
| {% endif %} | ||
|
|
||
| <h1 class="govuk-heading-l">{{ pageTitle }}</h1> | ||
|
|
||
| <p class="govuk-body">{{ introParagraph1 }}</p> | ||
| <p class="govuk-body">{{ introParagraph2 }}</p> | ||
| <p class="govuk-body">{{ introParagraph3 }}</p> | ||
| <p class="govuk-body">{{ forExample }}</p> | ||
|
|
||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li>{{ bullet1 }}</li> | ||
| <li>{{ bullet2 }}</li> | ||
| <li>{{ bullet3 }}</li> | ||
| <li>{{ bullet4 }}</li> | ||
| </ul> | ||
|
|
||
| <form method="post" action="{{ url }}" novalidate> | ||
| {% for field in fields %} | ||
| {% if field.componentType == 'radios' %} | ||
| {{ govukRadios(field.component) }} | ||
| {% endif %} | ||
| {% endfor %} | ||
|
|
||
| {{ stepButtons(saveAndContinue, saveForLater) }} | ||
| {{ csrfProtection(csrfToken) }} | ||
| </form> | ||
| {% endblock %} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.