From 7713fc37243fdd7fb037ebe017ba210c95d6ec53 Mon Sep 17 00:00:00 2001 From: Robert Bond Date: Fri, 17 Apr 2026 12:44:23 +0000 Subject: [PATCH] Merged PR 2256: refactor(representations): preserve Welsh conditional validation and summary... refactor(representations): preserve Welsh conditional validation and summary parity Related work items: #22441 --- .../representationCompleteSubmit.js | 9 +- .../representation/representationElements.js | 146 ++-- .../representationInterestedPartyPerson.js | 7 +- .../case/summary/components/SummaryCard.js | 24 + .../case/summary/components/SummaryRow.js | 15 + .../pinswg_planningappeals78id.js | 757 ++++++++--------- .../pinswg_planningconditionss73s79id.js | 795 ++++++++---------- context/representations-refactor-tracker.md | 95 ++- 8 files changed, 949 insertions(+), 899 deletions(-) create mode 100644 components/case/summary/components/SummaryCard.js create mode 100644 components/case/summary/components/SummaryRow.js diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js index cbd53f81..67011a7e 100644 --- a/components/case/representation/representationCompleteSubmit.js +++ b/components/case/representation/representationCompleteSubmit.js @@ -61,6 +61,13 @@ const RepCompleteSubmit = (props) => { repFormData = updateLinks(repFormData); + const representationOnBehalfOfDisplay = + repFormData.representationOnBehalfOf === "Yes" + ? t("myrepresentations:questionnaire-yes") + : repFormData.representationOnBehalfOf === "No" + ? t("myrepresentations:questionnaire-no") + : repFormData.representationOnBehalfOf; + //const repDate = new Date(); // let day = repDate.getDate(); @@ -406,7 +413,7 @@ const RepCompleteSubmit = (props) => {
{ - repFormData.representationOnBehalfOf + representationOnBehalfOfDisplay }
diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index d59ffda3..8f418db6 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -258,6 +258,26 @@ export const RenderCondtionalRadioList = ({ }) => { const required = (value) => (value ? undefined : "Required"); let { t } = useTranslation(); + + const yesValue = t("myrepresentations:questionnaire-yes"); + const noValue = t("myrepresentations:questionnaire-no"); + + const normalizeYesNo = (rawValue) => { + if (rawValue === true) return "Yes"; + if (rawValue === false) return "No"; + if (rawValue === "Yes" || rawValue === yesValue) return "Yes"; + if (rawValue === "No" || rawValue === noValue) return "No"; + return rawValue; + }; + + const isYesSelected = normalizeYesNo(value) === "Yes"; + + const requiredIfYes = (fieldValue, allValues) => { + const selectedValue = normalizeYesNo(allValues?.[id]); + return selectedValue === "Yes" && !String(fieldValue || "").trim() + ? "Required" + : undefined; + }; return ( <>
- {Object.keys(options).map((key, index) => ( -
+ {Object.keys(options).map((key, index) => { + const normalizedOptionValue = normalizeYesNo( + options[key] + ); + + return (
- - -
- {value == "Yes" && options[key] == "Yes" && (
-
+
+ {options[key] == "Yes" + ? t( + "myrepresentations:questionnaire-yes" + ) + : t( + "myrepresentations:questionnaire-no" + )} +
- )} -
- ))} + {isYesSelected && + normalizedOptionValue === "Yes" && ( +
+
+ + +
+
+ )} +
+ ); + })}
diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index 4f55b433..36ff8656 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -114,12 +114,7 @@ const RepInterestedPartyPerson = (props) => { name="representationOnBehalfOf" datafieldname="representationOnBehalfOf" // label="In what capacity do you wish to make representations on this case?" - options={[ - t( - "myrepresentations:questionnaire-yes" - ), - t("myrepresentations:questionnaire-no") - ]} + options={["Yes", "No"]} id="representationOnBehalfOf" className="govuk-radios__input" errorMsg={t( diff --git a/components/case/summary/components/SummaryCard.js b/components/case/summary/components/SummaryCard.js new file mode 100644 index 00000000..cceb7789 --- /dev/null +++ b/components/case/summary/components/SummaryCard.js @@ -0,0 +1,24 @@ +const SummaryCard = ({ + id, + title, + headingTag = "h2", + headingClassName = "govuk-heading-m govuk-!-margin-bottom-7", + children +}) => { + const HeadingTag = headingTag; + + return ( +
+
+
+ + {title} + + {children} +
+
+
+ ); +}; + +export default SummaryCard; diff --git a/components/case/summary/components/SummaryRow.js b/components/case/summary/components/SummaryRow.js new file mode 100644 index 00000000..d683cc4c --- /dev/null +++ b/components/case/summary/components/SummaryRow.js @@ -0,0 +1,15 @@ +const SummaryRow = ({ + label, + value, + keyClassName = "govuk-summary-list__key", + valueClassName = "govuk-summary-list__value" +}) => { + return ( +
+
{label}
+
{value}
+
+ ); +}; + +export default SummaryRow; diff --git a/components/case/summaryTypes/pinswg_planningappeals78id.js b/components/case/summaryTypes/pinswg_planningappeals78id.js index 27098810..06b2c822 100644 --- a/components/case/summaryTypes/pinswg_planningappeals78id.js +++ b/components/case/summaryTypes/pinswg_planningappeals78id.js @@ -3,6 +3,8 @@ import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import SummaryCard from "../summary/components/SummaryCard"; +import SummaryRow from "../summary/components/SummaryRow"; const Pinswg_planningappeals78id = (props) => { let { t } = useTranslation(); @@ -13,345 +15,300 @@ const Pinswg_planningappeals78id = (props) => { return (
-
-
-
-

- {t("case:summary-case-details-label")} -

- -
-
-
- {t("case:summary-case-type-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : casesObj[ + +
+ -
-
-
- {t("case:summary-lpa-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : casesObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] || + t("case:summary-no-date-entered-label") + } + /> +
+
+ {t("case:summary-lpa-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + casesObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
-
-
- {t("case:summary-eia-required-label")} -
-
- {router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : casesObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {t("case:summary-eia-required-label")} +
+
+ {router.locale == "cy" + ? jsonpath( + '$..[?(@.value=="' + + detailsObj[ "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-to-be-confirmed-label" - )} -
-
-
-
- {t("case:summary-procedure-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : detailsObj[ + ] + + '")].value_cy', + transLookup + ) + : detailsObj[ + "pinswg_eiarequired@OData.Community.Display.V1.FormattedValue" + ] || + t("case:summary-to-be-confirmed-label")} +
+
+
+
+ {t("case:summary-procedure-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + detailsObj[ "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
-
-
- {t("case:summary-type-of-event-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : detailsObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : detailsObj[ + "pinswg_procedure@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {t("case:summary-type-of-event-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + detailsObj[ "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} -
-
-
-
- {t("case:summary-status-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : casesObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : detailsObj[ + "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-information-to-date-label" + )} +
+
+
+
+ {t("case:summary-status-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + casesObj[ "statuscode@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} -
-
-
-
- {t("case:summary-decision-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_dicision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : detailsObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : casesObj[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ] || + t("case:summary-no-date-entered-label")} +
+
+
+
+ {t("case:summary-decision-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + detailsObj[ "pinswg_dicision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : detailsObj[ + "pinswg_dicision@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-information-to-date-label" + )} -
- {/* +
+ {/* {casesObj.caseDetails .outcome_document || ""} */} -
-
-
-
- {t("case:summary-decision-date-label")} -
-
- {_.has( - detailsObj, - "pinswg_casedecisiondate" - ) - ? !_.isEmpty( - detailsObj.pinswg_casedecisiondate - ) - ? formatDates( - detailsObj.pinswg_casedecisiondate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
- {casesObj.numberofchildincidents > 0 && ( -
-
- {t( - "case:summary-case-link-status-label" - )} -
-
- {_.has(casesObj, [ - "numberofchildincidents", - ]) - ? casesObj.numberofchildincidents > - 0 - ? t( - "case:summary-case-link-status-linked" - ) - : t( - "case:summary-case-link-status-not-linked" - ) - : t( - "case:summary-case-link-status-not-linked" - )} -
-
- )} - {casesObj.numberofchildincidents > 0 ? ( -
-
- {t( - "case:summary-linked-cases-label" - )} -
-
- {linkedCasesList( - props.currentView - .linkedCaseReferences - )} -
-
- ) : ( - "" - )} -
+
-
-
-
-
-
-

- {t("case:summary-dates-label")} -

-
-
-
- {t("case:summary-start-date-label")} -
-
- {_.has(detailsObj, "pinswg_startdate") - ? !_.isEmpty( - detailsObj.pinswg_startdate +
+
+ {t("case:summary-decision-date-label")} +
+
+ {_.has(detailsObj, "pinswg_casedecisiondate") + ? !_.isEmpty( + detailsObj.pinswg_casedecisiondate + ) + ? formatDates( + detailsObj.pinswg_casedecisiondate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+ {casesObj.numberofchildincidents > 0 && ( +
+
+ {t("case:summary-case-link-status-label")} +
+
+ {_.has(casesObj, ["numberofchildincidents"]) + ? casesObj.numberofchildincidents > 0 + ? t( + "case:summary-case-link-status-linked" ) - ? formatDates( - detailsObj.pinswg_startdate - ) - : t( - "case:summary-no-date-entered-label" - ) - : _.has( - detailsObj, - "pinswg_startdates" - ) - ? !_.isEmpty( - detailsObj.pinswg_startdates - ) - ? formatDates( - detailsObj.pinswg_startdates - ) - : t( - "case:summary-no-date-entered-label" - ) : t( - "case:summary-no-date-entered-label" - )} -
-
- -
-
- {t( - "case:summary-questionnaire-due-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_questionnaireduedate" - ) - ? !_.isEmpty( - detailsObj.pinswg_questionnaireduedate + "case:summary-case-link-status-not-linked" ) - ? formatDates( - detailsObj.pinswg_questionnaireduedate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
+ : t( + "case:summary-case-link-status-not-linked" + )} + +
+ )} + {casesObj.numberofchildincidents > 0 ? ( +
+
+ {t("case:summary-linked-cases-label")} +
+
+ {linkedCasesList( + props.currentView.linkedCaseReferences + )} +
+
+ ) : ( + "" + )} + + + +
+
+
+ {t("case:summary-start-date-label")} +
+
+ {_.has(detailsObj, "pinswg_startdate") + ? !_.isEmpty(detailsObj.pinswg_startdate) + ? formatDates( + detailsObj.pinswg_startdate + ) + : t( + "case:summary-no-date-entered-label" + ) + : _.has(detailsObj, "pinswg_startdates") + ? !_.isEmpty(detailsObj.pinswg_startdates) + ? formatDates( + detailsObj.pinswg_startdates + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
-
-
- {t( - "case:summary-statement-interested-party-due-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_statementduedate" - ) - ? !_.isEmpty( - detailsObj.pinswg_statementduedate - ) - ? formatDates( - detailsObj.pinswg_statementduedate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t("case:summary-questionnaire-due-date-label")} +
+
+ {_.has( + detailsObj, + "pinswg_questionnaireduedate" + ) + ? !_.isEmpty( + detailsObj.pinswg_questionnaireduedate + ) + ? formatDates( + detailsObj.pinswg_questionnaireduedate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
- {/*
+
+
+ {t( + "case:summary-statement-interested-party-due-date-label" + )} +
+
+ {_.has(detailsObj, "pinswg_statementduedate") + ? !_.isEmpty( + detailsObj.pinswg_statementduedate + ) + ? formatDates( + detailsObj.pinswg_statementduedate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+ + {/*
{t( "case:summary-interested-party-date-label" @@ -390,32 +347,28 @@ const Pinswg_planningappeals78id = (props) => {
*/} -
-
- {t( - "case:summary-final-comments-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_finalcommentsduedate" - ) - ? !_.isEmpty( - detailsObj.pinswg_finalcommentsduedate - ) - ? formatDates( - detailsObj.pinswg_finalcommentsduedate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
- {/*
+
+
+ {t("case:summary-final-comments-date-label")} +
+
+ {_.has( + detailsObj, + "pinswg_finalcommentsduedate" + ) + ? !_.isEmpty( + detailsObj.pinswg_finalcommentsduedate + ) + ? formatDates( + detailsObj.pinswg_finalcommentsduedate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+ {/*
{t( "case:summary-inquiry-evidence-date-label" @@ -440,7 +393,7 @@ const Pinswg_planningappeals78id = (props) => { )}
*/} - {/*
+ {/*
{t("case:summary-event-date-label")}
@@ -464,67 +417,61 @@ const Pinswg_planningappeals78id = (props) => {
*/} -
-
- {t("case:summary-event-date-label")} -
-
- {_.has( - detailsObj, - "pinswg_startdatetimeiftheevent" - ) - ? !_.isEmpty( - detailsObj.pinswg_startdatetimeiftheevent +
+
+ {t("case:summary-event-date-label")} +
+
+ {_.has( + detailsObj, + "pinswg_startdatetimeiftheevent" + ) + ? !_.isEmpty( + detailsObj.pinswg_startdatetimeiftheevent + ) + ? formatDates( + detailsObj.pinswg_startdatetimeiftheevent + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+ {detailsObj.pinswg_typeofevent == 846040002 || + detailsObj.pinswg_typeofevent == 846040007 || + detailsObj.pinswg_typeofevent == 846040012 || + detailsObj.pinswg_typeofevent == 846040009 ? ( +
+
+ {t("case:summary-start-event-time-label")} +
+ +
+ {_.has( + detailsObj, + "pinswg_startdatetimeiftheevent" + ) + ? !_.isEmpty( + detailsObj.pinswg_startdatetimeiftheevent + ) + ? formatDates( + detailsObj.pinswg_startdatetimeiftheevent, + true ) - ? formatDates( - detailsObj.pinswg_startdatetimeiftheevent - ) - : t( - "case:summary-no-date-entered-label" - ) : t( "case:summary-no-date-entered-label" - )} -
-
- {detailsObj.pinswg_typeofevent == 846040002 || - detailsObj.pinswg_typeofevent == 846040007 || - detailsObj.pinswg_typeofevent == 846040012 || - detailsObj.pinswg_typeofevent == 846040009 ? ( -
-
- {t( - "case:summary-start-event-time-label" - )} -
- -
- {_.has( - detailsObj, - "pinswg_startdatetimeiftheevent" - ) - ? !_.isEmpty( - detailsObj.pinswg_startdatetimeiftheevent - ) - ? formatDates( - detailsObj.pinswg_startdatetimeiftheevent, - true - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
- ) : ( - "" - )} -
-
-
-
+ ) + : t( + "case:summary-no-date-entered-label" + )} + +
+ ) : ( + "" + )} + + ); diff --git a/components/case/summaryTypes/pinswg_planningconditionss73s79id.js b/components/case/summaryTypes/pinswg_planningconditionss73s79id.js index 6561c998..bf56c540 100644 --- a/components/case/summaryTypes/pinswg_planningconditionss73s79id.js +++ b/components/case/summaryTypes/pinswg_planningconditionss73s79id.js @@ -3,6 +3,8 @@ import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import transLookup from "../../../data/lookuptranslations.json"; +import SummaryCard from "../summary/components/SummaryCard"; +import SummaryRow from "../summary/components/SummaryRow"; const Pinswg_planningconditionss73s79id = (props) => { let { t } = useTranslation(); @@ -13,383 +15,335 @@ const Pinswg_planningconditionss73s79id = (props) => { return (
-
-
-
-

- {t("case:summary-case-details-label")} -

- -
-
-
- {t("case:summary-case-type-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : casesObj[ + +
+ -
-
-
- {t("case:summary-lpa-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : casesObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : casesObj[ + "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + ] || + t("case:summary-no-date-entered-label") + } + /> +
+
+ {t("case:summary-lpa-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + casesObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
-
-
- {t("case:summary-eia-required-label")} -
-
- {router.locale == "cy" - ? jsonpath( - '$..[?(@.value=="' + - detailsObj[ - "pinswg_detailedeiascreeningrequiered@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - transLookup - ) - : detailsObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : casesObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {t("case:summary-eia-required-label")} +
+
+ {router.locale == "cy" + ? jsonpath( + '$..[?(@.value=="' + + detailsObj[ "pinswg_detailedeiascreeningrequiered@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-to-be-confirmed-label" - )} -
-
-
-
- {t("case:summary-procedure-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : detailsObj[ + ] + + '")].value_cy', + transLookup + ) + : detailsObj[ + "pinswg_detailedeiascreeningrequiered@OData.Community.Display.V1.FormattedValue" + ] || + t("case:summary-to-be-confirmed-label")} +
+
+
+
+ {t("case:summary-procedure-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + detailsObj[ "pinswg_procedure@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
-
-
- {t("case:summary-type-of-event-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : detailsObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : detailsObj[ + "pinswg_procedure@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {t("case:summary-type-of-event-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + detailsObj[ "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" - ] || ""} -
-
-
-
- {t("case:summary-status-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - casesObj[ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : casesObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : detailsObj[ + "pinswg_typeofevent@OData.Community.Display.V1.FormattedValue" + ] || ""} +
+
+
+
+ {t("case:summary-status-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + casesObj[ "statuscode@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-date-entered-label" - )} -
-
-
-
- {t("case:summary-decision-label")} -
-
- {router.locale == "cy" - ? jsonpath({ - path: - '$..[?(@ && @.value=="' + - detailsObj[ - "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] + - '")].value_cy', - json: transLookup, - eval: true, - }) - : detailsObj[ + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : casesObj[ + "statuscode@OData.Community.Display.V1.FormattedValue" + ] || + t("case:summary-no-date-entered-label")} +
+
+
+
+ {t("case:summary-decision-label")} +
+
+ {router.locale == "cy" + ? jsonpath({ + path: + '$..[?(@ && @.value=="' + + detailsObj[ "pinswg_decision@OData.Community.Display.V1.FormattedValue" - ] || - t( - "case:summary-no-information-to-date-label" - )} + ] + + '")].value_cy', + json: transLookup, + eval: true + }) + : detailsObj[ + "pinswg_decision@OData.Community.Display.V1.FormattedValue" + ] || + t( + "case:summary-no-information-to-date-label" + )} -
- {/* +
+ {/* {casesObj.caseDetails .outcome_document || ""} */} -
-
- {casesObj.numberofchildincidents > 0 && ( -
-
- {t( - "case:summary-case-link-status-label" - )} -
-
- {_.has(casesObj, [ - "numberofchildincidents", - ]) - ? casesObj.numberofchildincidents > - 0 - ? t( - "case:summary-case-link-status-linked" - ) - : t( - "case:summary-case-link-status-not-linked" - ) - : t( - "case:summary-case-link-status-not-linked" - )} -
-
- )} - {casesObj.numberofchildincidents > 0 ? ( -
-
- {t( - "case:summary-linked-cases-label" - )} -
-
- {linkedCasesList( - props.currentView - .linkedCaseReferences - )} -
-
- ) : ( - "" - )} -
+
-
-
-
-
-
-

- {t("case:summary-dates-label")} -

-
-
-
- {t("case:summary-start-date-label")} -
-
- {_.has(detailsObj, "pinswg_startdate") - ? !_.isEmpty( - detailsObj.pinswg_startdate + {casesObj.numberofchildincidents > 0 && ( +
+
+ {t("case:summary-case-link-status-label")} +
+
+ {_.has(casesObj, ["numberofchildincidents"]) + ? casesObj.numberofchildincidents > 0 + ? t( + "case:summary-case-link-status-linked" ) - ? formatDates( - detailsObj.pinswg_startdate - ) - : t( - "case:summary-no-date-entered-label" - ) - : _.has( - detailsObj, - "pinswg_startdates" - ) - ? !_.isEmpty( - detailsObj.pinswg_startdates - ) - ? formatDates( - detailsObj.pinswg_startdates - ) - : t( - "case:summary-no-date-entered-label" - ) : t( - "case:summary-no-date-entered-label" - )} -
-
+ "case:summary-case-link-status-not-linked" + ) + : t( + "case:summary-case-link-status-not-linked" + )} + +
+ )} + {casesObj.numberofchildincidents > 0 ? ( +
+
+ {t("case:summary-linked-cases-label")} +
+
+ {linkedCasesList( + props.currentView.linkedCaseReferences + )} +
+
+ ) : ( + "" + )} + + + +
+
+
+ {t("case:summary-start-date-label")} +
+
+ {_.has(detailsObj, "pinswg_startdate") + ? !_.isEmpty(detailsObj.pinswg_startdate) + ? formatDates( + detailsObj.pinswg_startdate + ) + : t( + "case:summary-no-date-entered-label" + ) + : _.has(detailsObj, "pinswg_startdates") + ? !_.isEmpty(detailsObj.pinswg_startdates) + ? formatDates( + detailsObj.pinswg_startdates + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
-
-
- {t( - "case:summary-questionnaire-due-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_questionnaireduedate" - ) - ? !_.isEmpty( - detailsObj.pinswg_questionnaireduedate - ) - ? formatDates( - detailsObj.pinswg_questionnaireduedate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t("case:summary-questionnaire-due-date-label")} +
+
+ {_.has( + detailsObj, + "pinswg_questionnaireduedate" + ) + ? !_.isEmpty( + detailsObj.pinswg_questionnaireduedate + ) + ? formatDates( + detailsObj.pinswg_questionnaireduedate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
-
-
- {t( - "case:summary-statement-due-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_statementduedate" - ) - ? !_.isEmpty( - detailsObj.pinswg_statementduedate - ) - ? formatDates( - detailsObj.pinswg_statementduedate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
+
+
+ {t("case:summary-statement-due-date-label")} +
+
+ {_.has(detailsObj, "pinswg_statementduedate") + ? !_.isEmpty( + detailsObj.pinswg_statementduedate + ) + ? formatDates( + detailsObj.pinswg_statementduedate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
-
-
- {t( - "case:summary-interested-party-date-label" - )} -
-
- {_.has( +
+
+ {t("case:summary-interested-party-date-label")} +
+
+ {_.has( + detailsObj, + "pinswg_otherpartiesstatement" + ) + ? !_.isEmpty( + detailsObj.pinswg_otherpartiesstatement + ) + ? formatDates( + detailsObj.pinswg_otherpartiesstatement + ) + : t( + "case:summary-no-date-entered-label" + ) + : _.has( detailsObj, - "pinswg_otherpartiesstatement" + "pinswg_otherpartiesstatements" ) - ? !_.isEmpty( - detailsObj.pinswg_otherpartiesstatement - ) - ? formatDates( - detailsObj.pinswg_otherpartiesstatement - ) - : t( - "case:summary-no-date-entered-label" - ) - : _.has( - detailsObj, - "pinswg_otherpartiesstatements" - ) - ? !_.isEmpty( - detailsObj.pinswg_otherpartiesstatements - ) - ? formatDates( - detailsObj.pinswg_otherpartiesstatements - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
+ ? !_.isEmpty( + detailsObj.pinswg_otherpartiesstatements + ) + ? formatDates( + detailsObj.pinswg_otherpartiesstatements + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} + +
-
-
- {t( - "case:summary-applicant-final-comments-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_finalcommentsduedate" - ) - ? !_.isEmpty( - detailsObj.pinswg_finalcommentsduedate - ) - ? formatDates( - detailsObj.pinswg_finalcommentsduedate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
- {/*
+
+
+ {t( + "case:summary-applicant-final-comments-date-label" + )} +
+
+ {_.has( + detailsObj, + "pinswg_finalcommentsduedate" + ) + ? !_.isEmpty( + detailsObj.pinswg_finalcommentsduedate + ) + ? formatDates( + detailsObj.pinswg_finalcommentsduedate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+ {/*
{t( "case:summary-inquiry-evidence-date-label" @@ -414,82 +368,63 @@ const Pinswg_planningconditionss73s79id = (props) => { )}
*/} -
-
- {t("case:summary-event-date-label")} -
-
- {_.has( - detailsObj, - "pinswg_dateeventrequested" - ) - ? !_.isEmpty( - detailsObj.pinswg_dateeventrequested - ) - ? formatDates( - detailsObj.pinswg_dateeventrequested - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
- -
-
- {t( - "case:summary-start-event-date-label" - )} -
-
- {_.has( - detailsObj, - "pinswg_startdateofevent" - ) - ? !_.isEmpty( - detailsObj.pinswg_startdateofevent - ) - ? formatDates( - detailsObj.pinswg_startdateofevent - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
-
-
- {t("case:summary-decision-date-label")} -
-
- {_.has( - detailsObj, - "pinswg_casedecisiondate" - ) - ? !_.isEmpty( - detailsObj.pinswg_casedecisiondate - ) - ? formatDates( - detailsObj.pinswg_casedecisiondate - ) - : t( - "case:summary-no-date-entered-label" - ) - : t( - "case:summary-no-date-entered-label" - )} -
-
- +
+
+ {t("case:summary-event-date-label")} +
+
+ {_.has(detailsObj, "pinswg_dateeventrequested") + ? !_.isEmpty( + detailsObj.pinswg_dateeventrequested + ) + ? formatDates( + detailsObj.pinswg_dateeventrequested + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
-
-
+ +
+
+ {t("case:summary-start-event-date-label")} +
+
+ {_.has(detailsObj, "pinswg_startdateofevent") + ? !_.isEmpty( + detailsObj.pinswg_startdateofevent + ) + ? formatDates( + detailsObj.pinswg_startdateofevent + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+
+
+ {t("case:summary-decision-date-label")} +
+
+ {_.has(detailsObj, "pinswg_casedecisiondate") + ? !_.isEmpty( + detailsObj.pinswg_casedecisiondate + ) + ? formatDates( + detailsObj.pinswg_casedecisiondate + ) + : t( + "case:summary-no-date-entered-label" + ) + : t("case:summary-no-date-entered-label")} +
+
+ +
); diff --git a/context/representations-refactor-tracker.md b/context/representations-refactor-tracker.md index f66f3913..e1633f73 100644 --- a/context/representations-refactor-tracker.md +++ b/context/representations-refactor-tracker.md @@ -6,8 +6,8 @@ Base branch: `refactor` ## Status -Current slice: Slice R6 — Async Data / Service Layer Cleanup -Status: COMPLETE +Current slice: Slice R7 — Summary / Case-Type Rendering Simplification +Status: IMPLEMENTED (manual validation in progress) --- @@ -214,6 +214,97 @@ Reduce duplication in summary-type components. - unify repeated rendering patterns - introduce shared summary renderer where safe +**Completion notes (this slice):** + +- Implemented on feature branch created from `refactor`: `rep-slice-r7-summary-rendering-simplification`. +- Added render-only summary primitives: + - `components/case/summary/components/SummaryCard.js` + - `components/case/summary/components/SummaryRow.js` +- Applied these primitives to a small proof subset of summary-type files only: + - `components/case/summaryTypes/pinswg_planningappeals78id.js` + - `components/case/summaryTypes/pinswg_planningconditionss73s79id.js` +- Preserved Slice R7 constraints: + - no CaseSummary orchestration changes + - no translation/date/bilingual logic moved into shared primitives + - no linked-cases extraction (kept inline) + - no row/card order changes intended + - no route/query/payload/Redux/business-rule changes +- Validation evidence: + - `npm run lint` completed (warnings only, no new errors). + - `npm run test:reps` completed: **7 passed**. + - Manual APP/IP/Agent/LPA and EN/CY checks: **in progress** (Welsh IP statement option-label parity issue detected and patched in representation flow check display). + +--- + +### Post-R7 follow-up patch — Welsh IP statement label parity + +**Issue observed during manual check:** + +- In Welsh journey (Interested Party → Statement), option-label parity regressed: + - selection step showed duplicated Welsh “No” labels + - check/submit summary displayed raw English `No` + +**Fix applied (minimal, behaviour-preserving):** + +- `components/case/representation/representationInterestedPartyPerson.js` + - restored canonical option values for conditional radio to `options={["Yes", "No"]}` so `RenderCondtionalRadioList` translation mapping behaves correctly. +- `components/case/representation/representationCompleteSubmit.js` + - added display mapping for `representationOnBehalfOf` summary value: + - `Yes` → `t("myrepresentations:questionnaire-yes")` + - `No` → `t("myrepresentations:questionnaire-no")` + - fallback unchanged for non-boolean/unexpected values + +**Validation evidence (follow-up patch):** + +- `npm run lint` completed (warnings only, no new errors). +- `npm run test:reps` completed: **7 passed (4.6m)**. +- Manual Welsh IP statement check: input labels and check-summary label now aligned via translation mapping. + +--- + +### Post-R7 follow-up patch 2 — Welsh IP conditional details submit validation + +**Issue observed during manual check:** + +- In Welsh journey (Interested Party → Statement), when selecting “Yes” and entering conditional details, submit could still block with required validation on the conditional text field. + +**Fix applied (minimal, behaviour-preserving):** + +- `components/case/representation/representationElements.js` + - In `RenderCondtionalRadioList`, made “Yes selected” detection bilingual-safe and value-safe: + - accepts canonical value (`"Yes"`), translated display value (`t("myrepresentations:questionnaire-yes")`), and boolean `true`. + - Replaced unconditional conditional-field validator with context-aware validator: + - `requiredIfYes` only enforces required when “Yes” is selected. + - Updated conditional rendering check to use the same normalized `isYesSelected` guard. + +**Validation evidence (follow-up patch 2):** + +- `npm run lint` completed (warnings only, no new errors). +- `npm run test:reps` run completed with **6 passed / 1 failed**. + - Failure: `[chromium] Raise representation as an Appellant` timed out waiting for `dd a.govuk-link--no-underline` (entry-link locator timeout), not in Welsh IP conditional details path. + +--- + +### Post-R7 follow-up patch 3 — Welsh conditional required check tied to current radio value + +**Issue observed during manual check:** + +- In Welsh journey, selecting “Yes” could still leave the conditional details field blocked with required validation (`Yn ofynnol`) after entering text, preventing progress. + +**Fix applied (minimal, behaviour-preserving):** + +- `components/case/representation/representationElements.js` + - Added explicit `normalizeYesNo(...)` mapping for both selected value and option values: + - canonical/translated/boolean values normalize to `"Yes"` / `"No"`. + - Radio `Field` values now use normalized canonical values (preserves existing payload expectation). + - Updated conditional `requiredIfYes` validator to evaluate against the **current form value** (`allValues[id]`) rather than closure-only value. + - Required check now trims whitespace and only errors when selected value resolves to `"Yes"` and details are empty. + +**Validation evidence (follow-up patch 3):** + +- `npm run lint` completed (warnings only, no new errors). +- `npm run test:reps` intentionally **not run** per user instruction while manual Welsh verification is in progress. + --- ### Slice R8 — Submission / Finalisation Boundary Isolation