diff --git a/.env.local b/.env.local index 7fcf638a..3fb9897f 100644 --- a/.env.local +++ b/.env.local @@ -271,4 +271,6 @@ HIDEERRORLOGS = false SHOWSIPS = true ALLOWED_IPS=::1,203.0.113.42,198.51.100.17 -UPLOAD_BATCH_COUNT = 5 \ No newline at end of file +UPLOAD_BATCH_COUNT = 5 + +NRWDOMAIN = rdbmedia.co.uk \ No newline at end of file diff --git a/components/case/representation/consultationAgent.js b/components/case/representation/consultationAgent.js index bfae03e6..ee3d8984 100644 --- a/components/case/representation/consultationAgent.js +++ b/components/case/representation/consultationAgent.js @@ -2,22 +2,22 @@ import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import { Field, change, reduxForm } from "redux-form"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { bytesToSize, getThumbnailIconByExtension } from "../../utils"; import { FileUploadField, RenderCondtionalRadioList, - RenderPickList, RenderRichMultiline, - shouldDisableButton, + shouldDisableButton } from "./representationElements"; +import RepresentationTypeSelectorBlock from "./elements/RepresentationTypeSelectorBlock"; import { useDropzone } from "react-dropzone"; import { setRepresentationCapacity, setRepresentationSubmit, - setFilesForRepresentations, + setFilesForRepresentations } from "../../../store/currentView/action"; const ConsultationAgent = (props) => { @@ -36,9 +36,23 @@ const ConsultationAgent = (props) => { setSavingStatus, savingStatus, setFilesForRepresentations, + onRepresentationTypeChange, + onTypeSelectionConfirmed } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); + const persistedRepresentationType = + currentView?.caseReference?.repDetails?.representationType; + const [typeSelectionConfirmed, setTypeSelectionConfirmed] = useState( + !!persistedRepresentationType + ); + + useEffect(() => { + if (persistedRepresentationType) { + setTypeSelectionConfirmed(true); + } + }, [persistedRepresentationType]); + if (JSON.stringify(formObj) != "{}") { setRepFileName(formObj.representationForm.values); @@ -63,63 +77,43 @@ const ConsultationAgent = (props) => { )); const required = (value) => (value ? undefined : "Required"); + const selectedRepresentationType = + formObj?.representationForm?.values?.representationType || + props.representationType; + + const isTypeConfirmed = + !!selectedRepresentationType && typeSelectionConfirmed; + + const selectedRepresentationTypeDisplay = + router.locale == "cy" + ? selectedRepresentationType == "Questionnaire" + ? "Holiadur" + : selectedRepresentationType == "Statement" + ? "Datganiad" + : selectedRepresentationType == "Final comments" + ? "Sylwadau terfynol" + : selectedRepresentationType + : selectedRepresentationType; + return ( <> -
-
- {typeof formObj.representationForm.values - .representationType == "undefined" && - props.representationType != "Select..." ? ( - <> -

- {t( - "myrepresentations:consultation-from-an-agent-heading" - )} -

- - - - - - ) : ( - - )} -
-
- {(typeof props.representationType != "undefined" || - typeof formObj.representationForm.values - .representationType != "undefined") && ( + + {isTypeConfirmed && ( <>
@@ -146,8 +140,7 @@ const ConsultationAgent = (props) => {

- {formObj.representationForm.values - .representationType == + {selectedRepresentationType == "Consultation Response" ? t( "myrepresentations:enter-comment-label" @@ -160,8 +153,7 @@ const ConsultationAgent = (props) => { className="govuk-fieldset" aria-describedby="commentBox-hint" > - {formObj.representationForm.values - .representationType == + {selectedRepresentationType == "Consultation Response" && (

{
)} - {typeof formObj.representationForm.values.representationType != - "undefined" && ( + {isTypeConfirmed && (
+ + ) : ( + <> +

+ {t( + "myrepresentations:representation-type-unavailable-label" + )} +

+ + {t( + "myrepresentations:return-home-link-label" + )} + + + )} ) : ( )}
+
); }; diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 239b4f5a..6261154d 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -58,6 +58,10 @@ let MakeRepresentation = (props) => { const [savingStatus, setSavingStatus] = useState(false); const [finaliseAppealProcess, setFinaliseAppealProcess] = useState(false); + const [representationTypeConfirmed, setRepresentationTypeConfirmed] = + useState( + !!props?.currentView?.caseReference?.repDetails?.representationType + ); //const [questionnaireCount, setQuestionnaireCount] = useState(0); @@ -586,7 +590,10 @@ let MakeRepresentation = (props) => { updateRepresentation, setSavingStatus, savingStatus, - setCurrentReference + setCurrentReference, + onRepresentationTypeChange: () => + setRepresentationTypeConfirmed(false), + onTypeSelectionConfirmed: () => setRepresentationTypeConfirmed(true) }; const { controlKey } = resolveRepresentationControlKey({ @@ -1108,7 +1115,7 @@ let MakeRepresentation = (props) => { const isQuestionnaire = formObj?.representationForm?.values?.representationType === - "Questionnaire"; + "Questionnaire" && representationTypeConfirmed; const appealIsConsultation = appealType === 846040002; const appealIsLocalImpact = diff --git a/components/case/representation/representationAgent.js b/components/case/representation/representationAgent.js index 6773b6aa..afe8a9bc 100644 --- a/components/case/representation/representationAgent.js +++ b/components/case/representation/representationAgent.js @@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import { Field, change, reduxForm } from "redux-form"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { bytesToSize, getThumbnailIconByExtension } from "../../utils"; import { @@ -36,10 +36,24 @@ const RepAgent = (props) => { updateRepresentation, setSavingStatus, savingStatus, - setFilesForRepresentations + setFilesForRepresentations, + onRepresentationTypeChange, + onTypeSelectionConfirmed } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); + const persistedRepresentationType = + currentView?.caseReference?.repDetails?.representationType; + const [typeSelectionConfirmed, setTypeSelectionConfirmed] = useState( + !!persistedRepresentationType + ); + + useEffect(() => { + if (persistedRepresentationType) { + setTypeSelectionConfirmed(true); + } + }, [persistedRepresentationType]); + if (JSON.stringify(formObj) != "{}") { setRepFileName(formObj.representationForm.values); @@ -64,23 +78,23 @@ const RepAgent = (props) => { )); const required = (value) => (value ? undefined : "Required"); - const hasTypeSelectionInline = - typeof formObj.representationForm.values.representationType == - "undefined" && props.representationType != "Select..."; + const selectedRepresentationType = + formObj?.representationForm?.values?.representationType || + props.representationType; + + const isTypeConfirmed = + !!selectedRepresentationType && typeSelectionConfirmed; const selectedRepresentationTypeDisplay = router.locale == "cy" - ? formObj.representationForm.values.representationType == - "Questionnaire" + ? selectedRepresentationType == "Questionnaire" ? "Holiadur" - : formObj.representationForm.values.representationType == - "Statement" + : selectedRepresentationType == "Statement" ? "Datganiad" - : formObj.representationForm.values.representationType == - "Final comments" + : selectedRepresentationType == "Final comments" ? "Sylwadau terfynol" - : formObj.representationForm.values.representationType - : formObj.representationForm.values.representationType; + : selectedRepresentationType + : selectedRepresentationType; const handleSaveExit = () => { let valuesObj = props.props.props.form[props.form].values || {}; @@ -98,13 +112,15 @@ const RepAgent = (props) => { "myrepresentations:representation-from-an-agent-heading" )} kindLabelText={t("myrepresentations:kind-of-rep-label")} - isTypeSelected={!hasTypeSelectionInline} + isTypeSelected={isTypeConfirmed} selectedTypeDisplay={selectedRepresentationTypeDisplay} + representationType={selectedRepresentationType} + setTypeSelectionConfirmed={setTypeSelectionConfirmed} + onRepresentationTypeChange={onRepresentationTypeChange} + onTypeSelectionConfirmed={onTypeSelectionConfirmed} optionsArr={appellantApplicantRepresentationArr} /> - {(typeof props.representationType != "undefined" || - typeof formObj.representationForm.values - .representationType != "undefined") && ( + {isTypeConfirmed && ( <>
@@ -227,8 +243,7 @@ const RepAgent = (props) => {
)} - {typeof formObj.representationForm.values.representationType != - "undefined" && ( + {isTypeConfirmed && ( { updateRepresentation, setSavingStatus, savingStatus, - setFilesForRepresentations + setFilesForRepresentations, + onRepresentationTypeChange, + onTypeSelectionConfirmed } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); + const persistedRepresentationType = + currentView?.caseReference?.repDetails?.representationType; + const [typeSelectionConfirmed, setTypeSelectionConfirmed] = useState( + !!persistedRepresentationType + ); + + useEffect(() => { + if (persistedRepresentationType) { + setTypeSelectionConfirmed(true); + } + }, [persistedRepresentationType]); + console.log(JSON.stringify(formObj) == "{}" ? "empty" : "value"); if (JSON.stringify(formObj) != "{}") { @@ -64,23 +77,23 @@ const RepAppellant = (props) => { index === self.findIndex((t) => t.name === value.name) ); - const hasTypeSelectionInline = - typeof formObj.representationForm.values.representationType == - "undefined" && props.representationType != "Select..."; + const selectedRepresentationType = + formObj?.representationForm?.values?.representationType || + props.representationType; + + const isTypeConfirmed = + !!selectedRepresentationType && typeSelectionConfirmed; const selectedRepresentationTypeDisplay = router.locale == "cy" - ? formObj.representationForm.values.representationType == - "Questionnaire" + ? selectedRepresentationType == "Questionnaire" ? "Holiadur" - : formObj.representationForm.values.representationType == - "Statement" + : selectedRepresentationType == "Statement" ? "Datganiad" - : formObj.representationForm.values.representationType == - "Final comments" + : selectedRepresentationType == "Final comments" ? "Sylwadau terfynol" - : formObj.representationForm.values.representationType - : formObj.representationForm.values.representationType; + : selectedRepresentationType + : selectedRepresentationType; const handleSaveExit = () => { let valuesObj = props.props.props.form[props.form].values || {}; @@ -98,13 +111,15 @@ const RepAppellant = (props) => { "myrepresentations:representation-from-an-appellant-heading" )} kindLabelText={t("myrepresentations:kind-of-rep-label")} - isTypeSelected={!hasTypeSelectionInline} + isTypeSelected={isTypeConfirmed} selectedTypeDisplay={selectedRepresentationTypeDisplay} + representationType={selectedRepresentationType} + setTypeSelectionConfirmed={setTypeSelectionConfirmed} + onRepresentationTypeChange={onRepresentationTypeChange} + onTypeSelectionConfirmed={onTypeSelectionConfirmed} optionsArr={appellantApplicantRepresentationArr} /> - {(typeof props.representationType != "undefined" || - typeof formObj.representationForm.values - .representationType != "undefined") && ( + {isTypeConfirmed && (

@@ -220,8 +235,7 @@ const RepAppellant = (props) => {

)} - {typeof formObj.representationForm.values.representationType != - "undefined" && ( + {isTypeConfirmed && ( { updateRepresentation, setSavingStatus, savingStatus, - setFilesForRepresentations + setFilesForRepresentations, + onRepresentationTypeChange, + onTypeSelectionConfirmed } = props; const required = (value) => (value ? undefined : "Required"); const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); + const persistedRepresentationType = + props.currentView?.caseReference?.repDetails?.representationType; + const [typeSelectionConfirmed, setTypeSelectionConfirmed] = useState( + !!persistedRepresentationType + ); + + useEffect(() => { + if (persistedRepresentationType) { + setTypeSelectionConfirmed(true); + } + }, [persistedRepresentationType]); + if (JSON.stringify(formObj) != "{}") { setRepFileName(formObj.representationForm.values); @@ -64,23 +78,23 @@ const RepInterestedPartyPerson = (props) => { )); - const hasTypeSelectionInline = - typeof formObj.representationForm.values.representationType == - "undefined" && props.representationType != "Select..."; + const selectedRepresentationType = + formObj?.representationForm?.values?.representationType || + props.representationType; + + const isTypeConfirmed = + !!selectedRepresentationType && typeSelectionConfirmed; const selectedRepresentationTypeDisplay = router.locale == "cy" - ? formObj.representationForm.values.representationType == - "Questionnaire" + ? selectedRepresentationType == "Questionnaire" ? "Holiadur" - : formObj.representationForm.values.representationType == - "Statement" + : selectedRepresentationType == "Statement" ? "Datganiad" - : formObj.representationForm.values.representationType == - "Final comments" + : selectedRepresentationType == "Final comments" ? "Sylwadau terfynol" - : formObj.representationForm.values.representationType - : formObj.representationForm.values.representationType; + : selectedRepresentationType + : selectedRepresentationType; const handleSaveExit = () => { let valuesObj = props.props.props.form[props.form].values || {}; @@ -98,15 +112,17 @@ const RepInterestedPartyPerson = (props) => { "myrepresentations:consultation-from-an-interested-person-heading" )} kindLabelText={t("myrepresentations:kind-of-rep-label")} - isTypeSelected={!hasTypeSelectionInline} + isTypeSelected={isTypeConfirmed} selectedTypeDisplay={selectedRepresentationTypeDisplay} + representationType={selectedRepresentationType} + setTypeSelectionConfirmed={setTypeSelectionConfirmed} + onRepresentationTypeChange={onRepresentationTypeChange} + onTypeSelectionConfirmed={onTypeSelectionConfirmed} optionsArr={interestedPersonRepresentationArr} validate={[required]} errorMsg={t("myrepresentations:select-an-option-label")} /> - {(typeof props.representationType != "undefined" || - typeof formObj.representationForm.values - .representationType != "undefined") && ( + {isTypeConfirmed && ( <>
@@ -213,8 +229,7 @@ const RepInterestedPartyPerson = (props) => {
)} - {typeof formObj.representationForm.values.representationType != - "undefined" && ( + {isTypeConfirmed && ( { @@ -49,6 +49,8 @@ let RepLPA = (props) => { setSavingStatus, savingStatus, setFilesForRepresentations, + onRepresentationTypeChange, + onTypeSelectionConfirmed } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); @@ -59,6 +61,36 @@ let RepLPA = (props) => { )); const required = (value) => (value ? undefined : "Required"); + const persistedRepresentationType = + currentView?.caseReference?.repDetails?.representationType; + const [typeSelectionConfirmed, setTypeSelectionConfirmed] = useState( + !!persistedRepresentationType + ); + + useEffect(() => { + if (persistedRepresentationType) { + setTypeSelectionConfirmed(true); + } + }, [persistedRepresentationType]); + + const selectedRepresentationType = + formObj?.representationForm?.values?.representationType || + props.representationType; + + const isTypeConfirmed = + !!selectedRepresentationType && typeSelectionConfirmed; + + const selectedRepresentationTypeDisplay = + router.locale == "cy" + ? selectedRepresentationType == "Questionnaire" + ? "Holiadur" + : selectedRepresentationType == "Statement" + ? "Datganiad" + : selectedRepresentationType == "Final comments" + ? "Sylwadau terfynol" + : selectedRepresentationType + : selectedRepresentationType; + const whichQuestionnaire = () => { { switch (currentView.caseReference.appealType) { @@ -183,7 +215,7 @@ let RepLPA = (props) => { currentView.caseReference.currentReference + '")]', json: setCaseDetailsObj, - eval: true, + eval: true }); let setCaseResultssObj = router.query.hasOwnProperty("state") @@ -202,7 +234,7 @@ let RepLPA = (props) => { currentView.caseReference.currentReference + '")]', json: setCaseResultssObj, - eval: true, + eval: true }); resultsObj = resultsObj[0]; @@ -225,62 +257,26 @@ let RepLPA = (props) => { return ( <> +
- {!_.has( - formObj["representationForm"], - ["values", "representationType"] || - typeof props.currentView.caseReference.repDetails != - "undefined" - ) ? ( - <> - - - - ) : ( - - )} -
-
-
-
- {(_.has(formObj["representationForm"], [ - "values", - "representationType", - ]) || - typeof props.representationType != "undefined") && - (props.representationType != "Questionnaire" && - props.representationType != "Select..." ? ( + {isTypeConfirmed && + (selectedRepresentationType != "Questionnaire" ? ( <>

{t("myrepresentations:enter-comment-label")} @@ -354,7 +350,8 @@ let RepLPA = (props) => { "myrepresentations:add-files-label" )} ticketnumber={ - props.currentView.caseReference.ticketnumber + props.currentView.caseReference + .ticketnumber } hint={"sdsd"} fileList={ @@ -401,9 +398,8 @@ let RepLPA = (props) => {

- {(typeof props.representationType != "undefined" || - _.has(formObj, "values", "representationType")) && - props.representationType == "Questionnaire" && ( + {isTypeConfirmed && + selectedRepresentationType == "Questionnaire" && ( <> {showQuestionnaireSection < questionnaireCount && ( @@ -443,14 +439,14 @@ let RepLPA = (props) => { // top: 0, // behavior: "smooth", // }); - setRepFileName( + (setRepFileName( props.formObj[ "representationForm" ].values ), setShowQuestionnaireSection( showQuestionnaireSection - 1 - ); + )); }} className="govuk-link" > @@ -503,9 +499,8 @@ let RepLPA = (props) => { )} )}{" "} - {(typeof props.representationType != "undefined" || - _.has(formObj, "values", "representationType")) && - props.representationType != "Questionnaire" && ( + {isTypeConfirmed && + selectedRepresentationType != "Questionnaire" && ( <>