From c33cdf1b28506ae30920622e8aa492b9bf0c5d5f Mon Sep 17 00:00:00 2001 From: robbond Date: Thu, 12 Mar 2026 09:49:40 +0000 Subject: [PATCH] refactor phase 3a top-level pages targeted actions imports --- pages/addresssearchresults.js | 10 +++---- pages/advancedsearch.js | 10 +++++-- pages/advancedsearchresults.js | 10 +++---- pages/contactus.js | 19 ++++++------ pages/dnsapplications.js | 13 ++++---- pages/index.js | 54 +++++++++++++++++++--------------- pages/searchresults.js | 11 +++---- pages/viewall.js | 4 +-- 8 files changed, 74 insertions(+), 57 deletions(-) diff --git a/pages/addresssearchresults.js b/pages/addresssearchresults.js index f3542535..247d9c80 100644 --- a/pages/addresssearchresults.js +++ b/pages/addresssearchresults.js @@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; import { connect } from "react-redux"; -import { getAddressSearch } from "../actions"; +import { getAddressSearch } from "../actions/services/searchService"; import SearchResults from "../components/addresssearchresults"; import Breadcrumbs from "../components/breadcrumbs"; import CookieBanner from "../components/cookieBanner"; @@ -125,11 +125,11 @@ export const getServerSideProps = wrapper.getServerSideProps( props: { searchResultsObj: { searchResultsObj: searchResultsObj, - searchDetailsObj: searchDetailsObj, + searchDetailsObj: searchDetailsObj }, currentType: "directResultsObj", - showLoginCheck: showLoginCheck, - }, + showLoginCheck: showLoginCheck + } }; } ); @@ -145,7 +145,7 @@ const mapStateToProps = (state) => { myCases: state.myCases, watchedCases: state.watchedCases, myRepresentations: state.myRepresentations, - awaitingSubmission: state.awaitingSubmission, + awaitingSubmission: state.awaitingSubmission }; }; diff --git a/pages/advancedsearch.js b/pages/advancedsearch.js index 04bfa3e2..0a65cac9 100644 --- a/pages/advancedsearch.js +++ b/pages/advancedsearch.js @@ -3,7 +3,11 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; 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 CookieBanner from "../components/cookieBanner"; import CRMError from "../components/crmError"; @@ -126,7 +130,7 @@ export const getServerSideProps = wrapper.getServerSideProps( let [appealTypeData, projectTypeData, lpaData] = await Promise.all([ await getAppealsTypes(), await getProjectTypes(), - await getLPA(), + await getLPA() ]); //const lpaData = require("../data/lpa.json"); @@ -146,7 +150,7 @@ const mapStateToProps = (state) => { appealType: state.appealType, LPAData: state.LPAData, //form: state.form, - accountDetails: state.accountDetails, + accountDetails: state.accountDetails }; }; diff --git a/pages/advancedsearchresults.js b/pages/advancedsearchresults.js index f2135ea9..4b483412 100644 --- a/pages/advancedsearchresults.js +++ b/pages/advancedsearchresults.js @@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; import { connect } from "react-redux"; -import { getAdvancedSearch } from "../actions"; +import { getAdvancedSearch } from "../actions/services/searchService"; import Breadcrumbs from "../components/breadcrumbs"; import CookieBanner from "../components/cookieBanner"; import Footer from "../components/footer"; @@ -13,7 +13,7 @@ import { setShowReps } from "../store/currentView/action"; import { setSearch } from "../store/search/action"; import { setSearchDetails, - setSearchResults, + setSearchResults } from "../store/searchOutput/action"; import ServiceBanner from "../components/servicebanner"; import { wrapper } from "../store/store"; @@ -140,8 +140,8 @@ export const getServerSideProps = wrapper.getServerSideProps( store.dispatch(setSearch(Object.entries(query))); return { props: { - showLoginCheck: showLoginCheck, - }, + showLoginCheck: showLoginCheck + } }; } ); @@ -157,7 +157,7 @@ const mapStateToProps = (state) => { myCases: state.myCases, watchedCases: state.watchedCases, myRepresentations: state.myRepresentations, - awaitingSubmission: state.awaitingSubmission, + awaitingSubmission: state.awaitingSubmission }; }; diff --git a/pages/contactus.js b/pages/contactus.js index 25c8f333..27ad44e4 100644 --- a/pages/contactus.js +++ b/pages/contactus.js @@ -13,10 +13,11 @@ import { formValueSelector, reduxForm, touch, - SubmissionError, + SubmissionError } from "redux-form"; 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"; @@ -28,7 +29,7 @@ const RenderPickList = ({ label, input, errorMsg, - meta: { touched, error }, + meta: { touched, error } }) => { let { t } = useTranslation(); @@ -318,7 +319,7 @@ let ContactUs = (props) => { const sendContactEmail = async (formValues) => { Object.assign(formValues, { "contactSubject": contactPurpose(formValues.typeOfContact).props - .children, + .children }); const reference = "PEDW-CONTACT-US"; @@ -340,7 +341,7 @@ let ContactUs = (props) => { alert("Something went wrong. Please try again later."); // Required: inform redux-form this is a submit error 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."); // Required: inform redux-form this is a submit error 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 { typeOfContactValue, 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({ behavior: "smooth", - block: "center", + block: "center" }); errorElement.focus({ preventScroll: true }); } else { @@ -556,6 +557,6 @@ export default connect( } console.log("Redux Form onSubmitFail:", submitError); - }, + } })(ContactUs) ); diff --git a/pages/dnsapplications.js b/pages/dnsapplications.js index a1315141..538c0d03 100644 --- a/pages/dnsapplications.js +++ b/pages/dnsapplications.js @@ -3,7 +3,10 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; import { connect } from "react-redux"; -import { getBasicDNSSearch, getDNSCoords } from "../actions"; +import { + getBasicDNSSearch, + getDNSCoords +} from "../actions/services/searchService"; import Breadcrumbs from "../components/breadcrumbs"; import CookieBanner from "../components/cookieBanner"; import DNSSearchResults from "../components/dnssearchresults"; @@ -14,7 +17,7 @@ import { setSearch } from "../store/search/action"; import { setSearchDetails, setSearchResults, - setDNSCoords, + setDNSCoords } from "../store/searchOutput/action"; import { wrapper } from "../store/store"; import ServiceBanner from "../components/servicebanner"; @@ -163,8 +166,8 @@ export const getServerSideProps = wrapper.getServerSideProps( return { props: { showMap: showMapCheck, - showLoginCheck: showLoginCheck, - }, + showLoginCheck: showLoginCheck + } }; } ); @@ -180,7 +183,7 @@ const mapStateToProps = (state) => { myCases: state.myCases, watchedCases: state.watchedCases, myRepresentations: state.myRepresentations, - awaitingSubmission: state.awaitingSubmission, + awaitingSubmission: state.awaitingSubmission }; }; diff --git a/pages/index.js b/pages/index.js index ad1ba3f9..ef0a423d 100644 --- a/pages/index.js +++ b/pages/index.js @@ -5,7 +5,10 @@ import Head from "next/head"; import { useRouter } from "next/router"; import { setCookie } from "nookies"; 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 Footer from "../components/footer"; import Header from "../components/header"; @@ -25,7 +28,7 @@ const Home = (props) => { loginEmailStr, loggedInUserEmail, hasLoginCode, - siteurl, + siteurl } = props; let { t, lang } = useTranslation(); @@ -46,24 +49,29 @@ const Home = (props) => { hasLoginCode == false ? "" //console.log("no session") : _.has(loggedInUserId, "value") - ? _.isEmpty(loggedInUserId.value) - ? router.replace({ - pathname: - router.locale == "cy" - ? "/account/register" - : "/account/register", - query: { - id: encodeURI(loggedInUserEmail), - }, - }) - : (setCookie(null, "pinsUser", loggedInUserId.value[0].contactid, { - path: "/", - }), - router.replace({ - pathname: - router.locale == "cy" ? "/cy/fymhorth" : "/myportal", - })) - : console.log("no value in user id"); + ? _.isEmpty(loggedInUserId.value) + ? router.replace({ + pathname: + router.locale == "cy" + ? "/account/register" + : "/account/register", + query: { + id: encodeURI(loggedInUserEmail) + } + }) + : (setCookie( + null, + "pinsUser", + loggedInUserId.value[0].contactid, + { + path: "/" + } + ), + router.replace({ + pathname: + router.locale == "cy" ? "/cy/fymhorth" : "/myportal" + })) + : console.log("no value in user id"); return (
@@ -194,8 +202,8 @@ export const getServerSideProps = wrapper.getServerSideProps( loggedInUserId: portalUserObj, loggedInUserEmail: loginEmailStr, hasLoginCode: hasLoginCode, - siteurl: process.env.API_ROOT, - }, + siteurl: process.env.API_ROOT + } }; } ); @@ -211,7 +219,7 @@ const mapStateToProps = (state) => { myCases: state.myCases, watchedCases: state.watchedCases, myRepresentations: state.myRepresentations, - awaitingSubmission: state.awaitingSubmission, + awaitingSubmission: state.awaitingSubmission }; }; export default connect(mapStateToProps)(Home); diff --git a/pages/searchresults.js b/pages/searchresults.js index 417c4ba3..82a10fd2 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -3,7 +3,8 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; 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 CookieBanner from "../components/cookieBanner"; import Footer from "../components/footer"; @@ -14,7 +15,7 @@ import { setShowReps } from "../store/currentView/action"; import { setSearch } from "../store/search/action"; import { setSearchDetails, - setSearchResults, + setSearchResults } from "../store/searchOutput/action"; import { wrapper } from "../store/store"; import ServiceBanner from "../components/servicebanner"; @@ -163,8 +164,8 @@ export const getServerSideProps = wrapper.getServerSideProps( return { props: { isLinkedCase: isLinked, - showLoginCheck: showLoginCheck, - }, + showLoginCheck: showLoginCheck + } }; } // } @@ -182,7 +183,7 @@ const mapStateToProps = (state) => { myCases: state.myCases, watchedCases: state.watchedCases, myRepresentations: state.myRepresentations, - awaitingSubmission: state.awaitingSubmission, + awaitingSubmission: state.awaitingSubmission }; }; diff --git a/pages/viewall.js b/pages/viewall.js index 1ce4f903..0c7c24b2 100644 --- a/pages/viewall.js +++ b/pages/viewall.js @@ -2,7 +2,7 @@ import useTranslation from "next-translate/useTranslation"; import Head from "next/head"; import { useRouter } from "next/router"; import { connect } from "react-redux"; -import { getBasicSearch } from "../actions"; +import { getBasicSearch } from "../actions/services/searchService"; import Breadcrumbs from "../components/breadcrumbs"; import CookieBanner from "../components/cookieBanner"; import Footer from "../components/footer"; @@ -119,7 +119,7 @@ const mapStateToProps = (state) => { search: state.search, searchResultsObj: state.searchResultsObj, form: state.form, - currentView: state.currentView, + currentView: state.currentView }; };