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
+48
View File
@@ -0,0 +1,48 @@
const ApiResponse = (req, res) => {
res.statusCode = 200;
res.json({
"value": [
{
"@odata.etag": 'W/"547952"',
"lpaname": "Vale of Glamorgan Council",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "21 Courtenay Road",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00017-B8X7N0",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Bridgend CBC",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "17 Colin Way",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00016-Y9K9Q0",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning (A)",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "120 Severn Grove",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00011-K1N0J8",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "25 Merches Gardens",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00015-L7J9H1",
"appellantApplicant": "Mrs Denise Williams",
},
],
});
};
export default ApiResponse;
+72
View File
@@ -0,0 +1,72 @@
const ApiResponse = (req, res) => {
res.statusCode = 200;
res.json({
"value": [
{
"@odata.etag": 'W/"547952"',
"lpaname": "Vale of Glamorgan Council",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "21 Courtenay Road",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00009-W8N6W4",
"appellantApplicant": "Mrs Denise Williams",
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue":
"Planning Appeal - S78",
"pinswg_appealcasetype": "846040000",
"statuscode@OData.Community.Display.V1.FormattedValue":
"In Progress",
"statuscode": "1",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Bridgend CBC",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "17 Colin Way",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00010-J9W6L5",
"appellantApplicant": "Mrs Denise Williams",
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue":
"Planning Appeal - S78",
"pinswg_appealcasetype": "846040000",
"statuscode@OData.Community.Display.V1.FormattedValue":
"In Progress",
"statuscode": "1",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning (A)",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "120 Severn Grove",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00011-K1N0J8",
"appellantApplicant": "Mrs Denise Williams",
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue":
"Planning Conditions - S73 + S79",
"pinswg_appealcasetype": "846040001",
"statuscode@OData.Community.Display.V1.FormattedValue":
"In Progress",
"statuscode": "1",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "25 Merches Gardens",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00012-D9W6S8",
"appellantApplicant": "Mrs Denise Williams",
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue":
"Planning Appeal - S78",
"pinswg_appealcasetype": "846040000",
"statuscode@OData.Community.Display.V1.FormattedValue":
"In Progress",
"statuscode": "1",
},
],
});
};
export default ApiResponse;
+48
View File
@@ -0,0 +1,48 @@
const ApiResponse = (req, res) => {
res.statusCode = 200;
res.json({
"value": [
{
"@odata.etag": 'W/"547952"',
"lpaname": "Vale of Glamorgan Council",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "21 Courtenay Road",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00009-W8N6W4",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Bridgend CBC",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "17 Colin Way",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00010-J9W6L5",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning (A)",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "120 Severn Grove",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00011-K1N0J8",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "25 Merches Gardens",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00012-D9W6S8",
"appellantApplicant": "Mrs Denise Williams",
},
],
});
};
export default ApiResponse;
+48
View File
@@ -0,0 +1,48 @@
const ApiResponse = (req, res) => {
res.statusCode = 200;
res.json({
"value": [
{
"@odata.etag": 'W/"547952"',
"lpaname": "Vale of Glamorgan Council",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "21 Courtenay Road",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00009-W8N6W4",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Bridgend CBC",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "17 Colin Way",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00010-J9W6L5",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning (A)",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "120 Severn Grove",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00011-K1N0J8",
"appellantApplicant": "Mrs Denise Williams",
},
{
"@odata.etag": 'W/"547952"',
"lpaname": "Cardiff County Council Planning",
"accountid": "56e7ef63-7e64-eb11-aaba-00224800be9c",
"address1": "25 Merches Gardens",
"town": "Cardiff",
"postcode": "CF24 0JL",
"reference": "CAS-00012-D9W6S8",
"appellantApplicant": "Mrs Denise Williams",
},
],
});
};
export default ApiResponse;
+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);
+88
View File
@@ -0,0 +1,88 @@
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 ViewAll from "../../components/myportal/viewall";
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 Cookies from "cookies";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { setSearch, getSearchObj } from "../../store/search/action";
import {
setSearchResults,
getSearchResultsObj,
} from "../../store/searchOutput/action";
import { getBasicSearch } from "../../actions";
const Home = (props) => {
const { footerLinks, pages } = props;
let { t, lang } = useTranslation();
const router = useRouter();
const { locale } = router;
const { appealtypes } = router.query;
return (
<div>
<Head>
<title>
{t("search:page-title")} - {t("common:service-name")}
</title>
</Head>
<div id="page_wrapper">
<CookieBanner />
<Header courseName={t("common:service-name")} />
<div className="govuk-width-container">
<Banner />
<Breadcrumbs
slug={appealtypes}
currentView={props.currentView.currentView}
/>
<ViewAll
searchString={"View All"}
searchResultsObj={props.searchResultsObj}
currentView={props.currentView.currentView}
myCases={props.myCases}
watchedCases={props.watchedCases}
myRepresentations={props.myRepresentations}
awaitingSubmission={props.awaitingSubmission}
/>
</div>
<Footer footerLinks={footerLinks} />
</div>
</div>
);
};
// export const getServerSideProps = wrapper.getServerSideProps(
// (store) =>
// async ({ req, res }) => {
// const searchResultsObj = (await getBasicSearch("View All")) || null;
// store.dispatch(setSearchResults(searchResultsObj));
// store.dispatch(setSearch("View All"));
// }
// );
const mapStateToProps = (state) => {
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,
currentView: state.currentView,
};
};
export default connect(mapStateToProps)(Home);
+2
View File
@@ -45,6 +45,7 @@ const Home = (props) => {
<ViewAll
searchString={"View All"}
searchResultsObj={props.searchResultsObj}
currentView={props.currentView.currentView}
/>
</div>
<Footer footerLinks={footerLinks} />
@@ -89,6 +90,7 @@ const mapStateToProps = (state) => {
search: state.search,
searchResultsObj: state.searchResultsObj,
form: state.form,
currentView: state.currentView,
};
};