diff --git a/actions/index.js b/actions/index.js
index 015e296e..28b80bd6 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -1,5 +1,7 @@
import axios from "axios";
import https from "https";
+import CryptoJS from "crypto-js";
+
//import {XMLHttpRequest} from 'xmlhttprequest';
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
@@ -13,9 +15,62 @@ if (process.browser) {
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
}
+const API_PATH = "/api/data/v8.2/";
+
+//const WEBAPI_URL = "https://devcrm2016.llcdt.gov.wales/DVPINS" + API_PATH;
+
+const WEBAPI_URL = "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
+
const agent = new https.Agent({
rejectUnauthorized: false,
});
+
+export const getSASToken = () => {
+ // var ns = "dev-pedw-ns.servicebus.windows.net";
+ // path = "dev-pedw-hc";
+ // keyrule = "devpedwnspolicy";
+ // key = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
+
+ var m_ResourceURI = "dev-pedw-ns.servicebus.windows.net";
+ var m_Path = "dev-pedw-hc";
+ var m_SasKey = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
+ var m_SasKeyName = "devpedwnspolicy";
+
+ var encodedResourceUri = encodeURIComponent(
+ "https://" + m_ResourceURI + "/" + m_Path + "/"
+ );
+
+ var t0 = new Date(1970, 1, 1, 0, 0, 0, 0);
+ var t1 = new Date();
+ var expireInSeconds =
+ +(31 * 24 * 3600) + 3600 + (((t1.getTime() - t0.getTime()) / 1000) | 0);
+
+ //the line below is a hack that converts to UTF8
+ var plainSignature = JSON.parse(
+ JSON.stringify(encodedResourceUri + "\n" + expireInSeconds)
+ );
+
+ var hash = CryptoJS.HmacSHA256(plainSignature, m_SasKey);
+ var base64HashValue = CryptoJS.enc.Base64.stringify(hash);
+
+ var token =
+ "SharedAccessSignature sr=" +
+ encodedResourceUri +
+ "&sig=" +
+ encodeURIComponent(base64HashValue) +
+ "&se=" +
+ expireInSeconds +
+ "&skn=" +
+ m_SasKeyName;
+
+ return token;
+};
+
+const accessToken =
+ "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSIsImtpZCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSJ9.eyJhdWQiOiJodHRwczovL2RldmNybTIwMTYubGxjZHQuZ292LndhbGVzLyIsImlzcyI6Imh0dHA6Ly9mcy50ZXN0Lmdvdi53YWxlcy9hZGZzL3NlcnZpY2VzL3RydXN0IiwiaWF0IjoxNjMxMjU4ODAzLCJuYmYiOjE2MzEyNTg4MDMsImV4cCI6MTYzMTI4NzYwMywidXBuIjpbIlJvYmVydC5Cb25kQHRlc3QuZ292LndhbGVzIiwicm9iZXJ0LmJvbmRAdGVzdC5nb3Yud2FsZXMiXSwicHJpbWFyeXNpZCI6IlMtMS01LTIxLTE4MDA4NDIwNzYtMjQ1NTYwNjU5LTQyMTU3NzU0NjktMTY2MjgiLCJ1bmlxdWVfbmFtZSI6IlhNXFxCb25kUiIsImFwcHR5cGUiOiJQdWJsaWMiLCJhcHBpZCI6IjQyN2ZhNzljLWI1ZmMtNDJhZC04M2Q0LTQxMGIwMzk0OGFiNiIsImF1dGhtZXRob2QiOiJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvYXV0aGVudGljYXRpb25tZXRob2Qvd2luZG93cyIsImF1dGhfdGltZSI6IjIwMjEtMDktMTBUMDc6MjY6MzQuMjI0WiIsInZlciI6IjEuMCJ9.XFymIQJVavP-7-8V7LdoYDD4836Z-aSxveMQDD1P3y_9M3Tiy3zINiLxCbSr8JaymFOuLOzWcnNXwh7HHZKY6gDC6tD1ALVKCBXmgTDaoR9j7XAOxSUaRl6ArIecd7o6UcqsHAvfpb5zu-ZIy0KxV9PFRxY4JHF_tfLAeAMnqIBq-yDrNBOlbg4Kd9VuAbAK5lNWp-BiMIzMqZUIrmD9HjwE17SWaEnApCNqTcGZ4h2EqDBWgqKae7B1AzoV_7mfp7CscLUBLGdbM-XsXw3t_AVc0xDHoOMuWfsoMfioJONoMsPqTNUY7VQev1pMrFDEFN-jqP4yqSdNlev6H47SCg";
+
+const SASToken = getSASToken();
+
const crmHeaders = {
withCredentials: true,
headers: {
@@ -23,62 +78,118 @@ const crmHeaders = {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Accept": "application/json",
- "Prefer": 'odata.include-annotations="*"',
- agent,
+ "Prefer": 'odata.include-annotations="*",return=representation',
+ "Authorization": "Bearer " + accessToken,
},
- auth: {
- username: "xm\bondr",
- password: "!Sky9fish1972",
+};
+
+const crmHeadersReturn = {
+ headers: {
+ "OData-MaxVersion": "4.0",
+ "OData-Version": "4.0",
+ "Accept": "application/json",
+ "Prefer": "return=representation",
+ "Content-Type": "application/json",
+ "Authorization": "Bearer " + accessToken,
+ },
+};
+
+const azureHeaders = {
+ headers: {
+ "OData-MaxVersion": "4.0",
+ "OData-Version": "4.0",
+ "Accept": "application/json",
+ "Prefer": 'odata.include-annotations="*",return=representation',
+ "Content-Type": "application/json",
+ "ServiceBusAuthorization": SASToken,
},
};
export const getBasicSearch = (searchString) => {
- console.log("got to axios", searchString);
- console.log("api_root: ", BASE_URL);
- return (
- axios
- //.get("https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=contains(title, '" + searchString + "')&$count=true", crmHeaders)
- //.get("https://jsonplaceholder.typicode.com/todos/1",{proxy:{protocol: 'http',host:'lon3.sme.zscloud.net',port: 80}})
- .get(BASE_URL + "/api/searchresults2", {
- httpsAgent: new https.Agent({ rejectUnauthorized: false }),
- })
- .then((res) => res.data)
- .catch((error) => {
- console.log("thiserror", error);
- })
- );
+ return axios
+ .get(
+ WEBAPI_URL +
+ "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" +
+ searchString +
+ "') and pinswg_appealcasetype ne null &$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
+
+export const getBasicSearchDetails = (appealType, caseReference) => {
+ return axios
+ .get(
+ WEBAPI_URL +
+ appealType +
+ "?$filter=pinswg_name eq '" +
+ caseReference +
+ "'&$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
};
export const getFormData = (whichForm) => {
console.log("got to axios", whichForm);
console.log("api_root: ", BASE_URL);
- return (
- axios
- //.get("api/appealforms/pinswg_dns", {
- //.get("api/appealforms/pinswg_planningobligationappeals106", {
- //.get("api/appealforms/pinswg_planningconditionss73s79", {
- //.get("api/appealforms/pinswg_row", {
- //.get("api/appealforms/pinswg_transportandworkact", {
- //.get("api/appealforms/pinswg_harbourrevisionorder", {
- //.get("api/appealforms/pinswg_planningappeals78", {
- //.get(api/appealforms/pinswg_householderappealhas", {
- .get(BASE_URL + "/api/appealforms/pinswg_" + whichForm, {
- httpsAgent: new https.Agent({ rejectUnauthorized: false }),
- })
- .then((res) => res.data)
- .catch((error) => {
- console.log("thiserror", error);
- })
- );
+ return axios
+ .get(
+ WEBAPI_URL +
+ "systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode%20eq%20%27pinswg_" +
+ whichForm +
+ "%27and%20type%20eq%202)&$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
+
+export const getMandatoryFields = (whichForm) => {
+ return axios
+ .get(
+ WEBAPI_URL +
+ "EntityDefinitions(LogicalName='pinswg_" +
+ whichForm +
+ "')/Attributes?$count=true&$select=LogicalName,RequiredLevel",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
+
+export const getPickLists = (whichForm) => {
+ return axios
+ .get(
+ WEBAPI_URL +
+ "EntityDefinitions(LogicalName='pinswg_" +
+ whichForm +
+ "')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
};
export const getAppealsTypes = () => {
- console.log("got to axios: appeal types");
- console.log("api_root: ", BASE_URL);
return axios
- .get(BASE_URL + "/api/lookups/pinswg_appealcasetype", {
- httpsAgent: new https.Agent({ rejectUnauthorized: false }),
- })
+ .get(
+ WEBAPI_URL +
+ "stringmaps?$filter=attributename%20eq%20%27pinswg_appealcasetype%27&$count=true&$select=value,stringmapid,organizationid,attributevalue",
+ azureHeaders
+ )
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -190,12 +301,7 @@ export const getAppealTypeDetail = (caseReference, appealcasetype) => {
export const getLPA = () => {
console.log("api_root: ", BASE_URL);
return axios
-
- .get(
- BASE_URL + "/api/lookups/pinswg_lpa",
- //.get("https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/accounts?$select=name",
- { httpsAgent: new https.Agent({ rejectUnauthorized: false }) }
- )
+ .get(WEBAPI_URL + "accounts?$count=true&$select=name", azureHeaders)
.then((res) => res.data)
.catch((error) => {
console.log("thi serror", error);
@@ -217,61 +323,66 @@ export const getPersonalAccount = () => {
});
};
-function makeid(length) {
- var result = "";
- var characters =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- var charactersLength = characters.length;
- for (var i = 0; i < length; i++) {
- result += characters.charAt(
- Math.floor(Math.random() * charactersLength)
- );
- }
- return result;
-}
+export const createCase = (appealTypeId) => {
+ appealTypeId = parseInt(appealTypeId);
+ var data = JSON.stringify({
+ "title": "insertion test case",
+ "customerid_contact@odata.bind":
+ "/contacts(f8b454ed-eded-eb11-aac7-00224800be9c)",
+ "pinswg_appealcasetype": appealTypeId,
+ });
-export const createCase = (lpaType, appealType) => {
- console.log();
-
- const lastPart = makeid(6);
-
- const middlePart = Math.floor(100000 + Math.random() * 900000);
-
- return "CAS-" + middlePart + "-" + lastPart.toUpperCase();
+ var config = {
+ method: "post",
+ url: WEBAPI_URL + "incidents",
+ headers: {
+ "OData-MaxVersion": "4.0",
+ "OData-Version": "4.0",
+ "Accept": "application/json",
+ "Prefer": 'odata.include-annotations="*",return=representation',
+ "Content-Type": "application/json",
+ "ServiceBusAuthorization": SASToken,
+ },
+ data: data,
+ };
+ console.log(config);
+ return axios(config)
+ .then((res) => {
+ // console.log("posted ", res.data);
+ return res.data;
+ })
+ .catch((error) => {
+ console.log("this serror", error);
+ });
};
-// var req = new XMLHttpRequest();
-// req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=contains(title, '000')&$count=true", true);
-// req.setRequestHeader("OData-MaxVersion", "4.0");
-// req.setRequestHeader("OData-Version", "4.0");
-// req.setRequestHeader("Accept", "application/json");
-// req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
-// req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
-// req.onreadystatechange = function() {
-// if (this.readyState === 4) {
-// req.onreadystatechange = null;
-// if (this.status === 200) {
-// var results = JSON.parse(this.response);
-// var recordCount = results["@odata.count"];
-// for (var i = 0; i < results.value.length; i++) {
-// var _accountid_value = results.value[i]["_accountid_value"];
-// var _accountid_value_formatted = results.value[i]["_accountid_value@OData.Community.Display.V1.FormattedValue"];
-// var _accountid_value_lookuplogicalname = results.value[i]["_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
-// var _customerid_value = results.value[i]["_customerid_value"];
-// var _customerid_value_formatted = results.value[i]["_customerid_value@OData.Community.Display.V1.FormattedValue"];
-// var _customerid_value_lookuplogicalname = results.value[i]["_customerid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
-// var pinswg_appealcasetype = results.value[i]["pinswg_appealcasetype"];
-// var pinswg_appealcasetype_formatted = results.value[i]["pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"];
-// var statuscode = results.value[i]["statuscode"];
-// var ticketnumber = results.value[i]["ticketnumber"];
-// var title = results.value[i]["title"];
-// }
-// } else {
-// Xrm.Utility.alertDialog(this.statusText);
-// }
-// }
-// };
-// req.send();
+export const updateCase = (incidentId, updateBody, updateFormCollection) => {
+ var data = JSON.stringify(updateBody);
+
+ var config = {
+ method: "patch",
+ //url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
+ url: "/api/proxy/" + updateFormCollection + "(" + incidentId + ")",
+ headers: {
+ "OData-MaxVersion": "4.0",
+ "OData-Version": "4.0",
+ "Accept": "application/json",
+ "Prefer": 'odata.include-annotations="*",return=representation',
+ "Content-Type": "application/json",
+ "ServiceBusAuthorization": SASToken,
+ },
+ data: data,
+ };
+ // console.log(config);
+ return axios(config)
+ .then((res) => {
+ console.log("patched ", res.data);
+ return res.data;
+ })
+ .catch((error) => {
+ console.log("thi serror", error);
+ });
+};
// //jquery version to get case number from an lpa and an appeal type
// var entity = {};
@@ -305,45 +416,62 @@ export const createCase = (lpaType, appealType) => {
// });
export const getMyCases = () => {
- return axios
-
- .get(BASE_URL + "/api/lookups/myCases", {
- httpsAgent: new https.Agent({ rejectUnauthorized: false }),
- })
- .then((res) => res.data)
- .catch((error) => {
- console.log("thi serror", error);
- });
+ return (
+ axios
+ // .get(BASE_URL + "/api/lookups/myCases", {
+ // httpsAgent: new https.Agent({ rejectUnauthorized: false }),
+ // })
+ .get(
+ WEBAPI_URL +
+ "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thi serror", error);
+ })
+ );
};
export const getMyRepresentations = () => {
- return axios
-
- .get(BASE_URL + "/api/lookups/myRepresentations", {
- httpsAgent: new https.Agent({ rejectUnauthorized: false }),
- })
- .then((res) => res.data)
- .catch((error) => {
- console.log("thi serror", error);
- });
+ return (
+ axios
+ // .get(BASE_URL + "/api/lookups/myRepresentations", {
+ // httpsAgent: new https.Agent({ rejectUnauthorized: false }),
+ // })
+ .get(
+ WEBAPI_URL +
+ "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thi serror", error);
+ })
+ );
};
export const getWatchedCases = () => {
- return axios
+ return (
+ axios
- .get(BASE_URL + "/api/lookups/watchedCases", {
- httpsAgent: new https.Agent({ rejectUnauthorized: false }),
- })
- .then((res) => res.data)
- .catch((error) => {
- w;
- console.log("thi serror", error);
- });
+ // .get(BASE_URL + "/api/lookups/watchedCases", {
+ // httpsAgent: new https.Agent({ rejectUnauthorized: false }),
+ // })
+ .get(
+ WEBAPI_URL +
+ "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true",
+ azureHeaders
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("this serror", error);
+ })
+ );
};
export const getAwaitingSubmission = () => {
return axios
-
.get(BASE_URL + "/api/lookups/awaitingSubmission", {
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
})
diff --git a/components/case.js b/components/case.js
index 4984fd98..2c06f59c 100644
--- a/components/case.js
+++ b/components/case.js
@@ -27,6 +27,7 @@ const CaseSummary = (props) => {
caseReference={props.caseReference}
currentType={props.currentType}
searchResultsObj={props.searchResultsObj}
+ searchDetailsObj={props.searchDetailsObj}
searchString={props.searchString}
/>
diff --git a/components/case/summary.js b/components/case/summary.js
index 02521be7..fd4c1325 100644
--- a/components/case/summary.js
+++ b/components/case/summary.js
@@ -16,15 +16,17 @@ const CaseSummary = (props) => {
watchedCases,
awaitingSubmission,
searchResultsObj,
+ searchDetailsObj,
currentType,
} = props;
let setCaseQueryObj = props[currentType];
+
var casesObj = {};
currentType == "searchResultsObj"
? (casesObj = jsonpath.query(
- setCaseQueryObj,
+ searchResultsObj,
'$..[?(@.title=="' + caseReference + '")]'
))
: (casesObj = jsonpath.query(
@@ -34,6 +36,14 @@ const CaseSummary = (props) => {
casesObj = Object.assign({}, ...casesObj);
+ var detailsObj = {};
+
+ detailsObj = jsonpath.query(
+ searchDetailsObj,
+ '$..[?(@.pinswg_name=="' + caseReference + '")]'
+ );
+
+ detailsObj = detailsObj[0];
return (
@@ -41,7 +51,7 @@ const CaseSummary = (props) => {
Reference:{" "}
{currentType == "searchResultsObj"
- ? casesObj.title
+ ? detailsObj.pinswg_name
: casesObj.reference}
@@ -51,7 +61,11 @@ const CaseSummary = (props) => {
{t("case:summary-applicant-label")}
- {casesObj.appellantApplicant || ""}
+ {
+ detailsObj[
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ }
@@ -59,7 +73,9 @@ const CaseSummary = (props) => {
{t("case:summary-agent-label")}
- Mr A Agent
+ {_.has(detailsObj, "pinswg_agentcontactname")
+ ? detailsObj.pinswg_agentcontactname
+ : ""}
@@ -67,12 +83,25 @@ const CaseSummary = (props) => {
{t("case:summary-site-address-label")}
- {casesObj.address1 || ""}
+ {_.has(detailsObj, "pinswg_siteaddressline1")
+ ? detailsObj.pinswg_siteaddressline1
+ : ""}
- {casesObj.town || ""}
-
+ {_.has(detailsObj, "pinswg_siteaddressline1")
+ ? detailsObj.pinswg_siteaddressline2
+ : ""}
- {casesObj.postcode || ""}
+ {_.has(detailsObj, "pinswg_siteaddressline1")
+ ? detailsObj.pinswg_siteaddresstown
+ : ""}
+
+ {_.has(detailsObj, "pinswg_siteaddressline1")
+ ? detailsObj.pinswg_siteaddresscounty
+ : ""}
+
+ {_.has(detailsObj, "pinswg_siteaddressline1")
+ ? detailsObj.pinswg_siteaddresspostcode
+ : ""}
@@ -120,7 +149,13 @@ const CaseSummary = (props) => {
{t("case:summary-lpa-label")}
- {casesObj.lpaname || ""}
+ {_.has(detailsObj, [
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
@@ -130,8 +165,12 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDetails.caseSummary ||
- ""}
+ {_.has(
+ detailsObj,
+ "pinswg_casedescription"
+ )
+ ? detailsObj.pinswg_casedescription
+ : ""}
@@ -142,8 +181,14 @@ const CaseSummary = (props) => {
{" "}
- {casesObj.caseDetails.caseOfficer ||
- ""}
+ {/* {casesObj.caseDetails.caseOfficer ||
+ ""} */}
+ {_.has(
+ detailsObj,
+ "pinswg_casedescription"
+ )
+ ? detailsObj.pinswg_casedescription
+ : ""}
@@ -151,8 +196,13 @@ const CaseSummary = (props) => {
{t("case:summary-procedure-label")}
- {casesObj.caseDetails.procedure ||
- ""}
+ {_.has(detailsObj, [
+ "pinswg_procedure@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "pinswg_procedure@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
@@ -170,15 +220,21 @@ const CaseSummary = (props) => {
{t("case:summary-decision-label")}
- {casesObj.caseDetails.decision ||
- ""}
+ {_.has(detailsObj, [
+ "pinswg_decision@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "pinswg_decision@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
+
-
+ {/*
{casesObj.caseDetails
.outcome_document || ""}
-
+ */}
@@ -188,8 +244,13 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDetails
- .caseLinkStatus || ""}
+ {_.has(detailsObj, [
+ "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "pinswg_linkedstatus@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "Not linked"}
@@ -199,8 +260,8 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDetails.linkedCases ||
- ""}
+ {/* {casesObj.caseDetails.linkedCases ||
+ ""} */}
@@ -219,8 +280,14 @@ const CaseSummary = (props) => {
{t("case:summary-start-date-label")}
- {casesObj.caseDates.start_date ||
- "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_startdate@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_startdate@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -231,8 +298,14 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDates
- .questionnaireDue || "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_questionnaireduedate@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -243,8 +316,14 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDates.statementsDue ||
- "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_statementduedate@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -255,9 +334,14 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDates
- .interestedPartyCommentsdue ||
- "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_otherpartiesstatement@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -268,9 +352,14 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDates
- .appellantLPAFinalCommentsdue ||
- "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -281,8 +370,14 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDates
- .inquiryEvidenceDue || "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_finalcommentsduedate@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -291,8 +386,14 @@ const CaseSummary = (props) => {
{t("case:summary-event-date-label")}
- {casesObj.caseDates.eventDate ||
- "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_dateeventrequested@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -303,8 +404,14 @@ const CaseSummary = (props) => {
)}
- {casesObj.caseDates.decisionDate ||
- "N/A"}
+ {_.has(
+ detailsObj,
+ "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue"
+ )
+ ? detailsObj[
+ "pinswg_dateoflpadecision@OData.Community.Display.V1.FormattedValue"
+ ]
+ : "N/A"}
@@ -313,6 +420,7 @@ const CaseSummary = (props) => {
+
{/*
diff --git a/components/elements/index.js b/components/elements/index.js
index 60e6afe2..e3824ff1 100644
--- a/components/elements/index.js
+++ b/components/elements/index.js
@@ -5,6 +5,7 @@ import DatePicker from "react-datepicker";
import React, { useState } from "react";
import "react-datepicker/dist/react-datepicker.css";
import moment from "moment";
+import jsonpath from "jsonpath";
const RenderTextfield = ({
id,
@@ -43,21 +44,39 @@ const RenderTextfield = ({
};
export function Textfield(props) {
- const { name, label, validate } = props;
+ const { name, label, validate, ticketnumber } = props;
const required = (value) => (value ? undefined : "Required");
-
- return (
-
- );
+ if (name == "pinswg_name") {
+ return (
+
+
+ {label}
+
+
+
+ );
+ } else {
+ return (
+
+ );
+ }
}
const RenderMultiline = ({
@@ -348,7 +367,7 @@ export function YesNofield(props) {
id={props.name}
className="govuk-radios__input"
//validate={[required]}
- errorMsg="Select and option"
+ errorMsg="Select an option"
component={RenderYesNo}
/>
);
@@ -356,48 +375,24 @@ export function YesNofield(props) {
const RenderPickList = ({
datafieldname,
+ picklistData,
name,
label,
input,
meta: { touched, errorStr },
}) => {
- const fetcher = (url) => fetch(url).then((res) => res.json());
-
- const { data, error } = useSWR("/api/lookups/" + datafieldname, fetcher);
- if (error)
- return (
-
-
- {label}
-
-
- empty
-
-
- );
- if (!data)
- return (
-
- );
- //console.log(JSON.stringify(data.GlobalOptionSet.Options));
-
- const dropdownObj = data.GlobalOptionSet.Options;
-
+ var dropdownObj = jsonpath.query(
+ picklistData,
+ "$..value[?(@.LogicalName=='" + datafieldname + "')]..Options"
+ );
+ dropdownObj = dropdownObj[0];
return (
Select...
{Object.keys(dropdownObj).map((key, index) => {
return (
-
+
{dropdownObj[key].Label.LocalizedLabels[0].Label}
);
@@ -421,6 +416,7 @@ export function PickList(props) {
name={props.name}
component={RenderPickList}
datafieldname={datafieldname}
+ picklistData={props.picklistData}
/>
);
@@ -438,12 +434,13 @@ export function NumericField(props) {
name={props.name}
id={props.name}
component="input"
- type="text"
+ type="number"
className="govuk-input govuk-input--width-20"
spellCheck="false"
//aria-describedby="account-number-hint"
pattern="[0-9]*"
inputMode="numeric"
+ parse={Number}
/>
);
@@ -461,12 +458,13 @@ export function DecimalField(props) {
name={props.name}
id={props.name}
component="input"
- type="text"
- className="govuk-input govuk-input--width-10"
+ type="number"
+ className="govuk-input govuk-input--width-10"
spellCheck="false"
//aria-describedby="account-number-hint"
pattern="[0-9]*"
inputMode="numeric"
+ parse={Number}
/>
);
diff --git a/components/homepage/dns.js b/components/homepage/dns.js
new file mode 100644
index 00000000..3247c710
--- /dev/null
+++ b/components/homepage/dns.js
@@ -0,0 +1,30 @@
+import Link from "next/link";
+import { useState } from "react";
+import { useRouter } from "next/router";
+import useTranslation from "next-translate/useTranslation";
+
+export default function Dns() {
+ let { t } = useTranslation();
+ return (
+
+
+
+ Developments of National Significance
+
+
+
+ A Development of National Significance (DNS) is a type
+ of planning application for a large infrastructure
+ project of national importance in Wales. Here you can
+ find out about proposed DNS applications.
+
+
+
+
+ View all Applications
+
+
+
+
+ );
+}
diff --git a/components/main.js b/components/main.js
index c5095231..03cda53b 100644
--- a/components/main.js
+++ b/components/main.js
@@ -2,35 +2,35 @@ import Link from "next/link";
import { useRouter } from "next/router";
import { useContext } from "react";
import useTranslation from "next-translate/useTranslation";
-import Login from "./homepage/login";
-import CaseSearch from "./homepage/casesearch";
-import Inspectorate from "./homepage/inspectorate";
-import CaseComment from "./homepage/casecomment";
-
+import Login from "./homepage/login";
+import CaseSearch from "./homepage/casesearch";
+import Inspectorate from "./homepage/inspectorate";
+import CaseComment from "./homepage/casecomment";
+import Dns from "./homepage/dns";
export default function Home({ children, pages }) {
- let { t } = useTranslation();
+ let { t } = useTranslation();
- const router = useRouter();
- const { locale } = router;
+ const router = useRouter();
+ const { locale } = router;
- return (
-
-
-
- );
+ return (
+
+
+
+ );
}
diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js
index fc4bba22..de81f1ee 100644
--- a/components/myportal/topthree.js
+++ b/components/myportal/topthree.js
@@ -32,12 +32,13 @@ const TopThree = (props) => {
onClick={() => {
setCurrentReference({
"currentReference":
- showTopThree.value[i].reference,
+ showTopThree.value[i]
+ .ticketnumber,
"currentType": topThreeType,
});
}}
>
- {showTopThree.value[i].reference}
+ {showTopThree.value[i].ticketnumber}
diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js
index 4455ad35..6a2eedd3 100644
--- a/components/myportal/viewall.js
+++ b/components/myportal/viewall.js
@@ -34,7 +34,7 @@ const ViewAllResults = (props) => {
Case Reference:
- {resultsArr[index].reference}
+ {resultsArr[index].ticketnumber}
@@ -51,11 +51,15 @@ const ViewAllResults = (props) => {
Appellant/Applicant:
- {resultsArr[index].appellantApplicant}
+ Mr smith
Authority:
- {resultsArr[index].lpaname}
+ {
+ resultsArr[index][
+ "_customerid_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ }
Case Type:
diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js
index 6eda3f21..4e32b4a1 100644
--- a/components/newappeal/buildcheckrow.js
+++ b/components/newappeal/buildcheckrow.js
@@ -2,6 +2,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import xpath from "xpath";
+import jsonpath from "jsonpath";
import BuildCheckField from "./buildCheckfield";
import { useSelector, shallowEqual, connect } from "react-redux";
import {
@@ -22,6 +23,7 @@ let BuildCheckRow = (props) => {
sectionCount,
onSubmit,
updateCurrentSection,
+ mandatoryFieldsData,
} = props;
const parser = new DOMParser();
@@ -56,44 +58,59 @@ let BuildCheckRow = (props) => {
rowXML[key].outerHTML,
"text/xml"
);
- var rows = xpath.select("//label/@description", doc);
- var fieldtype = xpath.select("//@classid", doc);
- var datafieldname = xpath.select("//@datafieldname", doc);
+ if (_.isEmpty(rowXML[key].innerHTML)) {
+ ("");
+ } else {
+ var rows = xpath.select("//label/@description", doc);
+ var fieldtype = xpath.select("//@classid", doc);
+ var datafieldname = xpath.select("//@datafieldname", doc);
+ const isRequiredField = jsonpath.query(
+ mandatoryFieldsData,
+ "$..value[?(@.LogicalName=='" +
+ datafieldname[0].value +
+ "')]"
+ );
- return (
-
- );
+ if (isRequiredField[0].RequiredLevel.Value != "None") {
+ return (
+
+ );
+ } else {
+ return null;
+ }
+ }
})}
>
);
diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js
index 310fa566..aa252a3d 100644
--- a/components/newappeal/buildchecksection.js
+++ b/components/newappeal/buildchecksection.js
@@ -28,6 +28,7 @@ let BuildCheckSection = (props) => {
handleSubmit,
formTitle,
setCurrentSection,
+ mandatoryFieldsData,
} = props;
const parser = new DOMParser();
@@ -56,32 +57,30 @@ let BuildCheckSection = (props) => {
return (
-
+
Are these answers correct?
- {Object.keys(titles).map((key) => (
- <>
-
+
+ {Object.keys(titles).map((key) => (
+ <>
+ {/*
{titles[key].value}
-
+ */}
-
-
- >
- ))}
-
+ >
+ ))}
+
@@ -94,7 +93,6 @@ let BuildCheckSection = (props) => {
-
);
};
diff --git a/components/newappeal/buildfield.js b/components/newappeal/buildfield.js
index 520749ee..00abafa9 100644
--- a/components/newappeal/buildfield.js
+++ b/components/newappeal/buildfield.js
@@ -2,6 +2,7 @@ import Link from "next/link";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import xpath from "xpath";
+
import {
Textfield,
DateField,
@@ -20,7 +21,7 @@ export default function BuildField(props) {
const router = useRouter();
const { locale } = router;
- const { fieldType, label, datafieldname } = props;
+ const { fieldType, label, datafieldname, mandatoryFieldData } = props;
const parser = new DOMParser();
@@ -31,7 +32,15 @@ export default function BuildField(props) {
);
break;
@@ -41,6 +50,7 @@ export default function BuildField(props) {
name={props.datafieldname}
label={props.label}
datafieldname={props.datafieldname}
+ picklistData={props.picklistData}
/>
);
break;
@@ -52,9 +62,17 @@ export default function BuildField(props) {
/>
);
break;
- case "{ 4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
+ case "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
return (
-
+
);
break;
case "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}":
diff --git a/components/newappeal/buildrow.js b/components/newappeal/buildrow.js
index f5211c4e..7efdb493 100644
--- a/components/newappeal/buildrow.js
+++ b/components/newappeal/buildrow.js
@@ -1,8 +1,10 @@
import Link from "next/link";
+import _ from "lodash";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import xpath from "xpath";
import BuildField from "./buildfield";
+import jsonpath from "jsonpath";
export default function BuildRow(props) {
let { t } = useTranslation();
@@ -10,7 +12,13 @@ export default function BuildRow(props) {
const router = useRouter();
const { locale } = router;
- const { rowXML, whichSection, sectionCount, onSubmit } = props;
+ const {
+ rowXML,
+ whichSection,
+ sectionCount,
+ onSubmit,
+ mandatoryFieldsData,
+ } = props;
const parser = new DOMParser();
@@ -21,18 +29,38 @@ export default function BuildRow(props) {
rowXML[key].outerHTML,
"text/xml"
);
- var rows = xpath.select("//label/@description", doc);
- var fieldtype = xpath.select("//@classid", doc);
- var datafieldname = xpath.select("//@datafieldname", doc);
- return (
-
- );
+ if (_.isEmpty(rowXML[key].innerHTML)) {
+ ("");
+ } else {
+ var rows = xpath.select("//label/@description", doc);
+ var fieldtype = xpath.select("//@classid", doc);
+ var datafieldname = xpath.select("//@datafieldname", doc);
+
+ const isRequiredField = jsonpath.query(
+ mandatoryFieldsData,
+ "$..value[?(@.LogicalName=='" +
+ datafieldname[0].value +
+ "')]"
+ );
+
+ if (isRequiredField[0].RequiredLevel.Value != "None") {
+ return (
+
+ );
+ } else {
+ return null;
+ }
+ }
})}
);
diff --git a/components/newappeal/buildsection.js b/components/newappeal/buildsection.js
index e9bcbda0..452126b2 100644
--- a/components/newappeal/buildsection.js
+++ b/components/newappeal/buildsection.js
@@ -32,19 +32,21 @@ let BuildSection = (props) => {
setCurrentSection,
refno,
gotoSection,
+ mandatoryFieldsData,
} = props;
const currentSection = props.appealType.currentSection;
const parser = new DOMParser();
var doc = parser.parseFromString(props.formXML, "text/xml");
- var titles = xpath.select(
- "//form/tabs/tab[" + currentSection + " ]/labels/label/@description",
- doc
- );
+ // var titles = xpath.select(
+ // "//form/tabs/tab[" + currentSection + " ]/labels/label/@description",
+ // doc
+ // );
var rowXML = xpath.select(
- "/form/tabs/tab[" +
- currentSection +
- "]/columns//sections/section/rows/row",
+ // "/form/tabs/tab[" +
+ // currentSection +
+ // "]/columns//sections/section/rows/row",
+ "/form/tabs/tab/columns//sections/section/rows/row",
doc
);
@@ -129,7 +131,8 @@ let BuildSection = (props) => {
- {titles[0].value}{" "}
+ {/* {titles[0].value}{" "} */}
+ Enter your appeal information
-
*/}
);
};
diff --git a/components/newappeal/complete.js b/components/newappeal/complete.js
index 1d6791ad..7989b388 100644
--- a/components/newappeal/complete.js
+++ b/components/newappeal/complete.js
@@ -7,11 +7,61 @@ import BuildRow from "./buildrow";
import { reduxForm, formValueSelector } from "redux-form";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { setCurrentSection } from "../../store/appealType/action";
+import { updateCase } from "../../actions";
+import jsonpath from "jsonpath";
+
+import data from "../../data/collections.json";
let CompleteAppeal = (props) => {
- // useEffect(() => {
- // window.scrollTo(0, 0);
- // });
+ // un comment to update incident with an appealtype id
+ useEffect(() => {
+ // console.log(props.appealType.caseReference.incidentid);
+ // console.log(props.appealType.appealTypeID);
+ // console.log(props.props.form.appealForm.values);
+
+ // console.log(updateBody);
+ // console.log(
+ // getFormCollection(
+ // "pinswg_" +
+ // props.appealType.caseReference[
+ // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ // ]
+ // .replace(/[\s\-\+\(\)\,\&\.]/g, "")
+ // .toLowerCase()
+ // )
+ // );
+
+ let incidentId = props.appealType.caseReference.incidentid;
+ let updateBody = props.props.form.appealForm.values;
+
+ Object.assign(updateBody, {
+ "pinswg_name": props.appealType.caseReference.ticketnumber,
+ });
+ updateBody = JSON.stringify(updateBody);
+
+ updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
+ updateBody = updateBody.replace(/:"No"/gm, `:false`);
+ updateBody = JSON.parse(updateBody);
+ let updateFormCollection = getFormCollection(
+ "pinswg_" +
+ props.appealType.caseReference[
+ "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ ]
+ .replace(/[\s\-\+\(\)\,\&\.]/g, "")
+ .toLowerCase()
+ );
+
+ updateCase(incidentId, updateBody, updateFormCollection);
+ }, []);
+
+ const getFormCollection = (formtype) => {
+ const collectionName = jsonpath.query(
+ data,
+ "$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
+ );
+ //console.log(collectionName[0]);
+ return collectionName[0];
+ };
let { t } = useTranslation();
@@ -52,6 +102,9 @@ let CompleteAppeal = (props) => {
setCurrentSection(currentSection + 1);
};
+ // console.log(JSON.stringify(props.props.form.appealForm.values, null, 2));
+ //alert(JSON.stringify(props.props.form.appealForm.values, null, 2));
+
return (
@@ -60,7 +113,9 @@ let CompleteAppeal = (props) => {
Your reference number
- {props.appealType.caseReference}
+
+ {props.appealType.caseReference.ticketnumber}
+
diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js
index 5450063b..a10bd7f9 100644
--- a/components/newappeal/createCase.js
+++ b/components/newappeal/createCase.js
@@ -33,11 +33,9 @@ let CreateCase = (props) => {
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions)
? [{}]
- : _.isEmpty(props.appealType.appealTypeOptions.GlobalOptionSet)
+ : _.isEmpty(props.appealType.appealTypeOptions.value)
? [{}]
- : _.isEmpty(props.appealType.appealTypeOptions.GlobalOptionSet.Options)
- ? [{}]
- : props.appealType.appealTypeOptions.GlobalOptionSet.Options;
+ : props.appealType.appealTypeOptions.value;
let lpaOptionsObj = _.isEmpty(props)
? [{}]
@@ -45,7 +43,9 @@ let CreateCase = (props) => {
? [{}]
: _.isEmpty(props.LPAData.LPAData)
? [{}]
- : jsonpath.query(props.LPAData.LPAData, "$..name");
+ : _.isEmpty(props.LPAData.LPAData)
+ ? [{}]
+ : props.LPAData.LPAData.value;
const RenderLPAList = ({
name,
@@ -96,9 +96,9 @@ let CreateCase = (props) => {
return (
- {optionsObj[key]}
+ {optionsObj[key].name}
);
})}
@@ -158,51 +158,37 @@ let CreateCase = (props) => {
{_.isEmpty(optionsObj[key])
? ""
- : _.isEmpty(
- optionsObj[key].Label
- )
+ : _.isEmpty(optionsObj[key])
? ""
: _.isEmpty(
- optionsObj[key].Label
- .LocalizedLabels
+ optionsObj[key].value
)
? ""
- : _.isEmpty(
- optionsObj[key].Label
- .LocalizedLabels[0]
- .Label
- )
- ? ""
- : optionsObj[key].Label
- .LocalizedLabels[0]
- .Label}
+ : optionsObj[key].value}
);
})}
@@ -217,9 +203,18 @@ let CreateCase = (props) => {
const onHandleSubmit = (values) => {
event.preventDefault();
- router.replace("/newappeal/" + values.appealTypes, null, {
- shallow: true,
- });
+ router.replace(
+ "/newappeal/" +
+ values.appealTypes.split(",")[1] +
+ "?lpa=" +
+ values.lpaTypes +
+ "&apt=" +
+ values.appealTypes.split(",")[0],
+ null,
+ {
+ shallow: true,
+ }
+ );
};
return (
@@ -273,8 +268,8 @@ const mapDispatchToProps = (dispatch) => {
);
dispatch(setAppealTypeID(event.target.value));
},
- onChangeSelectLPA: (event) => {
- dispatch(setAppealLPA(event.target.value));
+ onChangeSelectLPA: (lpaId) => {
+ dispatch(setAppealLPA(lpaId));
},
};
};
diff --git a/components/search/searchresults.js b/components/search/searchresults.js
index ebbfb932..a7842b99 100644
--- a/components/search/searchresults.js
+++ b/components/search/searchresults.js
@@ -3,54 +3,22 @@ import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { setCurrentReference } from "../../store/currentView/action";
import { connect } from "react-redux";
+import jsonpath from "jsonpath";
+import _ from "lodash";
const SearchResults = (props) => {
- const { searchString, searchResultsObj, setCurrentReference } = props;
+ const {
+ searchString,
+ searchResultsObj,
+ searchDetailsObj,
+ setCurrentReference,
+ } = props;
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
var resultsArr = searchResultsObj.value || [{}];
- const resultRow = Object.keys(resultsArr).map((key, index) => {
-
-
-
-
-
- wwwwwwwCase Reference:
-
- {resultsArr[key].title}
-
-
-
-
- Site Address:
- 23 Martineau Lane
- HASTINGS
-
- TN35 5DS
-
-
-
- Appellant/Applicant:
-
- Mr J Pocknell
-
-
- Authority:
- Hastings Borough Council{" "}
-
-
- Case Type:
- Planning (W){" "}
-
-
- Status:
- In Progress
-
-
;
- });
return (
@@ -87,6 +55,12 @@ const SearchResults = (props) => {
{resultsArr.map((item, key) => {
+ let detailsObj = jsonpath.query(
+ searchDetailsObj,
+ "$..value[?(@.pinswg_name=='" + item.title + "')]"
+ );
+ detailsObj = detailsObj[0];
+
return (
@@ -112,26 +86,64 @@ const SearchResults = (props) => {
Site Address:{" "}
- 23 Martineau Lane
- HASTINGS
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddressline1
+ : ""}
- TN35 5DS
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddressline2
+ : ""}
+
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddresstown
+ : ""}
+
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddresscounty
+ : ""}
+
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddresspostcode
+ : ""}
Appellant/Applicant:
- Mr J Pocknell
+ {_.has(detailsObj, [
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
Authority:
- {
- item[
- "_customerid_value@OData.Community.Display.V1.FormattedValue"
- ]
- }
+ {_.has(detailsObj, [
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
diff --git a/components/searchresults.js b/components/searchresults.js
index f55a274d..02599187 100644
--- a/components/searchresults.js
+++ b/components/searchresults.js
@@ -23,6 +23,7 @@ export default function Search(props) {
diff --git a/data/collections.json b/data/collections.json
new file mode 100644
index 00000000..af477149
--- /dev/null
+++ b/data/collections.json
@@ -0,0 +1,312 @@
+{
+ "value": [
+ {
+ "LogicalCollectionName": "pinswg_planningobligationss106flows",
+ "LogicalName": "pinswg_planningobligationss106flow",
+ "MetadataId": "efb4c590-19be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_dnsflows",
+ "LogicalName": "pinswg_dnsflow",
+ "MetadataId": "328e015f-dabe-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_harbourrevisionorderflows",
+ "LogicalName": "pinswg_harbourrevisionorderflow",
+ "MetadataId": "98bbb26e-e7be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_transportandworkactflows",
+ "LogicalName": "pinswg_transportandworkactflow",
+ "MetadataId": "ad4bfc8c-e1be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_maintenanceoflands127flows",
+ "LogicalName": "pinswg_maintenanceoflands127flow",
+ "MetadataId": "2b26362c-d3be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_environmentalpermittingflows",
+ "LogicalName": "pinswg_environmentalpermittingflow",
+ "MetadataId": "74dd4767-f2be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_dnses",
+ "LogicalName": "pinswg_dns",
+ "MetadataId": "36f07225-4a82-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_planningobligationappeals106s",
+ "LogicalName": "pinswg_planningobligationappeals106",
+ "MetadataId": "cb8beeae-8f81-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_planningconditionss73s79s",
+ "LogicalName": "pinswg_planningconditionss73s79",
+ "MetadataId": "093bf9ff-8d81-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_rows",
+ "LogicalName": "pinswg_row",
+ "MetadataId": "4ccc6e93-4f82-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_transportandworkacts",
+ "LogicalName": "pinswg_transportandworkact",
+ "MetadataId": "bc3edc4b-7d82-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_transportandworkacts",
+ "LogicalName": "pinswg_transportandworksact",
+ "MetadataId": "bc3edc4b-7d82-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_wayleaveflows",
+ "LogicalName": "pinswg_wayleaveflow",
+ "MetadataId": "a28054b9-e3be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_planningappeals78flows",
+ "LogicalName": "pinswg_planningappeals78flow",
+ "MetadataId": "ddaebde1-0fbe-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_harbourrevisionorders",
+ "LogicalName": "pinswg_harbourrevisionorder",
+ "MetadataId": "dc8dcd0d-4f82-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_miscellaneouscaseworks",
+ "LogicalName": "pinswg_miscellaneouscasework",
+ "MetadataId": "f519aa8e-5782-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_miscellaneouscaseworks",
+ "LogicalName": "pinswg_misccasework",
+ "MetadataId": "f519aa8e-5782-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_localdevelopmentplanses",
+ "LogicalName": "pinswg_localdevelopmentplans",
+ "MetadataId": "38ed3835-c1e0-eb11-aac5-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_planningappeals78s",
+ "LogicalName": "pinswg_planningappeals78",
+ "MetadataId": "8d7f813a-4183-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_enforcementnoticeappealsflow174s",
+ "LogicalName": "pinswg_enforcementnoticeappealsflow174",
+ "MetadataId": "a933cf28-20be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates",
+ "LogicalName": "pinswg_lawfuldevelopmentcertificate",
+ "MetadataId": "184e4861-9681-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates",
+ "LogicalName": "pinswg_lawfuldevelopmentcertificateappeals194195",
+ "MetadataId": "184e4861-9681-eb11-aac0-00224800be9c"
+ },
+
+
+
+ {
+ "LogicalCollectionName": "pinswg_highhedgestreepreservationflows",
+ "LogicalName": "pinswg_highhedgestreepreservationflow",
+ "MetadataId": "c365b924-f3be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_householderappealhases",
+ "LogicalName": "pinswg_householderappealhas",
+ "MetadataId": "a6c728b0-9081-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_enforcementlistedbuildingconservationaps",
+ "LogicalName": "pinswg_enforcementlistedbuildingconservationap",
+ "MetadataId": "c697be96-9481-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_enforcementlistedbuildingconservationaps",
+ "LogicalName": "pinswg_enforcementlistedbuildingandconservationappeals39",
+ "MetadataId": "c697be96-9481-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_callinss77s",
+ "LogicalName": "pinswg_callinss77",
+ "MetadataId": "dd309e51-4982-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_commonlands",
+ "LogicalName": "pinswg_commonland",
+ "MetadataId": "4161a618-5082-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_advertses",
+ "LogicalName": "pinswg_adverts",
+ "MetadataId": "0735866b-5482-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_hedgeshedgerowstreepreservationreplacems",
+ "LogicalName": "pinswg_hedgeshedgerowstreepreservationreplacem",
+ "MetadataId": "60f38fed-5382-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_hedgeshedgerowstreepreservationreplacems",
+ "LogicalName": "pinswg_highhedgestreepreservationordershedgerowstreereplacementnotice",
+ "MetadataId": "60f38fed-5382-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_compulsorypurchaseorderses",
+ "LogicalName": "pinswg_compulsorypurchaseorders",
+ "MetadataId": "054da4c7-5582-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_communityinfrastructurelevys117118119s",
+ "LogicalName": "pinswg_communityinfrastructurelevys117118119",
+ "MetadataId": "0c309f3c-4882-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_objectiveconfigs",
+ "LogicalName": "pinswg_objectiveconfig",
+ "MetadataId": "f89ae20c-4777-eb11-aabd-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_nonvalidations",
+ "LogicalName": "pinswg_nonvalidation",
+ "MetadataId": "37f31a93-5882-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_rightofwayflows",
+ "LogicalName": "pinswg_rightofwayflow",
+ "MetadataId": "b26c1d43-efbe-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_caseinvolvements",
+ "LogicalName": "pinswg_caseinvolvement",
+ "MetadataId": "65677cd9-4aae-eb11-aac3-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_commonlandflows",
+ "LogicalName": "pinswg_commonlandflow",
+ "MetadataId": "338fac85-e6be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates195flows",
+ "LogicalName": "pinswg_lawfuldevelopmentcertificates195flow",
+ "MetadataId": "0b8f5046-1dbe-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_advertisementappealanddiscontinuances",
+ "LogicalName": "pinswg_advertisementappealanddiscontinuance",
+ "MetadataId": "79b9ab3a-f1be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_documenthistories",
+ "LogicalName": "pinswg_documenthistory",
+ "MetadataId": "0d8e78a7-33a3-eb11-aac3-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_documents",
+ "LogicalName": "pinswg_document",
+ "MetadataId": "e6cbbbca-026a-eb11-aabb-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_electricityactflows",
+ "LogicalName": "pinswg_electricityactflow",
+ "MetadataId": "699c4318-e3be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_planningconditionss73s79flows",
+ "LogicalName": "pinswg_planningconditionss73s79flow",
+ "MetadataId": "510154b1-15be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_wayleaves",
+ "LogicalName": "pinswg_wayleave",
+ "MetadataId": "a0652117-5782-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_listedbuildingandconservationareaconsens",
+ "LogicalName": "pinswg_listedbuildingandconservationareaconsen",
+ "MetadataId": "4cd95405-8f81-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_listedbuildingandconservationareaconsens",
+ "LogicalName": "pinswg_listedbuildingandconservationareaconsents73s79",
+ "MetadataId": "4cd95405-8f81-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_callinapplicationss77flows",
+ "LogicalName": "pinswg_callinapplicationss77flow",
+ "MetadataId": "2a4f3d43-d4be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_transfercodes",
+ "LogicalName": "pinswg_transfercode",
+ "MetadataId": "a551ad5c-29f5-eb11-aac7-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_compulsorypurchaseordersflows",
+ "LogicalName": "pinswg_compulsorypurchaseordersflow",
+ "MetadataId": "a94f098b-f0be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_environmentalpermittings",
+ "LogicalName": "pinswg_environmentalpermitting",
+ "MetadataId": "62d4aa9a-5682-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_nonvaidationflows",
+ "LogicalName": "pinswg_nonvaidationflow",
+ "MetadataId": "e5ca3ceb-c1e0-eb11-aac5-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_enforcementnoticeappeals174s",
+ "LogicalName": "pinswg_enforcementnoticeappeals174",
+ "MetadataId": "930a3cc4-9181-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_ldps",
+ "LogicalName": "pinswg_ldp",
+ "MetadataId": "af424d4d-5882-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_maintenanceoflands217s",
+ "LogicalName": "pinswg_maintenanceoflands217",
+ "MetadataId": "bb302784-9581-eb11-aac0-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_enforcelistbuild39flows",
+ "LogicalName": "pinswg_enforcelistbuild39flow",
+ "MetadataId": "9423206e-d2be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_householderappealflows",
+ "LogicalName": "pinswg_householderappealflow",
+ "MetadataId": "330541bd-d5be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_miscellaneouscaseworkflows",
+ "LogicalName": "pinswg_miscellaneouscaseworkflow",
+ "MetadataId": "87db8649-f4be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_communityinfrastructurelevyflows",
+ "LogicalName": "pinswg_communityinfrastructurelevyflow",
+ "MetadataId": "92bc1e3d-e0be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_listedbuildconserv20flows",
+ "LogicalName": "pinswg_listedbuildconserv20flow",
+ "MetadataId": "4c11cbe9-27be-eb11-aac4-00224800be9c"
+ },
+ {
+ "LogicalCollectionName": "pinswg_electricityacts",
+ "LogicalName": "pinswg_electricityact",
+ "MetadataId": "6aedaab1-4a82-eb11-aac0-00224800be9c"
+ }
+ ]
+}
diff --git a/package.json b/package.json
index 8cba5ebe..278d7d7f 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
- "dev:app": "node ./server/server.js && yarn lint:js",
+ "dev:app": "node ./server/server.js",
"build": "NODE_ENV=production node_modules/next/dist/bin/next build",
"start": "node_modules/next/dist/bin/next start"
},
@@ -14,11 +14,13 @@
"axios": "^0.21.1",
"compression": "^1.7.4",
"cookies": "^0.8.0",
+ "crypto-js": "^4.1.1",
"dom": "^0.0.3",
"dynamics-web-api": "^1.7.4",
"express": "^4.17.1",
"govuk-frontend": "^3.13.0",
"https": "^1.0.0",
+ "hyco-https": "^1.4.5",
"jsonpath": "^1.1.1",
"jsonpath-plus": "^5.1.0",
"lodash": "^4.17.21",
@@ -55,4 +57,4 @@
"eslint-config-next": "^11.0.1",
"prettier": "2.3.2"
}
-}
\ No newline at end of file
+}
diff --git a/pages/api/proxy/[...route].js b/pages/api/proxy/[...route].js
new file mode 100644
index 00000000..479e5ddc
--- /dev/null
+++ b/pages/api/proxy/[...route].js
@@ -0,0 +1,110 @@
+import axios from "axios";
+import https from "https";
+import CryptoJS from "crypto-js";
+
+const WEBAPI_URL = "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
+
+// const azureHeaders = {
+// headers: {
+// "OData-MaxVersion": "4.0",
+// "OData-Version": "4.0",
+// "Accept": "application/json",
+// "Prefer": 'odata.include-annotations="*",return=representation',
+// "Content-Type": "application/json",
+// "ServiceBusAuthorization": SASToken,
+// },
+// };
+
+const getSASToken = () => {
+ var m_ResourceURI = "dev-pedw-ns.servicebus.windows.net";
+ var m_Path = "dev-pedw-hc";
+ var m_SasKey = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
+ var m_SasKeyName = "devpedwnspolicy";
+
+ var encodedResourceUri = encodeURIComponent(
+ "https://" + m_ResourceURI + "/" + m_Path + "/"
+ );
+
+ var t0 = new Date(1970, 1, 1, 0, 0, 0, 0);
+ var t1 = new Date();
+ var expireInSeconds =
+ +(31 * 24 * 3600) + 3600 + (((t1.getTime() - t0.getTime()) / 1000) | 0);
+
+ //the line below is a hack that converts to UTF8
+ var plainSignature = JSON.parse(
+ JSON.stringify(encodedResourceUri + "\n" + expireInSeconds)
+ );
+
+ var hash = CryptoJS.HmacSHA256(plainSignature, m_SasKey);
+ var base64HashValue = CryptoJS.enc.Base64.stringify(hash);
+
+ var token =
+ "SharedAccessSignature sr=" +
+ encodedResourceUri +
+ "&sig=" +
+ encodeURIComponent(base64HashValue) +
+ "&se=" +
+ expireInSeconds +
+ "&skn=" +
+ m_SasKeyName;
+
+ return token;
+};
+
+export default async function (req, res) {
+ // console.log(req.method);
+
+ var updateBody = {
+ "pinswg_areaofsiteinhectaresdec": 21,
+ "pinswg_developmentaffectsettingifalisted": false,
+ "pinswg_floorspaceinsquaremeters": "123123124",
+ "pinswg_incarelatestoca": false,
+ "pinswg_isfloodinganissue": true,
+ "pinswg_isthesitewithinanaonb": false,
+ "pinswg_landuse": "846040002",
+ "pinswg_sitewithinsssi": true,
+ "pinswg_sitewithinagreenbelt": false,
+ "pinswg_siteviewablefromroad": false,
+ "pinswg_typeofplanningapplication": "846040000",
+ };
+ var data = JSON.stringify(req.body);
+ const SASToken = getSASToken();
+
+ // console.log(SASToken);
+
+ var config = {
+ method: req.method,
+ //url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
+ url: WEBAPI_URL + req.query.route[0],
+ headers: {
+ "OData-MaxVersion": "4.0",
+ "OData-Version": "4.0",
+ "Accept": "application/json",
+ "Prefer": 'odata.include-annotations="*",return=representation',
+ "Authorization": SASToken,
+ "Content-Type": "application/json",
+ },
+ data: data,
+ };
+
+ console.log(config);
+
+ return new Promise((resolve, reject) => {
+ // console.log(config);
+ axios(config)
+ .then((response) => {
+ res.statusCode = 200;
+ res.setHeader("Content-Type", "application/json");
+ res.setHeader("Cache-Control", "max-age=1800000");
+ res.end(JSON.stringify(response.data));
+ console.log("response data", response.data);
+ resolve();
+ })
+ .catch((error) => {
+ console.log("proxy response error", error);
+ res.json(error);
+ res.status(405).end();
+ return resolve();
+ });
+ });
+}
diff --git a/pages/case.js b/pages/case.js
index fb0a32c4..4b651b81 100644
--- a/pages/case.js
+++ b/pages/case.js
@@ -41,6 +41,9 @@ const Home = (props) => {
searchResultsObj={
props.searchResultsObj.searchResultsObj
}
+ searchDetailsObj={
+ props.searchResultsObj.searchDetailsObj
+ }
myRepresentations={
props.myRepresentations.myRepresentations
}
diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js
index 544b1835..ddb60651 100644
--- a/pages/newappeal/[appealtypes].js
+++ b/pages/newappeal/[appealtypes].js
@@ -19,10 +19,18 @@ import {
setAppealTypeTitle,
setAppealTypeID,
getAppealTypeObj,
+ setAppealLPA,
setCaseReference,
} from "../../store/appealType/action";
import { setForm, getFormObj } from "../../store/formData/action";
-import { getFormData, getAppealsTypes, createCase } from "../../actions";
+import {
+ getFormData,
+ getAppealsTypes,
+ getMandatoryFields,
+ createCase,
+ getPickLists,
+ updateCase,
+} from "../../actions";
import xpath from "xpath";
import { reduxForm, FormName } from "redux-form";
@@ -52,16 +60,13 @@ let Home = (props) => {
doc
);
var sectionCount = xpath.select("/form/tabs/tab[*]", doc);
- sectionCount = sectionCount.length;
+ sectionCount = 1; //sectionCount.length;
var tabs = xpath.select("//form/tabs/tab[*]", doc);
- let optionsStr = props.appealType.appealTypeOptions.GlobalOptionSet.Options;
+ let optionsStr = props.appealType.appealTypeOptions.value;
- let selectedObj = jsonpath.query(
- optionsStr,
- "$..LocalizedLabels[?(@.Label)].Label"
- );
+ let selectedObj = jsonpath.query(optionsStr, "$..value");
//let optionsTitleObj = [];
@@ -121,7 +126,7 @@ let Home = (props) => {
role="main"
>
{props.appealType.currentSection == 9999 ? (
-
+
) : props.appealType.currentSection ==
sectionCount + 1 ? (
{
formTitle={formTitle}
appealType={props.appealType}
props={props}
+ mandatoryFieldsData={
+ props.formData.mandatoryFieldsData
+ }
/>
) : (
{
sectionCount={sectionCount}
onSubmit={onSubmit}
formTitle={formTitle}
+ mandatoryFieldsData={
+ props.formData.mandatoryFieldsData
+ }
props={props}
/>
)}
@@ -154,19 +165,36 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
//console.log("the query", query);
- const [appealTypeData, formdata] = await Promise.all([
+
+ const [
+ caseReferenceData,
+ appealTypeData,
+ mandatoryFieldsData,
+ pickListData,
+ formdata,
+ ] = await Promise.all([
+ await createCase(query.apt),
await getAppealsTypes(),
+ await getMandatoryFields(query.appealtypes),
+ await getPickLists(query.appealtypes),
await getFormData(query.appealtypes),
]);
- const caseReference = createCase("asasa", "asasa");
+ // let updateCaseReferenceData = await updateCase(
+ // caseReferenceData.incidentid,
+ // query.apt
+ // );
+ let caseReference = caseReferenceData;
let xmlStr = formdata;
xmlStr = formdata.value[0].formxml;
xmlStr = xmlStr.replace(/\\"/g, "");
- store.dispatch(setAppealTypeID(query.appealtypes));
+
+ //console.log(caseReference, query.appealtypes, formdata);
+ store.dispatch(setAppealLPA(query.lpa));
+ store.dispatch(setAppealTypeID(query.apt));
store.dispatch(setCaseReference(caseReference));
- store.dispatch(setForm(xmlStr));
+ store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
store.dispatch(setAppealType(appealTypeData));
}
);
diff --git a/pages/newappeal/index.js b/pages/newappeal/index.js
index 5cb68b62..e23e2652 100644
--- a/pages/newappeal/index.js
+++ b/pages/newappeal/index.js
@@ -12,7 +12,7 @@ import { useSelector, shallowEqual, connect } from "react-redux";
import { wrapper } from "../../store/store";
import Cookies from "cookies";
import { useRouter } from "next/router";
-import { useState } from "react";
+import { useEffect, useState } from "react";
import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import { reduxForm, formValueSelector } from "redux-form";
@@ -26,10 +26,15 @@ import {
setAppealLPA,
getAppealTypeObj,
} from "../../store/appealType/action";
-import { getAppealsTypes, getLPA } from "../../actions";
+import { getAppealsTypes, getLPA, updateCase, createCase } from "../../actions";
import { setLPA } from "../../store/lpa/action";
const Home = (props) => {
+ // useEffect(() => {
+ // // updateCase("3ffcf47c-5811-ec11-aac9-00224800be9c", "846040004");
+ // createCase();
+ // });
+
const { footerLinks, pages, formData } = props;
let { t, lang } = useTranslation();
@@ -75,14 +80,11 @@ const Home = (props) => {
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
- res.setHeader(
- "Cache-Control",
- "public, s-maxage=604800, stale-while-revalidate"
- );
- const [appealTypeData, lpaData] = await Promise.all([
+ const [appealTypeData, lpaData, caseData] = await Promise.all([
await getAppealsTypes(),
await getLPA(),
]);
+
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData));
}
diff --git a/pages/searchresults.js b/pages/searchresults.js
index 5d3b4082..9de1b67c 100644
--- a/pages/searchresults.js
+++ b/pages/searchresults.js
@@ -13,13 +13,16 @@ import { wrapper } from "../store/store";
import Cookies from "cookies";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
+import jsonpath from "jsonpath";
+import data from "../data/collections.json";
import { setSearch, getSearchObj } from "../store/search/action";
import {
setSearchResults,
+ setSearchDetails,
getSearchResultsObj,
} from "../store/searchOutput/action";
-import { getBasicSearch } from "../actions";
+import { getBasicSearch, getBasicSearchDetails } from "../actions";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -57,12 +60,57 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
console.log("query-", query);
- const searchResultsObj = (await getBasicSearch(query.q)) || null;
+ // const [searchResultsObj, searchDetailsObj] = await Promise.all(
+ // await getBasicSearch(query.q),
+ // await getBasicSearchDetails(query.d)
+ // );
+
+ const searchResultsObj = await getBasicSearch(query.q);
+ const searchDetailsObj = await getSearchDetails(searchResultsObj);
+ // console.log(searchDetailsObj);
store.dispatch(setSearchResults(searchResultsObj));
+ store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setSearch(query.q));
}
);
+const getFormCollection = (formtype) => {
+ const collectionName = jsonpath.query(
+ data,
+ "$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
+ );
+ //console.log(collectionName[0]);
+ return collectionName[0];
+};
+
+const getSearchDetails = (searchResultsObj) => {
+ //console.log(searchResultsObj);
+
+ let detailsArr = [];
+ searchResultsObj = searchResultsObj.value;
+ const detailsObj = searchResultsObj.map((searchDetail, index) => {
+ if (searchDetail.pinswg_appealcasetype == null) {
+ console.log(searchDetail.ticketnumber);
+ } else {
+ detailsArr.push(
+ getBasicSearchDetails(
+ getFormCollection(
+ "pinswg_" +
+ searchDetail[
+ "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ ]
+ .replace(/[\s\-\+\(\)\,\&\.]/g, "")
+ .toLowerCase()
+ ),
+ searchDetail.ticketnumber
+ )
+ );
+ }
+ });
+ //console.log(detailsArr);
+ return Promise.all(detailsArr);
+};
+
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
diff --git a/store/appealType/reducer.js b/store/appealType/reducer.js
index 905aa320..a2e025f4 100644
--- a/store/appealType/reducer.js
+++ b/store/appealType/reducer.js
@@ -6,7 +6,7 @@ const appealTypeDataInitialState = {
appealTypeID: {},
currentSection: 1,
appealLPA: "",
- caseReference: "",
+ caseReference: {},
formComplete: "false",
};
diff --git a/store/formData/action.js b/store/formData/action.js
index 24fce71e..7f990954 100644
--- a/store/formData/action.js
+++ b/store/formData/action.js
@@ -10,9 +10,12 @@ export const getFormObj = () => (dispatch) => {
});
};
-export const setForm = (formData) => (dispatch) => {
- return dispatch({
- type: formDataActionTypes.SETFORMDATA,
- formData: formData,
- });
-};
+export const setForm =
+ (formData, mandatoryFieldsData, pickListData) => (dispatch) => {
+ return dispatch({
+ type: formDataActionTypes.SETFORMDATA,
+ formData: formData,
+ mandatoryFieldsData: mandatoryFieldsData,
+ pickListData: pickListData,
+ });
+ };
diff --git a/store/formData/reducer.js b/store/formData/reducer.js
index 0617d82f..b36356ac 100644
--- a/store/formData/reducer.js
+++ b/store/formData/reducer.js
@@ -2,6 +2,8 @@ import { formDataActionTypes } from "./action";
const formDataInitialState = {
formData: {},
+ mandatoryFieldsData: {},
+ pickListData: {},
};
export default function reducer(state = formDataInitialState, action) {
@@ -9,6 +11,8 @@ export default function reducer(state = formDataInitialState, action) {
case formDataActionTypes.SETFORMDATA:
return {
formData: action.formData,
+ mandatoryFieldsData: action.mandatoryFieldsData,
+ pickListData: action.pickListData,
};
default:
return state;
diff --git a/store/searchOutput/action.js b/store/searchOutput/action.js
index 9e4e57bd..d357357e 100644
--- a/store/searchOutput/action.js
+++ b/store/searchOutput/action.js
@@ -2,6 +2,7 @@ export const searchResultsActionTypes = {
GETSEARCHRESULTS: "GETSEARCHRESULTS",
SETSEARCHRESULTS: "SETSEARCHRESULTS",
UPDATESEARCHRESULTS: "UPDATESEARCHRESULTS",
+ SETSEARCHDETAILS: "SETSEARCHDETAILS",
};
export const getSearchResultshObj = () => (dispatch) => {
@@ -16,3 +17,10 @@ export const setSearchResults = (searchResults) => (dispatch) => {
searchResultsObj: searchResults,
});
};
+
+export const setSearchDetails = (searchDetails) => (dispatch) => {
+ return dispatch({
+ type: searchResultsActionTypes.SETSEARCHDETAILS,
+ searchDetailsObj: searchDetails,
+ });
+};
diff --git a/store/searchOutput/reducer.js b/store/searchOutput/reducer.js
index 16a7e104..7f66cbbe 100644
--- a/store/searchOutput/reducer.js
+++ b/store/searchOutput/reducer.js
@@ -2,14 +2,21 @@ import { searchResultsActionTypes } from "./action";
const searchResultsInitialState = {
searchResultsObj: {},
+ searchDetailsObj: {},
};
export default function reducer(state = searchResultsInitialState, action) {
switch (action.type) {
case searchResultsActionTypes.SETSEARCHRESULTS:
return {
+ ...state,
searchResultsObj: action.searchResultsObj,
};
+ case searchResultsActionTypes.SETSEARCHDETAILS:
+ return {
+ ...state,
+ searchDetailsObj: action.searchDetailsObj,
+ };
default:
return state;
}
diff --git a/store/store.js b/store/store.js
index 154ae5e8..e59d8bdb 100644
--- a/store/store.js
+++ b/store/store.js
@@ -103,7 +103,7 @@ const makeStore = ({ isServer }) => {
const storage = require("redux-persist/lib/storage").default;
const persistConfig = {
- key: "acp_" + Math.floor(100000 + Math.random() * 900000),
+ key: "acp",
whitelist: [
"currentView",
"search",