add mock api calls for modules viewall component

This commit is contained in:
2021-07-29 14:46:09 +01:00
parent 777df3f907
commit 2b14eaaf1f
30 changed files with 884 additions and 112 deletions
+53 -32
View File
@@ -13,9 +13,26 @@ import { wrapper } from "../../store/store";
import Cookies from "cookies";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { setMyCases } from "../../store/myCases/action";
import { setMyRepresentations } from "../../store/myRepresentations/action";
import { setWatchedCases } from "../../store/watchedCases/action";
import { setAwaitingSubmission } from "../../store/awaitingSubmission/action";
import {
getMyCases,
getMyRepresentations,
getWatchedCases,
getAwaitingSubmission,
} from "../../actions";
const Home = (props) => {
const { footerLinks, pages } = props;
const {
footerLinks,
pages,
myCases,
myRepresentations,
watchedCases,
awaitingSubmission,
} = props;
let { t, lang } = useTranslation();
const router = useRouter();
@@ -35,7 +52,12 @@ const Home = (props) => {
<div className="govuk-width-container">
<Banner />
<Breadcrumbs slug={appealtypes} />
<MyPortal />
<MyPortal
myCases={myCases}
myRepresentations={myRepresentations}
watchedCases={watchedCases}
awaitingSubmission={awaitingSubmission}
/>
</div>
<Footer footerLinks={footerLinks} />
</div>
@@ -43,38 +65,37 @@ const Home = (props) => {
);
};
// export const getServerSideProps = wrapper.getServerSideProps(
// async ({ locale, store, req, res }) => {
// const token = await getToken();
// let accessToken = token.access_token;
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
//console.log("the query", query);
// const apiRoot = process.browser ? window.API_ROOT : process.env.API_ROOT;
const myCases = await getMyCases();
const myRepresentations = await getMyRepresentations();
const watchedCases = await getWatchedCases();
const awaitingSubmission = await getAwaitingSubmission();
// const [pages, footerLinks, courseListContent] = await Promise.all([
// await getPages(accessToken, locale),
// await getFooterLinks(accessToken, locale),
// await getCourseList(accessToken, locale),
// ]);
// //const courseID = await getCourseID
// store.dispatch(setApiRoot(apiRoot));
// store.dispatch(setPages(pages));
// store.dispatch(setFooterLinks(footerLinks));
// store.dispatch(setCourseListContent(courseListContent));
// }
// );
store.dispatch(setMyCases(myCases));
store.dispatch(setMyRepresentations(myRepresentations));
store.dispatch(setWatchedCases(watchedCases));
store.dispatch(setAwaitingSubmission(awaitingSubmission));
}
);
// const mapStateToProps = (state) => {
// //console.log(state);
const mapStateToProps = (state) => {
//console.log(state);
// return {
// apiroot: state.apiroot,
// courseListContent: state.courseListContent.courseListContent,
// pages: state.pages.pages,
// footerLinks: state.footerLinks.footerLinks,
// regions: state.regions,
// sectors: state.sectors,
// form: state.form,
// };
// };
return {
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,
};
};
export default Home; //connect(mapStateToProps)(Home);
export default connect(mapStateToProps)(Home);