reps defect 43 - also handles not submitting reps when date passed

This commit is contained in:
2025-01-30 14:12:15 +00:00
parent 6fb4f5722a
commit 6dded01501
4 changed files with 192 additions and 34 deletions
@@ -8,7 +8,16 @@ import RepComplete from "./representationComplete";
import RepLPAQuestionnaireCheck_enforcement from "./representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement";
import RepLPAQuestionnaireCheck_s78 from "./representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78";
import Link from "next/link";
import { bytesToSize, getThumbnailIconByExtension } from "../../utils";
import {
bytesToSize,
getThumbnailIconByExtension,
formatDates,
} from "../../utils";
import {
setCurrentReference,
setCurrentView,
} from "../../../store/currentView/action";
const RepCompleteSubmit = (props) => {
let { t } = useTranslation();
@@ -30,6 +39,7 @@ const RepCompleteSubmit = (props) => {
showQuestionnaireSection,
questionnaireCount,
finaliseAppealProcess,
setCurrentReference,
} = props;
const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
const files = acceptedFiles.map((file) => (
@@ -203,6 +213,34 @@ const RepCompleteSubmit = (props) => {
});
let filterFiles = [];
function showRepsEnded(endDate) {
let date = new Date();
date = new Date(date.toDateString());
const end = new Date(endDate);
return end > date ? false : true;
}
const checkRepDatePassed = () => {
if (repFormData.representationType == "Questionnaire") {
return false;
} else {
if (repFormData.representationType == "Final comments") {
return repFormData.hasOwnProperty(
"pinswg_finalcommentsduedate"
) && showRepsEnded(repFormData.pinswg_finalcommentsduedate)
? true
: false;
}
if (repFormData.representationType == "Statement") {
return repFormData.hasOwnProperty("pinswg_statementduedate") &&
showRepsEnded(repFormData.pinswg_statementduedate)
? true
: false;
}
}
};
return (
<>
{currentView.representationSubmitConfirmation == true ? (
@@ -291,7 +329,24 @@ const RepCompleteSubmit = (props) => {
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
// setSubmitBack();
setCurrentReference({
"ticketnumber":
repFormData.ticketnumber,
"currentReference":
repFormData.caseRef,
"currentType":
"myRepresentations",
"incidentid":
repFormData.incidentID,
"appealType":
repFormData.appealType,
"repDetails":
repFormData,
});
setRepresentationSubmit(
false
);
}}
>
{t(
@@ -326,7 +381,26 @@ const RepCompleteSubmit = (props) => {
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
// setSubmitBack();
setCurrentReference(
{
"ticketnumber":
repFormData.ticketnumber,
"currentReference":
repFormData.caseRef,
"currentType":
"myRepresentations",
"incidentid":
repFormData.incidentID,
"appealType":
repFormData.appealType,
"repDetails":
repFormData,
}
);
setRepresentationSubmit(
false
);
}}
>
{t(
@@ -365,7 +439,25 @@ const RepCompleteSubmit = (props) => {
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
// setSubmitBack();
setCurrentReference({
"ticketnumber":
repFormData.ticketnumber,
"currentReference":
repFormData.caseRef,
"currentType":
"myRepresentations",
"incidentid":
repFormData.incidentID,
"appealType":
repFormData.appealType,
"repDetails":
repFormData,
});
setRepresentationSubmit(
false
);
}}
>
{t("common:change-link-label")}
@@ -427,7 +519,23 @@ const RepCompleteSubmit = (props) => {
setRepresentationSubmit(
false
))
: setSubmitBack();
: (setCurrentReference({
"ticketnumber":
repFormData.ticketnumber,
"currentReference":
repFormData.caseRef,
"currentType":
"myRepresentations",
"incidentid":
repFormData.incidentID,
"appealType":
repFormData.appealType,
"repDetails":
repFormData,
}),
setRepresentationSubmit(
false
));
}}
>
{t("common:change-link-label")}
@@ -451,7 +559,6 @@ const RepCompleteSubmit = (props) => {
"myrepresentations:rep-check-tandc-para-one"
)}
</p>
<p>
{t(
"myrepresentations:rep-check-tandc-para-two"
@@ -466,25 +573,47 @@ const RepCompleteSubmit = (props) => {
</Link>
.
</p>
<p>
{t(
"myrepresentations:rep-check-tandc-para-three"
)}
</p>
{finaliseAppealProcess ? (
{checkRepDatePassed() ? (
<div className="govuk-warning-text noticebanner">
<strong className="govuk-warning-text__text">
<span className="govuk-visually-hidden">
Warning
</span>
</strong>
<div>
<div className=" govuk-body-s">
<h2 className="govuk-heading-s">
{t(
"myrepresentations:rep-period-passed-heading"
)}
</h2>
<p className="govuk-body-s">
{t(
"myrepresentations:rep-period-notice-label"
)}
</p>
</div>
</div>
</div>
) : finaliseAppealProcess ? (
<div className="">
<h3 className="govuk-heading-m govuk-!-margin-top-9">
Finalising your representation
submission
{t(
"myrepresentations:rep-finalising-heading"
)}
</h3>
<p className="govuk-body">
Currenly uploading files and finalising
your representation submission
{t(
"myrepresentations:rep-finalising-label"
)}
</p>
<p className="govuk-body textloading">
Please wait
{t("myrepresentations:rep-wait-label")}
</p>
</div>
) : (
@@ -573,7 +702,11 @@ const mapStateToProps = (state) => {
};
const mapDispatchToProps = (dispatch) => {
return {};
return {
setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(currentReference));
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(RepCompleteSubmit);