adding in gg endpoints and basic methods

This commit is contained in:
2021-12-02 12:50:05 +00:00
parent 12db998d3b
commit aaa1087d6b
7 changed files with 251 additions and 25 deletions
+38 -1
View File
@@ -16,6 +16,9 @@ import useTranslation from "next-translate/useTranslation";
import { getIncidents } from "../actions";
import { parseCookies } from "nookies";
import { getProviderConfig, getGGToken } from "../actions/govgateway";
import { getGovGatewayConfig } from "../store/govgateway/action";
const Home = (props) => {
const { footerLinks, pages, showLogin } = props;
let { t, lang } = useTranslation();
@@ -90,13 +93,47 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) => async (ctx) => {
const { query, req, res } = ctx;
console.log(query.code);
const showLoginCheck = process.env.SHOWLOGIN || false;
const hasLoginCode = typeof query.code != "undefined";
console.log("Show login module: ", showLoginCheck);
let providerConfig = await getProviderConfig();
console.log(providerConfig.token_endpoint);
store.dispatch(getGovGatewayConfig(providerConfig));
if (hasLoginCode == true) {
let ggToken = await getGGToken(
providerConfig.token_endpoint,
query.code,
process.env.GG_REDIRECT_URI
);
console.log(ggToken);
}
return {
props: { showLogin: showLoginCheck },
};
}
);
export default Home; //connect(mapStateToProps)(Home);
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
search: state.search,
searchResultsObj: state.searchResultsObj,
formData: state.formData,
appealType: state.appealType,
form: state.form,
myCases: state.myCases,
watchedCases: state.watchedCases,
myRepresentations: state.myRepresentations,
awaitingSubmission: state.awaitingSubmission,
govGateway: state.govGateway,
};
};
export default connect(mapStateToProps)(Home);