From 869264b7fac4789890ee2e4c0e148969e0ccb96d Mon Sep 17 00:00:00 2001 From: Robert Bond Date: Mon, 13 Apr 2026 10:15:56 +0000 Subject: [PATCH] Merged PR 2237: refactor(newappeal): extract BuildSection presentation components (Slice 4) refactor(newappeal): extract BuildSection presentation components (Slice 4) Related work items: #22583 --- .../newappeal/buildSection/ErrorSummary.js | 31 ++++ .../buildSection/PrimaryActionButtons.js | 5 + .../buildSection/SaveStatusIndicator.js | 14 ++ .../newappeal/buildSection/SectionHeader.js | 5 + .../buildSection/SidebarProgressPanel.js | 12 ++ components/newappeal/buildsection.js | 161 ++++++------------ context/refactor-tracker.md | 4 +- 7 files changed, 123 insertions(+), 109 deletions(-) create mode 100644 components/newappeal/buildSection/ErrorSummary.js create mode 100644 components/newappeal/buildSection/PrimaryActionButtons.js create mode 100644 components/newappeal/buildSection/SaveStatusIndicator.js create mode 100644 components/newappeal/buildSection/SectionHeader.js create mode 100644 components/newappeal/buildSection/SidebarProgressPanel.js diff --git a/components/newappeal/buildSection/ErrorSummary.js b/components/newappeal/buildSection/ErrorSummary.js new file mode 100644 index 00000000..f2bf9bfb --- /dev/null +++ b/components/newappeal/buildSection/ErrorSummary.js @@ -0,0 +1,31 @@ +const ErrorSummary = ({ hasErrors, errorItems }) => { + return hasErrors ? ( +
+

+ The following fields have a problem : +

+
+ +
+
+ ) : ( + "" + ); +}; + +export default ErrorSummary; diff --git a/components/newappeal/buildSection/PrimaryActionButtons.js b/components/newappeal/buildSection/PrimaryActionButtons.js new file mode 100644 index 00000000..84741b8c --- /dev/null +++ b/components/newappeal/buildSection/PrimaryActionButtons.js @@ -0,0 +1,5 @@ +const PrimaryActionButtons = ({ children }) => { + return
{children}
; +}; + +export default PrimaryActionButtons; diff --git a/components/newappeal/buildSection/SaveStatusIndicator.js b/components/newappeal/buildSection/SaveStatusIndicator.js new file mode 100644 index 00000000..86d23003 --- /dev/null +++ b/components/newappeal/buildSection/SaveStatusIndicator.js @@ -0,0 +1,14 @@ +const SaveStatusIndicator = ({ text }) => { + return ( + + {text} + {text} + + ); +}; + +export default SaveStatusIndicator; diff --git a/components/newappeal/buildSection/SectionHeader.js b/components/newappeal/buildSection/SectionHeader.js new file mode 100644 index 00000000..6d9c09ca --- /dev/null +++ b/components/newappeal/buildSection/SectionHeader.js @@ -0,0 +1,5 @@ +const SectionHeader = ({ title }) => { + return

{title}

; +}; + +export default SectionHeader; diff --git a/components/newappeal/buildSection/SidebarProgressPanel.js b/components/newappeal/buildSection/SidebarProgressPanel.js new file mode 100644 index 00000000..5c6903d5 --- /dev/null +++ b/components/newappeal/buildSection/SidebarProgressPanel.js @@ -0,0 +1,12 @@ +const SidebarProgressPanel = ({ children }) => { + return ( +
+
+ {children} +
+
+
+ ); +}; + +export default SidebarProgressPanel; diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js index e4355406..9b8ed214 100644 --- a/components/newappeal/buildsection.js +++ b/components/newappeal/buildsection.js @@ -34,6 +34,11 @@ import { import { FieldsTranslations } from "../elements"; import BuildProgress from "./buildprogress"; +import ErrorSummary from "./buildSection/ErrorSummary"; +import PrimaryActionButtons from "./buildSection/PrimaryActionButtons"; +import SaveStatusIndicator from "./buildSection/SaveStatusIndicator"; +import SectionHeader from "./buildSection/SectionHeader"; +import SidebarProgressPanel from "./buildSection/SidebarProgressPanel"; let BuildSection = (props) => { const [currentSectionSelected, setCurrentSectionSelected] = useState(1); @@ -354,11 +359,10 @@ let BuildSection = (props) => { window.scrollTo(0, 0); }; - let errorsobj = {}; - const ShowErrorHeader = (props) => { - errorsobj = props.props.appealForm.syncErrors; - errorsobj = _.keys(errorsobj); - + const getErrorItems = () => { + let errorsobj = _.keys( + _.get(props, "props.form.appealForm.syncErrors", {}) + ); const getErrorLabel = (whichField) => { var doc = parseXml(props.formXML); var errorFieldLabel = selectErrorFieldLabelDescription( @@ -369,47 +373,15 @@ let BuildSection = (props) => { return errorFieldLabel[0].value; }; - const ShowErrors = () => { - let errorList = []; - for (let i = 0; i < errorsobj.length; ++i) { - //get label from error key - search rowxml for id = errorobj + let errorItems = []; + for (let i = 0; i < errorsobj.length; ++i) { + errorItems.push({ + "field": errorsobj[i], + "label": getErrorLabel(errorsobj[i]) + }); + } - errorList.push( -
  • - - {" "} - {getErrorLabel(errorsobj[i])} - -
  • - ); - } - - return errorList; - }; - - return !_.isEmpty(errorsobj) ? ( -
    -

    - The following fields have a problem : -

    -
    -
      - -
    -
    -
    - ) : ( - "" - ); + return errorItems; }; const hasUploadFiles = () => { @@ -425,19 +397,12 @@ let BuildSection = (props) => { return (
    -

    - {FieldsTranslations(titles[0].value)} -

    +
    - {hasErrors == true ? ( - - ) : ( - "" - )} + { } /> -
    + {props.sectionCount != currentSection ? ( <> {currentSection > 1 && (savingStatus ? ( - - {router.locale == "cy" - ? "Nôl data" - : "Saving data"} - { - + ) : ( {savingStatus ? ( - - {router.locale == "cy" - ? "Nôl data" - : "Saving data"} - { - + ) : (
    +
    -
    -
    - {/* - Last section is {lastIndex} - {currentSection} - */} - - -
    -
    -
    + + {/* + Last section is {lastIndex} - {currentSection} + */} + +
    ); }; diff --git a/context/refactor-tracker.md b/context/refactor-tracker.md index 94612953..12a50e49 100644 --- a/context/refactor-tracker.md +++ b/context/refactor-tracker.md @@ -4,7 +4,7 @@ Base branch for this tracker: `refactor` ## Status -Current slice: Slice 4 — BuildSection UI Extraction +Current slice: Slice 5 — BuildCheckSection UI Extraction Status: READY TO START --- @@ -50,7 +50,7 @@ Status: COMPLETE ### Slice 4 — BuildSection UI Extraction -Status: NOT STARTED +Status: COMPLETE ---