diff --git a/actions/index.js b/actions/index.js index 9be1c68f..9d01abf4 100644 --- a/actions/index.js +++ b/actions/index.js @@ -62,17 +62,17 @@ export const getSASToken = () => { "&skn=" + m_SasKeyName; - console.log("///////////////////////"); - console.log( - "encodedURI:" + "https://" + m_ResourceURI + "/" + m_Path + "/" - ); - console.log("WEBAPI_URL: " + WEBAPI_URL); - console.log("m_ResourceURI: " + m_ResourceURI); - console.log("m_Path: " + m_Path); - console.log("m_SasKey: " + m_SasKey); - console.log("m_SasKeyName: " + m_SasKeyName); - console.log("token: " + token); - console.log("///////////////////////"); + // console.log("///////////////////////"); + // console.log( + // "encodedURI:" + "https://" + m_ResourceURI + "/" + m_Path + "/" + // ); + // console.log("WEBAPI_URL: " + WEBAPI_URL); + // console.log("m_ResourceURI: " + m_ResourceURI); + // console.log("m_Path: " + m_Path); + // console.log("m_SasKey: " + m_SasKey); + // console.log("m_SasKeyName: " + m_SasKeyName); + // console.log("token: " + token); + // console.log("///////////////////////"); return token; }; @@ -105,16 +105,16 @@ const crmHeadersReturn = { }; const azureHeaders = (SASToken) => { - console.log({ - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - "ServiceBusAuthorization": SASToken, - }, - }); + // console.log({ + // headers: { + // "OData-MaxVersion": "4.0", + // "OData-Version": "4.0", + // "Accept": "application/json", + // "Prefer": 'odata.include-annotations="*",return=representation', + // "Content-Type": "application/json", + // "ServiceBusAuthorization": SASToken, + // }, + // }); return { headers: { "OData-MaxVersion": "4.0", @@ -139,13 +139,13 @@ const azureHeaders = (SASToken) => { // }; export const getBasicSearch = (token, searchString) => { - console.log("\n\n", token, searchString); + //console.log("\n\n", token, searchString); 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", + "') and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true&$top=201", azureHeaders(token) ) .then((res) => { @@ -165,7 +165,7 @@ export const getBasicDNSSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011&$count=true", + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011&$orderby=createdon desc&$count=true", azureHeaders(token) ) .then((res) => res.data) @@ -174,8 +174,8 @@ export const getBasicDNSSearch = (token, searchString) => { }); }; -export const getAdvancedSearch = (searchString) => { - console.log(searchString.caseReference); +export const getAdvancedSearch = (token, searchString) => { + //console.log(searchString.caseReference); var queryString = ""; @@ -200,19 +200,19 @@ export const getAdvancedSearch = (searchString) => { searchString.apt : ""; - console.log( - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" + - queryString + - " &$count=true" - ); + // console.log( + // "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" + + // queryString + + // " &$count=true" + // ); return axios .get( WEBAPI_URL + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" + queryString + - " &$count=true", + " and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true&$top=201", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -251,7 +251,7 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { }); }; -export const getFormData = (whichForm) => { +export const getFormData = (token, whichForm) => { //console.log("got to axios", whichForm); //console.log("api_root: ", BASE_URL); return axios @@ -259,8 +259,8 @@ export const getFormData = (whichForm) => { WEBAPI_URL + "systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode%20eq%20%27pinswg_" + whichForm + - "%27and%20type%20eq%202)&$count=true", - azureHeaders + "%27and%20type%20eq%202)&$count=true&$top=201", + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -268,14 +268,14 @@ export const getFormData = (whichForm) => { }); }; -export const getMandatoryFields = (whichForm) => { +export const getMandatoryFields = (token, whichForm) => { return axios .get( WEBAPI_URL + "EntityDefinitions(LogicalName='pinswg_" + whichForm + "')/Attributes?$count=true&$select=LogicalName,RequiredLevel", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -283,14 +283,14 @@ export const getMandatoryFields = (whichForm) => { }); }; -export const getPickLists = (whichForm) => { +export const getPickLists = (token, whichForm) => { return axios .get( WEBAPI_URL + "EntityDefinitions(LogicalName='pinswg_" + whichForm + "')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -298,12 +298,12 @@ export const getPickLists = (whichForm) => { }); }; -export const getAppealsTypes = () => { +export const getAppealsTypes = (token) => { return axios .get( WEBAPI_URL + "stringmaps?$filter=attributename%20eq%20%27pinswg_appealcasetype%27&$count=true&$select=value,stringmapid,organizationid,attributevalue", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -413,10 +413,13 @@ export const getAppealTypeDetail = (caseReference, appealcasetype) => { }; //https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/pinswg_planningappeals78s?$filter=pinswg_name eq 'CAS-00015-L7J9H1' -export const getLPA = () => { +export const getLPA = (token) => { // console.log("api_root: ", BASE_URL); return axios - .get(WEBAPI_URL + "accounts?$count=true&$select=name", azureHeaders) + .get( + WEBAPI_URL + "accounts?$count=true&$select=name", + azureHeaders(token) + ) .then((res) => res.data) .catch((error) => { console.log("thi serror", error); @@ -439,6 +442,7 @@ export const getPersonalAccount = () => { }; export const getAppealID = ( + token, caseReference, updateFormCollection, primaryAttribute @@ -454,7 +458,7 @@ export const getAppealID = ( console.log("proxy url", weburl); return axios - .get(weburl, azureHeaders) + .get(weburl, azureHeaders(token)) .then((res) => { var appealID = res.data.value[0][primaryAttribute]; return appealID; @@ -540,14 +544,14 @@ export const updateCase = async ( }); }; -export const getMyCases = (loggedInUserId) => { +export const getMyCases = (token, loggedInUserId) => { return axios .get( WEBAPI_URL + "incidents?$select=ticketnumber,casetypecode,createdon,_customerid_value,description,incidentid,pinswg_appealcasetype,_pinswg_assignedinspectrids_value,statecode,statuscode,title&$filter=_customerid_value eq " + loggedInUserId + - " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3", - azureHeaders + " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3", + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -555,7 +559,7 @@ export const getMyCases = (loggedInUserId) => { }); }; -export const getMyRepresentations = () => { +export const getMyRepresentations = (token) => { return ( axios // .get(BASE_URL + "/api/lookups/myRepresentations", { @@ -564,7 +568,7 @@ export const getMyRepresentations = () => { .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&$top=3", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -573,7 +577,7 @@ export const getMyRepresentations = () => { ); }; -export const getWatchedCases = () => { +export const getWatchedCases = (token) => { return ( axios @@ -583,7 +587,7 @@ export const getWatchedCases = () => { .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&$top=3", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -592,7 +596,7 @@ export const getWatchedCases = () => { ); }; -export const getAwaitingSubmission = () => { +export const getAwaitingSubmission = (token) => { return axios .get(BASE_URL + "/api/lookups/awaitingSubmission", { httpsAgent: new https.Agent({ rejectUnauthorized: false }), @@ -603,7 +607,7 @@ export const getAwaitingSubmission = () => { }); }; -export const getPortalModuelDetails = (appealType, caseReference) => { +export const getPortalModuelDetails = (token, appealType, caseReference) => { return axios .get( WEBAPI_URL + @@ -611,7 +615,7 @@ export const getPortalModuelDetails = (appealType, caseReference) => { "?$filter=pinswg_name eq '" + caseReference + "'&$count=true", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { diff --git a/components/homepage/casecomment.js b/components/homepage/casecomment.js index 32101655..50e342c2 100644 --- a/components/homepage/casecomment.js +++ b/components/homepage/casecomment.js @@ -3,19 +3,26 @@ import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; export default function CaseComment() { - let { t } = useTranslation(); + let { t } = useTranslation(); - const router = useRouter(); - const { locale } = router; - return ( -
{t("home:casescomment-card-paragraph-one")}
-{t("home:casescomment-card-paragraph-two")}
-+ {t("home:casescomment-card-paragraph-one")}{" "} + + Casework.PEDW@gov.wales + +
++ {t("home:casescomment-card-paragraph-two")} +
+