diff --git a/actions/govgateway.js b/actions/govgateway.js index cf03784f..0b6e2061 100644 --- a/actions/govgateway.js +++ b/actions/govgateway.js @@ -1,5 +1,5 @@ import axios from "axios"; -import { hashAPIPath } from "./"; +import { hashAPIPath, consoleLogger } from "./"; const configEndpoint = process.env.GG_PROVIDER_CONFIG_ENDPOINT; const ggClientID = process.env.GG_CLIENT_ID; @@ -87,7 +87,9 @@ export const getPortalLogin = (emailAddress, token) => { .get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token)) .then((res) => res.data) .catch((error) => { - console.log("thiserror", error); + console.log(consoleLogger(error)); + //console.log("thiserror", error); + return JSON.stringify(error); }); }; diff --git a/actions/index.js b/actions/index.js index fccd1ea1..aa3a0d01 100644 --- a/actions/index.js +++ b/actions/index.js @@ -24,6 +24,18 @@ const WEBAPI_URL = process.env.RELAY_ROOT || "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/"; +export const consoleLogger = (err) => { + var errStr = + "///////\nServer Error " + + "\n" + + err.response.status + + " : " + + err.response.statusText + + "\n///////"; + + return errStr; +}; + export const getToken = () => { return axios .post( @@ -1027,7 +1039,7 @@ export const createAccount = (formValues) => { export const uploadFiles = async (formValues, filesObj, uploadhash) => { let files = filesObj; - console.log(formValues); + //console.log(formValues); var formData = new FormData(); formData.append("appealData", JSON.stringify(formValues)); @@ -1040,7 +1052,7 @@ export const uploadFiles = async (formValues, filesObj, uploadhash) => { } } - console.log(formData); + //console.log(formData); var queryUrl = "/api/file/upload"; diff --git a/components/myportal.js b/components/myportal.js index 9d0a9fcf..fa2dfde8 100644 --- a/components/myportal.js +++ b/components/myportal.js @@ -21,7 +21,7 @@ const MyPortal = (props) => { const { locale } = router; const handleLogout = () => { - console.log("////////////", "\n", "logout", "\n", "//////////"); + console.log("////////////\n" + "logout" + "\n////////////"); destroyCookie({}, "pinsUser"), window.localStorage.clear(), //router.replace(props.ggLogout); diff --git a/pages/api/documents/download/[id].js b/pages/api/documents/download/[id].js index 24493903..57e3534b 100644 --- a/pages/api/documents/download/[id].js +++ b/pages/api/documents/download/[id].js @@ -81,7 +81,8 @@ export default async function ApiProxy(req, res) { return "downloadComplete"; }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/createaccount_api.js b/pages/api/endpoint/createaccount_api.js index 2d87ccc1..f9ff3067 100644 --- a/pages/api/endpoint/createaccount_api.js +++ b/pages/api/endpoint/createaccount_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -43,7 +43,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/createcase_api.js b/pages/api/endpoint/createcase_api.js index 8a25d441..b3046f52 100644 --- a/pages/api/endpoint/createcase_api.js +++ b/pages/api/endpoint/createcase_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -65,7 +65,8 @@ export default async function ApiProxy(req, res) { console.log(data); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); diff --git a/pages/api/endpoint/createwatchedcases_api.js b/pages/api/endpoint/createwatchedcases_api.js index b5d13835..b17e4f97 100644 --- a/pages/api/endpoint/createwatchedcases_api.js +++ b/pages/api/endpoint/createwatchedcases_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -43,7 +43,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/deleteawaitingsubmissions_api.js b/pages/api/endpoint/deleteawaitingsubmissions_api.js index cd8b7263..d56bc4ad 100644 --- a/pages/api/endpoint/deleteawaitingsubmissions_api.js +++ b/pages/api/endpoint/deleteawaitingsubmissions_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -43,7 +43,8 @@ export default async function ApiProxy(req, res) { //console.log("deleted awaitingsubmission case - " + incidentID); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/deletemyrepresentations_api.js b/pages/api/endpoint/deletemyrepresentations_api.js index 1270f5ed..3efd9f69 100644 --- a/pages/api/endpoint/deletemyrepresentations_api.js +++ b/pages/api/endpoint/deletemyrepresentations_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -42,7 +42,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/deletewatchedcases_api.js b/pages/api/endpoint/deletewatchedcases_api.js index 836678d7..5ba1abef 100644 --- a/pages/api/endpoint/deletewatchedcases_api.js +++ b/pages/api/endpoint/deletewatchedcases_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -43,7 +43,8 @@ export default async function ApiProxy(req, res) { //console.log("deleted watched case - " + watchedCaseID); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getadvancedsearch_api.js b/pages/api/endpoint/getadvancedsearch_api.js index b9492a3d..c0067163 100644 --- a/pages/api/endpoint/getadvancedsearch_api.js +++ b/pages/api/endpoint/getadvancedsearch_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -75,7 +75,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); diff --git a/pages/api/endpoint/getadvancedsearchpaged_api.js b/pages/api/endpoint/getadvancedsearchpaged_api.js index d69d4c19..6ea0c127 100644 --- a/pages/api/endpoint/getadvancedsearchpaged_api.js +++ b/pages/api/endpoint/getadvancedsearchpaged_api.js @@ -93,7 +93,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); diff --git a/pages/api/endpoint/getappealid_api.js b/pages/api/endpoint/getappealid_api.js index 989c6ee6..4317372c 100644 --- a/pages/api/endpoint/getappealid_api.js +++ b/pages/api/endpoint/getappealid_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -39,7 +39,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getappealtypes_api.js b/pages/api/endpoint/getappealtypes_api.js index 7d578a0a..f5c20f71 100644 --- a/pages/api/endpoint/getappealtypes_api.js +++ b/pages/api/endpoint/getappealtypes_api.js @@ -1,6 +1,11 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +import { + getToken, + azureHeadersPaged, + azureHeaders, + consoleLogger, +} from "../../../actions"; /** * @swagger * /api/endpoint/getappealtypes_api: @@ -47,7 +52,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getawaitingsubmission_api.js b/pages/api/endpoint/getawaitingsubmission_api.js index 105c2909..3cf3a4b1 100644 --- a/pages/api/endpoint/getawaitingsubmission_api.js +++ b/pages/api/endpoint/getawaitingsubmission_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -38,7 +38,8 @@ export default async function ApiProxy(req, res) { }); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getawaitingsubmissionproxy_api.js b/pages/api/endpoint/getawaitingsubmissionproxy_api.js index 69f1237a..6d592f66 100644 --- a/pages/api/endpoint/getawaitingsubmissionproxy_api.js +++ b/pages/api/endpoint/getawaitingsubmissionproxy_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -38,7 +38,8 @@ export default async function ApiProxy(req, res) { //console.log(data); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getbasicdnssearch_api.js b/pages/api/endpoint/getbasicdnssearch_api.js index c4c7e0b6..d42a9fb3 100644 --- a/pages/api/endpoint/getbasicdnssearch_api.js +++ b/pages/api/endpoint/getbasicdnssearch_api.js @@ -1,7 +1,12 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeaders, azureHeadersPaged } from "../../../actions"; +import { + getToken, + azureHeaders, + azureHeadersPaged, + consoleLogger, +} from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -41,7 +46,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getbasicdnssearchdetails_api.js b/pages/api/endpoint/getbasicdnssearchdetails_api.js index f07eaa41..cbb032cc 100644 --- a/pages/api/endpoint/getbasicdnssearchdetails_api.js +++ b/pages/api/endpoint/getbasicdnssearchdetails_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -44,7 +44,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js b/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js index 74b05bf5..8501cbfd 100644 --- a/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js +++ b/pages/api/endpoint/getbasicdnssearchdetailspaged_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -48,7 +48,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); return res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getbasicdnssearchpaged_api.js b/pages/api/endpoint/getbasicdnssearchpaged_api.js index e55bd943..b983bfba 100644 --- a/pages/api/endpoint/getbasicdnssearchpaged_api.js +++ b/pages/api/endpoint/getbasicdnssearchpaged_api.js @@ -51,7 +51,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); return res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getbasicdnsurlsearch_api.js b/pages/api/endpoint/getbasicdnsurlsearch_api.js index 24bcbca7..418f9f6f 100644 --- a/pages/api/endpoint/getbasicdnsurlsearch_api.js +++ b/pages/api/endpoint/getbasicdnsurlsearch_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -49,7 +49,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getbasicpartsaveddetails_api.js b/pages/api/endpoint/getbasicpartsaveddetails_api.js index 31b1d9a2..bbbaf2aa 100644 --- a/pages/api/endpoint/getbasicpartsaveddetails_api.js +++ b/pages/api/endpoint/getbasicpartsaveddetails_api.js @@ -44,7 +44,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getbasicsearch_api.js b/pages/api/endpoint/getbasicsearch_api.js index 396fa471..0e7c4b12 100644 --- a/pages/api/endpoint/getbasicsearch_api.js +++ b/pages/api/endpoint/getbasicsearch_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -49,7 +49,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getbasicsearchdetails_api.js b/pages/api/endpoint/getbasicsearchdetails_api.js index 0abcb60b..7ed4f899 100644 --- a/pages/api/endpoint/getbasicsearchdetails_api.js +++ b/pages/api/endpoint/getbasicsearchdetails_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -44,7 +44,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getbasicsearchdetailspaged_api.js b/pages/api/endpoint/getbasicsearchdetailspaged_api.js index ab0a5871..7a37841d 100644 --- a/pages/api/endpoint/getbasicsearchdetailspaged_api.js +++ b/pages/api/endpoint/getbasicsearchdetailspaged_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -52,7 +52,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); return res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getbasicsearchpaged_api.js b/pages/api/endpoint/getbasicsearchpaged_api.js index c3458c2c..1396d762 100644 --- a/pages/api/endpoint/getbasicsearchpaged_api.js +++ b/pages/api/endpoint/getbasicsearchpaged_api.js @@ -62,7 +62,8 @@ export default async function ApiProxy(req, res) { dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getcase_api.js b/pages/api/endpoint/getcase_api.js index 13c8766f..da248bf6 100644 --- a/pages/api/endpoint/getcase_api.js +++ b/pages/api/endpoint/getcase_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -38,7 +38,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getdnscoords_api.js b/pages/api/endpoint/getdnscoords_api.js index 130e8437..c6d7ed82 100644 --- a/pages/api/endpoint/getdnscoords_api.js +++ b/pages/api/endpoint/getdnscoords_api.js @@ -1,6 +1,11 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +import { + getToken, + azureHeadersPaged, + azureHeaders, + consoleLogger, +} from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -36,7 +41,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getdnslist_api.js b/pages/api/endpoint/getdnslist_api.js index 0426e727..39c4e7e8 100644 --- a/pages/api/endpoint/getdnslist_api.js +++ b/pages/api/endpoint/getdnslist_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -41,7 +41,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getemailaccountcheck_api.js b/pages/api/endpoint/getemailaccountcheck_api.js index 8cb1cbba..4d6ee9e0 100644 --- a/pages/api/endpoint/getemailaccountcheck_api.js +++ b/pages/api/endpoint/getemailaccountcheck_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -38,7 +38,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getformdata_api.js b/pages/api/endpoint/getformdata_api.js index 4efb97f6..1e758021 100644 --- a/pages/api/endpoint/getformdata_api.js +++ b/pages/api/endpoint/getformdata_api.js @@ -1,6 +1,11 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +import { + getToken, + azureHeadersPaged, + azureHeaders, + consoleLogger, +} from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -37,7 +42,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getlinkedcases_api.js b/pages/api/endpoint/getlinkedcases_api.js index dc2d370f..9b7a0f23 100644 --- a/pages/api/endpoint/getlinkedcases_api.js +++ b/pages/api/endpoint/getlinkedcases_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -37,7 +37,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getlogin_api.js b/pages/api/endpoint/getlogin_api.js index b40b2f53..ca856d23 100644 --- a/pages/api/endpoint/getlogin_api.js +++ b/pages/api/endpoint/getlogin_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -44,9 +44,11 @@ export default async function ApiProxy(req, res) { azureHeadersPaged(token.access_token) ) .then(({ data }) => { + console.log(data); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getlpa_api.js b/pages/api/endpoint/getlpa_api.js index 525f4831..3f52b01a 100644 --- a/pages/api/endpoint/getlpa_api.js +++ b/pages/api/endpoint/getlpa_api.js @@ -1,6 +1,11 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +import { + getToken, + azureHeadersPaged, + azureHeaders, + consoleLogger, +} from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -35,8 +40,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { - console.log(err); + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getmandatoryfields_api.js b/pages/api/endpoint/getmandatoryfields_api.js index 1e5aa59f..7ca72412 100644 --- a/pages/api/endpoint/getmandatoryfields_api.js +++ b/pages/api/endpoint/getmandatoryfields_api.js @@ -1,6 +1,11 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions"; +import { + getToken, + azureHeadersPaged, + azureHeaders, + consoleLogger, +} from "../../../actions"; const WORDKEY = process.env.HASHKEY; diff --git a/pages/api/endpoint/getmycases_api.js b/pages/api/endpoint/getmycases_api.js index b92f1207..a80f88c2 100644 --- a/pages/api/endpoint/getmycases_api.js +++ b/pages/api/endpoint/getmycases_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -39,7 +39,8 @@ export default async function ApiProxy(req, res) { }); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getmyrepresentations_api.js b/pages/api/endpoint/getmyrepresentations_api.js index 398ea8dc..635f0ed3 100644 --- a/pages/api/endpoint/getmyrepresentations_api.js +++ b/pages/api/endpoint/getmyrepresentations_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -34,7 +34,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getmyrepresentationsproxy_api.js b/pages/api/endpoint/getmyrepresentationsproxy_api.js index 398ea8dc..635f0ed3 100644 --- a/pages/api/endpoint/getmyrepresentationsproxy_api.js +++ b/pages/api/endpoint/getmyrepresentationsproxy_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -34,7 +34,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getpartsavedappeal_api.js b/pages/api/endpoint/getpartsavedappeal_api.js index 632bb539..e75c5123 100644 --- a/pages/api/endpoint/getpartsavedappeal_api.js +++ b/pages/api/endpoint/getpartsavedappeal_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -54,7 +54,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getpersonalaccount_api.js b/pages/api/endpoint/getpersonalaccount_api.js index 16743aae..d732aeee 100644 --- a/pages/api/endpoint/getpersonalaccount_api.js +++ b/pages/api/endpoint/getpersonalaccount_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -36,7 +36,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }) : res.status(400).json(); diff --git a/pages/api/endpoint/getpicklists_api.js b/pages/api/endpoint/getpicklists_api.js index be830bb0..592e5612 100644 --- a/pages/api/endpoint/getpicklists_api.js +++ b/pages/api/endpoint/getpicklists_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; diff --git a/pages/api/endpoint/getportalmoduledetails_api.js b/pages/api/endpoint/getportalmoduledetails_api.js index c0fda940..5b1455eb 100644 --- a/pages/api/endpoint/getportalmoduledetails_api.js +++ b/pages/api/endpoint/getportalmoduledetails_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -43,7 +43,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getportalmoduledetailsproxy_api.js b/pages/api/endpoint/getportalmoduledetailsproxy_api.js index 4b6401d7..41b79c67 100644 --- a/pages/api/endpoint/getportalmoduledetailsproxy_api.js +++ b/pages/api/endpoint/getportalmoduledetailsproxy_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -39,7 +39,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getrepresentations_api.js b/pages/api/endpoint/getrepresentations_api.js index 84653594..2a3e0234 100644 --- a/pages/api/endpoint/getrepresentations_api.js +++ b/pages/api/endpoint/getrepresentations_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -34,7 +34,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getrepresentationsproxy_api.js b/pages/api/endpoint/getrepresentationsproxy_api.js index 0367f052..e120e308 100644 --- a/pages/api/endpoint/getrepresentationsproxy_api.js +++ b/pages/api/endpoint/getrepresentationsproxy_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -34,7 +34,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getsearchdocumentTypes_api.js b/pages/api/endpoint/getsearchdocumentTypes_api.js index a4ca5c6c..c5cb6b2c 100644 --- a/pages/api/endpoint/getsearchdocumentTypes_api.js +++ b/pages/api/endpoint/getsearchdocumentTypes_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -74,7 +74,8 @@ export default async function ApiProxy(req, res) { // (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(dataArr); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getsearchdocumentdetails_api.js b/pages/api/endpoint/getsearchdocumentdetails_api.js index a5b8a19c..8122fa3d 100644 --- a/pages/api/endpoint/getsearchdocumentdetails_api.js +++ b/pages/api/endpoint/getsearchdocumentdetails_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -62,7 +62,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getsearchdocumentdetailspaged_api.js b/pages/api/endpoint/getsearchdocumentdetailspaged_api.js index 7a9c7c5b..bd221ffd 100644 --- a/pages/api/endpoint/getsearchdocumentdetailspaged_api.js +++ b/pages/api/endpoint/getsearchdocumentdetailspaged_api.js @@ -82,7 +82,8 @@ export default async function ApiProxy(req, res) { (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1])); return res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getsearchdocumenthistory_api.js b/pages/api/endpoint/getsearchdocumenthistory_api.js index 2f2c5a5b..a2e7566d 100644 --- a/pages/api/endpoint/getsearchdocumenthistory_api.js +++ b/pages/api/endpoint/getsearchdocumenthistory_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -36,7 +36,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getsearchdocumenthistorypaged_api.js b/pages/api/endpoint/getsearchdocumenthistorypaged_api.js index 6d098214..5c20554b 100644 --- a/pages/api/endpoint/getsearchdocumenthistorypaged_api.js +++ b/pages/api/endpoint/getsearchdocumenthistorypaged_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -41,7 +41,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(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 index a7763975..a8ae5768 100644 --- a/pages/api/endpoint/getwatchedcases_api copy 2.js +++ b/pages/api/endpoint/getwatchedcases_api copy 2.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { getToken, azureHeaders, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -34,7 +34,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getwatchedcases_api.js b/pages/api/endpoint/getwatchedcases_api.js index 726bb769..53472ddb 100644 --- a/pages/api/endpoint/getwatchedcases_api.js +++ b/pages/api/endpoint/getwatchedcases_api.js @@ -63,7 +63,8 @@ export default async function ApiProxy(req, res) { }); res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/getwatchedcasesproxy_api.js b/pages/api/endpoint/getwatchedcasesproxy_api.js index d070540c..9505f281 100644 --- a/pages/api/endpoint/getwatchedcasesproxy_api.js +++ b/pages/api/endpoint/getwatchedcasesproxy_api.js @@ -34,7 +34,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/patchcase_api.js b/pages/api/endpoint/patchcase_api.js index 68a514d1..6ae5e8fb 100644 --- a/pages/api/endpoint/patchcase_api.js +++ b/pages/api/endpoint/patchcase_api.js @@ -1,7 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import _ from "lodash"; -import { getToken, azureHeadersPaged } from "../../../actions"; +import { getToken, azureHeadersPaged, consoleLogger } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -52,7 +52,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); diff --git a/pages/api/endpoint/updateaccount_api.js b/pages/api/endpoint/updateaccount_api.js index 8eea133a..d61a866f 100644 --- a/pages/api/endpoint/updateaccount_api.js +++ b/pages/api/endpoint/updateaccount_api.js @@ -44,7 +44,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/api/endpoint/updatepassword_api.js b/pages/api/endpoint/updatepassword_api.js index 8eea133a..d61a866f 100644 --- a/pages/api/endpoint/updatepassword_api.js +++ b/pages/api/endpoint/updatepassword_api.js @@ -44,7 +44,8 @@ export default async function ApiProxy(req, res) { .then(({ data }) => { res.status(200).json(data); }) - .catch(({ err }) => { + .catch((err) => { + console.log(consoleLogger(err)); res.status(400).json(err); }); } diff --git a/pages/dns/index.js b/pages/dns/index.js index e107eb6c..e55862ac 100644 --- a/pages/dns/index.js +++ b/pages/dns/index.js @@ -15,7 +15,7 @@ import { setSearchDetails, setSearchResults, } from "../../store/searchOutput/action"; - +import _ from "lodash"; import Breadcrumbs from "../../components/breadcrumbs"; const Home = (props) => { @@ -58,19 +58,33 @@ export const getServerSideProps = wrapper.getServerSideProps( ); let searchResultsObj = await getDNSList(); - searchResultsObj = - searchResultsObj.status == 502 - ? { - value: [], - errorCode: searchResultsObj.status, - errorMsg: searchResultsObj.statusText, - } - : searchResultsObj; + if (_.has(searchResultsObj, "status") != false) { + if (searchResultsObj.status == 400) { + return { + redirect: { + //destination: "/dns-not-found", + destination: "/error", + permanent: false, + }, + }; + } else { + searchResultsObj = + searchResultsObj.status == 502 + ? { + value: [], + errorCode: searchResultsObj.status, + errorMsg: searchResultsObj.statusText, + } + : searchResultsObj; - const searchDetailsObj = await getSearchDetails(searchResultsObj); - store.dispatch(setSearchResults(searchResultsObj)); - store.dispatch(setSearchDetails(searchDetailsObj)); - store.dispatch(setSearch("DNS")); + const searchDetailsObj = await getSearchDetails( + searchResultsObj + ); + store.dispatch(setSearchResults(searchResultsObj)); + store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setSearch("DNS")); + } + } } ); diff --git a/pages/dnsapplications.js b/pages/dnsapplications.js index e679b141..61e9e783 100644 --- a/pages/dnsapplications.js +++ b/pages/dnsapplications.js @@ -1,3 +1,4 @@ +import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; @@ -121,26 +122,40 @@ export const getServerSideProps = wrapper.getServerSideProps( ); let searchResultsObj = await getBasicDNSSearch(); - searchResultsObj = - searchResultsObj.status == 502 - ? { - value: [], - errorCode: searchResultsObj.status, - errorMsg: searchResultsObj.statusText, - } - : searchResultsObj; + if (_.has(searchResultsObj, "status") != false) { + if (searchResultsObj.status == 400) { + return { + redirect: { + //destination: "/dns-not-found", + destination: "/error", + permanent: false, + }, + }; + } else { + searchResultsObj = + searchResultsObj.status == 502 + ? { + value: [], + errorCode: searchResultsObj.status, + errorMsg: searchResultsObj.statusText, + } + : searchResultsObj; - const showMapCheck = process.env.SHOWMAPS || false; + const showMapCheck = process.env.SHOWMAPS || false; - const searchDetailsObj = await getSearchDetails(searchResultsObj); - const dnsCoords = await getDNSCoords(); - store.dispatch(setSearchResults(searchResultsObj)); - store.dispatch(setSearchDetails(searchDetailsObj)); - store.dispatch(setSearch("DNS")); - store.dispatch(setDNSCoords(dnsCoords)); - return { - props: { showMap: showMapCheck }, - }; + const searchDetailsObj = await getSearchDetails( + searchResultsObj + ); + const dnsCoords = await getDNSCoords(); + store.dispatch(setSearchResults(searchResultsObj)); + store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setSearch("DNS")); + store.dispatch(setDNSCoords(dnsCoords)); + return { + props: { showMap: showMapCheck }, + }; + } + } } ); diff --git a/pages/error.js b/pages/error.js new file mode 100644 index 00000000..4a378e1d --- /dev/null +++ b/pages/error.js @@ -0,0 +1,65 @@ +import useTranslation from "next-translate/useTranslation"; +import Head from "next/head"; +import Link from "next/link"; +import CookieBanner from "../components/cookieBanner"; +import Footer from "../components/footer"; +import Header from "../components/header"; +import { parseCookies, setCookie, destroyCookie } from "nookies"; +import { useSession, signIn, signOut } from "next-auth/react"; + +function Error({ statusCode }, props) { + let { t, lang } = useTranslation(); + const { footerLinks, pages } = props; + + return ( +
+ + + {t("case:page-title")} - {t("common:service-name")} + + +
+ +
+
+
+
+
+

{t("common:error-page-title")}

+

+ {statusCode + ? `An error ${statusCode} occurred on server` + : `An error occured`} +

+ + { + destroyCookie({}, "pinsUser"), + window.localStorage.clear(), + signOut({ + callbackUrl: "/", + }); + }} + > + {" "} + Go back home + +
+
+
+
+
+
+ ); +} + +Error.getInitialProps = ({ res, err }) => { + const statusCode = res ? res.statusCode : err ? err.statusCode : 404; + console.log(res, err); + return { statusCode }; +}; + +export default Error; diff --git a/pages/index.js b/pages/index.js index fff83e56..a65625c8 100644 --- a/pages/index.js +++ b/pages/index.js @@ -187,15 +187,28 @@ export const getServerSideProps = wrapper.getServerSideProps( let loginEmailStr = ""; if (hasLoginCode == true) { - (loginEmailStr = hashString(thisSession.user.email)), - (portalUserObj = await getPortalLogin( - thisSession.user.email, - relayToken - )), - console.log("loggin user stuff: ", portalUserObj), - store.dispatch(setAccountDetails(portalUserObj)); + loginEmailStr = hashString(thisSession.user.email); + portalUserObj = await getPortalLogin( + thisSession.user.email, + relayToken + ); + + if (_.has(portalUserObj, "status") != false) { + if (portalUserObj.status == 400) { + return { + redirect: { + //destination: "/dns-not-found", + destination: "/error", + permanent: false, + }, + }; + } else { + console.log("loggin user stuff: ", portalUserObj); + store.dispatch(setAccountDetails(portalUserObj)); + } + } } else { - console.log("no session"); + console.log("empty session"); } if (ggToken.status == 400) { diff --git a/pages/searchresults.js b/pages/searchresults.js index 0d1bad87..baff1cf0 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -15,6 +15,7 @@ import { setSearchResults, } from "../store/searchOutput/action"; import { wrapper } from "../store/store"; +import _ from "lodash"; const Home = (props) => { const { footerLinks, pages, isLinkedCase } = props; @@ -127,26 +128,40 @@ export const getServerSideProps = wrapper.getServerSideProps( let searchResultsObj = await getBasicSearch(query.q); - searchResultsObj = - searchResultsObj.status == 502 - ? { - value: [], - errorCode: searchResultsObj.status, - errorMsg: searchResultsObj.statusText, - } - : searchResultsObj; + if (_.has(searchResultsObj, "status") != false) { + if (searchResultsObj.status == 400) { + return { + redirect: { + //destination: "/dns-not-found", + destination: "/error", + permanent: false, + }, + }; + } else { + searchResultsObj = + searchResultsObj.status == 502 + ? { + value: [], + errorCode: searchResultsObj.status, + errorMsg: searchResultsObj.statusText, + } + : searchResultsObj; - //console.log("sssss", searchResultsObj); + //console.log("sssss", searchResultsObj); - const searchDetailsObj = await getSearchDetails(searchResultsObj); + const searchDetailsObj = await getSearchDetails( + searchResultsObj + ); - store.dispatch(setSearchResults(searchResultsObj)); - store.dispatch(setSearchDetails(searchDetailsObj)); - store.dispatch(setSearch(query.q)); + store.dispatch(setSearchResults(searchResultsObj)); + store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setSearch(query.q)); - return { - props: { isLinkedCase: isLinked }, - }; + return { + props: { isLinkedCase: isLinked }, + }; + } + } } );