wrapped calls in promise all

This commit is contained in:
2021-07-30 14:24:22 +01:00
parent 2b14eaaf1f
commit 9e9a168460
6 changed files with 43 additions and 16 deletions
+15 -2
View File
@@ -65,6 +65,9 @@ const Header = (props) => {
<div className="govuk-header__content govuk-!-width-one-half govuk-!-margin-top-3">
<Link href="/logout">
<a
onClick={() => {
window.localStorage.clear();
}}
className="govuk-header__link
govuk-header__link--service-name"
>
@@ -102,7 +105,12 @@ const Header = (props) => {
) : (
<li>
<Link href="/logout">
<a className="govuk-header__link ">
<a
onClick={() => {
window.localStorage.clear();
}}
className="govuk-header__link "
>
{t("common:signout-label")}
</a>
</Link>
@@ -152,7 +160,12 @@ const Header = (props) => {
{router.pathname != "/" ||
router.pathname != "/logout" ? (
<Link href="/logout">
<a className="govuk-header__link govuk-!-margin-right-3">
<a
onClick={() => {
window.localStorage.clear();
}}
className="govuk-header__link govuk-!-margin-right-3"
>
{t("common:signout-label")}
</a>
</Link>
+2 -2
View File
@@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev",
"dev:app": "node ./server/server.js && yarn lint:js",
"build": "NODE_ENV=production node_modules/next/dist/bin/next build --debug",
"build": "NODE_ENV=production node_modules/next/dist/bin/next build",
"start": "node_modules/next/dist/bin/next start"
},
"dependencies": {
@@ -52,4 +52,4 @@
"eslint-config-next": "^11.0.1",
"prettier": "2.3.2"
}
}
}
+11 -4
View File
@@ -70,10 +70,17 @@ export const getServerSideProps = wrapper.getServerSideProps(
async ({ query, req, res }) => {
//console.log("the query", query);
const myCases = await getMyCases();
const myRepresentations = await getMyRepresentations();
const watchedCases = await getWatchedCases();
const awaitingSubmission = await getAwaitingSubmission();
const [
myCases,
myRepresentations,
watchedCases,
awaitingSubmission,
] = await Promise.all([
await getMyCases(),
await getMyRepresentations(),
await getWatchedCases(),
await getAwaitingSubmission(),
]);
store.dispatch(setMyCases(myCases));
store.dispatch(setMyRepresentations(myRepresentations));
+5 -3
View File
@@ -154,15 +154,17 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
//console.log("the query", query);
store.dispatch(setAppealTypeID(query.appealtypes));
const appealTypeData = await getAppealsTypes();
const formdata = (await getFormData(query.appealtypes)) || null;
const [appealTypeData, formdata] = await Promise.all([
await getAppealsTypes(),
await getFormData(query.appealtypes),
]);
const caseReference = createCase("asasa", "asasa");
let xmlStr = formdata;
xmlStr = formdata.value[0].formxml;
xmlStr = xmlStr.replace(/\\"/g, "");
store.dispatch(setAppealTypeID(query.appealtypes));
store.dispatch(setCaseReference(caseReference));
store.dispatch(setForm(xmlStr));
store.dispatch(setAppealType(appealTypeData));
+4 -4
View File
@@ -75,10 +75,10 @@ const Home = (props) => {
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
const appealTypeData = await getAppealsTypes();
const lpaData = await getLPA();
console.log("appeal types", appealTypeData);
console.log("lpa typeswwwww", lpaData);
const [appealTypeData, lpaData] = await Promise.all([
await getAppealsTypes(),
await getLPA(),
]);
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData));
}
+6 -1
View File
@@ -95,7 +95,11 @@ const makeStore = ({ isServer }) => {
return createStore(reducer, bindMiddleware([thunkMiddleware]));
} else {
//If it's on client side, create a store which will persist
const { persistStore, persistReducer } = require("redux-persist");
const {
persistStore,
persistReducer,
createMigrate,
} = require("redux-persist");
const storage = require("redux-persist/lib/storage").default;
const persistConfig = {
@@ -114,6 +118,7 @@ const makeStore = ({ isServer }) => {
"watchedCases",
"form",
],
version: 1,
storage: storage,
stateReconciler: autoMergeLevel2, // if needed, use a safer storage
};