diff --git a/.env.local b/.env.local
index af89d049..b25b40e9 100644
--- a/.env.local
+++ b/.env.local
@@ -45,9 +45,9 @@ RELAYPATH = "dev-pedw-hc"
GOOGLE_TAG_MANAGER = GTM-T78CBC3
SHOWLOGIN = "true"
-SHOWREPRESENTATIONS = false
+SHOWREPRESENTATIONS = "true"
SHOWFILEUPLOAD = "false"
-SHOWMAPS = "true"
+SHOWMAPS = "false"
//BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
@@ -104,6 +104,7 @@ SECRET=SuperSecret
AZURE_CLIENT_ID = $CLIENT_ID
AZURE_TENANT_ID = $TENANT
AZURE_CLIENT_SECRET = $CLIENT_SECRET
+AZURE_STORAGE_ACCOUNT_NAME= "pedwdev"
AZURE_PEDW_STORAGE_ENDPOINT = https://pedwdev.blob.core.windows.net
AZURE_PEDW_CONTAINER = "pedwapplications"
diff --git a/actions/azurestorage.js b/actions/azurestorage.js
index 095a4836..245762fd 100644
--- a/actions/azurestorage.js
+++ b/actions/azurestorage.js
@@ -255,6 +255,44 @@ export const createBlob = async (formContent, containerName, caseref) => {
return formContent.pinswg_name;
};
+export const createRepBlob = async (formContent, containerName, caseref) => {
+ const containerToken = await createContainerSas(containerName);
+ const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`;
+ const containerClient = new ContainerClient(sasUrl);
+
+ formContent = JSON.parse(formContent);
+ let caseID = "";
+
+ caseID = _.has(formContent, "pinswg_name")
+ ? formContent.pinswg_name
+ : caseref;
+
+ const content = JSON.stringify(formContent);
+
+ console.log(content);
+ const blobName = caseref + "/" + caseID + "_rep.json";
+
+ console.log("blobName:", blobName);
+ const blockBlobClient = containerClient.getBlockBlobClient(blobName);
+
+ const uploadBlobResponse = await blockBlobClient.upload(
+ content,
+ Buffer.byteLength(content)
+ );
+
+ const tags = {
+ containerid: containerName,
+ caseID: caseID,
+ blobType: "Representation",
+ };
+
+ console.log("the tags:", tags);
+ const withTags = await blockBlobClient.setTags(tags);
+ const withMeta = await blockBlobClient.setMetadata(tags);
+
+ return formContent.pinswg_name;
+};
+
export const deleteBlob = async (containerName, blobName) => {
const creds = new DefaultAzureCredential();
@@ -545,7 +583,7 @@ export const getAllProgressBlobs = async (containerName) => {
let blobObj = [];
for await (const blob of containerClient.listBlobsFlat()) {
- blob.name.split("/")[1].indexOf(".json") > 0 &&
+ blob.name.split("/")[1].indexOf("_appeal.json") > 0 &&
blob.name.split("/")[1].indexOf("undefined") < 0 &&
blobObj.push({
"name": blob.name.split("/")[1],
diff --git a/actions/index.js b/actions/index.js
index 3d35652b..70f06342 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -1253,6 +1253,50 @@ export const uploadFiles = async (
}
};
+export const uploadRepFiles = async (
+ formValues,
+ filesObj,
+ containerID,
+ casefolderID
+) => {
+ let files = filesObj;
+
+ //console.log(formValues);
+ var formData = new FormData();
+ formData.append("appealData", JSON.stringify(formValues));
+ formData.append("containerID", containerID);
+ formData.append("casefolderID", casefolderID);
+ formData.append("repOrAppeal", true);
+
+ // files.forEach((file) => formData.append("files", file));
+
+ for (let i = 0; i < files.length; i++) {
+ for (let j = 0; j < files[i].length; j++) {
+ console.log(files[i][j].name);
+ formData.append(files[i][j].name, files[i][j]);
+ }
+ }
+
+ //console.log(formData);
+
+ var queryUrl = "/api/file/upload";
+
+ const config = {
+ method: "post",
+ url: queryUrl,
+ data: formData,
+ headers: { "content-type": "multipart/form-data" },
+ };
+
+ //console.log(config);
+ try {
+ const res = await axios(config);
+ return res.data;
+ } catch (error) {
+ console.log("this serror", error);
+ }
+};
+
export const getFilesFromBlob = (containerName, casefolderID) => {
return axios
.get(
diff --git a/actions/selectQueryTypes.js b/actions/selectQueryTypes.js
index 2ff061a5..aa1e657d 100644
--- a/actions/selectQueryTypes.js
+++ b/actions/selectQueryTypes.js
@@ -48,7 +48,7 @@ export const getSelectQuery = (appealTypeName) => {
return "&$select=_pinswg_appellant_value,pinswg_name,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_sitepostcode,pinswg_siteaddresstown,_pinswg_associatedlpa_value,pinswg_casedecisiondate,pinswg_dateeventrequested,pinswg_decision,pinswg_finalcommentsduedate,pinswg_otherpartiesstatement,pinswg_procedure,pinswg_questionnaireduedate,pinswg_startdate,pinswg_statementduedate,statuscode,pinswg_starttimeofevent,pinswg_typeofevent";
break;
case "pinswg_planningappeals78s":
- return "&$select=_pinswg_appellant_value,pinswg_name,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,pinswg_casedecisiondate,pinswg_dicision,pinswg_dateeventrequested,pinswg_finalcommentsduedate,pinswg_procedure,pinswg_questionnaireduedate,pinswg_startdate,pinswg_statementduedate,statuscode,pinswg_startdatetimeiftheevent,pinswg_typeofevent";
+ return "&$select=_pinswg_appellant_value,pinswg_name,pinswg_siteaddressline1,pinswg_siteaddressline2,pinswg_siteaddresspostcode,pinswg_siteaddresstown,pinswg_casedecisiondate,pinswg_dicision,pinswg_dateeventrequested,pinswg_finalcommentsduedate,pinswg_procedure,pinswg_questionnaireduedate,pinswg_startdate,pinswg_statementduedate,statuscode,pinswg_startdatetimeiftheevent,pinswg_representation_period_end_date,pinswg_extend_representation_date,pinswg_typeofevent";
break;
case "pinswg_planningconditionss73s79s":
return "&$select=_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_questionnaireduedate,pinswg_startdate,pinswg_statementduedate,statuscode,pinswg_startdateofevent,pinswg_typeofevent";
diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js
index 65d50d1d..293b58e4 100644
--- a/components/breadcrumbs.js
+++ b/components/breadcrumbs.js
@@ -84,17 +84,16 @@ const Breadcrumbs = (props) => {
{router.pathname == "/myportal/searchresults" ? (
<>
-
-
- {t("common:breadcrumb-my-portal")}
-
-
+ {t("common:breadcrumb-my-portal")}
+
{t("common:breadcrumb-search-results")}
@@ -531,6 +530,23 @@ const Breadcrumbs = (props) => {
)}
+
+
+
+ {
+ props.props.currentView
+ .caseReference
+ .currentReference
+ }
+
+
+
Make representation for:{" "}
{
diff --git a/components/case/representation/index.js b/components/case/representation/index.js
index fc36477b..90ecc0d7 100644
--- a/components/case/representation/index.js
+++ b/components/case/representation/index.js
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
-import _ from "lodash";
+import _, { property } from "lodash";
import {
Field,
FieldArray,
@@ -28,6 +28,12 @@ import RepInterestedPartyPerson from "./representationInterestedPartyPerson";
import RepLandOwner from "./representationLandowner";
import RepCompleteSubmit from "./representationCompleteSubmit";
import { useSession, signIn, signOut } from "next-auth/react";
+import {
+ updateCase,
+ patchCase,
+ uploadRepFiles,
+ sendEmail,
+} from "../../../actions";
import {
RenderPickList,
@@ -76,6 +82,18 @@ let MakeRepresentation = (props) => {
casesObj = Object.assign({}, ...casesObj);
+ var detailsObj = {};
+
+ currentType == "searchResultsObj"
+ ? (casesObj = jsonpath.query(
+ setCaseQueryObj,
+ '$..[?(@.title=="' + caseReference + '")]'
+ ))
+ : (casesObj = jsonpath.query(
+ setCaseQueryObj,
+ '$..[?(@.reference=="' + caseReference + '")]'
+ ));
+
const capacityOptionsArr = [
"Appellant",
"Agent",
@@ -129,6 +147,7 @@ let MakeRepresentation = (props) => {
currentView={currentView}
setSubmitBack={setSubmitBack}
props={props}
+ caseReference={caseReference}
/>
);
break;
@@ -214,31 +233,159 @@ let MakeRepresentation = (props) => {
}
};
+ const updateRepresentation = async (
+ values,
+ sendSavedEmail,
+ useSaveStatus
+ ) => {
+ let incidentId = props.appealType.caseReference.incidentid;
+ let updateBody = values || {};
+
+ // "pinswg_name": "2022-11-29-IP-REP_BOND_1",
+
+ const repDate = new Date();
+
+ let day = repDate.getDate();
+ let month = repDate.getMonth() + 1;
+ let year = repDate.getFullYear();
+
+ const repType = "";
+ switch (values.representationCapacity) {
+ case "Appellant":
+ repType = "APPELLANT";
+ break;
+ case "Agent":
+ repType = "AGENT";
+ break;
+ case "Interested Party/Person":
+ repType = "IP";
+ break;
+ case "Land Owner":
+ repType = "LO";
+ break;
+
+ default:
+ // code block
+ }
+
+ Object.assign(updateBody, {
+ "pinswg_name":
+ year +
+ "-" +
+ month +
+ "-" +
+ day +
+ "-" +
+ repType +
+ "-REP" +
+ "_" +
+ props.props.accountDetails.accountDetails.lastname,
+ "containerID": props.props.accountDetails.containerID,
+ });
+
+ updateBody = JSON.stringify(updateBody);
+ updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
+ updateBody = updateBody.replace(/:"No"/gm, `:false`);
+ updateBody = JSON.parse(updateBody);
+
+ Object.keys(updateBody).forEach((key) => {
+ if (updateBody[key] === null) {
+ delete updateBody[key];
+ }
+ if (key.indexOf("_") == 0) {
+ delete updateBody[key];
+ }
+ });
+
+ //console.log(updateBody);
+
+ window.alert(`form is :\n\n${JSON.stringify(updateBody, null, 2)}`);
+
+ const reference = "PEDW-PARTIAL-REP";
+ const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75";
+ const emailAddress = props.props.accountDetails.loggedinUserEmail;
+ const personalisation = {
+ "caseReference": props.caseReference,
+ "emailAddress": props.props.accountDetails.loggedinUserEmail,
+ "returnLink": "",
+ "linkExpiry": 10 * 60,
+ };
+ props.currentView.representationSubmit == "true" &&
+ (sendSavedEmail == true &&
+ sendEmail(templateId, emailAddress, personalisation, reference),
+ useSaveStatus &&
+ router.replace(
+ router.locale != "en"
+ ? router.locale + "/myportal"
+ : "/myportal"
+ ));
+ };
+
const onHandleSubmit = (values) => {
- // console.log(
- // values,
- // values.representationCapacity,
- // currentView.representationCapacity
- // );
+ currentView.representationSubmit != true
+ ? // console.log(
+ // values,
+ // values.representationCapacity,
+ // currentView.representationCapacity
+ // );
- // console.log(_.isEmpty(currentView.representationCapacity));
- // console.log(
- // values.representationCapacity
- // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- // .toLowerCase() == currentView.representationCapacity
- // );
+ // console.log(_.isEmpty(currentView.representationCapacity));
+ // console.log(
+ // values.representationCapacity
+ // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
+ // .toLowerCase() == currentView.representationCapacity
+ // );
- _.isEmpty(currentView.representationCapacity)
- ? setRepresentationCapacity(
- values.representationCapacity
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- )
- : setRepresentationSubmit("true");
+ _.isEmpty(currentView.representationCapacity)
+ ? 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),
+ uploadRepresentationFiles(values),
+ setRepresentationSubmitConfirmation(true));
window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`);
};
+ const uploadRepresentationFiles = (values) => {
+ // get filelists from values object
+ let fileListObj = _.filter(values, function (v, key) {
+ return _.includes(key, "representationDocuments");
+ });
+
+ console.log(fileListObj);
+
+ console.log(
+ "\n////////////////////////\n upload files:",
+ values.containerID
+ );
+
+ var dataObj = values;
+
+ for (let key in dataObj) {
+ _.includes(key, "representationDocuments") == true &&
+ delete dataObj[key];
+ }
+
+ uploadRepFiles(
+ dataObj,
+ fileListObj,
+ values.containerID,
+ props.caseReference
+ ).then((data) => {
+ //console.log("hello", data);
+
+ return data;
+ });
+ };
+
const repForm = props.props.form;
// console.log(
@@ -312,7 +459,7 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => {
return {
setRepresentationCapacity: (representationCapacity) => {
- dispatch(reset("representationForm"));
+ //dispatch(reset("representationForm"));
dispatch(setRepresentationCapacity(representationCapacity));
},
setRepresentationSubmit: (representationSubmit) => {
diff --git a/components/case/representation/representationAgent.js b/components/case/representation/representationAgent.js
index 692ed496..2ce3a432 100644
--- a/components/case/representation/representationAgent.js
+++ b/components/case/representation/representationAgent.js
@@ -7,6 +7,7 @@ import {
RenderTextfield,
RenderRadioList,
RenderMultiline,
+ RenderCondtionalRadioList,
} from "./representationElements";
import {
setRepresentationCapacity,
@@ -32,12 +33,15 @@ const RepAgent = (props) => {
{file.path} - {file.size} bytes
));
+ const required = (value) => (value ? undefined : "Required");
return (
-
Representation - agent
+
+ Representation from an Agent
+
-
+ {/*
{
label="Description of representation"
/>
+
*/}
+
diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js
index 8a4f4807..ac1bdaaa 100644
--- a/components/case/representation/representationAppellant.js
+++ b/components/case/representation/representationAppellant.js
@@ -39,6 +39,9 @@ const RepAppellant = (props) => {
+
+ Representation for an Appellant
+
-
+ {/*
{
label="Description of representation"
/>
-
+
*/}
diff --git a/components/case/representation/representationCapacitySelection.js b/components/case/representation/representationCapacitySelection.js
index e75265c4..a6f86ceb 100644
--- a/components/case/representation/representationCapacitySelection.js
+++ b/components/case/representation/representationCapacitySelection.js
@@ -47,6 +47,8 @@ let RepCapacitySelection = (props) => {
formObj={formObj}
currentType={currentType}
casesObj={casesObj}
+ caseReference={props.props.caseReference}
+ searchResultsObj={props.props.searchResultsObj}
/>{" "}
diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js
index 6a501fa9..859e6225 100644
--- a/components/case/representation/representationCompleteSubmit.js
+++ b/components/case/representation/representationCompleteSubmit.js
@@ -16,6 +16,7 @@ import {
} from "../../../store/currentView/action";
import { useDropzone } from "react-dropzone";
import RepComplete from "./representationComplete";
+import _ from "lodash";
const RepCompleteSubmit = (props) => {
let { t } = useTranslation();
@@ -38,6 +39,8 @@ const RepCompleteSubmit = (props) => {
));
+ const repFormData = formObj.representationForm.values;
+
return (
<>
{currentView.representationSubmitConfirmation == true ? (
@@ -47,6 +50,174 @@ const RepCompleteSubmit = (props) => {
Submit
+
+
+ Your representation:
+
+
+ {_.has(
+ repFormData,
+ "representationOnBehalfOf"
+ ) && (
+ <>
+
+ {repFormData.representationOnBehalfOf ==
+ "Yes" && (
+
+ )}
+ >
+ )}
+
+
+
The gathering and subsequent processing of the
personal data supplied by you in this form, is
@@ -90,7 +261,8 @@ const RepCompleteSubmit = (props) => {
className="govuk-button"
data-module="govuk-button"
onClick={() =>
- setRepresentationSubmitConfirmation()
+ //setRepresentationSubmitConfirmation()
+ setRepresentationSubmit(true)
}
>
Continue
diff --git a/components/case/representation/representationDetails.js b/components/case/representation/representationDetails.js
index 0964ce68..cd621e7e 100644
--- a/components/case/representation/representationDetails.js
+++ b/components/case/representation/representationDetails.js
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { Field, reduxForm } from "redux-form";
import { RenderPickList, RenderTextfield } from "./representationElements";
+import jsonpath from "jsonpath";
const RepDetails = (props) => {
let { t } = useTranslation();
@@ -10,7 +11,18 @@ const RepDetails = (props) => {
const router = useRouter();
const { locale } = router;
- const { currentType, casesObj } = props;
+ const { currentType, casesObj, caseReference } = props;
+
+ let setCaseDetailsObj = props.searchResultsObj.searchDetailsObj;
+
+ var detailsObj = {};
+
+ detailsObj = jsonpath.query(
+ setCaseDetailsObj,
+ '$..[?(@.pinswg_name=="' + caseReference + '")]'
+ );
+
+ detailsObj = detailsObj[0];
return (
<>
@@ -24,6 +36,9 @@ const RepDetails = (props) => {
{casesObj.appellantApplicant || ""}
+ {detailsObj[
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
+ ] || "not entered"}
{/*
@@ -39,12 +54,36 @@ const RepDetails = (props) => {
{t("case:summary-site-address-label")}
- {casesObj.address1 || ""}
-
- {casesObj.town || ""}
-
-
- {casesObj.postcode || ""}
+ {_.has(detailsObj, "pinswg_siteaddressline1")
+ ? detailsObj.pinswg_siteaddressline1
+ : ""}
+ {_.has(detailsObj, "pinswg_siteaddressline1") &&
+ detailsObj.pinswg_siteaddressline1 !=
+ null &&
}
+ {_.has(detailsObj, "pinswg_siteaddressline2")
+ ? detailsObj.pinswg_siteaddressline2
+ : ""}
+ {_.has(detailsObj, "pinswg_siteaddressline2") &&
+ detailsObj.pinswg_siteaddressline2 !=
+ null &&
}
+ {_.has(detailsObj, "pinswg_siteaddresstown")
+ ? detailsObj.pinswg_siteaddresstown
+ : ""}
+ {_.has(detailsObj, "pinswg_siteaddresstown") &&
+ detailsObj.pinswg_siteaddresstown !=
+ null &&
}
+ {_.has(detailsObj, "pinswg_siteaddresscounty")
+ ? detailsObj.pinswg_siteaddresscounty
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddresscounty"
+ ) &&
+ detailsObj.pinswg_siteaddresscounty !=
+ null &&
}
+ {_.has(detailsObj, "pinswg_siteaddresspostcode")
+ ? detailsObj.pinswg_siteaddresspostcode
+ : ""}
diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js
index 129d27b8..fbbe2d10 100644
--- a/components/case/representation/representationElements.js
+++ b/components/case/representation/representationElements.js
@@ -84,29 +84,176 @@ export const RenderRadioList = ({
);
};
+export const RenderCondtionalRadioList = ({
+ datafieldname,
+ legend,
+ name,
+ label,
+ id,
+ errorMsg,
+ options,
+ input: { onChange, value },
+ meta: { touched, error },
+ ...custom
+}) => {
+ const required = (value) => (value ? undefined : "Required");
+
+ return (
+ <>
+
+
+
+ >
+ );
+};
+
export const RenderPickList = ({
datafieldname,
name,
label,
input,
optionsArr,
- meta: { touched, errorStr },
+ meta: { touched, error },
+ errorMsg,
}) => {
return (
-
-
+ <>
+
+
+ {touched && error && (
+
+ Error:{" "}
+ {errorMsg}
+
+ )}
- {touched && errorStr && {errorStr}}
-
+
+
+
+
+ >
);
};
@@ -123,6 +270,8 @@ export const RenderTextfield = ({
meta: { touched, error },
...custom
}) => {
+ const required = (value) => (value ? undefined : "Required");
+
return (
<>
diff --git a/pages/advancedsearchresults.js b/pages/advancedsearchresults.js
index e50fa3a6..03185a84 100644
--- a/pages/advancedsearchresults.js
+++ b/pages/advancedsearchresults.js
@@ -14,6 +14,8 @@ import {
setSearchDetails,
setSearchResults,
} from "../store/searchOutput/action";
+import { setShowReps } from "../store/currentView/action";
+
import { wrapper } from "../store/store";
const Home = (props) => {
@@ -118,6 +120,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
const searchResultsObj = await getAdvancedSearch(query);
const searchDetailsObj = await getSearchDetails(searchResultsObj);
+ const showReps = process.env.SHOWREPRESENTATIONS || false;
+ store.dispatch(setShowReps(showReps));
+
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setSearch(Object.entries(query)));
diff --git a/pages/api/endpoint/getappealtypes_api.js b/pages/api/endpoint/getappealtypes_api.js
index f5c20f71..5c5aa7d3 100644
--- a/pages/api/endpoint/getappealtypes_api.js
+++ b/pages/api/endpoint/getappealtypes_api.js
@@ -39,7 +39,7 @@ export default async function ApiProxy(req, res) {
var token = await getToken();
var queryUrl =
- "stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
+ "stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
//"stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'Developments of National Significance' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
//console.log(queryUrl);
diff --git a/pages/api/endpoint/getbasicsearchdetails_api.js b/pages/api/endpoint/getbasicsearchdetails_api.js
index 11c410a9..e524b57c 100644
--- a/pages/api/endpoint/getbasicsearchdetails_api.js
+++ b/pages/api/endpoint/getbasicsearchdetails_api.js
@@ -34,7 +34,7 @@ export default async function ApiProxy(req, res) {
queryUrl = queryUrl + getSelectQuery(appealTypeName);
- //console.log("///////////\nquery: ", queryUrl, "<<<
{
const appealData = req.body.appealData;
const containerID = req.body.containerID[0];
const casefolderID = req.body.casefolderID[0];
+ const repOrAppeal = req.body.repOrAppeal || false;
console.log("there are files:", Object.keys(req.files).length);
@@ -33,10 +35,15 @@ ApiProxy.post(async (req, res) => {
//createContainer(containerID).then((containerName) => {
console.log("does this get folder name:", containerID, casefolderID);
- createBlob(appealData, containerID, casefolderID).then((data) => {
- Object.keys(req.files).length > 0 &&
- uploadFile(req.files, containerID, casefolderID);
- });
+ repOrAppeal
+ ? createRepBlob(appealData, containerID, casefolderID).then((data) => {
+ Object.keys(req.files).length > 0 &&
+ uploadFile(req.files, containerID, casefolderID);
+ })
+ : createBlob(appealData, containerID, casefolderID).then((data) => {
+ Object.keys(req.files).length > 0 &&
+ uploadFile(req.files, containerID, casefolderID);
+ });
//});
return res.status(200).json({ data: "success" });
diff --git a/pages/myportal/advancedsearch.js b/pages/myportal/advancedsearch.js
index 465c910b..efab7f49 100644
--- a/pages/myportal/advancedsearch.js
+++ b/pages/myportal/advancedsearch.js
@@ -88,6 +88,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData));
store.dispatch(setLoggedInUserId(loggedInUser));
+
+ thisSession != false &&
+ store.dispatch(setContainerID(thisSession.user.id));
}
);
diff --git a/pages/myportal/advancedsearchresults.js b/pages/myportal/advancedsearchresults.js
index 9d89e8ca..3ab20f86 100644
--- a/pages/myportal/advancedsearchresults.js
+++ b/pages/myportal/advancedsearchresults.js
@@ -6,6 +6,7 @@ import {
getAdvancedSearch,
getPortalModuleDetails,
getWatchedCases,
+ getPersonalAccount,
} from "../../actions";
import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner";
@@ -20,6 +21,12 @@ import {
setSearchDetails,
setSearchResults,
} from "../../store/searchOutput/action";
+
+import {
+ setAccountDetails,
+ setContainerID,
+ setLoggedInUserId,
+} from "../../store/accountDetails/action";
import { setSearch } from "../../store/search/action";
import { wrapper } from "../../store/store";
import {
@@ -27,6 +34,7 @@ import {
setWatchedCasesDetails,
} from "../../store/watchedCases/action";
import TimeOut from "../../components/timeout";
+import { getSession, useSession, signIn, signOut } from "next-auth/react";
const Home = (props) => {
const { footerLinks, pages, watchedCases } = props;
@@ -64,30 +72,39 @@ const Home = (props) => {
};
export const getServerSideProps = wrapper.getServerSideProps(
- (store) =>
- async ({ query, req, res }) => {
- console.log("query-", query);
- //console.log("search array:", Object.entries(query));
- const { cookies } = req;
+ (store) => async (ctx) => {
+ const { query, req, res } = ctx;
+ console.log("query-", query);
+ //console.log("search array:", Object.entries(query));
+ const { cookies } = req;
- let loggedInUser = cookies.pinsUser;
+ let loggedInUser = cookies.pinsUser;
+ let thisSession = await getSession(ctx);
- const [searchResultsObj, watchedCases] = await Promise.all([
+ thisSession != false &&
+ store.dispatch(setContainerID(thisSession.user.id));
+
+ const [accountDetails, searchResultsObj, watchedCases] =
+ await Promise.all([
+ await getPersonalAccount(loggedInUser),
await getAdvancedSearch(query),
await getWatchedCases(loggedInUser),
]);
- const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
- await getSearchDetails(searchResultsObj),
- await getDetails(watchedCases, "myWatchedCases"),
- ]);
+ console.log(accountDetails);
- store.dispatch(setSearchResults(searchResultsObj));
- store.dispatch(setSearchDetails(searchDetailsObj));
- store.dispatch(setWatchedCases(watchedCases));
- store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
- store.dispatch(setSearch(Object.entries(query)));
- }
+ const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
+ await getSearchDetails(searchResultsObj),
+ await getDetails(watchedCases, "myWatchedCases"),
+ ]);
+
+ store.dispatch(setAccountDetails(accountDetails));
+ store.dispatch(setSearchResults(searchResultsObj));
+ store.dispatch(setSearchDetails(searchDetailsObj));
+ store.dispatch(setWatchedCases(watchedCases));
+ store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
+ store.dispatch(setSearch(Object.entries(query)));
+ }
);
const getDetails = (resultsObj, detailsType) => {
@@ -123,6 +140,7 @@ const getDetails = (resultsObj, detailsType) => {
const mapStateToProps = (state) => {
return {
+ accountDetails: state.accountDetails,
currentView: state.currentView,
search: state.search,
searchResultsObj: state.searchResultsObj,
diff --git a/pages/myportal/index.js b/pages/myportal/index.js
index 973ce1d8..064c113d 100644
--- a/pages/myportal/index.js
+++ b/pages/myportal/index.js
@@ -14,6 +14,7 @@ import {
getWatchedCases,
consoleLogger,
getCase,
+ getPortalLogin,
} from "../../actions";
import { createContainer } from "../../actions/azurestorage";
import Breadcrumbs from "../../components/breadcrumbs";
@@ -158,10 +159,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
const { cookies } = req;
- let loggedInUser = cookies.pinsUser;
+ let loggedInUserCookie = cookies.pinsUser;
let thisSession = await getSession(ctx);
+ let [loggedInUser] = await Promise.all([
+ await getPortalLogin(thisSession.user.email),
+ ]);
+
+ loggedInUser = loggedInUser.value[0].contactid;
console.log("nextAuth Session:", thisSession);
if (_.has(thisSession, "user") == false) {
diff --git a/pages/myportal/representation.js b/pages/myportal/representation.js
index 8288f875..fa988486 100644
--- a/pages/myportal/representation.js
+++ b/pages/myportal/representation.js
@@ -99,6 +99,9 @@ const Home = (props) => {
searchResultsObj={
props.searchResultsObj.searchResultsObj
}
+ searchDetailsObj={
+ props.searchResultsObj.searchDetailsObj
+ }
myRepresentations={
props.myRepresentations.myRepresentations
}
diff --git a/pages/myportal/searchresults.js b/pages/myportal/searchresults.js
index b7657eb7..0037c0a4 100644
--- a/pages/myportal/searchresults.js
+++ b/pages/myportal/searchresults.js
@@ -7,6 +7,8 @@ import {
getBasicSearch,
getPortalModuleDetails,
getWatchedCases,
+ consoleLogger,
+ getPortalLogin,
} from "../../actions";
import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner";
@@ -76,13 +78,13 @@ export const getServerSideProps = wrapper.getServerSideProps(
const { cookies } = req;
- let loggedInUser = cookies.pinsUser;
+ let loggedInUserCookie = cookies.pinsUser;
let thisSession = await getSession(ctx);
- let [searchResultsObj, watchedCases] = await Promise.all([
+ let [searchResultsObj, loggedInUser] = await Promise.all([
await getBasicSearch(query.q),
- await getWatchedCases(loggedInUser),
+ await getPortalLogin(thisSession.user.email),
]);
searchResultsObj =
@@ -96,6 +98,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
//console.log("sssss", searchResultsObj);
+ loggedInUser = loggedInUser.value[0].contactid;
+
+ const watchedCases = await getWatchedCases(loggedInUser);
+
+ //console.log("sssss", loggedInUser);
+
const [accountDetails, searchDetailsObj, watchedCasesDetails] =
await Promise.all([
await getPersonalAccount(loggedInUser),
@@ -109,6 +117,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setWatchedCases(watchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setLoggedInUserId(loggedInUser));
+
+ thisSession != false &&
+ store.dispatch(setContainerID(thisSession.user.id));
}
);
diff --git a/pages/searchresults.js b/pages/searchresults.js
index af40d80c..15b55d8a 100644
--- a/pages/searchresults.js
+++ b/pages/searchresults.js
@@ -14,6 +14,7 @@ import {
setSearchDetails,
setSearchResults,
} from "../store/searchOutput/action";
+import { setShowReps } from "../store/currentView/action";
import { wrapper } from "../store/store";
import _ from "lodash";
@@ -116,9 +117,9 @@ const Home = (props) => {
};
export const getServerSideProps = wrapper.getServerSideProps(
- (store) =>
- async ({ query, req, res }) => {
- console.log("query-", query);
+ (store) => async (ctx) => {
+ const { query, req, res } = ctx;
+ console.log("query-", query);
let isLinked =
typeof query.lk != "undefined" && query.lk == "1"
@@ -127,6 +128,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
//console.log("is linked:", isLinked);
const showLoginCheck = process.env.SHOWLOGIN || false;
+ const showReps = process.env.SHOWREPRESENTATIONS || false;
+ store.dispatch(setShowReps(showReps));
let searchResultsObj = await getBasicSearch(query.q);
diff --git a/store/currentView/action.js b/store/currentView/action.js
index 91692b61..6d7be4c1 100644
--- a/store/currentView/action.js
+++ b/store/currentView/action.js
@@ -7,6 +7,7 @@ export const currentViewActionTypes = {
SETREPRESENTATIONSUBMITCONFIRMATION: "SETREPRESENTATIONSUBMITCONFIRMATION",
SETCURRENTLINKEDCASES: "SETCURRENTLINKEDCASES",
SETCURRENTPAGE: "SETCURRENTPAGE",
+ SETSHOWREPS: "SETSHOWREPS",
};
export const getCurrentViewObj = () => (dispatch) => {
@@ -72,3 +73,10 @@ export const setCurrentPage = (currentPage) => (dispatch) => {
currentPage: currentPage,
});
};
+
+export const setShowReps = (showReps) => (dispatch) => {
+ return dispatch({
+ type: currentViewActionTypes.SETSHOWREPS,
+ showReps: showReps,
+ });
+};
diff --git a/store/currentView/reducer.js b/store/currentView/reducer.js
index 1704ffc9..005c21ce 100644
--- a/store/currentView/reducer.js
+++ b/store/currentView/reducer.js
@@ -49,6 +49,11 @@ export default function reducer(state = currentViewInitialState, action) {
...state,
currentPage: action.currentPage,
};
+ case currentViewActionTypes.SETSHOWREPS:
+ return {
+ ...state,
+ showReps: action.showReps,
+ };
default:
return state;
}