refactor phase 3a top-level pages targeted actions imports

This commit is contained in:
2026-03-12 09:49:40 +00:00
parent eebcfffd5e
commit c33cdf1b28
8 changed files with 74 additions and 57 deletions
+5 -5
View File
@@ -2,7 +2,7 @@ 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 { getAddressSearch } from "../actions"; import { getAddressSearch } from "../actions/services/searchService";
import SearchResults from "../components/addresssearchresults"; import SearchResults from "../components/addresssearchresults";
import Breadcrumbs from "../components/breadcrumbs"; import Breadcrumbs from "../components/breadcrumbs";
import CookieBanner from "../components/cookieBanner"; import CookieBanner from "../components/cookieBanner";
@@ -125,11 +125,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
props: { props: {
searchResultsObj: { searchResultsObj: {
searchResultsObj: searchResultsObj, searchResultsObj: searchResultsObj,
searchDetailsObj: searchDetailsObj, searchDetailsObj: searchDetailsObj
}, },
currentType: "directResultsObj", currentType: "directResultsObj",
showLoginCheck: showLoginCheck, showLoginCheck: showLoginCheck
}, }
}; };
} }
); );
@@ -145,7 +145,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
}; };
}; };
+7 -3
View File
@@ -3,7 +3,11 @@ 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 { getAppealsTypes, getProjectTypes, getLPA } from "../actions"; import {
getAppealsTypes,
getProjectTypes,
getLPA
} from "../actions/services/referenceDataService";
import Breadcrumbs from "../components/breadcrumbs"; import Breadcrumbs from "../components/breadcrumbs";
import CookieBanner from "../components/cookieBanner"; import CookieBanner from "../components/cookieBanner";
import CRMError from "../components/crmError"; import CRMError from "../components/crmError";
@@ -126,7 +130,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
let [appealTypeData, projectTypeData, lpaData] = await Promise.all([ let [appealTypeData, projectTypeData, lpaData] = await Promise.all([
await getAppealsTypes(), await getAppealsTypes(),
await getProjectTypes(), await getProjectTypes(),
await getLPA(), await getLPA()
]); ]);
//const lpaData = require("../data/lpa.json"); //const lpaData = require("../data/lpa.json");
@@ -146,7 +150,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
}; };
}; };
+5 -5
View File
@@ -2,7 +2,7 @@ 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 { getAdvancedSearch } from "../actions"; import { getAdvancedSearch } from "../actions/services/searchService";
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";
@@ -13,7 +13,7 @@ import { setShowReps } from "../store/currentView/action";
import { setSearch } from "../store/search/action"; import { setSearch } from "../store/search/action";
import { import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults
} from "../store/searchOutput/action"; } from "../store/searchOutput/action";
import ServiceBanner from "../components/servicebanner"; import ServiceBanner from "../components/servicebanner";
import { wrapper } from "../store/store"; import { wrapper } from "../store/store";
@@ -140,8 +140,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
store.dispatch(setSearch(Object.entries(query))); store.dispatch(setSearch(Object.entries(query)));
return { return {
props: { props: {
showLoginCheck: showLoginCheck, showLoginCheck: showLoginCheck
}, }
}; };
} }
); );
@@ -157,7 +157,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
}; };
}; };
+10 -9
View File
@@ -13,10 +13,11 @@ import {
formValueSelector, formValueSelector,
reduxForm, reduxForm,
touch, touch,
SubmissionError, SubmissionError
} from "redux-form"; } from "redux-form";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createCRMTask, sendEmail } from "../actions"; import { createCRMTask } from "../actions/services/integrationService";
import { sendEmail } from "../actions/services/notifyService";
import { useState } from "react"; import { useState } from "react";
@@ -28,7 +29,7 @@ const RenderPickList = ({
label, label,
input, input,
errorMsg, errorMsg,
meta: { touched, error }, meta: { touched, error }
}) => { }) => {
let { t } = useTranslation(); let { t } = useTranslation();
@@ -318,7 +319,7 @@ let ContactUs = (props) => {
const sendContactEmail = async (formValues) => { const sendContactEmail = async (formValues) => {
Object.assign(formValues, { Object.assign(formValues, {
"contactSubject": contactPurpose(formValues.typeOfContact).props "contactSubject": contactPurpose(formValues.typeOfContact).props
.children, .children
}); });
const reference = "PEDW-CONTACT-US"; const reference = "PEDW-CONTACT-US";
@@ -340,7 +341,7 @@ let ContactUs = (props) => {
alert("Something went wrong. Please try again later."); alert("Something went wrong. Please try again later.");
// Required: inform redux-form this is a submit error // Required: inform redux-form this is a submit error
throw new SubmissionError({ throw new SubmissionError({
_error: "Failed to send email. Please try again later.", _error: "Failed to send email. Please try again later."
}); });
} }
}; };
@@ -367,7 +368,7 @@ let ContactUs = (props) => {
alert("Something went wrong. Please try again later."); alert("Something went wrong. Please try again later.");
// Required: inform redux-form this is a submit error // Required: inform redux-form this is a submit error
throw new SubmissionError({ throw new SubmissionError({
_error: "Failed to send email. Please try again later.", _error: "Failed to send email. Please try again later."
}); });
} }
}; };
@@ -513,7 +514,7 @@ const mapStateToProps = (state) => {
return { return {
typeOfContactValue, typeOfContactValue,
initialValues: email ? { contactEmail: email } : {}, initialValues: email ? { contactEmail: email } : {},
petEmail: process.env.NEXT_PUBLIC_PETEMAIL, petEmail: process.env.NEXT_PUBLIC_PETEMAIL
}; };
}; };
@@ -544,7 +545,7 @@ export default connect(
) { ) {
errorElement.scrollIntoView({ errorElement.scrollIntoView({
behavior: "smooth", behavior: "smooth",
block: "center", block: "center"
}); });
errorElement.focus({ preventScroll: true }); errorElement.focus({ preventScroll: true });
} else { } else {
@@ -556,6 +557,6 @@ export default connect(
} }
console.log("Redux Form onSubmitFail:", submitError); console.log("Redux Form onSubmitFail:", submitError);
}, }
})(ContactUs) })(ContactUs)
); );
+8 -5
View File
@@ -3,7 +3,10 @@ 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 { getBasicDNSSearch, getDNSCoords } from "../actions"; import {
getBasicDNSSearch,
getDNSCoords
} from "../actions/services/searchService";
import Breadcrumbs from "../components/breadcrumbs"; import Breadcrumbs from "../components/breadcrumbs";
import CookieBanner from "../components/cookieBanner"; import CookieBanner from "../components/cookieBanner";
import DNSSearchResults from "../components/dnssearchresults"; import DNSSearchResults from "../components/dnssearchresults";
@@ -14,7 +17,7 @@ import { setSearch } from "../store/search/action";
import { import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults,
setDNSCoords, setDNSCoords
} 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";
@@ -163,8 +166,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
return { return {
props: { props: {
showMap: showMapCheck, showMap: showMapCheck,
showLoginCheck: showLoginCheck, showLoginCheck: showLoginCheck
}, }
}; };
} }
); );
@@ -180,7 +183,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
}; };
}; };
+31 -23
View File
@@ -5,7 +5,10 @@ import Head from "next/head";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { setCookie } from "nookies"; import { setCookie } from "nookies";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { getIP, getPortalLogin, getToken, hashString } from "../actions"; import { hashString } from "../actions/core/hash";
import { getIP } from "../actions/core/logger";
import { getToken } from "../actions/core/token";
import { getPortalLogin } from "../actions/services/accountService";
import CookieBanner from "../components/cookieBanner"; import CookieBanner from "../components/cookieBanner";
import Footer from "../components/footer"; import Footer from "../components/footer";
import Header from "../components/header"; import Header from "../components/header";
@@ -25,7 +28,7 @@ const Home = (props) => {
loginEmailStr, loginEmailStr,
loggedInUserEmail, loggedInUserEmail,
hasLoginCode, hasLoginCode,
siteurl, siteurl
} = props; } = props;
let { t, lang } = useTranslation(); let { t, lang } = useTranslation();
@@ -46,24 +49,29 @@ const Home = (props) => {
hasLoginCode == false hasLoginCode == false
? "" //console.log("no session") ? "" //console.log("no session")
: _.has(loggedInUserId, "value") : _.has(loggedInUserId, "value")
? _.isEmpty(loggedInUserId.value) ? _.isEmpty(loggedInUserId.value)
? router.replace({ ? router.replace({
pathname: pathname:
router.locale == "cy" router.locale == "cy"
? "/account/register" ? "/account/register"
: "/account/register", : "/account/register",
query: { query: {
id: encodeURI(loggedInUserEmail), id: encodeURI(loggedInUserEmail)
}, }
}) })
: (setCookie(null, "pinsUser", loggedInUserId.value[0].contactid, { : (setCookie(
path: "/", null,
}), "pinsUser",
router.replace({ loggedInUserId.value[0].contactid,
pathname: {
router.locale == "cy" ? "/cy/fymhorth" : "/myportal", path: "/"
})) }
: console.log("no value in user id"); ),
router.replace({
pathname:
router.locale == "cy" ? "/cy/fymhorth" : "/myportal"
}))
: console.log("no value in user id");
return ( return (
<div> <div>
@@ -194,8 +202,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
loggedInUserId: portalUserObj, loggedInUserId: portalUserObj,
loggedInUserEmail: loginEmailStr, loggedInUserEmail: loginEmailStr,
hasLoginCode: hasLoginCode, hasLoginCode: hasLoginCode,
siteurl: process.env.API_ROOT, siteurl: process.env.API_ROOT
}, }
}; };
} }
); );
@@ -211,7 +219,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
}; };
}; };
export default connect(mapStateToProps)(Home); export default connect(mapStateToProps)(Home);
+6 -5
View File
@@ -3,7 +3,8 @@ 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 { getBasicSearch, getIP } from "../actions"; import { getIP } from "../actions/core/logger";
import { getBasicSearch } from "../actions/services/searchService";
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";
@@ -14,7 +15,7 @@ import { setShowReps } from "../store/currentView/action";
import { setSearch } from "../store/search/action"; import { setSearch } from "../store/search/action";
import { import {
setSearchDetails, setSearchDetails,
setSearchResults, setSearchResults
} 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";
@@ -163,8 +164,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
return { return {
props: { props: {
isLinkedCase: isLinked, isLinkedCase: isLinked,
showLoginCheck: showLoginCheck, showLoginCheck: showLoginCheck
}, }
}; };
} }
// } // }
@@ -182,7 +183,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
}; };
}; };
+2 -2
View File
@@ -2,7 +2,7 @@ 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 { getBasicSearch } from "../actions"; import { getBasicSearch } from "../actions/services/searchService";
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";
@@ -119,7 +119,7 @@ const mapStateToProps = (state) => {
search: state.search, search: state.search,
searchResultsObj: state.searchResultsObj, searchResultsObj: state.searchResultsObj,
form: state.form, form: state.form,
currentView: state.currentView, currentView: state.currentView
}; };
}; };