updated dns and create case queries
This commit is contained in:
+124
-85
@@ -1,5 +1,6 @@
|
||||
import axios from "axios";
|
||||
import https from "https";
|
||||
|
||||
//import {XMLHttpRequest} from 'xmlhttprequest';
|
||||
|
||||
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
||||
@@ -21,8 +22,35 @@ const agent = new https.Agent({
|
||||
rejectUnauthorized: false,
|
||||
});
|
||||
|
||||
// export const getAccessToken = () => {
|
||||
// var ns = "dev-pedw-ns.servicebus.windows.net";
|
||||
// path = "dev-pedw-hc";
|
||||
// keyrule = "devpedwnspolicy";
|
||||
// key = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
|
||||
|
||||
// let accessTokenHeader = {
|
||||
// headers: {
|
||||
// "ServiceBusAuthorization": https.createRelayToken(
|
||||
// https.createRelayHttpsUri(ns, path),
|
||||
// keyrule,
|
||||
// key
|
||||
// ),
|
||||
// },
|
||||
// };
|
||||
|
||||
// return axios
|
||||
// .get(ns + path, accessTokenHeader)
|
||||
// .then((res) => {
|
||||
// console.log(res.data);
|
||||
// return res.data;
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.log("thiserror", error);
|
||||
// });
|
||||
// };
|
||||
|
||||
const accessToken =
|
||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSIsImtpZCI6IlVXelVaa0U3OEx0NVBGRkJ0LV9seVdoMjdjTSJ9.eyJhdWQiOiJodHRwczovL2RldmNybTIwMTYubGxjZHQuZ292LndhbGVzLyIsImlzcyI6Imh0dHA6Ly9mcy50ZXN0Lmdvdi53YWxlcy9hZGZzL3NlcnZpY2VzL3RydXN0IiwiaWF0IjoxNjMxMTcwMjI1LCJuYmYiOjE2MzExNzAyMjUsImV4cCI6MTYzMTE5OTAyNSwidXBuIjpbIlJvYmVydC5Cb25kQHRlc3QuZ292LndhbGVzIiwicm9iZXJ0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YmYiOjE2MzEyNTg4MDMsImV4cCI6MTYzMTI4NzYwMywidXBuIjpbIlJvYmVydC5Cb25kQHRlc3QuZ292LndhbGVzIiwicm9iZXJ0LmJvbmRAdGVzdC5nb3Yud2FsZXMiXSwicHJpbWFyeXNpZCI6IlMtMS01LTIxLTE4MDA4NDIwNzYtMjQ1NTYwNjU5LTQyMTU3NzU0NjktMTY2MjgiLCJ1bmlxdWVfbmFtZSI6IlhNXFxCb25kUiIsImFwcHR5cGUiOiJQdWJsaWMiLCJhcHBpZCI6IjQyN2ZhNzljLWI1ZmMtNDJhZC04M2Q0LTQxMGIwMzk0OGFiNiIsImF1dGhtZXRob2QiOiJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvYXV0aGVudGljYXRpb25tZXRob2Qvd2luZG93cyIsImF1dGhfdGltZSI6IjIwMjEtMDktMTBUMDc6MjY6MzQuMjI0WiIsInZlciI6IjEuMCJ9.XFymIQJVavP-7-8V7LdoYDD4836Z-aSxveMQDD1P3y_9M3Tiy3zINiLxCbSr8JaymFOuLOzWcnNXwh7HHZKY6gDC6tD1ALVKCBXmgTDaoR9j7XAOxSUaRl6ArIecd7o6UcqsHAvfpb5zu-ZIy0KxV9PFRxY4JHF_tfLAeAMnqIBq-yDrNBOlbg4Kd9VuAbAK5lNWp-BiMIzMqZUIrmD9HjwE17SWaEnApCNqTcGZ4h2EqDBWgqKae7B1AzoV_7mfp7CscLUBLGdbM-XsXw3t_AVc0xDHoOMuWfsoMfioJONoMsPqTNUY7VQev1pMrFDEFN-jqP4yqSdNlev6H47SCg";
|
||||
|
||||
const crmHeaders = {
|
||||
withCredentials: true,
|
||||
@@ -31,21 +59,17 @@ const crmHeaders = {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*"',
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Authorization": "Bearer " + accessToken,
|
||||
},
|
||||
};
|
||||
|
||||
const crmHeadersReturn = {
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": "return=representation",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Credentials": "true",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + accessToken,
|
||||
},
|
||||
@@ -269,32 +293,60 @@ export const getPersonalAccount = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const createCase = (lpaType, appealType) => {
|
||||
return axios
|
||||
.post(
|
||||
WEBAPI_URL + "incidents",
|
||||
{
|
||||
"title": "insertion test case",
|
||||
"customerid_contact@odata.bind":
|
||||
"/contacts(f8b454ed-eded-eb11-aac7-00224800be9c)",
|
||||
},
|
||||
crmHeadersReturn
|
||||
)
|
||||
.then((res) => res.data)
|
||||
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,
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: WEBAPI_URL + "incidents",
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": "return=representation",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + accessToken,
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
console.log("posted ", res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("thi serror", error);
|
||||
console.log("this serror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCase = (incidentID, appealTypeId) => {
|
||||
return axios
|
||||
.patch(
|
||||
WEBAPI_URL + "incidents(" + incidentID + ")",
|
||||
{
|
||||
"pinswg_appealtype": appealTypeId,
|
||||
},
|
||||
crmHeadersReturn
|
||||
)
|
||||
appealTypeId = parseInt(appealTypeId);
|
||||
var data = JSON.stringify({
|
||||
"pinswg_appealcasetype": appealTypeId,
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: WEBAPI_URL + `incidents(${incidentID})`,
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": "return=representation",
|
||||
"Authorization": "Bearer " + accessToken,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
console.log("patched ", res.data);
|
||||
return res.data;
|
||||
@@ -304,39 +356,6 @@ export const updateCase = (incidentID, appealTypeId) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 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();
|
||||
|
||||
// //jquery version to get case number from an lpa and an appeal type
|
||||
// var entity = {};
|
||||
// entity.caseorigincode = 3;
|
||||
@@ -369,38 +388,58 @@ export const updateCase = (incidentID, appealTypeId) => {
|
||||
// });
|
||||
|
||||
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",
|
||||
crmHeaders
|
||||
)
|
||||
.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",
|
||||
crmHeaders
|
||||
)
|
||||
.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",
|
||||
crmHeaders
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const getAwaitingSubmission = () => {
|
||||
|
||||
@@ -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 (
|
||||
<div className="card" id="casesearch-card">
|
||||
<div className="card-body">
|
||||
<h3 className="heading-small card-heading">
|
||||
Developments of National Significance
|
||||
</h3>
|
||||
<div className="govuk-form-group">
|
||||
<p className="govuk-body-s">
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
<div className="govuk-form-group">
|
||||
<button type="submit" className="govuk-button">
|
||||
View all Applications
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+27
-27
@@ -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 (
|
||||
<main
|
||||
className="govuk-main-wrapper govuk-main-wrapper--auto-spacing"
|
||||
id="main-content"
|
||||
role="main"
|
||||
>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
|
||||
<div className="flex-container grid-row govuk-body ">
|
||||
<Login />
|
||||
<CaseSearch/>
|
||||
<CaseComment/>
|
||||
<Inspectorate/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
return (
|
||||
<main
|
||||
className="govuk-main-wrapper govuk-main-wrapper--auto-spacing"
|
||||
id="main-content"
|
||||
role="main"
|
||||
>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="flex-container grid-row govuk-body ">
|
||||
<Login />
|
||||
<CaseSearch />
|
||||
<CaseComment />
|
||||
<Dns />
|
||||
<Inspectorate />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -34,7 +34,7 @@ const ViewAllResults = (props) => {
|
||||
<span className="results-visually-hidden">
|
||||
Case Reference:
|
||||
</span>
|
||||
{resultsArr[index].reference}
|
||||
{resultsArr[index].ticketnumber}
|
||||
</a>
|
||||
</Link>
|
||||
</dd>
|
||||
@@ -51,11 +51,15 @@ const ViewAllResults = (props) => {
|
||||
<span className="results-visually-hidden">
|
||||
Appellant/Applicant:
|
||||
</span>
|
||||
{resultsArr[index].appellantApplicant}
|
||||
Mr smith
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14">
|
||||
<span className="results-visually-hidden">Authority:</span>
|
||||
{resultsArr[index].lpaname}
|
||||
{
|
||||
resultsArr[index][
|
||||
"_customerid_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14">
|
||||
<span className="results-visually-hidden">Case Type:</span>
|
||||
|
||||
@@ -167,24 +167,24 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
//console.log("the query", query);
|
||||
|
||||
const [
|
||||
updateCaseData,
|
||||
caseReferenceData,
|
||||
appealTypeData,
|
||||
mandatoryFieldsData,
|
||||
pickListData,
|
||||
formdata,
|
||||
] = await Promise.all([
|
||||
// await updateCase(
|
||||
// "3ffcf47c-5811-ec11-aac9-00224800be9c",
|
||||
// "846040004"
|
||||
// ),
|
||||
await createCase(),
|
||||
await createCase(query.apt),
|
||||
await getAppealsTypes(),
|
||||
await getMandatoryFields(query.appealtypes),
|
||||
await getPickLists(query.appealtypes),
|
||||
await getFormData(query.appealtypes),
|
||||
]);
|
||||
|
||||
// let updateCaseReferenceData = await updateCase(
|
||||
// caseReferenceData.incidentid,
|
||||
// query.apt
|
||||
// );
|
||||
|
||||
let caseReference = caseReferenceData;
|
||||
let xmlStr = formdata;
|
||||
xmlStr = formdata.value[0].formxml;
|
||||
|
||||
Reference in New Issue
Block a user