Removed proxy and added api calls, has gov gateway auth
This commit is contained in:
+35
-49
@@ -1,43 +1,39 @@
|
||||
import _ from "lodash";
|
||||
import Head from "next/head";
|
||||
import Header from "../components/header";
|
||||
import Banner from "../components/banner";
|
||||
import CookieBanner from "../components/cookieBanner";
|
||||
import Breadcrumbs from "../components/breadcrumbs";
|
||||
import SearchResults from "../components/searchresults";
|
||||
import Footer from "../components/footer";
|
||||
import Errorpage from "../components/errorpage";
|
||||
import styles from "../styles/Home.module.css";
|
||||
import { useSelector, shallowEqual, connect } from "react-redux";
|
||||
import { wrapper } from "../store/store";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import jsonpath from "jsonpath";
|
||||
import data from "../data/collections.json";
|
||||
|
||||
import { setSearch, getSearchObj } from "../store/search/action";
|
||||
import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
getSearchResultsObj,
|
||||
} from "../store/searchOutput/action";
|
||||
import { getBasicSearch, getBasicSearchDetails, getToken } from "../actions";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import { getBasicSearch } from "../actions";
|
||||
import Breadcrumbs from "../components/breadcrumbs";
|
||||
import CookieBanner from "../components/cookieBanner";
|
||||
import Footer from "../components/footer";
|
||||
import Header from "../components/header";
|
||||
import SearchResults from "../components/searchresults";
|
||||
import { getSearchDetails } from "../components/utils";
|
||||
import { setSearch } from "../store/search/action";
|
||||
import {
|
||||
setSearchDetails,
|
||||
setSearchResults,
|
||||
} from "../store/searchOutput/action";
|
||||
import { wrapper } from "../store/store";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
const { footerLinks, pages, isLinkedCase } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
const pageTitle = isLinkedCase
|
||||
? t("search:searchresults-title-label-linked-case") +
|
||||
" - " +
|
||||
t("common:service-name")
|
||||
: t("search:page-title") + " - " + t("common:service-name");
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("search:page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
<title>{pageTitle}</title>
|
||||
<>
|
||||
<link
|
||||
rel="canonical"
|
||||
@@ -108,6 +104,7 @@ const Home = (props) => {
|
||||
<SearchResults
|
||||
searchString={props.search.searchString}
|
||||
searchResultsObj={props.searchResultsObj}
|
||||
isLinkedCase={isLinkedCase}
|
||||
/>
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} />
|
||||
@@ -121,26 +118,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
async ({ query, req, res }) => {
|
||||
console.log("query-", query);
|
||||
|
||||
let token = await getToken();
|
||||
let isLinked =
|
||||
typeof query.lk != "undefined" && query.lk == "1"
|
||||
? true
|
||||
: false;
|
||||
|
||||
var tokenIssuedAt = new Date();
|
||||
var tokenExpiryTimeAt = new Date();
|
||||
tokenExpiryTimeAt.setSeconds(
|
||||
tokenExpiryTimeAt.getSeconds() + token.expires_in
|
||||
);
|
||||
//console.log("is linked:", isLinked);
|
||||
|
||||
console.log(
|
||||
"token issued:",
|
||||
tokenIssuedAt.toUTCString(),
|
||||
"\n",
|
||||
"token expires:",
|
||||
tokenExpiryTimeAt.toUTCString()
|
||||
);
|
||||
console.log(token);
|
||||
|
||||
token = token.access_token;
|
||||
|
||||
let searchResultsObj = await getBasicSearch(token, query.q);
|
||||
let searchResultsObj = await getBasicSearch(query.q);
|
||||
|
||||
searchResultsObj =
|
||||
searchResultsObj.status == 502
|
||||
@@ -153,14 +138,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
//console.log("sssss", searchResultsObj);
|
||||
|
||||
const searchDetailsObj = await getSearchDetails(
|
||||
token,
|
||||
searchResultsObj
|
||||
);
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch(query.q));
|
||||
|
||||
return {
|
||||
props: { isLinkedCase: isLinked },
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user