From c38d67a37fd7a626dec44e0a751afda81894573f Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 21 Feb 2023 13:25:43 +0000 Subject: [PATCH] update dns subsection autosuggest list --- components/utils/index.js | 10 ++++- pages/advancedsearchresults.js | 4 +- pages/dns/index.js | 7 ++++ pages/searchresults.js | 72 ++++++++++++++++------------------ store/store.js | 2 +- 5 files changed, 53 insertions(+), 42 deletions(-) diff --git a/components/utils/index.js b/components/utils/index.js index b6ccd460..bd4e5447 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -66,7 +66,15 @@ export const getSearchDetails = (searchResultsObj) => { searchResultsObj = searchResultsObj.value; const detailsObj = searchResultsObj.map((searchDetail, index) => { if (searchDetail.pinswg_appealcasetype == null) { - console.log(searchDetail.title); + //console.log(searchDetail.title); + detailsArr.push( + getBasicSearchDetails( + "pinswg_dnses", + searchDetail.title, + "pinswg_dnsid", + searchDetail.incidentid + ) + ); } else { let formMeta = getFormCollectionByID( searchDetail.pinswg_appealcasetype diff --git a/pages/advancedsearchresults.js b/pages/advancedsearchresults.js index 03185a84..074ffb70 100644 --- a/pages/advancedsearchresults.js +++ b/pages/advancedsearchresults.js @@ -119,9 +119,9 @@ export const getServerSideProps = wrapper.getServerSideProps( const searchResultsObj = await getAdvancedSearch(query); const searchDetailsObj = await getSearchDetails(searchResultsObj); - + const showLoginCheck = process.env.SHOWLOGIN || false; const showReps = process.env.SHOWREPRESENTATIONS || false; - store.dispatch(setShowReps(showReps)); + store.dispatch(setShowReps(showReps, showLoginCheck)); store.dispatch(setSearchResults(searchResultsObj)); store.dispatch(setSearchDetails(searchDetailsObj)); diff --git a/pages/dns/index.js b/pages/dns/index.js index e55862ac..01b18e6c 100644 --- a/pages/dns/index.js +++ b/pages/dns/index.js @@ -84,6 +84,13 @@ export const getServerSideProps = wrapper.getServerSideProps( store.dispatch(setSearchDetails(searchDetailsObj)); store.dispatch(setSearch("DNS")); } + } else { + const searchDetailsObj = await getSearchDetails( + searchResultsObj + ); + store.dispatch(setSearchResults(searchResultsObj)); + store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setSearch("DNS")); } } ); diff --git a/pages/searchresults.js b/pages/searchresults.js index 15b55d8a..e1948052 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -121,52 +121,48 @@ export const getServerSideProps = wrapper.getServerSideProps( const { query, req, res } = ctx; console.log("query-", query); - let isLinked = - typeof query.lk != "undefined" && query.lk == "1" - ? true - : false; + let isLinked = + typeof query.lk != "undefined" && query.lk == "1" ? true : false; - //console.log("is linked:", isLinked); - const showLoginCheck = process.env.SHOWLOGIN || false; - const showReps = process.env.SHOWREPRESENTATIONS || false; - store.dispatch(setShowReps(showReps)); + //console.log("is linked:", isLinked); + const showLoginCheck = process.env.SHOWLOGIN || false; + const showReps = process.env.SHOWREPRESENTATIONS || false; + store.dispatch(setShowReps(showReps, showLoginCheck)); - let searchResultsObj = await getBasicSearch(query.q); + let searchResultsObj = await getBasicSearch(query.q); - searchResultsObj = - searchResultsObj.status == 502 - ? { - value: [], - errorCode: searchResultsObj.status, - errorMsg: searchResultsObj.statusText, - } - : searchResultsObj; - - if (_.has(searchResultsObj, "status") == true) { - return { - redirect: { - //destination: "/dns-not-found", - destination: "/error", - permanent: false, - }, - }; - } else { - const searchDetailsObj = await getSearchDetails( - searchResultsObj - ); - - store.dispatch(setSearchResults(searchResultsObj)); - store.dispatch(setSearchDetails(searchDetailsObj)); - store.dispatch(setSearch(query.q)); - } + searchResultsObj = + searchResultsObj.status == 502 + ? { + value: [], + errorCode: searchResultsObj.status, + errorMsg: searchResultsObj.statusText, + } + : searchResultsObj; + if (_.has(searchResultsObj, "status") == true) { return { - props: { - isLinkedCase: isLinked, - showLoginCheck: showLoginCheck, + redirect: { + //destination: "/dns-not-found", + destination: "/error", + permanent: false, }, }; + } else { + const searchDetailsObj = await getSearchDetails(searchResultsObj); + + store.dispatch(setSearchResults(searchResultsObj)); + store.dispatch(setSearchDetails(searchDetailsObj)); + store.dispatch(setSearch(query.q)); } + + return { + props: { + isLinkedCase: isLinked, + showLoginCheck: showLoginCheck, + }, + }; + } // } // } ); diff --git a/store/store.js b/store/store.js index 9ba9d16f..44c85425 100644 --- a/store/store.js +++ b/store/store.js @@ -127,7 +127,7 @@ const makeStore = ({ isServer }) => { key: "acp", whitelist: [ "currentView", - "searchResultsObj", + //"searchResultsObj", "appealType", "LPAData", "accountDetails",