create pdf reps for lpa
This commit is contained in:
@@ -2,7 +2,7 @@ import Link from "next/link";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import jsonpath from "jsonpath";
|
||||
import jsonpath, { value } from "jsonpath";
|
||||
import _, { property } from "lodash";
|
||||
import {
|
||||
Field,
|
||||
@@ -23,11 +23,13 @@ import {
|
||||
setRepresentationReset,
|
||||
} from "../../../store/currentView/action";
|
||||
import RepCapacitySelection from "./representationCapacitySelection";
|
||||
import RepLPACapacitySelection from "./representationLPACapacitySelection";
|
||||
import RepDetails from "./representationDetails";
|
||||
import RepAppellant from "./representationAppellant";
|
||||
import RepAgent from "./representationAgent";
|
||||
import RepInterestedPartyPerson from "./representationInterestedPartyPerson";
|
||||
import RepLandOwner from "./representationLandowner";
|
||||
import RepLPA from "./representationLPA";
|
||||
import RepCompleteSubmit from "./representationCompleteSubmit";
|
||||
import { useSession, signIn, signOut } from "next-auth/react";
|
||||
import {
|
||||
@@ -35,6 +37,7 @@ import {
|
||||
patchCase,
|
||||
uploadRepFiles,
|
||||
sendEmail,
|
||||
generateRepPDF,
|
||||
} from "../../../actions";
|
||||
|
||||
import {
|
||||
@@ -43,6 +46,16 @@ import {
|
||||
RenderTextfield,
|
||||
} from "./representationElements";
|
||||
|
||||
import ReactPDF, {
|
||||
Document,
|
||||
Page,
|
||||
Text,
|
||||
View,
|
||||
StyleSheet,
|
||||
PDFViewer,
|
||||
} from "@react-pdf/renderer";
|
||||
import { object } from "prop-types";
|
||||
|
||||
let MakeRepresentation = (props) => {
|
||||
let { t } = useTranslation();
|
||||
const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
|
||||
@@ -87,28 +100,33 @@ let MakeRepresentation = (props) => {
|
||||
|
||||
var detailsObj = {};
|
||||
|
||||
const capacityOptionsArr = [
|
||||
"Appellant",
|
||||
"Agent",
|
||||
"Interested Party/Person",
|
||||
"Land Owner",
|
||||
];
|
||||
const capacityOptionsArr = ["Appellant", "Agent", "Interested Party"];
|
||||
|
||||
const appellantApplicantRepresentationArr = [
|
||||
"Other",
|
||||
"Statement",
|
||||
"Statement of common ground",
|
||||
"Final comments",
|
||||
"Written statement of evidence",
|
||||
"Other",
|
||||
];
|
||||
|
||||
const interestedPersonRepresentationArr = [
|
||||
"Interested Party/Person correspondence",
|
||||
"Statement",
|
||||
"Final comments",
|
||||
"Other",
|
||||
];
|
||||
|
||||
const lpaRepresentationArr = [
|
||||
"Questionnaire",
|
||||
"Final comments",
|
||||
"Written statement of evidence",
|
||||
"Other",
|
||||
];
|
||||
|
||||
const landOwnerRepresentationArr = [
|
||||
"Other",
|
||||
"Statement",
|
||||
"Final comments",
|
||||
"Written statement of evidence",
|
||||
"Other",
|
||||
];
|
||||
|
||||
const repCapacityType = () => {
|
||||
@@ -125,10 +143,38 @@ let MakeRepresentation = (props) => {
|
||||
.toLowerCase();
|
||||
};
|
||||
|
||||
const isLPA =
|
||||
props.props.accountDetails.accountDetails[
|
||||
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
|
||||
] == "LPA"
|
||||
? true
|
||||
: false;
|
||||
|
||||
const whichControl = () => {
|
||||
switch (currentView.representationCapacity) {
|
||||
case false:
|
||||
return (
|
||||
console.log(isLPA);
|
||||
console.log(
|
||||
currentView.representationCapacity,
|
||||
_.isEmpty(currentView.representationCapacity)
|
||||
);
|
||||
if (isLPA && _.isEmpty(currentView.representationCapacity)) {
|
||||
return (
|
||||
<RepLPACapacitySelection
|
||||
formObj={formObj}
|
||||
capacityOptionsArr={capacityOptionsArr}
|
||||
currentType={currentType}
|
||||
casesObj={casesObj}
|
||||
setRepresentationCapacity={"LPA"}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
caseReference={caseReference}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
switch (currentView.representationCapacity) {
|
||||
case false:
|
||||
<RepCapacitySelection
|
||||
formObj={formObj}
|
||||
capacityOptionsArr={capacityOptionsArr}
|
||||
@@ -141,89 +187,120 @@ let MakeRepresentation = (props) => {
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
caseReference={caseReference}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "appellant":
|
||||
//setRepresentationCapacity("appellant");
|
||||
return (
|
||||
<RepAppellant
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
appellantApplicantRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={setRepresentationCapacity}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "agent":
|
||||
//setRepresentationCapacity("agent");
|
||||
return (
|
||||
<RepAgent
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
appellantApplicantRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={setRepresentationCapacity}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "interestedparty/person":
|
||||
// setRepresentationCapacity("interestedpartyperson");
|
||||
return (
|
||||
<RepInterestedPartyPerson
|
||||
formObj={formObj}
|
||||
interestedPersonRepresentationArr={
|
||||
interestedPersonRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={setRepresentationCapacity}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "landowner":
|
||||
//setRepresentationCapacity("landowner");
|
||||
return (
|
||||
<RepLandOwner
|
||||
formObj={formObj}
|
||||
landOwnerRepresentationArr={landOwnerRepresentationArr}
|
||||
setRepresentationCapacity={setRepresentationCapacity}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return (
|
||||
<RepCapacitySelection
|
||||
formObj={formObj}
|
||||
capacityOptionsArr={capacityOptionsArr}
|
||||
currentType={currentType}
|
||||
casesObj={casesObj}
|
||||
setRepresentationCapacity={setRepresentationCapacity}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
/>;
|
||||
break;
|
||||
case "appellant":
|
||||
//setRepresentationCapacity("appellant");
|
||||
return (
|
||||
<RepAppellant
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
appellantApplicantRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "lpa":
|
||||
//setRepresentationCapacity("appellant");
|
||||
return (
|
||||
<RepLPA
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
lpaRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "agent":
|
||||
//setRepresentationCapacity("agent");
|
||||
return (
|
||||
<RepAgent
|
||||
formObj={formObj}
|
||||
appellantApplicantRepresentationArr={
|
||||
appellantApplicantRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "interestedparty/person":
|
||||
// setRepresentationCapacity("interestedpartyperson");
|
||||
return (
|
||||
<RepInterestedPartyPerson
|
||||
formObj={formObj}
|
||||
interestedPersonRepresentationArr={
|
||||
interestedPersonRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
case "landowner":
|
||||
//setRepresentationCapacity("landowner");
|
||||
return (
|
||||
<RepLandOwner
|
||||
formObj={formObj}
|
||||
landOwnerRepresentationArr={
|
||||
landOwnerRepresentationArr
|
||||
}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
onHandleSubmit={onHandleSubmit}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return (
|
||||
<RepCapacitySelection
|
||||
formObj={formObj}
|
||||
capacityOptionsArr={capacityOptionsArr}
|
||||
currentType={currentType}
|
||||
casesObj={casesObj}
|
||||
setRepresentationCapacity={
|
||||
setRepresentationCapacity
|
||||
}
|
||||
setRepresentationSubmit={setRepresentationSubmit}
|
||||
currentView={currentView}
|
||||
setSubmitBack={setSubmitBack}
|
||||
props={props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -258,6 +335,9 @@ let MakeRepresentation = (props) => {
|
||||
case "Land Owner":
|
||||
repType = "LO";
|
||||
break;
|
||||
case "LPA":
|
||||
repType = "LPA";
|
||||
break;
|
||||
|
||||
default:
|
||||
// code block
|
||||
@@ -280,6 +360,7 @@ let MakeRepresentation = (props) => {
|
||||
"containerID": props.props.accountDetails.containerID,
|
||||
"appealType": props.props.currentView.caseReference.appealType,
|
||||
"incidentID": props.props.currentView.caseReference.incidentid,
|
||||
"caseRef": props.props.currentView.caseReference.currentReference,
|
||||
});
|
||||
|
||||
updateBody = JSON.stringify(updateBody);
|
||||
@@ -321,19 +402,40 @@ let MakeRepresentation = (props) => {
|
||||
};
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
console.log("form values - ", JSON.stringify(values));
|
||||
Object.assign(values, {
|
||||
"containerID": props.props.accountDetails.containerID,
|
||||
"appealType": props.props.currentView.caseReference.appealType,
|
||||
"incidentID": props.props.currentView.caseReference.incidentid,
|
||||
"caseRef": props.props.currentView.caseReference.currentReference,
|
||||
"pinswg_name":
|
||||
props.props.currentView.caseReference.currentReference,
|
||||
"firstname": props.props.accountDetails.accountDetails.firstname,
|
||||
"lastname": props.props.accountDetails.accountDetails.lastname,
|
||||
"emailAddress":
|
||||
props.props.accountDetails.accountDetails.emailaddress1,
|
||||
});
|
||||
|
||||
currentView.representationSubmit != true
|
||||
? _.isEmpty(currentView.representationCapacity)
|
||||
? setRepresentationCapacity(
|
||||
values.representationCapacity
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
)
|
||||
? isLPA
|
||||
? setRepresentationCapacity("lpa")
|
||||
: setRepresentationCapacity(
|
||||
values.representationCapacity
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
)
|
||||
: setRepresentationSubmit(true)
|
||||
: currentView.representationSubmit == true
|
||||
? (console.log("capacity", currentView.representationCapacity),
|
||||
console.log("has errors:", props.invalid),
|
||||
props.invalid == false &&
|
||||
updateRepresentation(values, false, false),
|
||||
generateRepPDF(
|
||||
values,
|
||||
props.props.accountDetails.containerID,
|
||||
currentView.caseReference.currentReference
|
||||
),
|
||||
uploadRepresentationFiles(values),
|
||||
setRepresentationSubmitConfirmation(true))
|
||||
: console.log("nit updated");
|
||||
@@ -376,8 +478,8 @@ let MakeRepresentation = (props) => {
|
||||
const repForm = props.props.form;
|
||||
|
||||
console.log(
|
||||
"waht is representationSubmit:",
|
||||
currentView.representationSubmit
|
||||
"what is representationSubmit state: " +
|
||||
currentView.representationSubmit
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user