From 545f1c9b783f69ee077c47ebf7eb9e60d9e83201 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 11 Jan 2022 17:51:41 +0000 Subject: [PATCH] removed proxy and added endpoints for methods --- .env.local | 39 +- actions/index.js | 845 +++++++----------- components/case/documents.js | 42 +- components/case/representationList.js | 7 +- components/homepage/login.js | 4 +- components/search/dnssearchresults.js | 2 +- pages/_document.js | 12 +- pages/advancedsearch.js | 16 +- pages/api/documents/download/[id].js | 70 ++ pages/api/endpoint/createaccount_api.js | 50 ++ pages/api/endpoint/createwatchedcases_api.js | 51 ++ .../endpoint/deletemyrepresentations_api.js | 49 + pages/api/endpoint/deletewatchedcases_api.js | 49 + pages/api/endpoint/getadvancedsearch_api.js | 72 ++ .../endpoint/getadvancedsearchpaged_api.js | 77 ++ pages/api/endpoint/getappealid_api.js | 45 + pages/api/endpoint/getappealtypes_api.js | 37 + pages/api/endpoint/getbasicdnssearch_api.js | 43 + .../endpoint/getbasicdnssearchdetails_api.js | 43 + .../getbasicdnssearchdetailspaged_api.js | 44 + .../endpoint/getbasicdnssearchpaged_api.js | 47 + pages/api/endpoint/getbasicsearch_api.js | 45 + .../api/endpoint/getbasicsearchdetails_api.js | 48 + .../getbasicsearchdetailspaged_api.js | 49 + pages/api/endpoint/getbasicsearchpaged_api.js | 48 + .../api/endpoint/getemailaccountcheck_api.js | 40 + pages/api/endpoint/getlinkedcases_api.js | 44 + pages/api/endpoint/getlogin_api.js | 43 + pages/api/endpoint/getlpa_api.js | 37 + pages/api/endpoint/getmycases_api.js | 37 + .../api/endpoint/getmyrepresentations_api.js | 37 + .../endpoint/getmyrepresentationsproxy_api.js | 37 + pages/api/endpoint/getpersonalaccount_api.js | 37 + .../endpoint/getportalmoduledetails_api.js | 39 + .../getportalmoduledetailsproxy_api.js | 42 + pages/api/endpoint/getrepresentations_api.js | 40 + .../endpoint/getrepresentationsproxy_api.js | 37 + .../endpoint/getsearchdocumentdetails_api.js | 64 ++ .../getsearchdocumentdetailspaged_api.js | 67 ++ .../endpoint/getsearchdocumenthistory_api.js | 43 + .../getsearchdocumenthistorypaged_api.js | 48 + .../endpoint/getwatchedcases_api copy 2.js | 37 + pages/api/endpoint/getwatchedcases_api.js | 37 + .../api/endpoint/getwatchedcasesproxy_api.js | 40 + pages/api/endpoint/updateaccount_api.js | 50 ++ pages/api/endpoint/updatecase_api.js | 52 ++ pages/api/endpoint/updatepassword_api.js | 50 ++ pages/api/proxy/[...route].js | 195 ---- pages/dnsapplications.js | 16 +- pages/index.js | 6 +- pages/myportal/index.js | 31 +- pages/searchresults.js | 18 +- 52 files changed, 2236 insertions(+), 822 deletions(-) create mode 100644 pages/api/documents/download/[id].js create mode 100644 pages/api/endpoint/createaccount_api.js create mode 100644 pages/api/endpoint/createwatchedcases_api.js create mode 100644 pages/api/endpoint/deletemyrepresentations_api.js create mode 100644 pages/api/endpoint/deletewatchedcases_api.js create mode 100644 pages/api/endpoint/getadvancedsearch_api.js create mode 100644 pages/api/endpoint/getadvancedsearchpaged_api.js create mode 100644 pages/api/endpoint/getappealid_api.js create mode 100644 pages/api/endpoint/getappealtypes_api.js create mode 100644 pages/api/endpoint/getbasicdnssearch_api.js create mode 100644 pages/api/endpoint/getbasicdnssearchdetails_api.js create mode 100644 pages/api/endpoint/getbasicdnssearchdetailspaged_api.js create mode 100644 pages/api/endpoint/getbasicdnssearchpaged_api.js create mode 100644 pages/api/endpoint/getbasicsearch_api.js create mode 100644 pages/api/endpoint/getbasicsearchdetails_api.js create mode 100644 pages/api/endpoint/getbasicsearchdetailspaged_api.js create mode 100644 pages/api/endpoint/getbasicsearchpaged_api.js create mode 100644 pages/api/endpoint/getemailaccountcheck_api.js create mode 100644 pages/api/endpoint/getlinkedcases_api.js create mode 100644 pages/api/endpoint/getlogin_api.js create mode 100644 pages/api/endpoint/getlpa_api.js create mode 100644 pages/api/endpoint/getmycases_api.js create mode 100644 pages/api/endpoint/getmyrepresentations_api.js create mode 100644 pages/api/endpoint/getmyrepresentationsproxy_api.js create mode 100644 pages/api/endpoint/getpersonalaccount_api.js create mode 100644 pages/api/endpoint/getportalmoduledetails_api.js create mode 100644 pages/api/endpoint/getportalmoduledetailsproxy_api.js create mode 100644 pages/api/endpoint/getrepresentations_api.js create mode 100644 pages/api/endpoint/getrepresentationsproxy_api.js create mode 100644 pages/api/endpoint/getsearchdocumentdetails_api.js create mode 100644 pages/api/endpoint/getsearchdocumentdetailspaged_api.js create mode 100644 pages/api/endpoint/getsearchdocumenthistory_api.js create mode 100644 pages/api/endpoint/getsearchdocumenthistorypaged_api.js create mode 100644 pages/api/endpoint/getwatchedcases_api copy 2.js create mode 100644 pages/api/endpoint/getwatchedcases_api.js create mode 100644 pages/api/endpoint/getwatchedcasesproxy_api.js create mode 100644 pages/api/endpoint/updateaccount_api.js create mode 100644 pages/api/endpoint/updatecase_api.js create mode 100644 pages/api/endpoint/updatepassword_api.js delete mode 100644 pages/api/proxy/[...route].js diff --git a/.env.local b/.env.local index 46ec5624..a1452c61 100644 --- a/.env.local +++ b/.env.local @@ -2,6 +2,7 @@ ACCESS_TOKEN_ENDPOINT = https://login.microsoftonline.com/ TENANT = a8d860de-d5e1-45af-8376-d93f02e6b502 +//TENANT = 9ac1a5ab-cd58-409e-a1b6-6b10422a68f5 GRANT_TYPE = "client_credentials" HASHKEY = 028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c @@ -9,24 +10,24 @@ NEXT_PUBLIC_HASHKEY = 028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459 //Dev oauth -//CLIENT_ID = e082def0-3453-461f-9a5e-f4ab127dc015 -//CLIENT_SECRET = qW.7Q~TSr3sZmLEnJQJPXEdOckb_yo2t1yJmY -//RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ -//RELAYURI = "dev-pedw-ns.servicebus.windows.net" -//RELAYPATH = "dev-pedw-hc" +CLIENT_ID = e082def0-3453-461f-9a5e-f4ab127dc015 +CLIENT_SECRET = qW.7Q~TSr3sZmLEnJQJPXEdOckb_yo2t1yJmY +RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ +RELAYURI = "dev-pedw-ns.servicebus.windows.net" +RELAYPATH = "dev-pedw-hc" //Test Oauth -CLIENT_ID = 6619ad85-c908-490d-811b-de8c93c0f2aa -CLIENT_SECRET = qKo7Q~5QvLEplbwnBbint_I5lXqx_-kDm8Vj- -RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -RELAYURI = "test-pedw-ns.servicebus.windows.net" -RELAYPATH = "test-pedw-hc" +//CLIENT_ID = 6619ad85-c908-490d-811b-de8c93c0f2aa +//CLIENT_SECRET = qKo7Q~5QvLEplbwnBbint_I5lXqx_-kDm8Vj- +//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ +//RELAYURI = "test-pedw-ns.servicebus.windows.net" +//RELAYPATH = "test-pedw-hc" //Preprod Oauth -//CLIENT_ID = 75594242-8773-45c7-a3da-85e62485b2f3 -//CLIENT_SECRET = UDF7Q~OwTLIV7LXPHlIYHSWbJunlBD53ieLt- +//CLIENT_ID = ab6c4678-b31a-4eb3-b429-e039120e488a +//CLIENT_SECRET = Ioo7Q~RJfhWsE45wPsuHm1CzRk1SppnNN3lZF //RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/ //RELAYURI = "pp-pedw-ns.servicebus.windows.net" //RELAYPATH = "pp-pedw-hc" @@ -34,15 +35,15 @@ RELAYPATH = "test-pedw-hc" //Prod Oauth -//CLIENT_ID = 01904c07-9035-4cf9-a535-3945f6e470d2 -//CLIENT_SECRET = PRo7Q~GQoKSdARRqF-NOXQDx2Ka8UCINyvagk -//RELAY_ROOT = https://prod-pedw-ns.servicebus.windows.net/prod-pedw-hc/ -//RELAYURI = "prod-pedw-ns.servicebus.windows.net" -//RELAYPATH = "prod-pedw-hc" +CLIENT_ID = 01904c07-9035-4cf9-a535-3945f6e470d2 +CLIENT_SECRET = PRo7Q~GQoKSdARRqF-NOXQDx2Ka8UCINyvagk +RELAY_ROOT = https://prod-pedw-ns.servicebus.windows.net/prod-pedw-hc/ +RELAYURI = "prod-pedw-ns.servicebus.windows.net" +RELAYPATH = "prod-pedw-hc" GOOGLE_TAG_MANAGER = GTM-T78CBC3 -SHOWLOGIN = "true" +SHOWLOGIN = "false" SHOWREPRESENTATIONS = "false" BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2 @@ -65,4 +66,6 @@ GG_REDIRECT_URI = "http://localhost:3000" NEXT_PUBLIC_GG_CLIENT_ID = 5vTukeSpN7d6uBV7YLb7A5wOctzzkZ NEXT_PUBLIC_GG_REDIRECT_URI = "http://localhost:3000" +API_ROOT = "http://localhost:3000/" + diff --git a/actions/index.js b/actions/index.js index 93944b2c..a41fb24e 100644 --- a/actions/index.js +++ b/actions/index.js @@ -11,7 +11,7 @@ if (process.browser) { } else { BASE_URL = process.env.API_ROOT || `http://localhost:${port}`; } -const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY; +const WORDKEY = process.env.HASHKEY; const cache = {}; const API_PATH = "/api/data/v8.2/"; @@ -66,7 +66,7 @@ const tokenConfig = { }, }; -const azureHeaders = (access_token) => { +export const azureHeaders = (access_token) => { return { headers: { "OData-MaxVersion": "4.0", @@ -79,7 +79,7 @@ const azureHeaders = (access_token) => { }; }; -const azureHeadersPaged = (access_token) => { +export const azureHeadersPaged = (access_token) => { return { headers: { "OData-MaxVersion": "4.0", @@ -94,20 +94,13 @@ const azureHeadersPaged = (access_token) => { }; export const hashAPIPath = (queryPath) => { - var hashPath = - queryPath.indexOf("/api/proxy/") == -1 - ? queryPath - : queryPath.split("/api/proxy/")[1]; - var hashlink = CryptoJS.HmacSHA256( - hashPath, + queryPath, CryptoJS.enc.Hex.parse(WORDKEY) ); hashlink = hashlink.toString(CryptoJS.enc.Hex); - //return "&hash=" + hashlink; - - return (hashPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; }; export const hashString = (stringToHash) => { @@ -125,17 +118,13 @@ export const dehashString = (stringToDeHash) => { }; export const getBasicSearch = (token, searchString) => { - //console.log("\n\n", token, searchString); - - var queryUrl = - "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" + - searchString + - "') or contains(ticketnumber, '" + - searchString + - "')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true"; return axios .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + BASE_URL + + "/api/endpoint/getbasicsearch_api?token=" + + token + + "&searchString=" + + searchString, azureHeadersPaged(token) ) .then((res) => { @@ -147,33 +136,18 @@ export const getBasicSearch = (token, searchString) => { }; export const getBasicSearchPaged = (searchString, pageNumber) => { - //console.log("\n\n", token, searchString); - - //console.log(typeof pageNumber != "undefined"); - - var queryUrl = - "/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" + - searchString + - "') or contains(ticketnumber, '" + - searchString + - "')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + '' - : ""); - //console.log(queryUrl); return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getbasicsearchpaged_api?searchString=" + + searchString + + "&pageNumber=" + + pageNumber + ) .then((res) => { - // console.log(" "); - // console.log("/////////////////////"); - // console.log("data:" + res.data.value); - // console.log("/////////////////////"); - // console.log(" "); return res.data; }) .catch((error) => { - //console.log("thiserror", error); return error.response; }); }; @@ -184,7 +158,7 @@ export const getBasicDNSSearch = (token, searchString) => { return axios .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + BASE_URL + "/api/endpoint/getbasicdnssearch_api?token=" + token, azureHeadersPaged(token) ) .then((res) => res.data) @@ -194,14 +168,10 @@ export const getBasicDNSSearch = (token, searchString) => { }; export const getBasicDNSSearchPaged = (pageNumber) => { - var queryUrl = - "/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + '' - : ""); - return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getbasicdnssearchpaged_api?pageNumber=" + pageNumber + ) .then((res) => res.data) .catch((error) => { return error.response; @@ -209,43 +179,13 @@ export const getBasicDNSSearchPaged = (pageNumber) => { }; export const getAdvancedSearch = (token, searchString) => { - console.log("debug showing token: ", token); - console.log(searchString.caseReference); - - var queryString = ""; - - queryString += - searchString.q != null - ? "(contains(title, '" + - searchString.q + - "') or contains(ticketnumber,'" + - searchString.q + - "'))" - : ""; - - queryString += - searchString.lpa != null - ? (typeof searchString.q == "undefined" ? "" : " and ") + - "_pinswg_associatedlpa_value eq " + - searchString.lpa - : ""; - queryString += - searchString.apt != null - ? (typeof searchString.q == "undefined" && - typeof searchString.lpa == "undefined" - ? "" - : " and ") + - "pinswg_appealcasetype eq " + - searchString.apt - : ""; - - var queryUrl = - "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" + - queryString + - " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true"; return axios .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + BASE_URL + + "/api/endpoint/getadvancedsearch_api?token=" + + token + + "&searchstring=" + + JSON.stringify(searchString), azureHeadersPaged(token) ) .then((res) => res.data) @@ -261,44 +201,13 @@ export const getAdvancedSearch = (token, searchString) => { }; export const getAdvancedSearchPaged = (searchString, pageNumber) => { - //console.log(searchString); - var queryString = ""; - - queryString += - searchString.q != null - ? "(contains(title, '" + - searchString.q + - "') or contains(ticketnumber,'" + - searchString.q + - "'))" - : ""; - - queryString += - searchString.lpa != null - ? (typeof searchString.q == "undefined" ? "" : " and ") + - "_pinswg_associatedlpa_value eq " + - searchString.lpa - : ""; - queryString += - searchString.apt != null - ? (typeof searchString.q == "undefined" && - typeof searchString.lpa == "undefined" - ? "" - : " and ") + - "pinswg_appealcasetype eq " + - searchString.apt - : ""; - - var queryUrl = - "/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" + - queryString + - " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + ('') - : ""); - return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getadvancedsearchpaged_api?searchstring=" + + JSON.stringify(searchString) + + "&pageNumber=" + + pageNumber + ) .then((res) => res.data) .catch((error) => { let ErrResponse = { @@ -310,6 +219,7 @@ export const getAdvancedSearchPaged = (searchString, pageNumber) => { return ErrResponse; }); }; + export const getBasicSearchDetails = ( token, appealTypeName, @@ -317,7 +227,7 @@ export const getBasicSearchDetails = ( primaryIdAttribute, incidentID ) => { - //console.log("check appealtype:", appealType, caseReference); + //console.log("check appealtype:", appealTypeName, caseReference); var queryUrl = appealTypeName + @@ -345,48 +255,26 @@ export const getBasicSearchDetailsPaged = ( ) => { //console.log("check appealtype:", appealType, caseReference); - var queryUrl = - "/api/proxy/" + - appealTypeName + - "?$filter=_" + - primaryIdAttribute + - "s_value eq " + - incidentID + - "&$count=true"; - return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=" + + appealTypeName + + "&primaryIdAttribute=" + + primaryIdAttribute + + "&incidentID=" + + incidentID + ) .then((res) => res.data) .catch((error) => { console.log("this error", error); }); }; -export const getSearchDocumentDetails = (token, incidentID) => { - console.log(incidentID); - var queryUrl = - "pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " + - incidentID + - " and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference"; +export const getSearchDocumentDetails = (incidentID) => { return axios .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), - azureHeadersPaged(token) - ) - .then((res) => res.data) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getSearchDocumentHistory = (token, documentID) => { - var queryUrl = - "pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + - documentID; - return axios - .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), - azureHeadersPaged(token) + "/api/endpoint/getsearchdocumentdetails_api?incidentid=" + + incidentID ) .then((res) => res.data) .catch((error) => { @@ -395,109 +283,12 @@ export const getSearchDocumentHistory = (token, documentID) => { }; export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => { - console.log(incidentID); - - var queryUrl = - "/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " + - incidentID + - " and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + - encodeURI('') - : ""); - - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => res.data) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => { - var queryUrl = - "/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + - documentID + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + ('') - : ""); - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => res.data) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getSearchDocumentDetails1 = (incidentID) => { - var queryUrl = - "/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " + - incidentID + - "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference"; - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => res.data) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => { - var queryUrl = - "/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " + - incidentID + - "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + ('') - : ""); - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => res.data) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getSearchDocumentHistory1 = (documentID) => { - var queryUrl = - "/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + - documentID; - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => { - return res.data; - }) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => { - var queryUrl = - "/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + - documentID + - (typeof pageNumber != "undefined" - ? "&$skiptoken=" + ('') - : ""); - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => { - return res.data; - }) - .catch((error) => { - console.log("thiserror", error); - }); -}; - -export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { - var queryUrl = - "pinswg_dnses?$filter=pinswg_name eq '" + - caseReference + - "'&$count=true"; return axios .get( - WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), - azureHeadersPaged(token) + "/api/endpoint/getsearchdocumentdetailspaged_api?incidentid=" + + incidentID + + "&pageNumber=" + + pageNumber ) .then((res) => res.data) .catch((error) => { @@ -505,28 +296,49 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { }); }; -export const getBasicDNSSearchDetailsPaged = (caseReference) => { - var queryUrl = - "/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" + - caseReference + - "'&$count=true"; +export const getSearchDocumentHistory = (documentID) => { + return ( + axios + //.get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getsearchdocumenthistory_api?documentid=" + + documentID + ) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("thiserror", error); + }) + ); +}; - return axios - .get(queryUrl + hashAPIPath(queryUrl)) - .then((res) => res.data) - .catch((error) => { - console.log("thiserror", error); - }); +export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => { + return ( + axios + .get( + "/api/endpoint/getsearchdocumenthistorypaged_api?documentid=" + + documentID + + "&pageNumber=" + + pageNumber + ) + + // .get(queryUrl + hashAPIPath(queryUrl)) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("thiserror", error); + }) + ); }; export const getLinkedCases = (parentIncidentid) => { - //console.log(parentIncidentid); - var queryUrl = - "/api/proxy/incidents?$count=true&$filter=_parentcaseid_value eq " + - parentIncidentid + - " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid"; return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getlinkedcases_api?parentincidentid=" + + parentIncidentid + ) .then((res) => { //console.log(" linked date", res.data); return res.data; @@ -536,6 +348,48 @@ export const getLinkedCases = (parentIncidentid) => { }); }; +export const getAppealsTypes = (token) => { + return axios + .get( + BASE_URL + "/api/endpoint/getappealtypes_api?token=" + token, + azureHeaders(token) + ) + .then((res) => res.data) + .catch((error) => { + console.log(error); + let ErrResponse = { + value: [], + errorCode: error.response.status, + errorMsg: error.response.statusText, + }; + + return ErrResponse; + }); +}; + +export const getLPA = (token) => { + return axios + .get( + BASE_URL + "/api/endpoint/getlpa_api?token=" + token, + azureHeaders(token) + ) + .then((res) => { + //console.log(res.data); + return res.data; + }) + .catch((error) => { + let ErrResponse = { + value: [], + errorCode: error.response.status, + errorMsg: error.response.statusText, + }; + + return ErrResponse; + }); +}; + +// iteration 2 methods + export const getFormData = (token, whichForm) => { var queryUrl = "systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode eq 'pinswg_" + @@ -575,45 +429,6 @@ export const getPickLists = (token, whichForm) => { }); }; -export const getAppealsTypes = (token) => { - var queryUrl = - "stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc"; - return axios - .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) - .then((res) => res.data) - .catch((error) => { - console.log(error); - let ErrResponse = { - value: [], - errorCode: error.response.status, - errorMsg: error.response.statusText, - }; - - return ErrResponse; - }); -}; - -export const getLPA = (token) => { - // console.log("api_root: ", BASE_URL); - var queryUrl = - "accounts?$count=true&$filter=pinswg_isalocalplanningauthorityaccount eq 846040000&$select=name&$orderby=name asc"; - return axios - .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) - .then((res) => { - //console.log(res.data); - return res.data; - }) - .catch((error) => { - let ErrResponse = { - value: [], - errorCode: error.response.status, - errorMsg: error.response.statusText, - }; - - return ErrResponse; - }); -}; - export const getPersonalAccount = (token, contactid) => { var queryUrl = "contacts(" + @@ -642,18 +457,15 @@ export const getAppealID = ( updateFormCollection, primaryAttribute ) => { - const queryUrl = - "/api/proxy/" + - updateFormCollection + - "?$count=true&$select=_" + - primaryAttribute + - "s_value&$filter=pinswg_name eq '" + - caseReference + - "'"; - - console.log("proxy url ", queryUrl); return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getappealid_api?updateFormCollection=" + + updateFormCollection + + "&primaryAttribute=" + + primaryAttribute + + "&caseReference=" + + caseReference + ) .then((res) => { var appealID = res.data.value[0][primaryAttribute]; return appealID; @@ -664,15 +476,13 @@ export const getAppealID = ( }; export const getLogin = (emailAddress, pwd) => { - var queryUrl = - "/api/proxy/contacts?$filter=emailaddress1 eq '" + - emailAddress + - "' and pinswg_custom_password eq '" + - pwd + - "'&$count=true&$select=emailaddress1,contactid,pinswg_custom_password,yomifullname,firstname,lastname"; - return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + "/api/endpoint/getlogin_api?emailAddress=" + + emailAddress + + "&pwd=" + + pwd + ) .then((res) => res.data) .catch((error) => { console.log("thiserror", error); @@ -715,57 +525,15 @@ export const createCase = (token, appealTypeId, lpaID, contactid) => { }); }; -export const updateCase = async ( - incidentId, - updateBody, - updateFormCollection, - primaryAttribute, - caseReference -) => { - var data = JSON.stringify(updateBody); - - var appealObj = await getAppealID( - caseReference, - updateFormCollection, - primaryAttribute - ); - - console.log("appeal obj ", appealObj); - - var queryUrl = "/api/proxy/" + updateFormCollection + "(" + appealObj + ")"; - var config = { - method: "patch", - //url: updateFormCollection + "(" + incidentId + ")", - url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json;odata.metadata=none", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - }, - 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); - }); -}; - export const getMyCases = (token, loggedInUserId) => { - //console.log("in action ", loggedInUserId); - var queryUrl = - "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"; return axios - .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .get( + BASE_URL + + "/api/endpoint/getmycases_api?token=" + + token + + "&loggedInUserId=" + + loggedInUserId + ) .then((res) => { return res.data; }) @@ -775,12 +543,14 @@ export const getMyCases = (token, loggedInUserId) => { }; export const getMyRepresentations = (token, loggedInUserId) => { - var queryUrl = - "pinswg_representationses?$filter= _pinswg_contact_value eq " + - loggedInUserId + - "&$count=true&$orderby=createdon desc"; return axios - .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .get( + BASE_URL + + "/api/endpoint/getmyrepresentations_api?token=" + + token + + "&loggedInUserId=" + + loggedInUserId + ) .then((res) => res.data) .catch((error) => { console.log("this serror", error); @@ -788,50 +558,23 @@ export const getMyRepresentations = (token, loggedInUserId) => { }; export const getMyRepresentationsProxy = (token, loggedInUserId) => { - var queryUrl = - "/api/proxy/pinswg_representationses?$filter= _pinswg_contact_value eq " + - loggedInUserId + - "&$count=true&$orderby=createdon desc"; return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + BASE_URL + + "/api/endpoint/getmyrepresentationsproxy_api?token=" + + token + + "&loggedInUserId=" + + loggedInUserId + ) .then((res) => res.data) .catch((error) => { console.log("this serror", error); }); }; -export const deleteMyRepresentations = (myRepresentationsID) => { - var queryUrl = - "/api/proxy/pinswg_representationses(" + myRepresentationsID + ")"; - var config = { - method: "delete", - url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json;odata.metadata=none", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - }, - }; - // console.log(config); - return axios(config) - .then((res) => { - //console.log("deleted ", res.data); - return res.data; - }) - .catch((error) => { - console.log("this serror", error); - }); -}; - export const getRepresentations = (incidentID) => { - var queryUrl = - "/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " + - incidentID + - " and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc"; return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID) .then((res) => res.data) .catch((error) => { console.log("this serror", error); @@ -839,12 +582,15 @@ export const getRepresentations = (incidentID) => { }; export const getRepresentationsProxy = (token, incidentID) => { - var queryUrl = - "/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " + - incidentID + - "&$count=true&$orderby=createdon desc"; return axios .get(queryUrl + hashAPIPath(queryUrl)) + .get( + BASE_URL + + "/api/endpoint/getrepresentationsproxy_api?token=" + + token + + "&incidentID=" + + incidentID + ) .then((res) => res.data) .catch((error) => { console.log("this serror", error); @@ -852,12 +598,14 @@ export const getRepresentationsProxy = (token, incidentID) => { }; export const getWatchedCases = (token, loggedInUserId) => { - var queryUrl = - "pinswg_watchlists?$filter= _pinswg_contact_value eq " + - loggedInUserId + - "&$count=true&$orderby=createdon desc"; return axios - .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .get( + BASE_URL + + "/api/endpoint/getwatchedcases_api?token=" + + token + + "&loggedInUserId=" + + loggedInUserId + ) .then((res) => res.data) .catch((error) => { console.log("this serror", error); @@ -865,69 +613,20 @@ export const getWatchedCases = (token, loggedInUserId) => { }; export const getWatchedCasesProxy = (token, loggedInUserId) => { - var queryUrl = - "/api/proxy/pinswg_watchlists?$filter= _pinswg_contact_value eq " + - loggedInUserId + - "&$count=true&$orderby=createdon desc"; return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + BASE_URL + + "/api/endpoint/getwatchedcasesproxy_api?token=" + + token + + "&loggedInUserId=" + + loggedInUserId + ) .then((res) => res.data) .catch((error) => { console.log("this serror", error); }); }; -export const createWatchedCases = (formValues) => { - var data = JSON.stringify(formValues); - var queryUrl = "/api/proxy/pinswg_watchlists"; - - var config = { - method: "post", - url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json;odata.metadata=none", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - }, - 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); - }); -}; - -export const deleteWatchedCases = (watchedCaseID) => { - var queryUrl = "/api/proxy/pinswg_watchlists(" + watchedCaseID + ")"; - var config = { - method: "delete", - url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json;odata.metadata=none", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - }, - }; - // console.log(config); - return axios(config) - .then((res) => { - //console.log("deleted ", res.data); - return res.data; - }) - .catch((error) => { - console.log("this serror", error); - }); -}; - export const getAwaitingSubmission = (token) => { return axios .get(BASE_URL + "/api/lookups/awaitingSubmission", { @@ -940,13 +639,16 @@ export const getAwaitingSubmission = (token) => { }; export const getPortalModuleDetails = (token, appealType, caseReference) => { - var queryUrl = - appealType + - "?$filter=pinswg_name eq '" + - caseReference + - "'&$count=true"; return axios - .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .get( + BASE_URL + + "/api/endpoint/getportalmoduledetails_api?token=" + + token + + "&appealType=" + + appealType + + "&caseReference=" + + caseReference + ) .then((res) => res.data) .catch((error) => { console.log("thiserror", error); @@ -958,14 +660,14 @@ export const getPortalModuleDetailsProxy = ( appealType, caseReference ) => { - var queryUrl = - "/api/proxy/" + - appealType + - "?$filter=pinswg_name eq '" + - caseReference + - "'&$count=true"; return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + BASE_URL + + "/api/endpoint/getportalmoduledetailsproxy_api?appealType=" + + appealType + + "&caseReference=" + + caseReference + ) .then((res) => res.data) .catch((error) => { console.log("thiserror", error); @@ -973,30 +675,31 @@ export const getPortalModuleDetailsProxy = ( }; export const getEmailAccountCheck = (emailAddress) => { - var queryUrl = - "/api/proxy/contacts?$filter=emailaddress1 eq '" + - emailAddress + - "'&$count=true&$select=emailaddress1, contactid"; return axios - .get(queryUrl + hashAPIPath(queryUrl)) + .get( + BASE_URL + + "/api/endpoint/getemailaccountcheck_api?emailAddress=" + + emailAddress + ) .then((res) => res.data) .catch((error) => { console.log("thiserror", error); }); }; -export const createAccount = (formValues) => { - var data = formValues; //JSON.stringify(formValues); - var queryUrl = "/api/proxy/contacts"; +//uses more than get methods + +export const updatePassword = (contactId, newpassword) => { + var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId; + var data = { "pinswg_custom_password": newpassword }; var config = { method: "post", - url: queryUrl + hashAPIPath(queryUrl), + url: queryUrl, data: data, }; - // console.log(config); + return axios(config) .then((res) => { - // console.log("posted ", res.data); return res.data; }) .catch((error) => { @@ -1005,11 +708,10 @@ export const createAccount = (formValues) => { }; export const updateAccount = async (contactId, updateBody) => { - var data = updateBody; //JSON.stringify(updateBody); - var queryUrl = "/api/proxy/contacts(" + contactId + ")"; - queryUrl = queryUrl + hashAPIPath(queryUrl); + var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId; + var data = updateBody; var config = { - method: "patch", + method: "post", url: queryUrl, data: data, }; @@ -1022,20 +724,119 @@ export const updateAccount = async (contactId, updateBody) => { }); }; -export const updatePassword = (contactId, newpassword) => { - let updateBody = { "pinswg_custom_password": newpassword }; - var data = updateBody; //JSON.stringify(updateBody); - var queryUrl = "/api/proxy/contacts(" + contactId + ")"; - queryUrl = queryUrl + hashAPIPath(queryUrl); +export const createWatchedCases = (formValues) => { + var data = formValues; + var queryUrl = window.apiRoot + "api/endpoint/createwatchedcases_api"; + + console.log(queryUrl); var config = { - method: "patch", + method: "post", url: queryUrl, 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); + }); +}; + +export const updateCase = async ( + incidentId, + updateBody, + updateFormCollection, + primaryAttribute, + caseReference +) => { + var data = JSON.stringify(updateBody); + + var appealObj = await getAppealID( + caseReference, + updateFormCollection, + primaryAttribute + ); + + var queryUrl = + "/api/endpoint/updatecase_api?updateFormCollection=" + + updateFormCollection + + "&appealObj=" + + appealObj; + + var config = { + method: "post", + url: queryUrl + hashAPIPath(queryUrl), + data: data, + }; + + return axios(config) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("thi serror", error); + }); +}; + +export const deleteMyRepresentations = (myRepresentationsID) => { + var queryUrl = + "/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" + + myRepresentationsID; + + var config = { + method: "delete", + url: queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json;odata.metadata=none", + "Prefer": 'odata.include-annotations="*",return=representation', + "Content-Type": "application/json", + }, + }; + // console.log(config); + return axios(config) + .then((res) => { + //console.log("deleted ", res.data); + return res.data; + }) + .catch((error) => { + console.log("this serror", error); + }); +}; + +export const deleteWatchedCases = (watchedCaseID) => { + var queryUrl = + "/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID; + var config = { + method: "delete", + url: queryUrl, + }; + + return axios(config) + .then((res) => { + //console.log("deleted ", res.data); + return res.data; + }) + .catch((error) => { + console.log("this serror", error); + }); +}; + +export const createAccount = (formValues) => { + var data = formValues; + var queryUrl = "/api/endpoint/createaccount_api"; + var config = { + method: "post", + url: queryUrl, + data: data, + }; + + return axios(config) + .then((res) => { + // console.log("posted ", res.data); return res.data; }) .catch((error) => { diff --git a/components/case/documents.js b/components/case/documents.js index 5746ec72..7c94e1c1 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -12,10 +12,10 @@ import CryptoJS from "crypto-js"; import { getBasicSearch, getBasicSearchDetails, - getSearchDocumentDetails1, - getSearchDocumentHistory1, - getSearchDocumentHistory1Paged, - getSearchDocumentDetails1Paged, + getSearchDocumentDetails, + getSearchDocumentHistory, + getSearchDocumentHistoryPaged, + getSearchDocumentDetailsPaged, getToken, } from "../../actions"; @@ -105,9 +105,9 @@ const DocumentDetails = (props) => { >
{t( @@ -191,23 +191,9 @@ const DocumentDetails = (props) => { ); }; - const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY; - - const encryptDocReference = (documentRef) => { - var hashlink = CryptoJS.HmacSHA256( - "documents/download/" + documentRef, - CryptoJS.enc.Hex.parse(WORDKEY) - ); - hashlink = hashlink.toString(CryptoJS.enc.Hex); - - return ( - "/api/proxy/documents/download/" + documentRef + "?hash=" + hashlink - ); - }; - useEffect(() => { const docDetailsObj = async () => { - let docObj = await getSearchDocumentDetails1(incidentid) + let docObj = await getSearchDocumentDetails(incidentid) .then((data) => { //console.log(data); setDocumentDetails(data); @@ -239,7 +225,7 @@ const DocumentDetails = (props) => { console.log(historyDetail.pinswg_documentid); } else { historyArr.push( - getSearchDocumentHistory1( + getSearchDocumentHistory( historyDetail.pinswg_documentid ) ); @@ -252,8 +238,7 @@ const DocumentDetails = (props) => { }, [incidentid, setDocumentHistory, setDocumentDetails]); const getDocumentResults = (pageNumber) => { - //console.log(advancedSearch, searchString, pageNumber); - getSearchDocumentDetails1Paged(incidentid, pageNumber) + getSearchDocumentDetailsPaged(incidentid, pageNumber) .then((data) => { //console.log(data); setDocumentDetails(data); @@ -269,10 +254,7 @@ const DocumentDetails = (props) => { }; const getDocumentDetails = async () => { - let docObj = await getSearchDocumentDetails1Paged( - incidentid, - pageNumber - ) + let docObj = await getSearchDocumentDetailsPaged(incidentid, pageNumber) .then((data) => { //console.log(data); setDocumentDetails(data); @@ -303,7 +285,7 @@ const DocumentDetails = (props) => { console.log(historyDetail.pinswg_documentid); } else { historyArr.push( - getSearchDocumentHistory1Paged( + getSearchDocumentHistoryPaged( historyDetail.pinswg_documentid, pageNumber ) diff --git a/components/case/representationList.js b/components/case/representationList.js index 2e0b42f7..da22ec6e 100644 --- a/components/case/representationList.js +++ b/components/case/representationList.js @@ -73,12 +73,7 @@ const RepresentationList = (props) => { return (
- + {t("case:documents-name-label")}: diff --git a/components/homepage/login.js b/components/homepage/login.js index d15571d5..4d94cbc8 100644 --- a/components/homepage/login.js +++ b/components/homepage/login.js @@ -207,7 +207,7 @@ let Login = (props) => {

{t("home:login-card-title")}

{" "} - {/*
+ {validLoginID == false && (
Incorrect username or password @@ -254,7 +254,7 @@ let Login = (props) => { {t("home:login-card-button")}
-
*/} +

{ getBasicDNSSearchPaged(pageNumber) .then((data) => { - //console.log(data); + console.log(data); setSearchResults(data); return data; }) diff --git a/pages/_document.js b/pages/_document.js index a52ff4f0..0b9facb4 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -52,9 +52,15 @@ class MyDocument extends Document { /> )} {!process.browser && ( - + <> + + + )}

diff --git a/pages/advancedsearch.js b/pages/advancedsearch.js index ec940206..e54e694e 100644 --- a/pages/advancedsearch.js +++ b/pages/advancedsearch.js @@ -147,14 +147,14 @@ export const getServerSideProps = wrapper.getServerSideProps( tokenExpiryTimeAt.getSeconds() + token.expires_in ); - console.log( - "token issued:", - tokenIssuedAt.toUTCString(), - "\n", - "token expires:", - tokenExpiryTimeAt.toUTCString() - ); - console.log(token); + // console.log( + // "token issued:", + // tokenIssuedAt.toUTCString(), + // "\n", + // "token expires:", + // tokenExpiryTimeAt.toUTCString() + // ); + // console.log(token); token = token.access_token; const [appealTypeData, lpaData] = await Promise.all([ diff --git a/pages/api/documents/download/[id].js b/pages/api/documents/download/[id].js new file mode 100644 index 00000000..2d740e8c --- /dev/null +++ b/pages/api/documents/download/[id].js @@ -0,0 +1,70 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken } from "../../../../actions"; + +const WORDKEY = process.env.HASHKEY; +const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT; +const tenantId = process.env.TENANT; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +const azureHeadersPaged = (access_token) => { + return { + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json;odata.metadata=none", + "Prefer": + 'odata.include-annotations="*",return=representation, odata.maxpagesize=10', + "Content-Type": "application/json", + "Authorization": "Bearer " + access_token, + }, + }; +}; + +export default async function ApiProxy(req, res) { + var token = await getToken(); + + var docRef = req.query; + + console.log(docRef.id); + + var queryUrl = "documents/download/" + docRef.id + "?hash=" + docRef.hash; + + console.log(WEBAPI_URL + queryUrl); + return axios + .get( + WEBAPI_URL + queryUrl, // + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then((response) => { + console.log(response.headers); + res.status(200); + res.setHeader( + "Content-disposition", + "attachment; filename=" + + response.headers["content-disposition"].split( + "filename=" + )[1] + ); + res.end(response.data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/createaccount_api.js b/pages/api/endpoint/createaccount_api.js new file mode 100644 index 00000000..7cb30c57 --- /dev/null +++ b/pages/api/endpoint/createaccount_api.js @@ -0,0 +1,50 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var token = await getToken(); + var queryUrl = "contacts"; + var data = JSON.stringify(req.body); + + var config = { + method: "post", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*",return=representation', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + return axios(config) + .then(({ data }) => { + console.log("deleted "); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/createwatchedcases_api.js b/pages/api/endpoint/createwatchedcases_api.js new file mode 100644 index 00000000..69e17ffe --- /dev/null +++ b/pages/api/endpoint/createwatchedcases_api.js @@ -0,0 +1,51 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var token = await getToken(); + var data = JSON.stringify(req.body); + var queryUrl = "pinswg_watchlists"; + + console.log("create case"); + + var config = { + method: "post", + url: queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + return axios(config) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/deletemyrepresentations_api.js b/pages/api/endpoint/deletemyrepresentations_api.js new file mode 100644 index 00000000..3aeaa1f0 --- /dev/null +++ b/pages/api/endpoint/deletemyrepresentations_api.js @@ -0,0 +1,49 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var myRepresentationsID = req.query.myRepresentationsID; + var token = await getToken(); + var queryUrl = "pinswg_representationses(" + myRepresentationsID + ")"; + + var config = { + method: "delete", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + }; + + return axios(config) + .then(({ data }) => { + console.log("deleted "); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/deletewatchedcases_api.js b/pages/api/endpoint/deletewatchedcases_api.js new file mode 100644 index 00000000..3d2bb698 --- /dev/null +++ b/pages/api/endpoint/deletewatchedcases_api.js @@ -0,0 +1,49 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var watchedCaseID = req.query.watchedCaseID; + var token = await getToken(); + var queryUrl = "pinswg_watchlists(" + watchedCaseID + ")"; + + var config = { + method: "delete", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + }; + + return axios(config) + .then(({ data }) => { + console.log("deleted "); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getadvancedsearch_api.js b/pages/api/endpoint/getadvancedsearch_api.js new file mode 100644 index 00000000..d25feeee --- /dev/null +++ b/pages/api/endpoint/getadvancedsearch_api.js @@ -0,0 +1,72 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var searchString = req.query.searchstring; + var token = req.query.token; + + searchString = JSON.parse(searchString); + + var queryString = ""; + + queryString += + searchString.q != null + ? "(contains(title, '" + + searchString.q + + "') or contains(ticketnumber,'" + + searchString.q + + "'))" + : ""; + + queryString += + searchString.lpa != null + ? (typeof searchString.q == "undefined" ? "" : " and ") + + "_pinswg_associatedlpa_value eq " + + searchString.lpa + : ""; + queryString += + searchString.apt != null + ? (typeof searchString.q == "undefined" && + typeof searchString.lpa == "undefined" + ? "" + : " and ") + + "pinswg_appealcasetype eq " + + searchString.apt + : ""; + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" + + queryString + + " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getadvancedsearchpaged_api.js b/pages/api/endpoint/getadvancedsearchpaged_api.js new file mode 100644 index 00000000..9f54e0ec --- /dev/null +++ b/pages/api/endpoint/getadvancedsearchpaged_api.js @@ -0,0 +1,77 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (hashPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var searchString = req.query.searchstring; + var pageNumber = req.query.pageNumber; + var token = await getToken(); + + searchString = JSON.parse(searchString); + + var queryString = ""; + + queryString += + searchString.q != null + ? "(contains(title, '" + + searchString.q + + "') or contains(ticketnumber,'" + + searchString.q + + "'))" + : ""; + + queryString += + searchString.lpa != null + ? (typeof searchString.q == "undefined" ? "" : " and ") + + "_pinswg_associatedlpa_value eq " + + searchString.lpa + : ""; + queryString += + searchString.apt != null + ? (typeof searchString.q == "undefined" && + typeof searchString.lpa == "undefined" + ? "" + : " and ") + + "pinswg_appealcasetype eq " + + searchString.apt + : ""; + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" + + queryString + + " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" + + (typeof pageNumber != "undefined" + ? "&$skiptoken=" + ('') + : ""); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getappealid_api.js b/pages/api/endpoint/getappealid_api.js new file mode 100644 index 00000000..46c9aace --- /dev/null +++ b/pages/api/endpoint/getappealid_api.js @@ -0,0 +1,45 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var caseReference = req.query.caseReference; + var updateFormCollection = req.query.updateFormCollection; + var primaryAttribute = req.query.primaryAttribute; + var token = await getToken(); + + const queryUrl = + updateFormCollection + + "?$count=true&$select=_" + + primaryAttribute + + "s_value&$filter=pinswg_name eq '" + + caseReference + + "'"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getappealtypes_api.js b/pages/api/endpoint/getappealtypes_api.js new file mode 100644 index 00000000..0fc9f186 --- /dev/null +++ b/pages/api/endpoint/getappealtypes_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var token = req.query.token; + + var queryUrl = + "stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicdnssearch_api.js b/pages/api/endpoint/getbasicdnssearch_api.js new file mode 100644 index 00000000..1f45571f --- /dev/null +++ b/pages/api/endpoint/getbasicdnssearch_api.js @@ -0,0 +1,43 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var token = req.query.token; + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true"; + + console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl)); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicdnssearchdetails_api.js b/pages/api/endpoint/getbasicdnssearchdetails_api.js new file mode 100644 index 00000000..acee0cb8 --- /dev/null +++ b/pages/api/endpoint/getbasicdnssearchdetails_api.js @@ -0,0 +1,43 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var caseReference = req.query.caseReference; + var token = req.query.token; + + var queryUrl = + "pinswg_dnses?$filter=pinswg_name eq '" + + caseReference + + "'&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js b/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js new file mode 100644 index 00000000..22782f99 --- /dev/null +++ b/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js @@ -0,0 +1,44 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var caseReference = req.query.caseReference; + var token = await getToken(); + + var queryUrl = + "pinswg_dnses?$filter=pinswg_name eq '" + + caseReference + + "'&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicdnssearchpaged_api.js b/pages/api/endpoint/getbasicdnssearchpaged_api.js new file mode 100644 index 00000000..18b4eb04 --- /dev/null +++ b/pages/api/endpoint/getbasicdnssearchpaged_api.js @@ -0,0 +1,47 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + //console.log(hashlink); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var pageNumber = req.query.pageNumber; + var token = await getToken(); + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" + + (typeof pageNumber != "undefined" + ? "&$skiptoken=" + '' + : ""); + + console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl)); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicsearch_api.js b/pages/api/endpoint/getbasicsearch_api.js new file mode 100644 index 00000000..4a0e8185 --- /dev/null +++ b/pages/api/endpoint/getbasicsearch_api.js @@ -0,0 +1,45 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var searchString = req.query.searchString; + var token = req.query.token; + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" + + searchString + + "') or contains(ticketnumber, '" + + searchString + + "')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicsearchdetails_api.js b/pages/api/endpoint/getbasicsearchdetails_api.js new file mode 100644 index 00000000..dd842872 --- /dev/null +++ b/pages/api/endpoint/getbasicsearchdetails_api.js @@ -0,0 +1,48 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var appealTypeName = req.query.appealTypeName; + var primaryIdAttribute = req.query.primaryIdAttribute; + var incidentID = req.query.incidentID; + var token = req.query.token; + + var queryUrl = + appealTypeName + + "?$filter=_" + + primaryIdAttribute + + "s_value eq " + + incidentID + + "&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicsearchdetailspaged_api.js b/pages/api/endpoint/getbasicsearchdetailspaged_api.js new file mode 100644 index 00000000..52013c62 --- /dev/null +++ b/pages/api/endpoint/getbasicsearchdetailspaged_api.js @@ -0,0 +1,49 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var appealTypeName = req.query.appealTypeName; + var primaryIdAttribute = req.query.primaryIdAttribute; + var incidentID = req.query.incidentID; + var token = await getToken(); + + var queryUrl = + appealTypeName + + "?$filter=_" + + primaryIdAttribute + + "s_value eq " + + incidentID + + "&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicsearchpaged_api.js b/pages/api/endpoint/getbasicsearchpaged_api.js new file mode 100644 index 00000000..fa4f1065 --- /dev/null +++ b/pages/api/endpoint/getbasicsearchpaged_api.js @@ -0,0 +1,48 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var searchString = req.query.searchString; + var pageNumber = req.query.pageNumber; + var token = await getToken(); + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" + + searchString + + "') or contains(ticketnumber, '" + + searchString + + "')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" + + (typeof pageNumber != "undefined" + ? "&$skiptoken=" + '' + : ""); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getemailaccountcheck_api.js b/pages/api/endpoint/getemailaccountcheck_api.js new file mode 100644 index 00000000..9ca3f935 --- /dev/null +++ b/pages/api/endpoint/getemailaccountcheck_api.js @@ -0,0 +1,40 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var emailAddress = req.query.emailAddress; + var token = await getToken(); + + var queryUrl = + "contacts?$filter=emailaddress1 eq '" + + emailAddress + + "'&$count=true&$select=emailaddress1, contactid"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getlinkedcases_api.js b/pages/api/endpoint/getlinkedcases_api.js new file mode 100644 index 00000000..4f22492b --- /dev/null +++ b/pages/api/endpoint/getlinkedcases_api.js @@ -0,0 +1,44 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var parentIncidentid = req.query.parentincidentid; + var token = await getToken(); + + var queryUrl = + "incidents?$count=true&$filter=_parentcaseid_value eq " + + parentIncidentid + + " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getlogin_api.js b/pages/api/endpoint/getlogin_api.js new file mode 100644 index 00000000..9759740f --- /dev/null +++ b/pages/api/endpoint/getlogin_api.js @@ -0,0 +1,43 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var emailAddress = req.query.emailAddress; + var pwd = req.query.pwd; + var token = await getToken(); + + var queryUrl = + "contacts?$filter=emailaddress1 eq '" + + emailAddress + + "' and pinswg_custom_password eq '" + + pwd + + "'&$count=true&$select=emailaddress1,contactid,pinswg_custom_password,yomifullname,firstname,lastname"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getlpa_api.js b/pages/api/endpoint/getlpa_api.js new file mode 100644 index 00000000..1d79aeb3 --- /dev/null +++ b/pages/api/endpoint/getlpa_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var token = req.query.token; + + var queryUrl = + "accounts?$count=true&$filter=pinswg_isalocalplanningauthorityaccount eq 846040000&$select=name&$orderby=name asc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getmycases_api.js b/pages/api/endpoint/getmycases_api.js new file mode 100644 index 00000000..8271015f --- /dev/null +++ b/pages/api/endpoint/getmycases_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = req.query.token; + + var queryUrl = + "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"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getmyrepresentations_api.js b/pages/api/endpoint/getmyrepresentations_api.js new file mode 100644 index 00000000..b8d25b34 --- /dev/null +++ b/pages/api/endpoint/getmyrepresentations_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = req.query.token; + + var queryUrl = + "pinswg_representationses?$filter= _pinswg_contact_value eq " + + loggedInUserId + + "&$count=true&$orderby=createdon desc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getmyrepresentationsproxy_api.js b/pages/api/endpoint/getmyrepresentationsproxy_api.js new file mode 100644 index 00000000..b8d25b34 --- /dev/null +++ b/pages/api/endpoint/getmyrepresentationsproxy_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = req.query.token; + + var queryUrl = + "pinswg_representationses?$filter= _pinswg_contact_value eq " + + loggedInUserId + + "&$count=true&$orderby=createdon desc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getpersonalaccount_api.js b/pages/api/endpoint/getpersonalaccount_api.js new file mode 100644 index 00000000..b109ca1d --- /dev/null +++ b/pages/api/endpoint/getpersonalaccount_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var contactid = req.query.contactid; + var token = req.query.token; + + var queryUrl = + "contacts(" + + contactid + + ")?$select=firstname, lastname, emailaddress1, telephone1, company, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode&$count=true"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getportalmoduledetails_api.js b/pages/api/endpoint/getportalmoduledetails_api.js new file mode 100644 index 00000000..37c4c192 --- /dev/null +++ b/pages/api/endpoint/getportalmoduledetails_api.js @@ -0,0 +1,39 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var appealType = req.query.appealType; + var caseReference = req.query.caseReference; + var token = req.query.token; + + var queryUrl = + appealType + + "?$filter=pinswg_name eq '" + + caseReference + + "'&$count=true"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getportalmoduledetailsproxy_api.js b/pages/api/endpoint/getportalmoduledetailsproxy_api.js new file mode 100644 index 00000000..655d861f --- /dev/null +++ b/pages/api/endpoint/getportalmoduledetailsproxy_api.js @@ -0,0 +1,42 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var appealType = req.query.appealType; + var caseReference = req.query.caseReference; + var token = await getToken(); + + var queryUrl = + appealType + + "?$filter=pinswg_name eq '" + + caseReference + + "'&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getrepresentations_api.js b/pages/api/endpoint/getrepresentations_api.js new file mode 100644 index 00000000..987684a2 --- /dev/null +++ b/pages/api/endpoint/getrepresentations_api.js @@ -0,0 +1,40 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = await getToken(); + + var queryUrl = + "pinswg_representationses?$filter= _pinswg_case_value eq " + + incidentID + + " and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getrepresentationsproxy_api.js b/pages/api/endpoint/getrepresentationsproxy_api.js new file mode 100644 index 00000000..b92286f7 --- /dev/null +++ b/pages/api/endpoint/getrepresentationsproxy_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var incidentID = req.query.incidentID; + var token = req.query.token; + + var queryUrl = + "pinswg_representationses?$filter= _pinswg_case_value eq " + + incidentID + + "&$count=true&$orderby=createdon desc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getsearchdocumentdetails_api.js b/pages/api/endpoint/getsearchdocumentdetails_api.js new file mode 100644 index 00000000..8ce7c392 --- /dev/null +++ b/pages/api/endpoint/getsearchdocumentdetails_api.js @@ -0,0 +1,64 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +const encryptDocReference = (documentRef) => { + var hashlink = CryptoJS.HmacSHA256( + "documents/download/" + documentRef, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + var hashStr = + "/api/documents/download/" + documentRef + "?hash=" + hashlink; + + return hashStr; +}; + +export default async function ApiProxy(req, res) { + var incidentID = req.query.incidentid; + var token = await getToken(); + + var queryUrl = + "pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " + + incidentID + + "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + data.value.forEach(function (element) { + element.pinswg_hashlink = encryptDocReference( + element.pinswg_isharedocumentreference + ); + }); + //console.log("details data:", data); + + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getsearchdocumentdetailspaged_api.js b/pages/api/endpoint/getsearchdocumentdetailspaged_api.js new file mode 100644 index 00000000..480390aa --- /dev/null +++ b/pages/api/endpoint/getsearchdocumentdetailspaged_api.js @@ -0,0 +1,67 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +const encryptDocReference = (documentRef) => { + var hashlink = CryptoJS.HmacSHA256( + "documents/download/" + documentRef, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + var hashStr = + "/api/documents/download/" + documentRef + "?hash=" + hashlink; + + return hashStr; +}; + +export default async function ApiProxy(req, res) { + var pageNumber = req.query.pageNumber; + var incidentID = req.query.incidentid; + var token = await getToken(); + + var queryUrl = + "pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " + + incidentID + + "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" + + (typeof pageNumber != "undefined" + ? "&$skiptoken=" + ('') + : ""); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + data.value.forEach(function (element) { + element.pinswg_hashlink = encryptDocReference( + element.pinswg_isharedocumentreference + ); + }); + //console.log("details paged data:", data); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getsearchdocumenthistory_api.js b/pages/api/endpoint/getsearchdocumenthistory_api.js new file mode 100644 index 00000000..3c22cbbc --- /dev/null +++ b/pages/api/endpoint/getsearchdocumenthistory_api.js @@ -0,0 +1,43 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var documentID = req.query.documentid; + var token = await getToken(); + + var queryUrl = + "pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + + documentID; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getsearchdocumenthistorypaged_api.js b/pages/api/endpoint/getsearchdocumenthistorypaged_api.js new file mode 100644 index 00000000..4f47b85b --- /dev/null +++ b/pages/api/endpoint/getsearchdocumenthistorypaged_api.js @@ -0,0 +1,48 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; + +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var documentID = req.query.documentid; + var pageNumber = req.query.pageNumber; + var token = await getToken(); + + var queryUrl = + "pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " + + documentID; + // + + // (typeof pageNumber != "undefined" + // ? "&$skiptoken=" + ('') + // : ""); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeadersPaged(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getwatchedcases_api copy 2.js b/pages/api/endpoint/getwatchedcases_api copy 2.js new file mode 100644 index 00000000..cd7d502c --- /dev/null +++ b/pages/api/endpoint/getwatchedcases_api copy 2.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = req.query.token; + + var queryUrl = + "pinswg_watchlists?$filter= _pinswg_contact_value eq " + + loggedInUserId + + "&$count=true&$orderby=createdon desc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getwatchedcases_api.js b/pages/api/endpoint/getwatchedcases_api.js new file mode 100644 index 00000000..cd7d502c --- /dev/null +++ b/pages/api/endpoint/getwatchedcases_api.js @@ -0,0 +1,37 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = req.query.token; + + var queryUrl = + "pinswg_watchlists?$filter= _pinswg_contact_value eq " + + loggedInUserId + + "&$count=true&$orderby=createdon desc"; + + return axios + .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getwatchedcasesproxy_api.js b/pages/api/endpoint/getwatchedcasesproxy_api.js new file mode 100644 index 00000000..b9dda1ae --- /dev/null +++ b/pages/api/endpoint/getwatchedcasesproxy_api.js @@ -0,0 +1,40 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = await getToken(); + + var queryUrl = + "pinswg_watchlists?$filter= _pinswg_contact_value eq " + + loggedInUserId + + "&$count=true&$orderby=createdon desc"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/updateaccount_api.js b/pages/api/endpoint/updateaccount_api.js new file mode 100644 index 00000000..fef1f06d --- /dev/null +++ b/pages/api/endpoint/updateaccount_api.js @@ -0,0 +1,50 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var contactId = req.query.contactId; + var token = await getToken(); + var data = JSON.stringify(req.body); + var queryUrl = "contacts(" + contactId + ")"; + + var config = { + method: "patch", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + return axios(config) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/updatecase_api.js b/pages/api/endpoint/updatecase_api.js new file mode 100644 index 00000000..6a6203ee --- /dev/null +++ b/pages/api/endpoint/updatecase_api.js @@ -0,0 +1,52 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var data = JSON.stringify(req.body); + var appealObj = rea.query.appealObj; + var updateFormCollection = req.query.updateFormCollection; + var queryUrl = updateFormCollection + "(" + appealObj + ")"; + + var token = await getToken(); + + var config = { + method: "patch", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + return axios(config) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/updatepassword_api.js b/pages/api/endpoint/updatepassword_api.js new file mode 100644 index 00000000..fef1f06d --- /dev/null +++ b/pages/api/endpoint/updatepassword_api.js @@ -0,0 +1,50 @@ +import axios from "axios"; +import https from "https"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } from "../../../actions"; +const WORDKEY = process.env.HASHKEY; + +const WEBAPI_URL = + process.env.RELAY_ROOT || + "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; + +const hashAPIPath = (queryPath) => { + var hashlink = CryptoJS.HmacSHA256( + queryPath, + CryptoJS.enc.Hex.parse(WORDKEY) + ); + hashlink = hashlink.toString(CryptoJS.enc.Hex); + + //return "&hash=" + hashlink; + + return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var contactId = req.query.contactId; + var token = await getToken(); + var data = JSON.stringify(req.body); + var queryUrl = "contacts(" + contactId + ")"; + + var config = { + method: "patch", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + return axios(config) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/proxy/[...route].js b/pages/api/proxy/[...route].js deleted file mode 100644 index c575e5bc..00000000 --- a/pages/api/proxy/[...route].js +++ /dev/null @@ -1,195 +0,0 @@ -import axios from "axios"; -import https from "https"; -import CryptoJS from "crypto-js"; -import HmacSHA256 from "crypto-js/hmac-sha256"; -import { rest } from "lodash"; - -const PROXY_RELAY_URL = - "https://" + - (process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net") + - "/" + - (process.env.RELAYPATH || "dev-pedw-hc") + - "/"; - -const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT; -const tenantId = process.env.TENANT; - -const tokenBody = - "grant_type=" + - process.env.GRANT_TYPE + - "&client_id=" + - process.env.CLIENT_ID + - "&client_secret=" + - process.env.CLIENT_SECRET + - "&scope=" + - "https://" + - process.env.RELAYURI + - "/.default"; - -const tokenConfig = { - headers: { - "Content-Type": "application/x-www-form-urlencoded", - "Cache-Control": "no-cache", - }, -}; - -export const getToken = () => { - return axios - .post( - `${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`, - tokenBody, - tokenConfig - ) - .then((res) => res.data) - .then((data) => { - return data; - }) - .catch((error) => { - console.log("error :", error.response); - // return error; - }); -}; - -function checkProxyPath(queryPath) { - const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY; - - var hashPath = - queryPath.indexOf("/api/proxy/") == -1 - ? queryPath - : queryPath.split("/api/proxy/")[1]; - - const wordKey = WORDKEY; - var hashlink = CryptoJS.HmacSHA256( - decodeURI(hashPath), - CryptoJS.enc.Hex.parse(wordKey) - ); - - hashlink = hashlink.toString(CryptoJS.enc.Hex); - - return hashlink; -} - -export default async function ApiProxy(req, res) { - var data = req.body; //JSON.stringify(req.body); - var accessToken = await getToken(); - accessToken = accessToken.access_token; - - const isDocument = req.url.indexOf("/documents/download") > -1; - - let hashCheckPath = - req.url.indexOf("?hash=") > -1 - ? req.url.split("?hash=")[0] - : req.url.split("&hash=")[0]; - - let hashCheckValue = - req.url.indexOf("?hash=") > -1 - ? req.url.split("?hash=")[1] - : req.url.split("&hash=")[1]; - - let hashFromRequest = checkProxyPath(hashCheckPath); - - let proxyDestinationURL = - PROXY_RELAY_URL + - (req.url.indexOf("?hash=") > -1 - ? req.url.split("?hash=")[0] - : req.url.split("&hash=")[0] - ).split("/api/proxy/")[1] + - (req.url.indexOf("?hash=") > -1 - ? "?hash=" + req.url.split("?hash=")[1] - : "&hash=" + req.url.split("&hash=")[1]); - - var configNoData = { - method: req.method, - //url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")", - url: proxyDestinationURL, - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": - 'odata.include-annotations="*",return=representation,odata.maxpagesize=10', - "Authorization": "Bearer " + accessToken, - "Content-Type": "application/json", - }, - }; - - var config = { - method: req.method, - url: proxyDestinationURL, - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Authorization": "Bearer " + accessToken, - "Content-Type": "application/json", - }, - data: data, - }; - - var configDocument = { - method: req.method, - url: - PROXY_RELAY_URL + - req.url.split("?hash=")[0].split("/api/proxy/")[1] + - "?hash=" + - req.url.split("?hash=")[1], - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Authorization": "Bearer " + accessToken, - "Content-Type": "application/json", - }, - responseType: "arraybuffer", - }; - - if (hashCheckValue == hashFromRequest) { - return new Promise((resolve, reject) => { - let hasDocument = - hashCheckPath.indexOf("/download") > 0 ? true : false; - - axios( - req.method == "PATCH" - ? config - : req.method == "GET" - ? hasDocument - ? configDocument - : configNoData - : config - ) - .then((response) => { - res.statusCode = 200; - if (hasDocument) { - res.setHeader( - "Content-disposition", - "attachment; filename=" + - response.headers["content-disposition"].split( - "filename=" - )[1] - ); - res.end(response.data); - } else { - res.setHeader("Content-Type", "application/json"); - // res.setHeader("Cache-Control", "max-age=1800000"); - res.end(JSON.stringify(response.data)); - } - resolve(); - }) - .catch((error) => { - console.log("proxy response error", error); - //res.json(error); - res.status(405).end(); - return resolve(); - }); - }); - } else { - console.log( - "no matching hash", - hashCheckValue + " - " + hashFromRequest - ); - res.status(405).end(); - return resolve(); - } -} diff --git a/pages/dnsapplications.js b/pages/dnsapplications.js index 3174cdab..c56405a3 100644 --- a/pages/dnsapplications.js +++ b/pages/dnsapplications.js @@ -136,14 +136,14 @@ export const getServerSideProps = wrapper.getServerSideProps( tokenExpiryTimeAt.getSeconds() + token.expires_in ); - console.log( - "token issued:", - tokenIssuedAt.toUTCString(), - "\n", - "token expires:", - tokenExpiryTimeAt.toUTCString() - ); - console.log(token); + // console.log( + // "token issued:", + // tokenIssuedAt.toUTCString(), + // "\n", + // "token expires:", + // tokenExpiryTimeAt.toUTCString() + // ); + // console.log(token); token = token.access_token; diff --git a/pages/index.js b/pages/index.js index afe10ab8..37dcd31e 100644 --- a/pages/index.js +++ b/pages/index.js @@ -31,8 +31,6 @@ import { } from "../store/accountDetails/action"; import { parseCookies, setCookie, destroyCookie } from "nookies"; -const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY; - const Home = (props) => { const { footerLinks, @@ -53,9 +51,9 @@ const Home = (props) => { let expDate = new Date(now); expDate.setDate(now.getDate() + 1); - console.log("hashed email str", loginEmailStr); + //console.log("hashed email str", loginEmailStr); _.isEmpty(loggedInUserId) != false && !hasGGCode - ? console.log("no log in no ggcode") + ? console.log("no ggcode") : _.has(loggedInUserId, "value") ? _.isEmpty(loggedInUserId.value) ? router.replace({ diff --git a/pages/myportal/index.js b/pages/myportal/index.js index c761f4a7..4ad13026 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -165,7 +165,7 @@ export const getServerSideProps = wrapper.getServerSideProps( const { cookies } = req; - console.log("the cookoies", cookies); + // console.log("the cookoies", cookies); let token = await getToken(); token = token.access_token; @@ -174,13 +174,13 @@ export const getServerSideProps = wrapper.getServerSideProps( let providerConfig = await getProviderConfig(); - console.log( - "logout endpoint: ", - providerConfig.end_session_endpoint, - "\n", - "redirect:", - process.env.GG_REDIRECT_URI - ); + // console.log( + // "logout endpoint: ", + // providerConfig.end_session_endpoint, + // "\n", + // "redirect:", + // process.env.GG_REDIRECT_URI + //); store.dispatch(getGovGatewayConfig(providerConfig)); @@ -199,11 +199,11 @@ export const getServerSideProps = wrapper.getServerSideProps( ]); //const cookiesMaker = nookies.get(ctx) - console.log( - "acc details:", - accountDetails, - _.has(accountDetails, "errorCode") != false - ); + // console.log( + // "acc details:", + // accountDetails, + // _.has(accountDetails, "errorCode") != false + // ); if (_.has(accountDetails, "errorCode") != false) { return { @@ -222,7 +222,7 @@ export const getServerSideProps = wrapper.getServerSideProps( await getDetails(token, myCases, "myCases"), await getDetails(token, myRepresentations, "myRepresentations"), await getDetails(token, watchedCases, "myWatchedCases"), - // await getDetails(awaitingSubmission), + //await getDetails(awaitingSubmission), ]); store.dispatch(setAccountDetails(accountDetails)); @@ -244,7 +244,7 @@ export const getServerSideProps = wrapper.getServerSideProps( ); const getDetails = (token, resultsObj, detailsType) => { - console.log(resultsObj); + console.log(detailsType); let detailsArr = []; resultsObj = resultsObj.value; const detailsObj = resultsObj.map((searchDetail, index) => { @@ -271,7 +271,6 @@ const getDetails = (token, resultsObj, detailsType) => { ); } }); - //console.log(detailsArr); return Promise.all(detailsArr); }; diff --git a/pages/searchresults.js b/pages/searchresults.js index 4fab7c5e..7aa56256 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -131,7 +131,7 @@ export const getServerSideProps = wrapper.getServerSideProps( ? true : false; - console.log("is linked:", isLinked); + //console.log("is linked:", isLinked); let token = await getToken(); var tokenIssuedAt = new Date(); @@ -140,14 +140,14 @@ export const getServerSideProps = wrapper.getServerSideProps( tokenExpiryTimeAt.getSeconds() + token.expires_in ); - console.log( - "token issued:", - tokenIssuedAt.toUTCString(), - "\n", - "token expires:", - tokenExpiryTimeAt.toUTCString() - ); - console.log(token); + // console.log( + // "token issued:", + // tokenIssuedAt.toUTCString(), + // "\n", + // "token expires:", + // tokenExpiryTimeAt.toUTCString() + // ); + // //console.log(token); token = token.access_token;