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 ( +
+ + +
+ ); + } 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 ( -
- - -
- ); - if (!data) - return ( -
-
{label} loading...
-
- ); - //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 (