From a14726ee0aabe403c3f62ab11e9700bc513a9eee Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 21 Jul 2022 08:07:46 +0100 Subject: [PATCH] debuf fix on search results --- actions/index.js | 8 +++- pages/api/documents/download/[id].js | 2 +- pages/searchresults.js | 60 ++++++++++++++-------------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/actions/index.js b/actions/index.js index aa3a0d01..337c698d 100644 --- a/actions/index.js +++ b/actions/index.js @@ -31,8 +31,11 @@ export const consoleLogger = (err) => { err.response.status + " : " + err.response.statusText + + "\nRequest URL: " + + err.response.config.url + + "\nRequest Time: " + + err.response.headers.date + "\n///////"; - return errStr; }; @@ -50,7 +53,8 @@ export const getToken = () => { }) .catch((error) => { //console.log("error :", error.response); - // return error; + consoleLogger(error); + return error; }); }; diff --git a/pages/api/documents/download/[id].js b/pages/api/documents/download/[id].js index 57e3534b..ac991720 100644 --- a/pages/api/documents/download/[id].js +++ b/pages/api/documents/download/[id].js @@ -1,7 +1,7 @@ import axios from "axios"; import https from "https"; import CryptoJS from "crypto-js"; -import { getToken } from "../../../../actions"; +import { getToken, consoleLogger } from "../../../../actions"; const WORDKEY = process.env.HASHKEY; const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT; diff --git a/pages/searchresults.js b/pages/searchresults.js index baff1cf0..a853cb8b 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -128,41 +128,39 @@ export const getServerSideProps = wrapper.getServerSideProps( let searchResultsObj = await getBasicSearch(query.q); - 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; + searchResultsObj = + searchResultsObj.status == 502 + ? { + value: [], + errorCode: searchResultsObj.status, + errorMsg: searchResultsObj.statusText, + } + : searchResultsObj; - //console.log("sssss", searchResultsObj); + if (_.has(searchResultsObj, "status") == true) { + return { + redirect: { + //destination: "/dns-not-found", + destination: "/error", + permanent: false, + }, + }; + } else { + const searchDetailsObj = await getSearchDetails( + searchResultsObj + ); - const searchDetailsObj = await getSearchDetails( - searchResultsObj - ); - - store.dispatch(setSearchResults(searchResultsObj)); - store.dispatch(setSearchDetails(searchDetailsObj)); - store.dispatch(setSearch(query.q)); - - return { - props: { isLinkedCase: isLinked }, - }; - } + store.dispatch(setSearchResults(searchResultsObj)); + store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setSearch(query.q)); } + + return { + props: { isLinkedCase: isLinked }, + }; } + // } + // } ); const mapStateToProps = (state) => {