From eae42c36228abae8ebaaa3bcd72c8266dbd432f4 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Mon, 28 Apr 2025 17:14:59 +0100 Subject: [PATCH] 16435 logic to disable continue button so cant submit empty rep --- .../case/representation/consultationAgent.js | 5 +++++ .../representation/consultationAppellant.js | 6 ++++++ .../consultationInterestedPartyPerson.js | 5 +++++ components/case/representation/index.js | 2 +- .../representation/representationAgent.js | 21 ++++++------------- .../representation/representationAppellant.js | 21 ++++++------------- .../representationCompleteSubmit.js | 2 +- .../representation/representationElements.js | 6 ++++++ .../representationInterestedPartyPerson.js | 5 +++++ .../case/representation/representationLPA.js | 5 +++++ components/case/summary.js | 1 + 11 files changed, 47 insertions(+), 32 deletions(-) diff --git a/components/case/representation/consultationAgent.js b/components/case/representation/consultationAgent.js index d5390b44..50a8d6dd 100644 --- a/components/case/representation/consultationAgent.js +++ b/components/case/representation/consultationAgent.js @@ -211,6 +211,11 @@ const ConsultationAgent = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={ + props.currentView.fileList.length < 1 + ? true + : false + } > {t("common:continue-button")} diff --git a/components/case/representation/consultationAppellant.js b/components/case/representation/consultationAppellant.js index 440477ec..033591a3 100644 --- a/components/case/representation/consultationAppellant.js +++ b/components/case/representation/consultationAppellant.js @@ -171,6 +171,7 @@ const ConsultationAppellant = (props) => { {" "} )} + {typeof formObj.representationForm.values.representationType != "undefined" && (
@@ -179,6 +180,11 @@ const ConsultationAppellant = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={ + props.currentView.fileList.length < 1 + ? true + : false + } > {t("common:continue-button")} diff --git a/components/case/representation/consultationInterestedPartyPerson.js b/components/case/representation/consultationInterestedPartyPerson.js index 79181de2..d9e8130a 100644 --- a/components/case/representation/consultationInterestedPartyPerson.js +++ b/components/case/representation/consultationInterestedPartyPerson.js @@ -219,6 +219,11 @@ const ConsultationInterestedPartyPerson = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={ + props.currentView.fileList.length < 1 + ? true + : false + } > {t("common:continue-button")} diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 0dd0bca2..93d71218 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -445,7 +445,7 @@ let MakeRepresentation = (props) => { currentView.caseReference.specialistProcess == 846040000 && buildArr.pop("Statements"); - console.log("is this a sip......", isSIPS, !isLPA); + //console.log("is this a sip......", isSIPS, !isLPA); isSIPS && buildArr.push("Consultation Response"); isSIPS && buildArr.push("Local Impact Report"); diff --git a/components/case/representation/representationAgent.js b/components/case/representation/representationAgent.js index 6e13b87e..c561500a 100644 --- a/components/case/representation/representationAgent.js +++ b/components/case/representation/representationAgent.js @@ -10,6 +10,7 @@ import { RenderCondtionalRadioList, RenderPickList, RenderRichMultiline, + shouldDisableButton, } from "./representationElements"; import { useDropzone } from "react-dropzone"; @@ -246,24 +247,14 @@ const RepAgent = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={shouldDisableButton({ + props, + formObj, + })} > {t("common:continue-button")} - {/* {router.query.state != "edit" && ( - { - setRepresentationCapacity(); - props.updateField( - "representationForm", - "representationCapacity", - "" - ); - }} - className="govuk-link" - > - {t("common:back-link")} - - )} */} + {savingStatus ? ( {router.locale == "cy" diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index 5dc66794..b8b54ec9 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -9,6 +9,7 @@ import { FileUploadField, RenderPickList, RenderRichMultiline, + shouldDisableButton, } from "./representationElements"; import { useDropzone } from "react-dropzone"; @@ -225,6 +226,7 @@ const RepAppellant = (props) => {
{" "} )} + {typeof formObj.representationForm.values.representationType != "undefined" && (
@@ -233,24 +235,13 @@ const RepAppellant = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={shouldDisableButton({ + props, + formObj, + })} > {t("common:continue-button")} - {/* {router.query.state != "edit" && ( - { - setRepresentationCapacity(); - props.updateField( - "representationForm", - "representationType", - "" - ); - }} - className="govuk-link" - > - {t("common:back-link")} - - )} */} {savingStatus ? ( diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js index ed001436..a4302dd7 100644 --- a/components/case/representation/representationCompleteSubmit.js +++ b/components/case/representation/representationCompleteSubmit.js @@ -279,7 +279,7 @@ const RepCompleteSubmit = (props) => { "myrepresentations:consultation-check-your-rep-heading" ) : t( - "myrepresentations:rrep-check-your-rep-heading" + "myrepresentations:rep-check-your-rep-heading" )}
diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index 9fade1e2..737506f7 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -1390,6 +1390,12 @@ export function FileUploadField(props) { ); } +export const shouldDisableButton = ({ props, formObj }) => + !( + props?.currentView?.fileList?.length > 0 || + typeof formObj?.representationForm?.values?.representationComments !== + "undefined" + ); // export const RepresentationGuidanceText = (appealType) => { // let { t } = useTranslation(); diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index ca59a797..d77fd6d2 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -10,6 +10,7 @@ import { RenderCondtionalRadioList, RenderPickList, RenderRichMultiline, + shouldDisableButton, } from "./representationElements"; import { useDropzone } from "react-dropzone"; @@ -238,6 +239,10 @@ const RepInterestedPartyPerson = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={shouldDisableButton({ + props, + formObj, + })} > {t("common:continue-button")} diff --git a/components/case/representation/representationLPA.js b/components/case/representation/representationLPA.js index 9818fe09..1d38c9e9 100644 --- a/components/case/representation/representationLPA.js +++ b/components/case/representation/representationLPA.js @@ -11,6 +11,7 @@ import { FileUploadField, RenderMultiline, RenderPickList, + shouldDisableButton, } from "./representationElements"; import RepresentationProgress_enforcement from "./representationProgress/representationProgress_enforcement"; import RepresentationProgress_s78 from "./representationProgress/representationProgress_s78"; @@ -510,6 +511,10 @@ let RepLPA = (props) => { type="submit" className="govuk-button" data-module="govuk-button" + disabled={shouldDisableButton({ + props, + formObj, + })} onClick={() => { let valuesObj = props.props.props.form[props.form] diff --git a/components/case/summary.js b/components/case/summary.js index b252b94a..21457102 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -41,6 +41,7 @@ import { isObjectNotEmpty, hasOwnPropertyAndNotNull, linkedCasesList, + showRepsEnded, } from "./summary/utils/helpers"; import CaseNoticeBanner from "./caseNoticeBanner";