From 8b385217c3e38d791da72f515275e580ff01ee70 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 28 May 2024 08:57:02 +0100 Subject: [PATCH] adjusted timetable to display correct dates --- actions/selectQueryTypes.js | 6 +- components/case/representation/index.js | 203 +++++++++--------- .../representation/representationAgent.js | 28 ++- .../representation/representationAppellant.js | 28 ++- .../representationInterestedPartyPerson.js | 85 +++++--- .../case/representation/representationLPA.js | 22 +- store/currentView/reducer.js | 2 +- 7 files changed, 233 insertions(+), 141 deletions(-) diff --git a/actions/selectQueryTypes.js b/actions/selectQueryTypes.js index 6060ddb3..9612fd96 100644 --- a/actions/selectQueryTypes.js +++ b/actions/selectQueryTypes.js @@ -1,7 +1,7 @@ export const getSelectQuery = (appealTypeName) => { switch (appealTypeName) { case "pinswg_advertses": - return "&$select=modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddresscounty,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_procedure,pinswg_questionnaireduedate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent,pinswg_startdate,pinswg_otherpartiesstatement,pinswg_finalcommentsduedate,pinswg_proofsofevidencewrittenstatementsofeviden"; + return "&$select=pinswg_speacialistcaseprocess,modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddresscounty,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_procedure,pinswg_questionnaireduedate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent,pinswg_startdate,pinswg_otherpartiesstatement,pinswg_finalcommentsduedate,pinswg_proofsofevidencewrittenstatementsofeviden"; break; case "pinswg_callinss77s": return "&$select=modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddresscounty,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_procedure,pinswg_proofsofevidencewrittenstatementsofeviden,pinswg_questionnaireduedate,pinswg_startdate,statuscode,pinswg_dateexportedtoiss,pinswg_startdateofevent,pinswg_typeofevent"; @@ -13,6 +13,8 @@ export const getSelectQuery = (appealTypeName) => { return "&$select=modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddresscounty,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatement,pinswg_procedure,pinswg_proofsofevidencewrittenstatementsofeviden,pinswg_questionnaireduedate,pinswg_relevantauthorityname,pinswg_startdate,statuscode,pinswg_startdateofevent,pinswg_typeofevent"; break; case "pinswg_hedgeshedgerowstreepreservationreplacems": + return "&$select=pinswg_specialistcaseprocess,modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddresscounty,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatement,pinswg_procedure,pinswg_proofsofevidencewrittenstatementsofeviden,pinswg_questionnaireduedate,pinswg_relevantauthorityname,pinswg_startdate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent,pinswg_statementduedate"; + break; case "pinswg_miscellaneouscaseworks": case "pinswg_wayleaves": return "&$select=modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddresscounty,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatement,pinswg_procedure,pinswg_proofsofevidencewrittenstatementsofeviden,pinswg_questionnaireduedate,pinswg_relevantauthorityname,pinswg_startdate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent,pinswg_statementduedate"; @@ -63,7 +65,7 @@ export const getSelectQuery = (appealTypeName) => { return "&$select=modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatements,pinswg_procedure,pinswg_questionnaireduedate,pinswg_startdate,pinswg_statementduedate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent"; break; case "pinswg_rows": - return "&$select=modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatement,pinswg_procedure,pinswg_proofsofevidencewrittenstatementsofeviden,pinswg_questionnaireduedate,pinswg_relevantauthorityname,pinswg_startdate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent,pinswg_statementduedate"; + return "&$select=pinswg_specialistcaseprocess,modifiedon,_pinswg_appellant_value,pinswg_name,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatement,pinswg_procedure,pinswg_proofsofevidencewrittenstatementsofeviden,pinswg_questionnaireduedate,pinswg_relevantauthorityname,pinswg_startdate,statuscode,pinswg_startdateoftheevent,pinswg_typeofevent,pinswg_statementduedate"; break; default: return ""; diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 12f10348..9244c7ad 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -229,7 +229,7 @@ let MakeRepresentation = (props) => { const buildRepsArr = (detailsObj) => { let buildArr = []; - console.log(currentView.caseReference.appealType); + console.log(currentView.caseReference.appealType, ""); let todaysDate = new Date(); @@ -241,62 +241,50 @@ let MakeRepresentation = (props) => { let statementDueDate; isDNS - ? (startDate = new Date( + ? ((startDate = new Date( + detailsObj.pinswg_applicationacceptedasvalid + )), + (questionnaireDate = new Date( new Date( - detailsObj.pinswg_applicationacceptedasvalid + detailsObj.pinswg_endofrepresentationperiod ).setHours(23, 59, 59, 999) - ))( - (questionnaireDate = new Date( - new Date( - detailsObj.pinswg_endofrepresentationperiod - ).setHours(23, 59, 59, 999) - )) - )( - (finalCommentsDate = new Date( - new Date(detailsObj.pinswg_finalcommentsduedate).setHours( - 23, - 59, - 59, - 999 - ) - )) - )( - (statementDueDate = new Date( - new Date( - detailsObj.pinswg_endofrepresentationperiod - ).setHours(23, 59, 59, 999) - )) - ) - : (startDate = new Date( - new Date(detailsObj.pinswg_startdate).setHours( + )), + (finalCommentsDate = new Date( + new Date(detailsObj.pinswg_finalcommentsduedate).setHours( 23, 59, 59, 999 ) )), - (questionnaireDate = new Date( - new Date(detailsObj.pinswg_questionnaireduedate).setHours( - 23, - 59, - 59, - 999 - ) - )), - (finalCommentsDate = new Date( - new Date(detailsObj.pinswg_finalcommentsduedate).setHours( - 23, - 59, - 59, - 999 - ) - )), - (statementDueDate = new Date( - new Date( - detailsObj.pinswg_statementduedate || - detailsObj.pinswg_statementsduedate - ).setHours(23, 59, 59, 999) - )); + (statementDueDate = new Date( + new Date( + detailsObj.pinswg_endofrepresentationperiod + ).setHours(23, 59, 59, 999) + ))) + : ((startDate = new Date(detailsObj.pinswg_startdate)), + (questionnaireDate = new Date( + new Date(detailsObj.pinswg_questionnaireduedate).setHours( + 23, + 59, + 59, + 999 + ) + )), + (finalCommentsDate = new Date( + new Date(detailsObj.pinswg_finalcommentsduedate).setHours( + 23, + 59, + 59, + 999 + ) + )), + (statementDueDate = new Date( + new Date( + detailsObj.pinswg_statementduedate || + detailsObj.pinswg_statementsduedate + ).setHours(23, 59, 59, 999) + ))); isLPA && currentView.caseReference.appealType != 846040019 && @@ -795,6 +783,10 @@ let MakeRepresentation = (props) => { props.props.currentView.caseReference.currentReference, "pinswg_questionnaireduedate": detailsObj.pinswg_questionnaireduedate, + "pinswg_endofrepresentationperiod": + detailsObj.pinswg_endofrepresentationperiod, + "pinswg_applicationacceptedasvalid": + detailsObj.pinswg_applicationacceptedasvalid, "pinswg_statementduedate": detailsObj.pinswg_statementduedate, "pinswg_finalcommentsduedate": detailsObj.pinswg_finalcommentsduedate, @@ -1048,64 +1040,69 @@ let MakeRepresentation = (props) => { {" "} - {Object.keys( + {typeof props.props.currentView + .representationCapacity != + "undefined" && props.props.currentView - .representationCapacity - ).length > 0 && ( -
- {savingStatus ? ( - - {router.locale == "cy" - ? "Nôl data" - : "Saving data"} - { - - ) : ( - - )} -
- )} + console.log( + "on save:", + valuesObj + ); + updateRepresentation( + valuesObj, + false, + true + ); + }} + > + {t( + "common:save-exit-button" + )} + + )} + + )}
{formObj.hasOwnProperty( "representationForm" diff --git a/components/case/representation/representationAgent.js b/components/case/representation/representationAgent.js index 6a5f851e..e0976063 100644 --- a/components/case/representation/representationAgent.js +++ b/components/case/representation/representationAgent.js @@ -2,7 +2,7 @@ import Link from "next/link"; import { connect } from "react-redux"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; -import { Field, reduxForm } from "redux-form"; +import { Field, reduxForm, change } from "redux-form"; import { RenderPickList, RenderTextfield, @@ -48,7 +48,8 @@ const RepAgent = (props) => {
{typeof formObj.representationForm.values - .representationType == "undefined" ? ( + .representationType == "undefined" && + props.representationType != "Select..." ? ( <>

{t( @@ -208,6 +209,11 @@ const RepAgent = (props) => { { setRepresentationCapacity(); + props.updateField( + "representationForm", + "representationCapacity", + "" + ); }} className="govuk-link" > @@ -219,4 +225,20 @@ const RepAgent = (props) => { ); }; -export default RepAgent; +const mapStateToProps = (state, props) => {}; + +const mapDispatchToProps = (dispatch) => ({ + updateField: (form, field, newValue) => + dispatch(change(form, field, newValue)), +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)( + reduxForm({ + form: "representationForm", + enableReinitialize: true, + destroyOnUnmount: false, + })(RepAgent) +); diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index cdb38359..7febc3bc 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -2,7 +2,7 @@ import Link from "next/link"; import { connect } from "react-redux"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; -import { Field, reduxForm, reset } from "redux-form"; +import { Field, reduxForm, reset, change } from "redux-form"; import React, { useCallback, useEffect, useMemo, useState } from "react"; import { @@ -49,7 +49,8 @@ const RepAppellant = (props) => {
{typeof formObj.representationForm.values - .representationType == "undefined" ? ( + .representationType == "undefined" && + props.representationType != "Select..." ? ( <>

{t( @@ -192,6 +193,11 @@ const RepAppellant = (props) => { { setRepresentationCapacity(); + props.updateField( + "representationForm", + "representationType", + "" + ); }} className="govuk-link" > @@ -203,4 +209,20 @@ const RepAppellant = (props) => { ); }; -export default RepAppellant; +const mapStateToProps = (state, props) => {}; + +const mapDispatchToProps = (dispatch) => ({ + updateField: (form, field, newValue) => + dispatch(change(form, field, newValue)), +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)( + reduxForm({ + form: "representationForm", + enableReinitialize: true, + destroyOnUnmount: false, + })(RepAppellant) +); diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index 019a40c0..c11f21ec 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -1,7 +1,8 @@ import Link from "next/link"; +import { connect } from "react-redux"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; -import { Field, reduxForm } from "redux-form"; +import { Field, reduxForm, change } from "redux-form"; import { RenderPickList, RenderTextfield, @@ -10,6 +11,11 @@ import { RenderRichMultiline, FileUploadField, } from "./representationElements"; +import { + getFormCollectionByID, + getThumbnailIconByExtension, + bytesToSize, +} from "../../utils"; import { useDropzone } from "react-dropzone"; const RepInterestedPartyPerson = (props) => { @@ -38,29 +44,33 @@ const RepInterestedPartyPerson = (props) => { return ( <>
-

- {t( - "myrepresentations:representation-from-an-interested-person-heading" - )} -

- - {typeof props.representationType == undefined || - typeof formObj.representationForm.values - .representationType == "undefined" ? ( - + {typeof formObj.representationForm.values + .representationType == "undefined" && + props.representationType != "Select..." ? ( + <> +

+ {t( + "myrepresentations:representation-from-an-interested-person-heading" + )} +

+ + + + + ) : (
{ setRepresentationCapacity(); - //setRepresentationSubmit(true); + props.updateField( + "representationForm", + "representationCapacity", + "" + ); + props.updateField( + "representationForm", + "representationType", + "" + ); }} className="govuk-link" > @@ -172,4 +191,20 @@ const RepInterestedPartyPerson = (props) => { ); }; -export default RepInterestedPartyPerson; +const mapStateToProps = (state, props) => {}; + +const mapDispatchToProps = (dispatch) => ({ + updateField: (form, field, newValue) => + dispatch(change(form, field, newValue)), +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)( + reduxForm({ + form: "representationForm", + enableReinitialize: true, + destroyOnUnmount: false, + })(RepInterestedPartyPerson) +); diff --git a/components/case/representation/representationLPA.js b/components/case/representation/representationLPA.js index e65c5d7c..c3242aa1 100644 --- a/components/case/representation/representationLPA.js +++ b/components/case/representation/representationLPA.js @@ -3,7 +3,7 @@ import _ from "lodash"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { connect } from "react-redux"; -import { Field, reduxForm, formValueSelector } from "redux-form"; +import { Field, reduxForm, formValueSelector, change } from "redux-form"; import { RenderPickList, RenderTextfield, @@ -339,7 +339,8 @@ let RepLPA = (props) => { "representationType", ]) || typeof props.representationType != "undefined") && - (props.representationType != "Questionnaire" ? ( + (props.representationType != "Questionnaire" && + props.representationType != "Select..." ? ( <>

{t("myrepresentations:enter-comment-label")} @@ -480,10 +481,15 @@ let RepLPA = (props) => { { //setRepresentationCapacity(); + props.updateField( + "representationForm", + "representationType", + "" + ); }} className="govuk-link" > - {t("common:back-link")} + {t("common:back-link")}ss )} @@ -505,6 +511,11 @@ RepLPA = connect((state) => { }; })(RepLPA); +const mapDispatchToProps = (dispatch) => ({ + updateField: (form, field, newValue) => + dispatch(change(form, field, newValue)), +}); + const mapStateToProps = (state, props) => { let initialValuesTemp = Object.assign( state.currentView.caseReference.hasOwnProperty("repDetails") @@ -534,7 +545,10 @@ const mapStateToProps = (state, props) => { }; }; -export default connect(mapStateToProps)( +export default connect( + mapStateToProps, + mapDispatchToProps +)( reduxForm({ form: "representationForm", enableReinitialize: true, diff --git a/store/currentView/reducer.js b/store/currentView/reducer.js index 52056d9a..df8cdbae 100644 --- a/store/currentView/reducer.js +++ b/store/currentView/reducer.js @@ -3,7 +3,7 @@ import { currentViewActionTypes } from "./action"; const currentViewInitialState = { currentView: {}, caseReference: {}, - representationCapacity: {}, + representationCapacity: "", representationSubmit: "", representationSubmitConfirmation: {}, representationMessageSent: false,