make formatdates function shared in utils
This commit is contained in:
@@ -39,22 +39,7 @@ import {
|
||||
sendEmail,
|
||||
generateRepPDF,
|
||||
} from "../../../actions";
|
||||
|
||||
import {
|
||||
RenderPickList,
|
||||
RenderRadioList,
|
||||
RenderTextfield,
|
||||
} from "./representationElements";
|
||||
|
||||
import ReactPDF, {
|
||||
Document,
|
||||
Page,
|
||||
Text,
|
||||
View,
|
||||
StyleSheet,
|
||||
PDFViewer,
|
||||
} from "@react-pdf/renderer";
|
||||
import { object } from "prop-types";
|
||||
import { formatDates } from "../../../components/utils";
|
||||
|
||||
let MakeRepresentation = (props) => {
|
||||
let { t } = useTranslation();
|
||||
@@ -87,6 +72,13 @@ let MakeRepresentation = (props) => {
|
||||
let setCaseQueryObj = props[currentType] || {};
|
||||
var casesObj = {};
|
||||
|
||||
const isLPA =
|
||||
props.props.accountDetails.accountDetails[
|
||||
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
|
||||
] == "LPA"
|
||||
? true
|
||||
: false;
|
||||
|
||||
currentType == "searchResultsObj"
|
||||
? (casesObj = jsonpath.query(
|
||||
setCaseQueryObj,
|
||||
@@ -103,32 +95,52 @@ let MakeRepresentation = (props) => {
|
||||
|
||||
const capacityOptionsArr = ["Appellant", "Agent", "Interested Party"];
|
||||
|
||||
const appellantApplicantRepresentationArr = [
|
||||
"Statement",
|
||||
"Final comments",
|
||||
"Written statement of evidence",
|
||||
"Other",
|
||||
];
|
||||
let setCaseDetailsObj = router.query.hasOwnProperty("state")
|
||||
? router.query.state == "edit"
|
||||
? props.props.myRepresentations.myRepresentations
|
||||
: props.props.searchResultsObj.searchDetailsObj
|
||||
: props.props.searchResultsObj.searchDetailsObj;
|
||||
|
||||
const interestedPersonRepresentationArr = [
|
||||
"Statement",
|
||||
"Final comments",
|
||||
"Other",
|
||||
];
|
||||
var detailsObj = {};
|
||||
|
||||
const lpaRepresentationArr = [
|
||||
"Questionnaire",
|
||||
"Final comments",
|
||||
"Written statement of evidence",
|
||||
"Other",
|
||||
];
|
||||
detailsObj = jsonpath.query(
|
||||
setCaseDetailsObj,
|
||||
'$..[?(@.pinswg_name=="' +
|
||||
currentView.caseReference.currentReference +
|
||||
'")]'
|
||||
);
|
||||
|
||||
const landOwnerRepresentationArr = [
|
||||
"Statement",
|
||||
"Final comments",
|
||||
"Written statement of evidence",
|
||||
"Other",
|
||||
];
|
||||
detailsObj = detailsObj[0];
|
||||
|
||||
const buildRepsArr = (detailsObj) => {
|
||||
let buildArr = [];
|
||||
|
||||
let todaysDate = new Date();
|
||||
|
||||
let startDate = new Date(detailsObj.pinswg_startdate);
|
||||
let questionnaireDate = new Date(
|
||||
detailsObj.pinswg_questionnaireduedate
|
||||
);
|
||||
let finalCommentsDate = new Date(
|
||||
detailsObj.pinswg_finalcommentsduedate
|
||||
);
|
||||
let statementDueDate = new Date(detailsObj.pinswg_statementduedate);
|
||||
|
||||
isLPA &&
|
||||
todaysDate >= startDate &&
|
||||
todaysDate <= questionnaireDate &&
|
||||
buildArr.push("Questionnaire");
|
||||
|
||||
todaysDate >= startDate &&
|
||||
todaysDate <= statementDueDate &&
|
||||
buildArr.push("Statement");
|
||||
|
||||
todaysDate >= statementDueDate &&
|
||||
todaysDate <= finalCommentsDate &&
|
||||
buildArr.push("Final comments");
|
||||
|
||||
return buildArr;
|
||||
};
|
||||
|
||||
const repCapacityType = () => {
|
||||
return _.isEmpty(formObj["representationForm"])
|
||||
@@ -144,19 +156,12 @@ let MakeRepresentation = (props) => {
|
||||
.toLowerCase();
|
||||
};
|
||||
|
||||
const isLPA =
|
||||
props.props.accountDetails.accountDetails[
|
||||
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
|
||||
] == "LPA"
|
||||
? true
|
||||
: false;
|
||||
|
||||
const whichControl = () => {
|
||||
console.log(isLPA);
|
||||
console.log(
|
||||
currentView.representationCapacity,
|
||||
_.isEmpty(currentView.representationCapacity)
|
||||
);
|
||||
// console.log(isLPA);
|
||||
// console.log(
|
||||
// currentView.representationCapacity,
|
||||
// _.isEmpty(currentView.representationCapacity)
|
||||
// );
|
||||
|
||||
if (isLPA && _.isEmpty(currentView.representationCapacity)) {
|
||||
return (
|
||||
@@ -196,9 +201,9 @@ let MakeRepresentation = (props) => {
|
||||
return (
|
||||
<RepAppellant
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
appellantApplicantRepresentationArr
|
||||
}
|
||||
appellantApplicantRepresentationArr={buildRepsArr(
|
||||
detailsObj
|
||||
)}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
@@ -215,9 +220,9 @@ let MakeRepresentation = (props) => {
|
||||
return (
|
||||
<RepLPA
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
lpaRepresentationArr
|
||||
}
|
||||
appellantApplicantRepresentationArr={buildRepsArr(
|
||||
detailsObj
|
||||
)}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
@@ -234,9 +239,9 @@ let MakeRepresentation = (props) => {
|
||||
return (
|
||||
<RepAgent
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
appellantApplicantRepresentationArr
|
||||
}
|
||||
appellantApplicantRepresentationArr={buildRepsArr(
|
||||
detailsObj
|
||||
)}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
@@ -253,9 +258,9 @@ let MakeRepresentation = (props) => {
|
||||
return (
|
||||
<RepInterestedPartyPerson
|
||||
formObj={formObj}
|
||||
interestedPersonRepresentationArr={
|
||||
interestedPersonRepresentationArr
|
||||
}
|
||||
interestedPersonRepresentationArr={buildRepsArr(
|
||||
detailsObj
|
||||
)}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
@@ -272,9 +277,9 @@ let MakeRepresentation = (props) => {
|
||||
return (
|
||||
<RepLandOwner
|
||||
formObj={formObj}
|
||||
landOwnerRepresentationArr={
|
||||
landOwnerRepresentationArr
|
||||
}
|
||||
landOwnerRepresentationArr={buildRepsArr(
|
||||
detailsObj
|
||||
)}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
@@ -552,15 +557,9 @@ let MakeRepresentation = (props) => {
|
||||
|
||||
const repForm = props.props.form;
|
||||
|
||||
console.log(
|
||||
"what is representationSubmit state: " +
|
||||
currentView.representationSubmit,
|
||||
props.initialValues
|
||||
);
|
||||
|
||||
try {
|
||||
let value = props.initialValues;
|
||||
console.log("has props"), value;
|
||||
//console.log("has props"), value;
|
||||
setRepresentationCapacity(
|
||||
props.initialValues.representationCapacity.toLowerCase()
|
||||
);
|
||||
@@ -615,7 +614,392 @@ let MakeRepresentation = (props) => {
|
||||
Make a representation on:{" "}
|
||||
{currentView.caseReference.currentReference}
|
||||
</h1>
|
||||
{whichControl()}
|
||||
<div id="rep-form">
|
||||
<div className="govuk-grid-column-three-quarters">
|
||||
{whichControl()}
|
||||
</div>
|
||||
<div className="govuk-grid-column-one-quarter">
|
||||
{" "}
|
||||
<div className="card">
|
||||
<div class="card-body">
|
||||
<h4 className="govuk-heading-s">
|
||||
Timetable
|
||||
</h4>
|
||||
<div className="govuk-summary-list">
|
||||
<div className="govuk-body-s">
|
||||
Questionnaire due:
|
||||
<span className="govuk-body-s">
|
||||
{" "}
|
||||
{formatDates(
|
||||
detailsObj.pinswg_questionnaireduedate
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="govuk-body-s">
|
||||
Statements due:
|
||||
<span className="govuk-body-s">
|
||||
{" "}
|
||||
{formatDates(
|
||||
detailsObj.pinswg_statementduedate
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="govuk-body-s">
|
||||
Final comments due:
|
||||
<span className="govuk-body-s">
|
||||
{" "}
|
||||
{formatDates(
|
||||
detailsObj.pinswg_finalcommentsduedate
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{formObj.hasOwnProperty(
|
||||
"representationForm"
|
||||
) &&
|
||||
formObj[
|
||||
"representationForm"
|
||||
].hasOwnProperty("values") &&
|
||||
formObj[
|
||||
"representationForm"
|
||||
].values.hasOwnProperty(
|
||||
"representationType"
|
||||
) &&
|
||||
formObj["representationForm"].values
|
||||
.representationType ==
|
||||
"Questionnaire" && (
|
||||
<div
|
||||
id="step-by-step-navigation"
|
||||
data-module="gemstepnav"
|
||||
className="app-step-nav app-step-nav--active"
|
||||
data-id="e01e924b-9c7c-4c71-8241-66a575c2f61f"
|
||||
data-show-text="show"
|
||||
data-hide-text="hide"
|
||||
data-show-all-text="Show all"
|
||||
data-hide-all-text="Hide all"
|
||||
>
|
||||
<ol className="app-step-nav__steps">
|
||||
<li
|
||||
className={
|
||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
||||
" sectionIncomplete"
|
||||
}
|
||||
aria-current="step"
|
||||
data-show=""
|
||||
id="check-youre-allowed-to-drive"
|
||||
>
|
||||
<div
|
||||
className="app-step-nav__header js-toggle-panel "
|
||||
data-position="1"
|
||||
>
|
||||
<h3 className="app-step-nav__title ">
|
||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||
<span className="app-step-nav__circle-inner">
|
||||
<span className="app-step-nav__circle-background">
|
||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||
Step
|
||||
</span>{" "}
|
||||
1
|
||||
<span
|
||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||
aria-hidden="true"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="js-step-title">
|
||||
<a
|
||||
href="#"
|
||||
onClick={() => {
|
||||
gotoSection(
|
||||
1
|
||||
);
|
||||
}}
|
||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||
aria-expanded="false"
|
||||
aria-controls="step-panel-check-youre-allowed-to-drive-1"
|
||||
>
|
||||
<span className="js-step-title-text govuk-!-font-size-16">
|
||||
Appeal
|
||||
procedure
|
||||
and
|
||||
site
|
||||
visit
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
className={
|
||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
||||
" sectionComplete"
|
||||
}
|
||||
aria-current="step"
|
||||
data-show=""
|
||||
id="check-youre-allowed-to-drive"
|
||||
>
|
||||
<div
|
||||
className="app-step-nav__header js-toggle-panel "
|
||||
data-position="1"
|
||||
>
|
||||
<h3 className="app-step-nav__title ">
|
||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||
<span className="app-step-nav__circle-inner">
|
||||
<span className="app-step-nav__circle-background">
|
||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||
Step
|
||||
</span>{" "}
|
||||
2
|
||||
<span
|
||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||
aria-hidden="true"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="js-step-title">
|
||||
<a
|
||||
href="#"
|
||||
onClick={() => {
|
||||
gotoSection(
|
||||
2
|
||||
);
|
||||
}}
|
||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||
aria-expanded="false"
|
||||
aria-controls="step-panel-check-youre-allowed-to-drive-1"
|
||||
>
|
||||
<span className="js-step-title-text govuk-!-font-size-16">
|
||||
Supporting
|
||||
documents
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
className={
|
||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
||||
" sectionIncomplete"
|
||||
}
|
||||
aria-current="step"
|
||||
data-show=""
|
||||
id="check-youre-allowed-to-drive"
|
||||
>
|
||||
<div
|
||||
className="app-step-nav__header js-toggle-panel "
|
||||
data-position="1"
|
||||
>
|
||||
<h3 className="app-step-nav__title ">
|
||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||
<span className="app-step-nav__circle-inner">
|
||||
<span className="app-step-nav__circle-background">
|
||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||
Step
|
||||
</span>{" "}
|
||||
3
|
||||
<span
|
||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||
aria-hidden="true"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="js-step-title">
|
||||
<a
|
||||
href="#"
|
||||
onClick={() => {
|
||||
gotoSection(
|
||||
3
|
||||
);
|
||||
}}
|
||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||
aria-expanded="false"
|
||||
aria-controls="step-panel-check-youre-allowed-to-drive-1"
|
||||
>
|
||||
<span className="js-step-title-text govuk-!-font-size-16">
|
||||
Statutory
|
||||
considerations
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
className={
|
||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
||||
" sectionIncomplete"
|
||||
}
|
||||
aria-current="step"
|
||||
data-show=""
|
||||
id="check-youre-allowed-to-drive"
|
||||
>
|
||||
<div
|
||||
className="app-step-nav__header js-toggle-panel "
|
||||
data-position="1"
|
||||
>
|
||||
<h3 className="app-step-nav__title ">
|
||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||
<span className="app-step-nav__circle-inner">
|
||||
<span className="app-step-nav__circle-background">
|
||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||
Step
|
||||
</span>{" "}
|
||||
4
|
||||
<span
|
||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||
aria-hidden="true"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="js-step-title">
|
||||
<a
|
||||
href="#"
|
||||
onClick={() => {
|
||||
gotoSection(
|
||||
4
|
||||
);
|
||||
}}
|
||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||
aria-expanded="false"
|
||||
aria-controls="step-panel-check-youre-allowed-to-drive-1"
|
||||
>
|
||||
<span className="js-step-title-text govuk-!-font-size-16">
|
||||
Suggested
|
||||
considerations
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
className={
|
||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
||||
" sectionIncomplete"
|
||||
}
|
||||
aria-current="step"
|
||||
data-show=""
|
||||
id="check-youre-allowed-to-drive"
|
||||
>
|
||||
<div
|
||||
className="app-step-nav__header js-toggle-panel "
|
||||
data-position="1"
|
||||
>
|
||||
<h3 className="app-step-nav__title ">
|
||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||
<span className="app-step-nav__circle-inner">
|
||||
<span className="app-step-nav__circle-background">
|
||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||
Step
|
||||
</span>{" "}
|
||||
5
|
||||
<span
|
||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||
aria-hidden="true"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="js-step-title">
|
||||
<a
|
||||
href="#"
|
||||
onClick={() => {
|
||||
gotoSection(
|
||||
5
|
||||
);
|
||||
}}
|
||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||
aria-expanded="false"
|
||||
aria-controls="step-panel-check-youre-allowed-to-drive-1"
|
||||
>
|
||||
<span className="js-step-title-text govuk-!-font-size-16">
|
||||
Attached
|
||||
links
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
className={
|
||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
||||
" sectionIncomplete"
|
||||
}
|
||||
aria-current="step"
|
||||
data-show=""
|
||||
id="check-youre-allowed-to-drive"
|
||||
>
|
||||
<div
|
||||
className="app-step-nav__header js-toggle-panel "
|
||||
data-position="1"
|
||||
>
|
||||
<h3 className="app-step-nav__title ">
|
||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||
<span className="app-step-nav__circle-inner">
|
||||
<span className="app-step-nav__circle-background">
|
||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||
Step
|
||||
</span>{" "}
|
||||
6
|
||||
<span
|
||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||
aria-hidden="true"
|
||||
>
|
||||
:
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="js-step-title">
|
||||
<a
|
||||
href="#"
|
||||
onClick={() => {
|
||||
gotoSection(
|
||||
6
|
||||
);
|
||||
}}
|
||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||
aria-expanded="false"
|
||||
aria-controls="step-panel-check-youre-allowed-to-drive-1"
|
||||
>
|
||||
<span className="js-step-title-text govuk-!-font-size-16">
|
||||
Declaration
|
||||
</span>
|
||||
</a>
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
@@ -626,7 +1010,7 @@ let MakeRepresentation = (props) => {
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
console.log("\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n in map state", state);
|
||||
//console.log("\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n in map state", state);
|
||||
|
||||
return {
|
||||
search: state.search,
|
||||
|
||||
Reference in New Issue
Block a user