This commit is contained in:
2022-12-16 11:36:01 +00:00
parent f6d934d951
commit 98aefdd867
36 changed files with 1258 additions and 371 deletions
+3 -2
View File
@@ -45,9 +45,9 @@ RELAYPATH = "dev-pedw-hc"
GOOGLE_TAG_MANAGER = GTM-T78CBC3 GOOGLE_TAG_MANAGER = GTM-T78CBC3
SHOWLOGIN = "true" SHOWLOGIN = "true"
SHOWREPRESENTATIONS = false SHOWREPRESENTATIONS = "true"
SHOWFILEUPLOAD = "false" SHOWFILEUPLOAD = "false"
SHOWMAPS = "true" SHOWMAPS = "false"
//BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2 //BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
@@ -104,6 +104,7 @@ SECRET=SuperSecret
AZURE_CLIENT_ID = $CLIENT_ID AZURE_CLIENT_ID = $CLIENT_ID
AZURE_TENANT_ID = $TENANT AZURE_TENANT_ID = $TENANT
AZURE_CLIENT_SECRET = $CLIENT_SECRET AZURE_CLIENT_SECRET = $CLIENT_SECRET
AZURE_STORAGE_ACCOUNT_NAME= "pedwdev"
AZURE_PEDW_STORAGE_ENDPOINT = https://pedwdev.blob.core.windows.net AZURE_PEDW_STORAGE_ENDPOINT = https://pedwdev.blob.core.windows.net
AZURE_PEDW_CONTAINER = "pedwapplications" AZURE_PEDW_CONTAINER = "pedwapplications"
+39 -1
View File
@@ -255,6 +255,44 @@ export const createBlob = async (formContent, containerName, caseref) => {
return formContent.pinswg_name; 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) => { export const deleteBlob = async (containerName, blobName) => {
const creds = new DefaultAzureCredential(); const creds = new DefaultAzureCredential();
@@ -545,7 +583,7 @@ export const getAllProgressBlobs = async (containerName) => {
let blobObj = []; let blobObj = [];
for await (const blob of containerClient.listBlobsFlat()) { 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 && blob.name.split("/")[1].indexOf("undefined") < 0 &&
blobObj.push({ blobObj.push({
"name": blob.name.split("/")[1], "name": blob.name.split("/")[1],
+44
View File
@@ -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) => { export const getFilesFromBlob = (containerName, casefolderID) => {
return axios return axios
.get( .get(
+1 -1
View File
@@ -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"; 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; break;
case "pinswg_planningappeals78s": 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; break;
case "pinswg_planningconditionss73s79s": 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"; 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";
+21 -5
View File
@@ -84,17 +84,16 @@ const Breadcrumbs = (props) => {
{router.pathname == "/myportal/searchresults" ? ( {router.pathname == "/myportal/searchresults" ? (
<> <>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
<Link <a
href={ href={
router.locale != "en" router.locale != "en"
? router.locale + "/myportal" ? router.locale + "/myportal"
: "/myportal" : "/myportal"
} }
className="govuk-breadcrumbs__link"
> >
<a className="govuk-breadcrumbs__link"> {t("common:breadcrumb-my-portal")}
{t("common:breadcrumb-my-portal")} </a>
</a>
</Link>
</li> </li>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
{t("common:breadcrumb-search-results")} {t("common:breadcrumb-search-results")}
@@ -531,6 +530,23 @@ const Breadcrumbs = (props) => {
</Link> </Link>
</li> </li>
)} )}
<li className="govuk-breadcrumbs__list-item">
<Link
href={
router.locale != "en"
? router.locale + "/case"
: "/case"
}
>
<a className="govuk-breadcrumbs__link">
{
props.props.currentView
.caseReference
.currentReference
}
</a>
</Link>
</li>
<li className="govuk-breadcrumbs__list-item"> <li className="govuk-breadcrumbs__list-item">
Make representation for:{" "} Make representation for:{" "}
{ {
+167 -20
View File
@@ -3,7 +3,7 @@ import { useState, useEffect } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation"; import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath"; import jsonpath from "jsonpath";
import _ from "lodash"; import _, { property } from "lodash";
import { import {
Field, Field,
FieldArray, FieldArray,
@@ -28,6 +28,12 @@ import RepInterestedPartyPerson from "./representationInterestedPartyPerson";
import RepLandOwner from "./representationLandowner"; import RepLandOwner from "./representationLandowner";
import RepCompleteSubmit from "./representationCompleteSubmit"; import RepCompleteSubmit from "./representationCompleteSubmit";
import { useSession, signIn, signOut } from "next-auth/react"; import { useSession, signIn, signOut } from "next-auth/react";
import {
updateCase,
patchCase,
uploadRepFiles,
sendEmail,
} from "../../../actions";
import { import {
RenderPickList, RenderPickList,
@@ -76,6 +82,18 @@ let MakeRepresentation = (props) => {
casesObj = Object.assign({}, ...casesObj); casesObj = Object.assign({}, ...casesObj);
var detailsObj = {};
currentType == "searchResultsObj"
? (casesObj = jsonpath.query(
setCaseQueryObj,
'$..[?(@.title=="' + caseReference + '")]'
))
: (casesObj = jsonpath.query(
setCaseQueryObj,
'$..[?(@.reference=="' + caseReference + '")]'
));
const capacityOptionsArr = [ const capacityOptionsArr = [
"Appellant", "Appellant",
"Agent", "Agent",
@@ -129,6 +147,7 @@ let MakeRepresentation = (props) => {
currentView={currentView} currentView={currentView}
setSubmitBack={setSubmitBack} setSubmitBack={setSubmitBack}
props={props} props={props}
caseReference={caseReference}
/> />
); );
break; 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) => { const onHandleSubmit = (values) => {
// console.log( currentView.representationSubmit != true
// values, ? // console.log(
// values.representationCapacity, // values,
// currentView.representationCapacity // values.representationCapacity,
// ); // currentView.representationCapacity
// );
// console.log(_.isEmpty(currentView.representationCapacity)); // console.log(_.isEmpty(currentView.representationCapacity));
// console.log( // console.log(
// values.representationCapacity // values.representationCapacity
// .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
// .toLowerCase() == currentView.representationCapacity // .toLowerCase() == currentView.representationCapacity
// ); // );
_.isEmpty(currentView.representationCapacity) _.isEmpty(currentView.representationCapacity)
? setRepresentationCapacity( ? setRepresentationCapacity(
values.representationCapacity values.representationCapacity
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "") .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase() .toLowerCase()
) )
: setRepresentationSubmit("true"); : 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)}`); 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; const repForm = props.props.form;
// console.log( // console.log(
@@ -312,7 +459,7 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
setRepresentationCapacity: (representationCapacity) => { setRepresentationCapacity: (representationCapacity) => {
dispatch(reset("representationForm")); //dispatch(reset("representationForm"));
dispatch(setRepresentationCapacity(representationCapacity)); dispatch(setRepresentationCapacity(representationCapacity));
}, },
setRepresentationSubmit: (representationSubmit) => { setRepresentationSubmit: (representationSubmit) => {
@@ -7,6 +7,7 @@ import {
RenderTextfield, RenderTextfield,
RenderRadioList, RenderRadioList,
RenderMultiline, RenderMultiline,
RenderCondtionalRadioList,
} from "./representationElements"; } from "./representationElements";
import { import {
setRepresentationCapacity, setRepresentationCapacity,
@@ -32,12 +33,15 @@ const RepAgent = (props) => {
{file.path} - {file.size} bytes {file.path} - {file.size} bytes
</li> </li>
)); ));
const required = (value) => (value ? undefined : "Required");
return ( return (
<div id="rep-appellant"> <div id="rep-appellant">
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<h2 className="govuk-heading-m ">Representation - agent</h2> <h2 className="govuk-heading-m ">
Representation from an Agent
</h2>
<div className="govuk-form-group"> <div className="govuk-form-group">
<label <label
@@ -54,7 +58,7 @@ const RepAgent = (props) => {
/> />
</div> </div>
</div> </div>
<div className="govuk-grid-row"> {/* <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<Field <Field
className="govuk-input govuk-!-width-three-quarters" className="govuk-input govuk-!-width-three-quarters"
@@ -67,6 +71,24 @@ const RepAgent = (props) => {
label="Description of representation" label="Description of representation"
/> />
</div> </div>
</div> */}
<div className="govuk-grid-row">
<div className="govuk-form-group">
<Field
name="representationOnBehalfOf"
datafieldname="representationOnBehalfOf"
// label="In what capacity do you wish to make representations on this case?"
options={["Yes", "No"]}
id="representationOnBehalfOf"
className="govuk-radios__input"
errorMsg={t("newappeal:select-an-option-label")}
component={RenderCondtionalRadioList}
validate={[required]}
legend={
"Are you acting on behalf of a company, group or organisation?"
}
/>
</div>
</div> </div>
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
@@ -39,6 +39,9 @@ const RepAppellant = (props) => {
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<h2 className="govuk-heading-m ">
Representation for an Appellant
</h2>
<label <label
className="govuk-label govuk-body-m" className="govuk-label govuk-body-m"
htmlFor="representationType" htmlFor="representationType"
@@ -53,7 +56,7 @@ const RepAppellant = (props) => {
/> />
</div> </div>
</div> </div>
<div className="govuk-grid-row"> {/* <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<Field <Field
className="govuk-input govuk-!-width-three-quarters" className="govuk-input govuk-!-width-three-quarters"
@@ -66,7 +69,7 @@ const RepAppellant = (props) => {
label="Description of representation" label="Description of representation"
/> />
</div> </div>
</div> </div> */}
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<p className="govuk-body"> <p className="govuk-body">
@@ -47,6 +47,8 @@ let RepCapacitySelection = (props) => {
formObj={formObj} formObj={formObj}
currentType={currentType} currentType={currentType}
casesObj={casesObj} casesObj={casesObj}
caseReference={props.props.caseReference}
searchResultsObj={props.props.searchResultsObj}
/>{" "} />{" "}
<div id="rep-details" className="vo_hiddens"> <div id="rep-details" className="vo_hiddens">
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
@@ -16,6 +16,7 @@ import {
} from "../../../store/currentView/action"; } from "../../../store/currentView/action";
import { useDropzone } from "react-dropzone"; import { useDropzone } from "react-dropzone";
import RepComplete from "./representationComplete"; import RepComplete from "./representationComplete";
import _ from "lodash";
const RepCompleteSubmit = (props) => { const RepCompleteSubmit = (props) => {
let { t } = useTranslation(); let { t } = useTranslation();
@@ -38,6 +39,8 @@ const RepCompleteSubmit = (props) => {
</li> </li>
)); ));
const repFormData = formObj.representationForm.values;
return ( return (
<> <>
{currentView.representationSubmitConfirmation == true ? ( {currentView.representationSubmitConfirmation == true ? (
@@ -47,6 +50,174 @@ const RepCompleteSubmit = (props) => {
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
<div className="govuk-grid-row govuk-body"> <div className="govuk-grid-row govuk-body">
<h1 className="govuk-heading-m ">Submit</h1> <h1 className="govuk-heading-m ">Submit</h1>
<dl className="govuk-summary-list ">
<h2 className="govuk-heading-m govuk-!-margin-top-9">
Your representation:
</h2>
<div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key">
{t(
"case:representation-representation-type"
)}
</dt>
<dd className="govuk-summary-list__value">
{repFormData.representationType}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
}}
>
{t("newappeal:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
{/* {FieldsTranslations(
rows[0].value
)} */}
</span>
</a>
</dd>
</div>
{_.has(
repFormData,
"representationOnBehalfOf"
) && (
<>
<div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key">
{t(
"case:representation-onbehalfof"
)}
</dt>
<dd className="govuk-summary-list__value">
{
repFormData.representationOnBehalfOf
}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
}}
>
{t(
"newappeal:change-link-label"
)}
<span className="govuk-visually-hidden">
{" "}
{/* {FieldsTranslations(
rows[0].value
)} */}
</span>
</a>
</dd>
</div>
{repFormData.representationOnBehalfOf ==
"Yes" && (
<div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key">
{t(
"case:representation-onbehalfof-details"
)}
</dt>
<dd className="govuk-summary-list__value">
{
repFormData.representationOnBehalfOf_details
}
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
}}
>
{t(
"newappeal:change-link-label"
)}
<span className="govuk-visually-hidden">
{" "}
{/* {FieldsTranslations(
rows[0].value
)} */}
</span>
</a>
</dd>
</div>
)}
</>
)}
<div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key">
{t("case:representation-comments")}
</dt>
<dd className="govuk-summary-list__value">
<span
dangerouslySetInnerHTML={{
__html: repFormData.representationComments,
}}
/>
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
}}
>
{t("newappeal:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
{/* {FieldsTranslations(
rows[0].value
)} */}
</span>
</a>
</dd>
</div>
<div className="govuk-summary-list__row">
<dt className="govuk-summary-list__key">
{t("case:representation-files")}
</dt>
<dd className="govuk-summary-list__value">
files
</dd>
<dd className="govuk-summary-list__actions">
<a
className="govuk-link"
href="#"
onClick={() => {
setSubmitBack();
}}
>
{t("newappeal:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
{/* {FieldsTranslations(
rows[0].value
)} */}
</span>
</a>
</dd>
</div>
</dl>
<p> <p>
The gathering and subsequent processing of the The gathering and subsequent processing of the
personal data supplied by you in this form, is personal data supplied by you in this form, is
@@ -90,7 +261,8 @@ const RepCompleteSubmit = (props) => {
className="govuk-button" className="govuk-button"
data-module="govuk-button" data-module="govuk-button"
onClick={() => onClick={() =>
setRepresentationSubmitConfirmation() //setRepresentationSubmitConfirmation()
setRepresentationSubmit(true)
} }
> >
Continue Continue
@@ -3,6 +3,7 @@ import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation"; import useTranslation from "next-translate/useTranslation";
import { Field, reduxForm } from "redux-form"; import { Field, reduxForm } from "redux-form";
import { RenderPickList, RenderTextfield } from "./representationElements"; import { RenderPickList, RenderTextfield } from "./representationElements";
import jsonpath from "jsonpath";
const RepDetails = (props) => { const RepDetails = (props) => {
let { t } = useTranslation(); let { t } = useTranslation();
@@ -10,7 +11,18 @@ const RepDetails = (props) => {
const router = useRouter(); const router = useRouter();
const { locale } = router; 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 ( return (
<> <>
@@ -24,6 +36,9 @@ const RepDetails = (props) => {
</dt> </dt>
<dd className="govuk-summary-list__value"> <dd className="govuk-summary-list__value">
{casesObj.appellantApplicant || ""} {casesObj.appellantApplicant || ""}
{detailsObj[
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
] || "not entered"}
</dd> </dd>
</div> </div>
{/* <div className="govuk-summary-list__row"> {/* <div className="govuk-summary-list__row">
@@ -39,12 +54,36 @@ const RepDetails = (props) => {
{t("case:summary-site-address-label")} {t("case:summary-site-address-label")}
</dt> </dt>
<dd className="govuk-summary-list__value"> <dd className="govuk-summary-list__value">
{casesObj.address1 || ""} {_.has(detailsObj, "pinswg_siteaddressline1")
<br /> ? detailsObj.pinswg_siteaddressline1
{casesObj.town || ""} : ""}
{_.has(detailsObj, "pinswg_siteaddressline1") &&
<br /> detailsObj.pinswg_siteaddressline1 !=
{casesObj.postcode || ""} null && <br />}
{_.has(detailsObj, "pinswg_siteaddressline2")
? detailsObj.pinswg_siteaddressline2
: ""}
{_.has(detailsObj, "pinswg_siteaddressline2") &&
detailsObj.pinswg_siteaddressline2 !=
null && <br />}
{_.has(detailsObj, "pinswg_siteaddresstown")
? detailsObj.pinswg_siteaddresstown
: ""}
{_.has(detailsObj, "pinswg_siteaddresstown") &&
detailsObj.pinswg_siteaddresstown !=
null && <br />}
{_.has(detailsObj, "pinswg_siteaddresscounty")
? detailsObj.pinswg_siteaddresscounty
: ""}
{_.has(
detailsObj,
"pinswg_siteaddresscounty"
) &&
detailsObj.pinswg_siteaddresscounty !=
null && <br />}
{_.has(detailsObj, "pinswg_siteaddresspostcode")
? detailsObj.pinswg_siteaddresspostcode
: ""}
</dd> </dd>
</div> </div>
</dl> </dl>
@@ -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 (
<>
<div
className={
touched && error
? "govuk-form-group govuk-form-group--error"
: "govuk-form-group "
}
>
<fieldset
className="govuk-fieldset"
aria-describedby={id + "-hint"}
>
<legend className="govuk-fieldset__legend govuk-fieldset__legend--s govuk-!-font-weight-regular">
<label
className="govuk-fieldset__heading govuk-body-m"
id={id + "_label"}
>
{label}
</label>
</legend>
{touched && error && (
<span
id={id + "-error"}
className="govuk-error-message"
>
<span className="govuk-visually-hidden">
Error:
</span>{" "}
{errorMsg}
</span>
)}
<legend className="govuk-fieldset__legend govuk-fieldset__legend--m">
<label
className="govuk-fieldset__heading govuk-body-m"
id="representationCapacity_label"
>
{legend}
</label>
</legend>
<div id={id + "-hint"} className="govuk-hint">
e.g. &lsquo;Owners of Numbers 1-5 High Street&lsquo;, or
&lsquo;Mr and Mrs Smith&lsquo; or &lsquo;The executors
of Mr Evans&lsquo; estate&lsquo;
</div>
<div className="govuk-radios">
{Object.keys(options).map((key, index) => (
<div key={key} className="govuk-!-margin-bottom-3">
<div
className="govuk-radios__item"
data-children-count={key}
key={key}
>
<Field
id={id + "_" + index}
name={id}
component="input"
type="radio"
className="govuk-radios__input"
value={options[key]}
validate={[required]}
/>
<label
className="govuk-label govuk-radios__label"
htmlFor={id + "_" + index}
>
{options[key]}
</label>
</div>
{value == "Yes" && options[key] == "Yes" && (
<div
className="govuk-radios__conditional "
id={"conditional-" + id}
>
<div
className="govuk-form-group"
key={"yes_group_" + key}
>
<label
className="govuk-label"
htmlFor={id + "_details"}
>
Enter the name of the
company/group/organisation *
</label>
<Field
className="govuk-input govuk-!-width-one-half"
id={id + "_details"}
name={id + "_details"}
component="input"
type="text"
/>
</div>
</div>
)}
</div>
))}
</div>
</fieldset>
</div>
</>
);
};
export const RenderPickList = ({ export const RenderPickList = ({
datafieldname, datafieldname,
name, name,
label, label,
input, input,
optionsArr, optionsArr,
meta: { touched, errorStr }, meta: { touched, error },
errorMsg,
}) => { }) => {
return ( return (
<div> <>
<select {...input} className="govuk-select " id={name} name={name}> <div
<option>Select...</option> className={
{Object.keys(optionsArr).map((key, index) => { touched && error
return ( ? "govuk-form-group govuk-form-group--error"
<option key={key} value={optionsArr[key]}> : "govuk-form-group "
{optionsArr[key]} }
</option> >
); <label className="govuk-label" htmlFor="sort">
})} {label}
</select> </label>
{touched && error && (
<span
id="passport-issued-error"
className="govuk-error-message"
>
<span className="govuk-visually-hidden">Error:</span>{" "}
{errorMsg}
</span>
)}
{touched && errorStr && <span>{errorStr}</span>} <div>
</div> <select
{...input}
className="govuk-select "
id={name}
name={name}
>
<option>Select...</option>
{Object.keys(optionsArr).map((key, index) => {
return (
<option key={key} value={optionsArr[key]}>
{optionsArr[key]}
</option>
);
})}
</select>
</div>
</div>
</>
); );
}; };
@@ -123,6 +270,8 @@ export const RenderTextfield = ({
meta: { touched, error }, meta: { touched, error },
...custom ...custom
}) => { }) => {
const required = (value) => (value ? undefined : "Required");
return ( return (
<> <>
<label className="govuk-label " htmlFor={id} id={id + "_label"}> <label className="govuk-label " htmlFor={id} id={id + "_label"}>
@@ -140,6 +289,7 @@ export const RenderTextfield = ({
name={name} name={name}
id={id} id={id}
type={type} type={type}
validate={[required]}
/> />
</> </>
); );
@@ -219,6 +369,7 @@ export function MultiLinefield(props) {
component={RenderMultiline} component={RenderMultiline}
type="text" type="text"
rows="5" rows="5"
validate={[required]}
className="govuk-textarea govuk-input--width-30" className="govuk-textarea govuk-input--width-30"
aria-describedby={props.name + "-hint"} aria-describedby={props.name + "-hint"}
/> />
@@ -448,15 +599,9 @@ export const RenderFileUpload = (field) => {
onDrop={(filesToUpload, e) => { onDrop={(filesToUpload, e) => {
const renamedAcceptedFiles = filesToUpload.map( const renamedAcceptedFiles = filesToUpload.map(
(file) => (file) =>
new File( new File([file], `${file.name}`, {
[file], type: file.type,
`${getDocumentType(field.documentTypeCode)}_${ })
file.name
}`,
{
type: file.type,
}
)
); );
field.input.onChange(renamedAcceptedFiles); field.input.onChange(renamedAcceptedFiles);
}} }}
@@ -561,3 +706,25 @@ export const RenderFileUpload = (field) => {
</> </>
); );
}; };
export function FileUploadField(props) {
return (
<>
<h2 className="govuk-heading-s">{props.label} </h2>
<Field
name={props.name}
id={props.name}
component={RenderFileUpload}
className="govuk-input govuk-input--width-20"
//validate={[required]}
label={props.label}
errorMsg="Is required"
ticketnumber={props.ticketnumber}
hint={props.hint}
fileList={props.fileList}
setFilesForAppeal={props.setFilesForAppeal}
containerID={props.containerID}
/>
</>
);
}
@@ -5,8 +5,9 @@ import { Field, reduxForm } from "redux-form";
import { import {
RenderPickList, RenderPickList,
RenderTextfield, RenderTextfield,
RenderRadioList, RenderCondtionalRadioList,
RenderMultiline, RenderMultiline,
FileUploadField,
} from "./representationElements"; } from "./representationElements";
import { useDropzone } from "react-dropzone"; import { useDropzone } from "react-dropzone";
@@ -21,6 +22,8 @@ const RepInterestedPartyPerson = (props) => {
setRepresentationCapacity, setRepresentationCapacity,
setRepresentationSubmit, setRepresentationSubmit,
} = props; } = props;
const required = (value) => (value ? undefined : "Required");
const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
const files = acceptedFiles.map((file) => ( const files = acceptedFiles.map((file) => (
<li key={file.path}> <li key={file.path}>
@@ -32,7 +35,7 @@ const RepInterestedPartyPerson = (props) => {
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<h2 className="govuk-heading-m "> <h2 className="govuk-heading-m ">
Representation - interested Representation from an Interested Party/Person
</h2> </h2>
<div className="govuk-form-group"> <div className="govuk-form-group">
@@ -46,262 +49,84 @@ const RepInterestedPartyPerson = (props) => {
name="representationType" name="representationType"
component={RenderPickList} component={RenderPickList}
datafieldname="representationType" datafieldname="representationType"
validate={[required]}
optionsArr={interestedPersonRepresentationArr} optionsArr={interestedPersonRepresentationArr}
errorMsg={t("newappeal:select-an-option-label")}
/> />
</div> </div>
</div> </div>
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<Field <Field
className="govuk-input govuk-!-width-three-quarters" name="representationOnBehalfOf"
id="representationDescription" datafieldname="representationOnBehalfOf"
name="representationDescription" // label="In what capacity do you wish to make representations on this case?"
value="email" options={["Yes", "No"]}
data-aria-controls="representationDescription" id="representationOnBehalfOf"
type="text" className="govuk-radios__input"
component={RenderTextfield} errorMsg={t("newappeal:select-an-option-label")}
label="Description of representation" component={RenderCondtionalRadioList}
validate={[required]}
legend={
"Are you acting on behalf of a company, group or organisation?"
}
/> />
</div> </div>
<div className="govuk-grid-row"> </div>
<div className="govuk-form-group">
<fieldset <div className="govuk-grid-row">
className="govuk-fieldset" <div className="govuk-form-group">
aria-describedby="contact-hint" <p className="govuk-body">
> You can enter your comments in the space provided or
<legend className="govuk-fieldset__legend govuk-fieldset__legend--l"> attach a separate document.
<label </p>
className="govuk-fieldset__heading govuk-body-m" <fieldset
id="representationCapacity_label" className="govuk-fieldset"
> aria-describedby="commentBox-hint"
Are you acting on behalf of a company, >
group or organisation? <div id="commentBox-hint" className="govuk-hint">
</label> My comments are set out in:
</legend> </div>
<div id="contact-hint" className="govuk-hint"> <div className="govuk-form-group">
e.g. &lsquo;Owners of Numbers 1-5 High <Field
Street&lsquo;, or &lsquo;Mr and Mrs name="representationComments"
Smith&lsquo; or &lsquo;The executors of Mr id="representationComments"
Evans&lsquo; estate&lsquo; component={RenderMultiline}
</div> type="text"
<div rows="5"
className="govuk-radios govuk-radios--conditional" className="govuk-textarea govuk-input--width-30"
data-module="govuk-radios" aria-describedby={props.name + "-hint"}
> />
<div className="govuk-radios__item"> </div>
<input
className="govuk-radios__input" <div className="govuk-form-group govuk-!-margin-bottom-9">
id="contact" <FileUploadField
name="contact" name={"representationDocuments"}
type="radio" label={"Add your files"}
value="email" ticketnumber={props.props.caseReference}
data-aria-controls="conditional-contact" hint={"sdsd"}
/> fileList={[]}
<label setFilesForRepresentation={[]}
className="govuk-label govuk-radios__label" containerID={
htmlFor="contact" props.props.props.accountDetails
> .containerID
Yes }
</label> />
</div> </div>
<div </fieldset>
className="govuk-radios__conditional govuk-radios__conditional--hidden" </div>{" "}
id="conditional-contact" </div>
> <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-button-group">
<label {/* <button
className="govuk-label" type="submit"
htmlFor="contact-by-email" className="govuk-button"
> data-module="govuk-button"
Enter the name of the >
company/group/organisation * Continue
</label> </button> */}
<input {/* <Link href="/representation">
className="govuk-input govuk-!-width-one-third"
id="contact-by-email"
name="contact-by-email"
type="email"
spellCheck="false"
autoComplete="email"
/>
</div>
</div>
<div className="govuk-radios__item">
<input
className="govuk-radios__input"
id="contact-2"
name="contact"
type="radio"
value="phone"
data-aria-controls="conditional-contact-2"
/>
<label
className="govuk-label govuk-radios__label"
htmlFor="contact-2"
>
No
</label>
</div>
</div>
</fieldset>
</div>
</div>
<div className="govuk-grid-row">
<div className="govuk-form-group">
<p className="govuk-body">
You can enter your comments in the space
provided or attach a separate document.
</p>
<fieldset
className="govuk-fieldset"
aria-describedby="commentBox-hint"
>
<div
id="commentBox-hint"
className="govuk-hint"
>
My comments are set out in:*
</div>
<div
className="govuk-checkboxes"
data-module="govuk-checkboxes"
>
<div className="govuk-checkboxes__item">
<Field
className="govuk-checkboxes__input"
id="commentBox"
name="commentBox"
value="email"
data-aria-controls="commentBox"
type="checkbox"
component={RenderTextfield}
/>
<label
className="govuk-label govuk-checkboxes__label"
htmlFor="commentBox"
>
the box below{" "}
</label>
</div>
<div
className={
_.isEmpty(
formObj["representationForm"]
)
? "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden rr"
: _.isEmpty(
formObj[
"representationForm"
].values
)
? "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden q11 "
: _.isEmpty(
formObj[
"representationForm"
].values.commentBox
)
? formObj["representationForm"]
.values.commentBox ==
false
? "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden www"
: "govuk-checkboxes__conditional"
: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden wwwaqqqq"
}
id="conditional-commentBox"
>
<div className="govuk-form-group">
<Field
name="representationComments"
id="representationComments"
component={RenderMultiline}
type="text"
rows="5"
className="govuk-textarea govuk-input--width-30"
aria-describedby={
props.name + "-hint"
}
/>
</div>
</div>
<div className="govuk-checkboxes__item">
<Field
className="govuk-checkboxes__input"
id="documentBox"
name="documentBox"
value="email"
data-aria-controls="documentBox"
type="checkbox"
component={RenderTextfield}
/>
<label
className="govuk-label govuk-checkboxes__label"
htmlFor="documentBox"
>
separate documents
</label>
</div>
<div
className={
_.isEmpty(
formObj["representationForm"]
)
? "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden rr"
: _.isEmpty(
formObj[
"representationForm"
].values
)
? "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden www"
: _.isEmpty(
formObj[
"representationForm"
].values.documentBox
)
? formObj["representationForm"]
.values.documentBox ==
false
? "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden www"
: "govuk-checkboxes__conditional"
: "govuk-checkboxes__conditional govuk-checkboxes__conditional--hidden"
}
id="conditional-documentBox"
>
<div className="govuk-form-group">
<section className="container">
<div
{...getRootProps({
className: "dropzone",
})}
>
<input
{...getInputProps()}
/>
<p>
Drag and drop files here
or click to select files
</p>
</div>
<aside>
<h4>Files</h4>
<ul>{files}</ul>
</aside>
</section>
</div>
</div>
</div>
</fieldset>
</div>{" "}
</div>
<div className="govuk-grid-row">
<div className="govuk-button-group">
<button
type="submit"
className="govuk-button"
data-module="govuk-button"
>
Continue
</button>
{/* <Link href="/representation">
<a <a
onClick={() => { onClick={() => {
setRepresentationSubmit(true); setRepresentationSubmit(true);
@@ -311,15 +136,15 @@ const RepInterestedPartyPerson = (props) => {
Continue Continue
</a> </a>
</Link> */} </Link> */}
<a <a
onClick={() => { onClick={() => {
setRepresentationCapacity(); setRepresentationCapacity();
}} //setRepresentationSubmit(true);
className="govuk-link" }}
> className="govuk-link"
Back >
</a> Back
</div> </a>
</div> </div>
</div> </div>
</div> </div>
@@ -37,7 +37,7 @@ const RepLandOwner = (props) => {
<div className="govuk-grid-column-full"> <div className="govuk-grid-column-full">
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<h2 className="govuk-heading-m "> <h2 className="govuk-heading-m ">
Representation - landowner Representation for a Land owner
</h2> </h2>
<div className="govuk-form-group"> <div className="govuk-form-group">
@@ -55,7 +55,7 @@ const RepLandOwner = (props) => {
/> />
</div> </div>
</div> </div>
<div className="govuk-grid-row"> {/* <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<Field <Field
className="govuk-input govuk-!-width-three-quarters" className="govuk-input govuk-!-width-three-quarters"
@@ -68,7 +68,7 @@ const RepLandOwner = (props) => {
label="Description of representation" label="Description of representation"
/> />
</div> </div>
</div> </div> */}
<div className="govuk-grid-row"> <div className="govuk-grid-row">
<div className="govuk-form-group"> <div className="govuk-form-group">
<p className="govuk-body"> <p className="govuk-body">
+93 -1
View File
@@ -113,6 +113,16 @@ const CaseSummary = (props) => {
let showDetails = typeof detailsObj != "undefined" ? true : false; let showDetails = typeof detailsObj != "undefined" ? true : false;
var timestamp = Date.parse(
detailsObj.pinswg_representation_period_end_date
);
if (isNaN(timestamp) == false) {
var d = new Date(timestamp);
}
let hasEndDate = typeof d != "undefined";
let showDetailsBlock = let showDetailsBlock =
showDetails == true ? ( showDetails == true ? (
<div> <div>
@@ -139,7 +149,6 @@ const CaseSummary = (props) => {
] || "not entered"} ] || "not entered"}
</dd> </dd>
</div> </div>
{detailsObj.pinswg_agentcontactname != null && {detailsObj.pinswg_agentcontactname != null &&
(_.has( (_.has(
detailsObj, detailsObj,
@@ -279,6 +288,71 @@ const CaseSummary = (props) => {
</dl> </dl>
</div> </div>
</div> </div>
{props.currentView.showReps == "true" &&
_.has(detailsObj, "pinswg_startdate") &&
hasEndDate &&
showReps(
detailsObj.pinswg_startdate,
detailsObj.pinswg_representation_period_end_date
) && (
<div className="govuk-grid-row">
<div className="govuk-grid-column-full">
<div className="govuk-button-group">
<Link
href={{
pathname:
"/myportal/representation",
query: {
case:
currentType ==
"searchResultsObj"
? detailsObj.pinswg_name
: casesObj.reference,
},
}}
>
<a className="govuk-button">
{t(
"case:summary-make-representation-label"
)}
</a>
</Link>
<a
onClick={() => {
//spinnerState();
router.back();
}}
className="govuk-button govuk-button--secondary"
>
{t("case:summary-back-button-label")}
</a>
</div>
</div>
</div>
)}
{props.currentView.showReps == "true" &&
_.has(detailsObj, "pinswg_startdate") &&
hasEndDate &&
showRepsEnded(
detailsObj.pinswg_startdate,
detailsObj.pinswg_representation_period_end_date
) && (
<div className="govuk-grid-row">
<div className="govuk-grid-column-full">
<div className="govuk-button-group">
<div className="govuk-body">
Representation Period ended on{" "}
{formatDates(
detailsObj.pinswg_representation_period_end_date
)}
</div>
</div>
</div>
</div>
)}
{/* 1{" "} {/* 1{" "}
{_.has(detailsObj, "pinswg_startdatetimeiftheevent") && {_.has(detailsObj, "pinswg_startdatetimeiftheevent") &&
detailsObj.pinswg_startdatetimeiftheevent} detailsObj.pinswg_startdatetimeiftheevent}
@@ -725,6 +799,24 @@ const CaseSummary = (props) => {
); );
} }
function showReps(startDate, endDate) {
const date = new Date();
date = new Date(date.toDateString());
const start = new Date(startDate);
const end = new Date(endDate);
return date >= start && date <= end ? true : false;
}
function showRepsEnded(startDate, endDate) {
const date = new Date();
date = new Date(date.toDateString());
const start = new Date(startDate);
const end = new Date(endDate);
return date > start && date > end ? true : false;
}
return ( return (
<> <>
{showDetailsBlock} {showDetailsBlock}
+2 -2
View File
@@ -1540,8 +1540,8 @@ const RenderFileUpload = (field) => {
width="50" width="50"
/> />
<span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5"> <span className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5">
{file.name.slice(file.name.indexOf("_") + 1)} ( {/* {file.name.slice(file.name.indexOf("_") + 1)} ( */}{" "}
({bytesToSize(file.size)}) {file.name}( ({bytesToSize(file.size)})
</span> </span>
</div> </div>
))} ))}
+1 -1
View File
@@ -1,7 +1,7 @@
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation"; import useTranslation from "next-translate/useTranslation";
import TopThree from "./topthree"; import TopThree from "./topthree_reps";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { setCurrentView } from "../../store/currentView/action"; import { setCurrentView } from "../../store/currentView/action";
+237
View File
@@ -0,0 +1,237 @@
import Link from "next/link";
import _ from "lodash";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { setCurrentReference } from "../../store/currentView/action";
import { connect } from "react-redux";
import { parseCookies } from "nookies";
import {
getWatchedCasesProxy,
getPortalModuleDetailsProxy,
deleteWatchedCases,
deleteAwaitingSubmissions,
getAwaitingSubmissionProxy,
} from "../../actions";
import jsonpath from "jsonpath";
import transLookup from "../../data/lookuptranslations.json";
import {
setWatchedCases,
setWatchedCasesDetails,
} from "../../store/watchedCases/action";
import {
setAwaitingSubmission,
setAwaitingSubmissionDetails,
} from "../../store/awaitingSubmission/action";
import { getFormCollectionByID } from "../utils";
const TopThree = (props) => {
let { t } = useTranslation();
const {
showTopThree,
showDetails,
setCurrentReference,
topThreeType,
setWatchedCases,
setWatchedCasesDetails,
setAwaitingSubmission,
setAwaitingSubmissionDetails,
} = props;
const router = useRouter();
const { locale } = router;
let topthreeRow = [];
let showTopThreeArr = showTopThree.value;
const deleteItem = (caseID, topThreeType) => {
let cookies = parseCookies();
//console.log("sssss", caseID, topThreeType);
topThreeType == "watchedCases" &&
deleteWatchedCases(caseID)
.then((data) => data)
.then(() => {
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
setWatchedCases(data),
getDetails(data, "myWatchedCases").then((data) => {
setWatchedCasesDetails(data);
});
});
});
topThreeType == "awaitingSubmission" &&
deleteAwaitingSubmissions(caseID)
.then((data) => {
return data;
})
.then(() => {
getAwaitingSubmissionProxy(cookies.pinsUser).then(
(data) => {
setAwaitingSubmission(data),
getDetails(data, "awaitingSubmission").then(
(data) => {
// console.log(
// "submission get details:",
// data
// );
setAwaitingSubmissionDetails(data);
}
);
}
);
});
};
const getDetails = (resultsObj, detailsType) => {
//console.log(resultsObj);
let detailsArr = [];
resultsObj = resultsObj.value;
const detailsObj = resultsObj.map((searchDetail, index) => {
if (searchDetail.pinswg_appealcasetype == null) {
console.log(
detailsType != "myWatchedCases"
? searchDetail.ticketnumber
: searchDetail[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
]
);
} else {
detailsArr.push(
getPortalModuleDetailsProxy(
getFormCollectionByID(
searchDetail.pinswg_appealcasetype
).LogicalCollectionName,
detailsType != "myWatchedCases"
? searchDetail.ticketnumber
: searchDetail[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
]
)
);
}
});
//console.log(detailsArr);
return Promise.all(detailsArr);
};
const getIncidentId = (topThreeType, objArr) => {
switch (topThreeType) {
case "myCases":
return objArr.incidentid;
break;
case "watchedCases":
return objArr._pinswg_watchedcase_value;
break;
case "myRepresentations":
return objArr.ticketnumber;
break;
case "awaitingSubmission":
return objArr.ticketnumber;
break;
default:
// code block
}
};
let topThreeOnlyArr = showTopThreeArr.slice(0, 3);
Object.keys(topThreeOnlyArr).map((key, index) => {
topthreeRow.push(
<div className="cardModuleItem" key={index}>
<div className="cardModuleDetails">
<div className="cardModuleReference">
<b>Representation ID:</b>
<Link href="#">
<a
className="govuk-link--no-underline"
data-id={index}
onClick={() => {
setCurrentReference({
"currentReference":
topThreeType != "watchedCases"
? topThreeType !=
"myRepresentations"
? showTopThreeArr[key]
.ticketnumber
: showTopThreeArr[key][
"_pinswg_case_value@OData.Community.Display.V1.FormattedValue"
]
: showTopThreeArr[key][
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
],
"currentType": topThreeType,
"incidentid": getIncidentId(
topThreeType,
showTopThreeArr[key]
),
"appealType":
showTopThreeArr[key]
.pinswg_appealcasetype,
});
}}
>
{showTopThreeArr[key].pinswg_name}
</a>
</Link>
</div>
<div className="cardModuleReference">
<b>{t("myportal:case-reference")}:</b>{" "}
{
showTopThreeArr[key][
"_pinswg_case_value@OData.Community.Display.V1.FormattedValue"
]
}
</div>
</div>
</div>
);
});
let noRecordsLabel = "";
switch (topThreeType) {
case "watchedCases":
noRecordsLabel = t("myportal:norecords-watched-cases");
break;
case "myRepresentations":
noRecordsLabel = t("myportal:norecords-representations");
break;
case "myCases":
noRecordsLabel = t("myportal:norecords-cases");
break;
case "awaitingSubmission":
noRecordsLabel = t("myportal:norecords-awaiting-submissions");
break;
}
return (
<>
{topthreeRow.length == 0 ? (
<div>{noRecordsLabel}</div>
) : (
topthreeRow
)}
</>
);
};
const mapDispatchToProps = (dispatch) => {
return {
setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(currentReference));
},
setWatchedCases: (watchedCases) => {
dispatch(setWatchedCases(watchedCases));
},
setWatchedCasesDetails: (watchedCasesDetails) => {
dispatch(setWatchedCasesDetails(watchedCasesDetails));
},
setAwaitingSubmission: (awaitingSubmission) => {
dispatch(setAwaitingSubmission(awaitingSubmission));
},
setAwaitingSubmissionDetails: (awaitingSubmissionDetails) => {
dispatch(setAwaitingSubmissionDetails(awaitingSubmissionDetails));
},
};
};
export default connect(null, mapDispatchToProps)(TopThree);
+8 -5
View File
@@ -306,8 +306,6 @@ const SearchResults = (props) => {
item.incidentid, item.incidentid,
"appealType": "appealType":
item.pinswg_appealcasetype, item.pinswg_appealcasetype,
"showreps":
props.showLoginCheck,
}); });
}} }}
> >
@@ -536,12 +534,17 @@ const SearchResults = (props) => {
)} )}
</dd> </dd>
)} )}
{showLoginCheck == "true" && !session && ( {/* {showLoginCheck == "true" && !session && (
<dd> <dd>
<span <span
className="govuk-summary-list__actionLink watchLink" className="govuk-summary-list__actionLink watchLink"
onClick={() => { onClick={() => {
signIn("email"); // signIn("email");
signIn("email", {
callbackUrl:
"/myportal/searchresults?q=" +
searchString,
});
// selectWatchedCase( // selectWatchedCase(
// cookies.pinsUser, // cookies.pinsUser,
// item.incidentid, // item.incidentid,
@@ -557,7 +560,7 @@ const SearchResults = (props) => {
<span className="eye"></span> <span className="eye"></span>
</span> </span>
</dd> </dd>
)} )} */}
</div> </div>
); );
}) })
+1 -1
View File
@@ -10,7 +10,7 @@ module.exports = {
], ],
"pages": { "pages": {
"*": ["common", "newappeal", "search"], "*": ["common", "newappeal", "search"],
"/": ["common", "home"], "/": ["common", "home", "case"],
"/error": ["common", "home", "myportal"], "/error": ["common", "home", "myportal"],
"/myportal": ["myportal", "common", "home"], "/myportal": ["myportal", "common", "home"],
"/myportal/viewall": ["search", "myportal"], "/myportal/viewall": ["search", "myportal"],
+7 -2
View File
@@ -2,7 +2,7 @@
"page-title": "Cyfeirnod", "page-title": "Cyfeirnod",
"case-card-title": "Reference: APP/B1415/W/20/3271702", "case-card-title": "Reference: APP/B1415/W/20/3271702",
"summary-reference-label": "Cyfeirnod", "summary-reference-label": "Cyfeirnod",
"summary-applicant-label": "Apelydd/Ymgeisydd", "summary-applicant-label": "Apelydd",
"summary-applicantonly-label": "Ymgeisydd", "summary-applicantonly-label": "Ymgeisydd",
"summary-agent-label": "Asiant", "summary-agent-label": "Asiant",
"summary-site-address-label": "Cyfeiriad y Safle", "summary-site-address-label": "Cyfeiriad y Safle",
@@ -78,5 +78,10 @@
"summary-case-website-label": "Gwefan", "summary-case-website-label": "Gwefan",
"summary-case-recommendation-label": "Argymhelliad", "summary-case-recommendation-label": "Argymhelliad",
"summary-no-details-label": "Nid oes unrhyw fanylion ar gael ar hyn o bryd", "summary-no-details-label": "Nid oes unrhyw fanylion ar gael ar hyn o bryd",
"summary-case-relevant-authoritylabel": "Awdurdod perthnasol" "summary-case-relevant-authoritylabel": "Awdurdod perthnasol",
"representation-representation-type": "Pa fath o gynrychiolaeth ydych chi'n ei wneud?",
"representation-onbehalfof": "A ydych yn gweithredu ar ran cwmni, grŵp neu sefydliad",
"representation-onbehalfof-details": "Enw'r cwmni/grŵp/sefydliad",
"representation-comments": "Sylwadau",
"representation-files": "Ffeiliau perthnasol"
} }
+7 -2
View File
@@ -2,7 +2,7 @@
"page-title": "Reference", "page-title": "Reference",
"case-card-title": "Reference: APP/B1415/W/20/3271702", "case-card-title": "Reference: APP/B1415/W/20/3271702",
"summary-reference-label": "Reference", "summary-reference-label": "Reference",
"summary-applicant-label": "Appellant/Applicant", "summary-applicant-label": "Appellant",
"summary-applicantonly-label": "Applicant", "summary-applicantonly-label": "Applicant",
"summary-agent-label": "Agent", "summary-agent-label": "Agent",
"summary-site-address-label": "Site Address", "summary-site-address-label": "Site Address",
@@ -78,5 +78,10 @@
"summary-case-website-label": "Website", "summary-case-website-label": "Website",
"summary-case-recommendation-label": "Recommendation", "summary-case-recommendation-label": "Recommendation",
"summary-no-details-label": "No details currently held", "summary-no-details-label": "No details currently held",
"summary-case-relevant-authoritylabel": "Relevant authority" "summary-case-relevant-authoritylabel": "Relevant authority",
"representation-representation-type": "What kind of representation are you making?",
"representation-onbehalfof": "Are you acting on behalf of a company, group or organisation",
"representation-onbehalfof-details": "Name of the company/group/organisation",
"representation-comments": "Comments",
"representation-files": "Relevant files"
} }
+1 -1
View File
@@ -35,6 +35,7 @@ function Error({ statusCode }, props) {
{t("common:error-instruction-label")} {t("common:error-instruction-label")}
</p> </p>
<a <a
href={session != null ? "#" : "/"}
className="govuk-link" className="govuk-link"
onClick={() => { onClick={() => {
window.localStorage.clear(), window.localStorage.clear(),
@@ -46,7 +47,6 @@ function Error({ statusCode }, props) {
: Router.push("/"); : Router.push("/");
}} }}
> >
{" "}
Go back home Go back home
</a> </a>
</div> </div>
+5
View File
@@ -14,6 +14,8 @@ import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults,
} from "../store/searchOutput/action"; } from "../store/searchOutput/action";
import { setShowReps } from "../store/currentView/action";
import { wrapper } from "../store/store"; import { wrapper } from "../store/store";
const Home = (props) => { const Home = (props) => {
@@ -118,6 +120,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
const searchResultsObj = await getAdvancedSearch(query); const searchResultsObj = await getAdvancedSearch(query);
const searchDetailsObj = await getSearchDetails(searchResultsObj); const searchDetailsObj = await getSearchDetails(searchResultsObj);
const showReps = process.env.SHOWREPRESENTATIONS || false;
store.dispatch(setShowReps(showReps));
store.dispatch(setSearchResults(searchResultsObj)); store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj)); store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setSearch(Object.entries(query))); store.dispatch(setSearch(Object.entries(query)));
+1 -1
View File
@@ -39,7 +39,7 @@ export default async function ApiProxy(req, res) {
var token = await getToken(); var token = await getToken();
var queryUrl = 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"; //"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); //console.log(queryUrl);
@@ -34,7 +34,7 @@ export default async function ApiProxy(req, res) {
queryUrl = queryUrl + getSelectQuery(appealTypeName); queryUrl = queryUrl + getSelectQuery(appealTypeName);
//console.log("///////////\nquery: ", queryUrl, "<<<<end query"); console.log("///////////\nquery: ", queryUrl, "<<<<end query");
return axios return axios
.get( .get(
@@ -26,7 +26,7 @@ export default async function ApiProxy(req, res) {
loggedInUserId + loggedInUserId +
"&$count=true&$orderby=createdon desc"; "&$count=true&$orderby=createdon desc";
//console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl)); console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
return axios return axios
.get( .get(
+11 -4
View File
@@ -3,6 +3,7 @@ import {
getContainers, getContainers,
getBlobs, getBlobs,
createBlob, createBlob,
createRepBlob,
uploadFile, uploadFile,
} from "../../../actions/azurestorage"; } from "../../../actions/azurestorage";
@@ -21,6 +22,7 @@ ApiProxy.post(async (req, res) => {
const appealData = req.body.appealData; const appealData = req.body.appealData;
const containerID = req.body.containerID[0]; const containerID = req.body.containerID[0];
const casefolderID = req.body.casefolderID[0]; const casefolderID = req.body.casefolderID[0];
const repOrAppeal = req.body.repOrAppeal || false;
console.log("there are files:", Object.keys(req.files).length); console.log("there are files:", Object.keys(req.files).length);
@@ -33,10 +35,15 @@ ApiProxy.post(async (req, res) => {
//createContainer(containerID).then((containerName) => { //createContainer(containerID).then((containerName) => {
console.log("does this get folder name:", containerID, casefolderID); console.log("does this get folder name:", containerID, casefolderID);
createBlob(appealData, containerID, casefolderID).then((data) => { repOrAppeal
Object.keys(req.files).length > 0 && ? createRepBlob(appealData, containerID, casefolderID).then((data) => {
uploadFile(req.files, containerID, casefolderID); 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" }); return res.status(200).json({ data: "success" });
+3
View File
@@ -88,6 +88,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setAppealType(appealTypeData)); store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData)); store.dispatch(setLPA(lpaData));
store.dispatch(setLoggedInUserId(loggedInUser)); store.dispatch(setLoggedInUserId(loggedInUser));
thisSession != false &&
store.dispatch(setContainerID(thisSession.user.id));
} }
); );
+35 -17
View File
@@ -6,6 +6,7 @@ import {
getAdvancedSearch, getAdvancedSearch,
getPortalModuleDetails, getPortalModuleDetails,
getWatchedCases, getWatchedCases,
getPersonalAccount,
} from "../../actions"; } from "../../actions";
import Breadcrumbs from "../../components/breadcrumbs"; import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner"; import CookieBanner from "../../components/cookieBanner";
@@ -20,6 +21,12 @@ import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults,
} from "../../store/searchOutput/action"; } from "../../store/searchOutput/action";
import {
setAccountDetails,
setContainerID,
setLoggedInUserId,
} from "../../store/accountDetails/action";
import { setSearch } from "../../store/search/action"; import { setSearch } from "../../store/search/action";
import { wrapper } from "../../store/store"; import { wrapper } from "../../store/store";
import { import {
@@ -27,6 +34,7 @@ import {
setWatchedCasesDetails, setWatchedCasesDetails,
} from "../../store/watchedCases/action"; } from "../../store/watchedCases/action";
import TimeOut from "../../components/timeout"; import TimeOut from "../../components/timeout";
import { getSession, useSession, signIn, signOut } from "next-auth/react";
const Home = (props) => { const Home = (props) => {
const { footerLinks, pages, watchedCases } = props; const { footerLinks, pages, watchedCases } = props;
@@ -64,30 +72,39 @@ const Home = (props) => {
}; };
export const getServerSideProps = wrapper.getServerSideProps( export const getServerSideProps = wrapper.getServerSideProps(
(store) => (store) => async (ctx) => {
async ({ query, req, res }) => { const { query, req, res } = ctx;
console.log("query-", query); console.log("query-", query);
//console.log("search array:", Object.entries(query)); //console.log("search array:", Object.entries(query));
const { cookies } = req; 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 getAdvancedSearch(query),
await getWatchedCases(loggedInUser), await getWatchedCases(loggedInUser),
]); ]);
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([ console.log(accountDetails);
await getSearchDetails(searchResultsObj),
await getDetails(watchedCases, "myWatchedCases"),
]);
store.dispatch(setSearchResults(searchResultsObj)); const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
store.dispatch(setSearchDetails(searchDetailsObj)); await getSearchDetails(searchResultsObj),
store.dispatch(setWatchedCases(watchedCases)); await getDetails(watchedCases, "myWatchedCases"),
store.dispatch(setWatchedCasesDetails(watchedCasesDetails)); ]);
store.dispatch(setSearch(Object.entries(query)));
} 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) => { const getDetails = (resultsObj, detailsType) => {
@@ -123,6 +140,7 @@ const getDetails = (resultsObj, detailsType) => {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
accountDetails: state.accountDetails,
currentView: state.currentView, currentView: state.currentView,
search: state.search, search: state.search,
searchResultsObj: state.searchResultsObj, searchResultsObj: state.searchResultsObj,
+7 -1
View File
@@ -14,6 +14,7 @@ import {
getWatchedCases, getWatchedCases,
consoleLogger, consoleLogger,
getCase, getCase,
getPortalLogin,
} from "../../actions"; } from "../../actions";
import { createContainer } from "../../actions/azurestorage"; import { createContainer } from "../../actions/azurestorage";
import Breadcrumbs from "../../components/breadcrumbs"; import Breadcrumbs from "../../components/breadcrumbs";
@@ -158,10 +159,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
const { cookies } = req; const { cookies } = req;
let loggedInUser = cookies.pinsUser; let loggedInUserCookie = cookies.pinsUser;
let thisSession = await getSession(ctx); 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); console.log("nextAuth Session:", thisSession);
if (_.has(thisSession, "user") == false) { if (_.has(thisSession, "user") == false) {
+3
View File
@@ -99,6 +99,9 @@ const Home = (props) => {
searchResultsObj={ searchResultsObj={
props.searchResultsObj.searchResultsObj props.searchResultsObj.searchResultsObj
} }
searchDetailsObj={
props.searchResultsObj.searchDetailsObj
}
myRepresentations={ myRepresentations={
props.myRepresentations.myRepresentations props.myRepresentations.myRepresentations
} }
+14 -3
View File
@@ -7,6 +7,8 @@ import {
getBasicSearch, getBasicSearch,
getPortalModuleDetails, getPortalModuleDetails,
getWatchedCases, getWatchedCases,
consoleLogger,
getPortalLogin,
} from "../../actions"; } from "../../actions";
import Breadcrumbs from "../../components/breadcrumbs"; import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner"; import CookieBanner from "../../components/cookieBanner";
@@ -76,13 +78,13 @@ export const getServerSideProps = wrapper.getServerSideProps(
const { cookies } = req; const { cookies } = req;
let loggedInUser = cookies.pinsUser; let loggedInUserCookie = cookies.pinsUser;
let thisSession = await getSession(ctx); let thisSession = await getSession(ctx);
let [searchResultsObj, watchedCases] = await Promise.all([ let [searchResultsObj, loggedInUser] = await Promise.all([
await getBasicSearch(query.q), await getBasicSearch(query.q),
await getWatchedCases(loggedInUser), await getPortalLogin(thisSession.user.email),
]); ]);
searchResultsObj = searchResultsObj =
@@ -96,6 +98,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
//console.log("sssss", searchResultsObj); //console.log("sssss", searchResultsObj);
loggedInUser = loggedInUser.value[0].contactid;
const watchedCases = await getWatchedCases(loggedInUser);
//console.log("sssss", loggedInUser);
const [accountDetails, searchDetailsObj, watchedCasesDetails] = const [accountDetails, searchDetailsObj, watchedCasesDetails] =
await Promise.all([ await Promise.all([
await getPersonalAccount(loggedInUser), await getPersonalAccount(loggedInUser),
@@ -109,6 +117,9 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setWatchedCases(watchedCases)); store.dispatch(setWatchedCases(watchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails)); store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setLoggedInUserId(loggedInUser)); store.dispatch(setLoggedInUserId(loggedInUser));
thisSession != false &&
store.dispatch(setContainerID(thisSession.user.id));
} }
); );
+6 -3
View File
@@ -14,6 +14,7 @@ import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults,
} from "../store/searchOutput/action"; } from "../store/searchOutput/action";
import { setShowReps } from "../store/currentView/action";
import { wrapper } from "../store/store"; import { wrapper } from "../store/store";
import _ from "lodash"; import _ from "lodash";
@@ -116,9 +117,9 @@ const Home = (props) => {
}; };
export const getServerSideProps = wrapper.getServerSideProps( export const getServerSideProps = wrapper.getServerSideProps(
(store) => (store) => async (ctx) => {
async ({ query, req, res }) => { const { query, req, res } = ctx;
console.log("query-", query); console.log("query-", query);
let isLinked = let isLinked =
typeof query.lk != "undefined" && query.lk == "1" typeof query.lk != "undefined" && query.lk == "1"
@@ -127,6 +128,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
//console.log("is linked:", isLinked); //console.log("is linked:", isLinked);
const showLoginCheck = process.env.SHOWLOGIN || false; const showLoginCheck = process.env.SHOWLOGIN || false;
const showReps = process.env.SHOWREPRESENTATIONS || false;
store.dispatch(setShowReps(showReps));
let searchResultsObj = await getBasicSearch(query.q); let searchResultsObj = await getBasicSearch(query.q);
+8
View File
@@ -7,6 +7,7 @@ export const currentViewActionTypes = {
SETREPRESENTATIONSUBMITCONFIRMATION: "SETREPRESENTATIONSUBMITCONFIRMATION", SETREPRESENTATIONSUBMITCONFIRMATION: "SETREPRESENTATIONSUBMITCONFIRMATION",
SETCURRENTLINKEDCASES: "SETCURRENTLINKEDCASES", SETCURRENTLINKEDCASES: "SETCURRENTLINKEDCASES",
SETCURRENTPAGE: "SETCURRENTPAGE", SETCURRENTPAGE: "SETCURRENTPAGE",
SETSHOWREPS: "SETSHOWREPS",
}; };
export const getCurrentViewObj = () => (dispatch) => { export const getCurrentViewObj = () => (dispatch) => {
@@ -72,3 +73,10 @@ export const setCurrentPage = (currentPage) => (dispatch) => {
currentPage: currentPage, currentPage: currentPage,
}); });
}; };
export const setShowReps = (showReps) => (dispatch) => {
return dispatch({
type: currentViewActionTypes.SETSHOWREPS,
showReps: showReps,
});
};
+5
View File
@@ -49,6 +49,11 @@ export default function reducer(state = currentViewInitialState, action) {
...state, ...state,
currentPage: action.currentPage, currentPage: action.currentPage,
}; };
case currentViewActionTypes.SETSHOWREPS:
return {
...state,
showReps: action.showReps,
};
default: default:
return state; return state;
} }