refactor phase 3a pages-newappeal-and-case targeted actions imports

This commit is contained in:
2026-03-12 09:43:47 +00:00
parent 0da4a4b3b4
commit eebcfffd5e
3 changed files with 58 additions and 56 deletions
+27 -25
View File
@@ -3,15 +3,17 @@ import useTranslation from "next-translate/useTranslation";
import Head from "next/head"; import Head from "next/head";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { getIP } from "../../actions/core/logger";
import { import {
getBasicSearch,
getCaseMessage,
getIP,
getPersonalAccount, getPersonalAccount,
getPortalLogin, getPortalLogin
} from "../../actions/services/accountService";
import {
getCaseMessage,
getSIPSEvents, getSIPSEvents,
getSIPSMedia, getSIPSMedia
} from "../../actions"; } from "../../actions/services/caseService";
import { getBasicSearch } from "../../actions/services/searchService";
import Breadcrumbs from "../../components/breadcrumbs"; import Breadcrumbs from "../../components/breadcrumbs";
import Case from "../../components/case"; import Case from "../../components/case";
import CookieBanner from "../../components/cookieBanner"; import CookieBanner from "../../components/cookieBanner";
@@ -25,7 +27,7 @@ import {
setEventDetails, setEventDetails,
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults,
setMediaDetails, setMediaDetails
} from "../../store/searchOutput/action"; } from "../../store/searchOutput/action";
import { wrapper } from "../../store/store"; import { wrapper } from "../../store/store";
import ServiceBanner from "../../components/servicebanner"; import ServiceBanner from "../../components/servicebanner";
@@ -35,7 +37,7 @@ const CaseHome = (props) => {
pages, pages,
setSearchResults, setSearchResults,
setSearchDetails, setSearchDetails,
searchResultsObj, searchResultsObj
} = props; } = props;
let { t, lang } = useTranslation(); let { t, lang } = useTranslation();
@@ -140,7 +142,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
if (thisSession) { if (thisSession) {
console.log(" has sesssion......."); console.log(" has sesssion.......");
[loggedInUser] = await Promise.all([ [loggedInUser] = await Promise.all([
await getPortalLogin(thisSession.user.email), await getPortalLogin(thisSession.user.email)
]); ]);
loggedInUser = loggedInUser.value[0].contactid; loggedInUser = loggedInUser.value[0].contactid;
@@ -164,14 +166,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) { if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
eventsObj = await getSIPSEvents( eventsObj = await getSIPSEvents(
searchDetailsObj[0].value[0].pinswg_sipsid, searchDetailsObj[0].value[0].pinswg_sipsid
); );
store.dispatch(setEventDetails(eventsObj)); store.dispatch(setEventDetails(eventsObj));
} }
if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) { if (searchResultsObj.value[0].pinswg_appealcasetype == 846040002) {
mediaObj = await getSIPSMedia( mediaObj = await getSIPSMedia(
searchDetailsObj[0].value[0].pinswg_sipsid, searchDetailsObj[0].value[0].pinswg_sipsid
); );
store.dispatch(setMediaDetails(mediaObj)); store.dispatch(setMediaDetails(mediaObj));
} }
@@ -191,15 +193,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
console.log( console.log(
searchResultsObj["@odata.count"] > 1 || searchResultsObj["@odata.count"] > 1 ||
searchResultsObj["@odata.count"] < 1, searchResultsObj["@odata.count"] < 1
); );
if (searchResultsObj["@odata.count"] < 1) { if (searchResultsObj["@odata.count"] < 1) {
return { return {
redirect: { redirect: {
destination: "/404", destination: "/404",
permanent: false, permanent: false
}, }
}; };
} else { } else {
if (searchResultsObj["@odata.count"] > 1) { if (searchResultsObj["@odata.count"] > 1) {
@@ -207,8 +209,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
redirect: { redirect: {
//destination: "/dns-not-found", //destination: "/dns-not-found",
destination: "/404", destination: "/404",
permanent: false, permanent: false
}, }
}; };
} else { } else {
store.dispatch(setSearchResults(searchResultsObj)); store.dispatch(setSearchResults(searchResultsObj));
@@ -231,8 +233,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
.pinswg_speacialistcaseprocess || .pinswg_speacialistcaseprocess ||
searchDetailsObj[0].value[0] searchDetailsObj[0].value[0]
.pinswg_specialistcaseprocess .pinswg_specialistcaseprocess
: "", : ""
}), })
); );
} }
} }
@@ -243,19 +245,19 @@ export const getServerSideProps = wrapper.getServerSideProps(
searchResultsObj: searchResultsObj, searchResultsObj: searchResultsObj,
searchDetailsObj: searchDetailsObj, searchDetailsObj: searchDetailsObj,
eventsObj: eventsObj, eventsObj: eventsObj,
mediaObj: mediaObj, mediaObj: mediaObj
}, },
currentType: "directResultsObj", currentType: "directResultsObj",
docsOffline: process.env.DOCAPI_OFFLINE || false, docsOffline: process.env.DOCAPI_OFFLINE || false,
messagesObj: await getCaseMessage( messagesObj: await getCaseMessage(
searchResultsObj.value[0].incidentid, searchResultsObj.value[0].incidentid
), ),
showFilteredDocs: process.env.SHOWFILTERDOCS || false, showFilteredDocs: process.env.SHOWFILTERDOCS || false,
showMaps: process.env.SHOWMAPS, showMaps: process.env.SHOWMAPS,
showLoginCheck: process.env.SHOWLOGIN || false, showLoginCheck: process.env.SHOWLOGIN || false
}, }
}; };
}, }
); );
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
@@ -271,7 +273,7 @@ const mapStateToProps = (state) => {
myCases: state.myCases, myCases: state.myCases,
watchedCases: state.watchedCases, watchedCases: state.watchedCases,
myRepresentations: state.myRepresentations, myRepresentations: state.myRepresentations,
awaitingSubmission: state.awaitingSubmission, awaitingSubmission: state.awaitingSubmission
}; };
}; };
@@ -279,7 +281,7 @@ const mapDispatchToProps = (dispatch) => {
return { return {
setCurrentReference: (currentReference) => { setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(refno)); dispatch(setCurrentReference(refno));
}, }
// setSearchResults: (searchResults) => { // setSearchResults: (searchResults) => {
// dispatch(setSearchResults(searchResults)); // dispatch(setSearchResults(searchResults));
// }, // },
+22 -22
View File
@@ -3,12 +3,12 @@ import useTranslation from "next-translate/useTranslation";
import Head from "next/head"; import Head from "next/head";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { getIP } from "../../../actions/core/logger";
import { import {
getIP,
getIncidentbyID,
getPersonalAccount, getPersonalAccount,
getPortalLogin, getPortalLogin
} from "../../../actions"; } from "../../../actions/services/accountService";
import { getIncidentbyID } from "../../../actions/services/caseService";
import Breadcrumbs from "../../../components/breadcrumbs"; import Breadcrumbs from "../../../components/breadcrumbs";
import Case from "../../../components/case"; import Case from "../../../components/case";
import CookieBanner from "../../../components/cookieBanner"; import CookieBanner from "../../../components/cookieBanner";
@@ -16,7 +16,7 @@ import Footer from "../../../components/footer";
import Header from "../../../components/header"; import Header from "../../../components/header";
import { import {
getFormCollectionByID, getFormCollectionByID,
getSearchDetails, getSearchDetails
} from "../../../components/utils"; } from "../../../components/utils";
import { setAccountDetails } from "../../../store/accountDetails/action"; import { setAccountDetails } from "../../../store/accountDetails/action";
import { setCurrentReference } from "../../../store/currentView/action"; import { setCurrentReference } from "../../../store/currentView/action";
@@ -113,7 +113,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
if (thisSession) { if (thisSession) {
console.log(" has sesssion......."); console.log(" has sesssion.......");
[loggedInUser] = await Promise.all([ [loggedInUser] = await Promise.all([
await getPortalLogin(thisSession.user.email), await getPortalLogin(thisSession.user.email)
]); ]);
loggedInUser = loggedInUser.value[0].contactid; loggedInUser = loggedInUser.value[0].contactid;
@@ -147,20 +147,20 @@ export const getServerSideProps = wrapper.getServerSideProps(
whichAppeal == "pinswg_harbourrevisionorders" whichAppeal == "pinswg_harbourrevisionorders"
? "pinswg_postcode" ? "pinswg_postcode"
: whichAppeal == "pinswg_transportandworkacts" || : whichAppeal == "pinswg_transportandworkacts" ||
whichAppeal == "pinswg_electricityacts" || whichAppeal == "pinswg_electricityacts" ||
whichAppeal == "pinswg_dnses" whichAppeal == "pinswg_dnses"
? "pinswg_postcode" ? "pinswg_postcode"
: "pinswg_siteaddresspostcode"; : "pinswg_siteaddresspostcode";
var defaultFirstLineAddress = var defaultFirstLineAddress =
whichAppeal == "pinswg_ldps" || whichAppeal == "pinswg_ldps" ||
whichAppeal == "pinswg_harbourrevisionorders" whichAppeal == "pinswg_harbourrevisionorders"
? "pinswg_postcode" ? "pinswg_postcode"
: whichAppeal == "pinswg_transportandworkacts" || : whichAppeal == "pinswg_transportandworkacts" ||
whichAppeal == "pinswg_electricityacts" || whichAppeal == "pinswg_electricityacts" ||
whichAppeal == "pinswg_dnses" whichAppeal == "pinswg_dnses"
? "pinswg_addressline1" ? "pinswg_addressline1"
: "pinswg_siteaddressline1"; : "pinswg_siteaddressline1";
store.dispatch( store.dispatch(
req.headers.hasOwnProperty("referer") req.headers.hasOwnProperty("referer")
@@ -190,8 +190,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
return { return {
redirect: { redirect: {
destination: "/404", destination: "/404",
permanent: false, permanent: false
}, }
}; };
} else { } else {
store.dispatch( store.dispatch(
@@ -201,7 +201,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
"currentType": "searchResultsObj", "currentType": "searchResultsObj",
"incidentid": searchResultsObj.value[0].incidentid, "incidentid": searchResultsObj.value[0].incidentid,
"appealType": "appealType":
searchResultsObj.value[0].pinswg_appealcasetype, searchResultsObj.value[0].pinswg_appealcasetype
}) })
); );
} }
@@ -209,11 +209,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
props: { props: {
searchResultsObj: { searchResultsObj: {
searchResultsObj: searchResultsObj, searchResultsObj: searchResultsObj,
searchDetailsObj: searchDetailsObj, searchDetailsObj: searchDetailsObj
}, },
currentType: "directResultsObj", currentType: "directResultsObj",
docsOffline: process.env.DOCAPI_OFFLINE || false, docsOffline: process.env.DOCAPI_OFFLINE || false
}, }
}; };
} }
); );
@@ -231,7 +231,7 @@ const mapStateToProps = (state) => {
myCases: state.myCases, myCases: state.myCases,
watchedCases: state.watchedCases, watchedCases: state.watchedCases,
myRepresentations: state.myRepresentations, myRepresentations: state.myRepresentations,
awaitingSubmission: state.awaitingSubmission, awaitingSubmission: state.awaitingSubmission
}; };
}; };
@@ -239,7 +239,7 @@ const mapDispatchToProps = (dispatch) => {
return { return {
setCurrentReference: (currentReference) => { setCurrentReference: (currentReference) => {
dispatch(setCurrentReference(refno)); dispatch(setCurrentReference(refno));
}, }
}; };
}; };
+9 -9
View File
@@ -7,9 +7,9 @@ import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { import {
getAppealsTypesForNewAppeal, getAppealsTypesForNewAppeal,
getLPA, getLPA
getPersonalAccount, } from "../../actions/services/referenceDataService";
} from "../../actions"; import { getPersonalAccount } from "../../actions/services/accountService";
import Breadcrumbs from "../../components/breadcrumbs"; import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner"; import CookieBanner from "../../components/cookieBanner";
import Footer from "../../components/footer"; import Footer from "../../components/footer";
@@ -18,7 +18,7 @@ import CreateCase from "../../components/newappeal/createCase";
import { import {
setAccountDetails, setAccountDetails,
setContainerID, setContainerID,
setLoggedInUserId, setLoggedInUserId
} from "../../store/accountDetails/action"; } from "../../store/accountDetails/action";
import { setAppealType } from "../../store/appealType/action"; import { setAppealType } from "../../store/appealType/action";
import { setLPA } from "../../store/lpa/action"; import { setLPA } from "../../store/lpa/action";
@@ -162,8 +162,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
return { return {
redirect: { redirect: {
destination: "/auth/signin", destination: "/auth/signin",
permanent: false, permanent: false
}, }
}; };
} else { } else {
let loggedInUserIdent = thisSession.user.id; let loggedInUserIdent = thisSession.user.id;
@@ -175,7 +175,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
[ [
await getAppealsTypesForNewAppeal(), await getAppealsTypesForNewAppeal(),
await getLPA(), await getLPA(),
await getPersonalAccount(loggedInUser), await getPersonalAccount(loggedInUser)
] ]
); );
@@ -195,7 +195,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setContainerID(thisSession.user.id)); store.dispatch(setContainerID(thisSession.user.id));
return { return {
props: { loggedInUserIdent: loggedInUserIdent }, props: { loggedInUserIdent: loggedInUserIdent }
}; };
} }
} }
@@ -209,7 +209,7 @@ const mapStateToProps = (state) => {
appealType: state.appealType, appealType: state.appealType,
LPAData: state.LPAData, LPAData: state.LPAData,
form: state.form, form: state.form,
accountDetails: state.accountDetails, accountDetails: state.accountDetails
}; };
}; };