Merged PR 2295: resolved lint warnings

resolved lint warnings

Related work items: #22873
This commit is contained in:
Robert Bond
2026-05-05 17:13:53 +00:00
parent 46a0e0b185
commit 1a2c3ede3b
19 changed files with 128 additions and 127 deletions
+1 -1
View File
@@ -255,7 +255,7 @@ APPLICATIONINSIGHTS_CONNECTIONSTRING = InstrumentationKey=7a06e24a-793c-47bc-898
// Test Connection string
# NEXT_PUBLIC_APP_INSIGHT = InstrumentationKey=cc60e8e7-5b30-4c2b-a176-8b96b21b12df;IngestionEndpoint=https://ukwest-0.in.applicationinsights.azure.com/;LiveEndpoint=https://ukwest.livediagnostics.monitor.azure.com/;ApplicationId=2a4094be-6fd1-46ab-a67d-5f241692b129
NEXT_PUBLIC_APP_INSIGHT = InstrumentationKey=cc60e8e7-5b30-4c2b-a176-8b96b21b12df;IngestionEndpoint=https://ukwest-0.in.applicationinsights.azure.com/;LiveEndpoint=https://ukwest.livediagnostics.monitor.azure.com/;ApplicationId=2a4094be-6fd1-46ab-a67d-5f241692b129
// Preprod Connection string
# NEXT_PUBLIC_APP_INSIGHT = InstrumentationKey=7370f0f9-834d-4c7a-b3c4-9951fcad5ad2;IngestionEndpoint=https://ukwest-0.in.applicationinsights.azure.com/;LiveEndpoint=https://ukwest.livediagnostics.monitor.azure.com/;ApplicationId=04362cb7-6dfc-469e-8274-12243e8be851
@@ -50,7 +50,7 @@ const PersonalDetailsComplete = (props) => {
}
doUpdate();
}, [loggedinUserId, formValues, prefLang]);
}, [loggedinUserId, formValues, prefLang, userLang]);
return (
<>
+12 -12
View File
@@ -28,9 +28,15 @@ function AppealsTab(props) {
const [fieldSortState, setfieldSortState] = useState("desc");
const [loginToWatch, setLoginToWatch] = useState("true");
const searchDetailsObj = props.searchResultsObj.searchDetailsObj || {};
const resultsArr = props.searchResultsObj.searchResultsObj.value || [];
const searchResultsObj = props.searchResultsObj.searchResultsObj;
const {
searchResultsObj: searchResultsState,
setSearchResults,
setSearchDetails
} = props;
const searchDetailsObj = searchResultsState.searchDetailsObj || {};
const resultsArr = searchResultsState.searchResultsObj.value || [];
const searchResultsObj = searchResultsState.searchResultsObj;
const { t } = useTranslation();
const router = useRouter();
@@ -75,20 +81,14 @@ function AppealsTab(props) {
fieldSort,
selectedOption
).then((data) => {
props.setSearchResults(data); // ✅ use props, not import
setSearchResults(data);
return getSearchDetailsPaged(data).then((details) => {
props.setSearchDetails(details); // ✅ use props, not import
setSearchDetails(details);
setShowSpinnerState(false);
});
});
},
[
advancedSearch,
searchString,
selectedOption,
props.setSearchDetails,
props.setSearchResults
]
[selectedOption, setSearchDetails, setSearchResults]
);
useEffect(() => {
+6 -9
View File
@@ -936,17 +936,16 @@ const DocumentsTab = (props) => {
)
.then((data) => data)
.then((data) => {
props.setDocumentDetails(data);
setDocumentDetails(data);
setShowSpinnerState(false);
});
},
[
props.incidentid,
selectedOption,
selectedDocumentType,
selectedWeeks,
selectedDocumentOrigin,
props.setDocumentDetails
setDocumentDetails
]
);
@@ -957,7 +956,7 @@ const DocumentsTab = (props) => {
orderBy,
fieldSort
).then((data) => {
props.setDocumentDetails(data);
setDocumentDetails(data);
return data;
});
@@ -1060,7 +1059,7 @@ const DocumentsTab = (props) => {
selectedDocumentType,
selectedWeeks
).then((data) => {
props.setDocumentDetails(data);
setDocumentDetails(data);
setDocumentSearchState(true);
return data;
@@ -1072,13 +1071,11 @@ const DocumentsTab = (props) => {
//const searchDocumentResultsObj = docDetailsObj();
}, [
incidentid,
props.setDocumentDetails,
setDocumentDetails,
selectedOption,
selectedDocumentType,
fieldSortState,
orderByState,
getDocumentTypes,
getOrigin,
getDocumentResults,
lang,
selectedWeeks
@@ -1134,7 +1131,7 @@ const DocumentsTab = (props) => {
<select
onChange={(e) => {
setSelectedWeeks(e.target.value);
props.setCurrentPage(1);
setCurrentPage(1);
}}
value={selectedWeeks}
className="govuk-select"
+3 -3
View File
@@ -447,14 +447,14 @@ const MediaDetails = ({ mediaObj, whichTab, title, useNoCookie = true }) => {
const { t } = useTranslation();
const router = useRouter();
const mediaArr = mediaObj?.value || [];
const sourceMedia = mediaObj?.value;
const isActive = whichTab ? whichTab === "case-media" : true;
// Build list of playable items (publishable only)
const videoItems = useMemo(() => {
const isWelsh = router.locale === "cy";
return (mediaArr || [])
return (sourceMedia || [])
.filter((x) => x?.pinswg_publishtoweb)
.map((item) => {
const link = isWelsh
@@ -480,7 +480,7 @@ const MediaDetails = ({ mediaObj, whichTab, title, useNoCookie = true }) => {
};
})
.filter(Boolean);
}, [mediaArr, router.locale]);
}, [sourceMedia, router.locale]);
const [selectedIndex, setSelectedIndex] = useState(0);
@@ -66,7 +66,10 @@ const RenderRepresentationTypeRadioList = ({
const hintId = `${optionId}-hint`;
return (
<div className="govuk-radios__item representation-type-option">
<div
key={option.value || optionId}
className="govuk-radios__item representation-type-option"
>
<input
className="govuk-radios__input"
id={optionId}
@@ -195,35 +198,6 @@ const RepresentationTypeSelectorBlock = ({
</label>
)}
</div>
<style jsx>{`
.representation-type-radio-item {
display: flex !important;
flex-direction: column !important;
align-items: flex-start;
width: 100%;
}
.representation-type-radio-choice {
display: block;
width: 100%;
}
.representation-type-radio-hint {
display: block;
clear: both;
margin-left: 40px;
margin-top: 4px;
margin-bottom: 8px;
width: calc(100% - 40px);
}
@media (max-width: 640px) {
.representation-type-radio-hint {
margin-left: 34px;
margin-top: 2px;
}
}
`}</style>
</div>
);
};
+16 -2
View File
@@ -874,15 +874,29 @@ let MakeRepresentation = (props) => {
// Prepare data object for upload
const dataObj = cleanedValues;
const caseFolderReference =
props.caseReference ||
dataObj.ticketnumber ||
currentView?.caseReference?.ticketnumber ||
currentView?.caseReference?.currentReference ||
dataObj.caseRef ||
"";
// Update links on values
const updatedValues = updateLinks(cleanedValues);
const resolvedContainerID =
updatedValues.containerID ||
dataObj.containerID ||
props?.props?.accountDetails?.containerID ||
props?.props?.accountDetails?.accountDetails?.containerID;
// Perform file upload and return the promise
return uploadRepFiles(
dataObj,
[{}],
updatedValues.containerID,
`${props.caseReference}/${dataObj.repfile_name}`
resolvedContainerID,
`${caseFolderReference}/${dataObj.repfile_name}`
);
};
+4 -2
View File
@@ -2076,10 +2076,12 @@ const CaseSummary = (props) => {
) : null;
}
const fallbackIncidentId = setCaseQueryObj?.value?.[0]?.incidentid;
useEffect(() => {
const linkCaseObj = async () => {
let docObj = await getLinkedCases(
incidentid || setCaseQueryObj.value[0].incidentid
incidentid || fallbackIncidentId
).then((data) => {
//console.log(data);
setCurrentLinkedCases(data);
@@ -2090,7 +2092,7 @@ const CaseSummary = (props) => {
};
const linkedCases = linkCaseObj();
}, [incidentid, setCurrentLinkedCases]);
}, [incidentid, fallbackIncidentId, setCurrentLinkedCases]);
let now = new Date();
let expDate = new Date(now);
@@ -353,8 +353,8 @@ const AwaitingSubmissionFromBlob = (props) => {
<h3 className="heading-small card-heading">
{t("myportal:awatitingsubmission-card-title")}
</h3>
<TopThreeRow />
{props.awaitingSubmissionFromBlob["@odata.count"] > 1 && (
<div className="cardVieAll">
<Link
+2 -2
View File
@@ -44,7 +44,7 @@ const MyRepresentations = (props) => {
onClick={() => {
setCurrentView({
"viewName": "My Representations",
"viewKey": "myRepresentations",
"viewKey": "myRepresentations"
});
}}
>
@@ -65,7 +65,7 @@ const mapDispatchToProps = (dispatch) => {
return {
setCurrentView: (currentView) => {
dispatch(setCurrentView(currentView));
},
}
};
};
@@ -43,7 +43,7 @@ const MyRepresentations = (props) => {
onClick={() => {
setCurrentView({
"viewName": "My Representations",
"viewKey": "myRepresentations",
"viewKey": "myRepresentations"
});
}}
>
@@ -64,7 +64,7 @@ const mapDispatchToProps = (dispatch) => {
return {
setCurrentView: (currentView) => {
dispatch(setCurrentView(currentView));
},
}
};
};
+6 -2
View File
@@ -238,8 +238,12 @@ const TopThree = (props) => {
? "/fymhorth/representation"
: "/myportal/representation",
query: {
case: showTopThreeArr[key]
.ticketnumber,
case:
showTopThreeArr[key]
.ticketnumber ||
showTopThreeArr[key].caseRef ||
showTopThreeArr[key]
.pinswg_name,
state: "edit",
created:
showTopThreeArr[key]
+11 -14
View File
@@ -4,7 +4,7 @@ import useTranslation from "next-translate/useTranslation";
import Link from "next/link";
import { useRouter } from "next/router";
import { parseCookies } from "nookies";
import { useCallback, useState } from "react";
import { useState } from "react";
import { connect } from "react-redux";
import {
deleteAwaitingSubmissionsFromBlob,
@@ -98,7 +98,7 @@ const ViewAllResults = (props) => {
const isWatchedCases = currentViewKey === "watchedCases";
const isMyCases = currentViewKey === "myCases";
var resultsArr = isAwaitingSubmissionDetails
const resultsArr = isAwaitingSubmissionDetails
? props["awaitingSubmission"].awaitingSubmissionDetails.case
: isMySubmittedReps
? props[currentViewKey][currentViewKey]
@@ -286,7 +286,7 @@ const ViewAllResults = (props) => {
}
setCurrentReference({
"statuscode": item.statuscode,
"statuscode": item.statuscode ?? null,
ticketnumber: item.ticketnumber,
currentReference: getCurrentReference(item),
currentType: currentViewKey,
@@ -452,10 +452,10 @@ const ViewAllResults = (props) => {
const renderLineBreak = valueToDisplay && idx < 4; // Only insert <br> if it's not the last element
return (
<>
<span key={`${field}-${idx}`}>
{valueToDisplay}
{renderLineBreak && <br />}
</>
</span>
);
})}
</dd>
@@ -845,15 +845,12 @@ const ViewAllResults = (props) => {
//setShowSpinnerState(true);
};
const getSearchPageResults = useCallback(
(pageNumber, orderBy, fieldSort) => {
//console.log(advancedSearch, searchString, pageNumber);
//console.log(pageNumber, orderBy, fieldSort);
resultsArr.sort(dynamicSort(orderBy, fieldSort));
//console.log(resultsArr);
},
[selectedOption]
);
const getSearchPageResults = (pageNumber, orderBy, fieldSort) => {
//console.log(advancedSearch, searchString, pageNumber);
//console.log(pageNumber, orderBy, fieldSort);
resultsArr.sort(dynamicSort(orderBy, fieldSort));
//console.log(resultsArr);
};
function dynamicSort(property, order) {
var sort_order = 1;
-1
View File
@@ -619,7 +619,6 @@ let AboutYou = (props) => {
component={RenderTextfield}
type="text"
className="govuk-input govuk-input--width-20"
validate={[required, emojicheck]}
label={t(
"newappeal:about-you-agent-contact-details-companyname-label"
)}
+4 -4
View File
@@ -13,6 +13,8 @@ let CompleteAppeal = (props) => {
const legacyProps = props.props;
const legacyFormState = legacyProps.form;
const legacyAccountDetails = legacyProps.accountDetails;
const router = useRouter();
const { locale } = router;
useEffect(() => {
let incidentId = props.appealType.caseReference.incidentid;
@@ -77,14 +79,12 @@ let CompleteAppeal = (props) => {
legacyAccountDetails.loggedinUserId,
props.appealType.appealTypeID,
legacyAccountDetails.loggedinUserEmail,
legacyAccountDetails.containerID
legacyAccountDetails.containerID,
router.locale
]);
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
const {
formXML,
sectionCount,
+11 -8
View File
@@ -897,20 +897,23 @@ const SearchResults = (props) => {
setCurrentPage(pageNumber);
resultsArr = _.sortBy(resultsArr, [
function (o) {
return o[orderBy];
}
]);
let sortedResults = [];
setResultsArr((previousResults) => {
sortedResults = _.sortBy(previousResults, [
function (o) {
return o[orderBy];
}
]);
fieldSort == "desc" && resultsArr.reverse();
fieldSort == "desc" && sortedResults.reverse();
return sortedResults;
});
setShowSpinnerState(false);
setResultsArr(resultsArr);
console.log(
"================================\n",
resultsArr,
sortedResults,
"sort done",
"\n=================================\n"
);
+6 -4
View File
@@ -150,6 +150,11 @@ export const loadExistingRepresentation = async ({ store, ctx, bootstrap }) => {
console.log("is lpa?:", isLPA);
const searchResultsObj = await getBasicSearch(query.case);
const searchDetailsObj = await getSearchDetails(searchResultsObj);
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setContainerID(thisSession.user.id));
store.dispatch(setMyRepresentations(myRepresentations));
store.dispatch(setMyRepresentationsDetails(myRepresentationsDetails));
@@ -166,7 +171,6 @@ export const loadExistingRepresentation = async ({ store, ctx, bootstrap }) => {
store.dispatch(
setCurrentReference({
"statuscode": result.statuscode,
"ticketnumber":
result.ticketnumber || result.caseRef || result.pinswg_name,
"currentReference": result.caseRef,
@@ -181,7 +185,7 @@ export const loadExistingRepresentation = async ({ store, ctx, bootstrap }) => {
store.dispatch(setRepresentationCapacity(result.representationCapacity));
const repsFileListObj = await getRepsFilesBlobs(
result.containerID,
result.containerID || thisSession.user.id,
result.ticketnumber || result.caseRef,
result.repfile_name
);
@@ -224,8 +228,6 @@ export const loadNewRepresentation = async ({ store, ctx, bootstrap }) => {
store.dispatch(
setCurrentReference({
"statuscode": searchResultsObj.value[0].statuscode,
"isNRW":
accountDetails.emailaddress1.includes(process.env.NRWDOMAIN) ||
false,
+10 -4
View File
@@ -9,6 +9,8 @@ const ApiProxy = nextConnect();
ApiProxy.use(middleware);
ApiProxy.post(async (req, res) => {
const getFieldValue = (field) => (Array.isArray(field) ? field[0] : field);
const checkHash = req.query.hash;
if (typeof checkHash === "undefined" || checkHash.length === 0) {
@@ -32,10 +34,14 @@ ApiProxy.post(async (req, res) => {
});
}
const appealData = req.body.appealData;
const containerID = req.body?.containerID?.[0];
const casefolderID = req.body?.casefolderID?.[0];
const repOrAppeal = req.body.repOrAppeal || false;
const appealData = getFieldValue(req.body?.appealData);
const containerID = getFieldValue(req.body?.containerID);
const casefolderID = getFieldValue(req.body?.casefolderID);
const repOrAppealRaw = getFieldValue(req.body?.repOrAppeal);
const repOrAppeal =
repOrAppealRaw === true ||
repOrAppealRaw === "true" ||
repOrAppealRaw === "1";
if (
typeof containerID === "undefined" ||
+28 -25
View File
@@ -7,7 +7,7 @@ import Footer from "../../components/footer";
import Header from "../../components/header";
import ServiceBanner from "../../components/servicebanner";
import { useRouter } from "next/router";
import { useState, useEffect } from "react";
import { useState, useEffect, useCallback } from "react";
const SignIn = (props) => {
let { t, lang } = useTranslation();
@@ -20,7 +20,7 @@ const SignIn = (props) => {
const [formData, setFormData] = useState({
email: query.email || "",
callbackUrl: "",
csrfToken: "",
csrfToken: ""
});
const [submitForm, setSubmitForm] = useState(false);
@@ -54,23 +54,26 @@ const SignIn = (props) => {
// }, 500); // Short delay to ensure form is populated before submission
// };
const handleSubmit = async (event) => {
event.preventDefault();
setButtonDisabled(true); // Disable the submit button to avoid multiple submissions
const handleSubmit = useCallback(
async (event) => {
event.preventDefault();
setButtonDisabled(true); // Disable the submit button to avoid multiple submissions
try {
const res = await fetch("/api/auth/signin/emailAPI", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData),
});
try {
const res = await fetch("/api/auth/signin/emailAPI", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(formData)
});
const data = await res.json();
setResponse(data); // Update response state
} catch (error) {
console.error("Error submitting the form:", error);
}
};
const data = await res.json();
setResponse(data); // Update response state
} catch (error) {
console.error("Error submitting the form:", error);
}
},
[formData]
);
// Trigger form submission automatically when data is ready
useEffect(() => {
@@ -79,7 +82,7 @@ const SignIn = (props) => {
setFormData((prevState) => ({
...prevState,
csrfToken: csrfToken,
callbackUrl: callbackUrl || prevState.callbackUrl, // Ensure callback URL is set
callbackUrl: callbackUrl || prevState.callbackUrl // Ensure callback URL is set
}));
}
}, [query.email, csrfToken, callbackUrl, response]);
@@ -89,7 +92,7 @@ const SignIn = (props) => {
if (formData.email && formData.csrfToken && !response) {
handleSubmit(new Event("submit"));
}
}, [formData, response]);
}, [formData, response, handleSubmit]);
// Handle redirection after form submission based on response
useEffect(() => {
@@ -231,8 +234,8 @@ export async function getServerSideProps(context) {
return {
redirect: {
destination: "/403", // custom "Access Denied" page
permanent: false,
},
permanent: false
}
};
}
@@ -240,8 +243,8 @@ export async function getServerSideProps(context) {
return {
redirect: {
destination: "/status",
permanent: false,
},
permanent: false
}
};
}
@@ -250,7 +253,7 @@ export async function getServerSideProps(context) {
"\n//////////////////////\n",
"Sign in callbackurl: " + context.req.headers.host,
context.locale,
csrfToken + "\n//////////////////////\n",
csrfToken + "\n//////////////////////\n"
);
let formURL = context.req.headers.host;
console.log("formUrl:", formURL);
@@ -279,7 +282,7 @@ export async function getServerSideProps(context) {
url.search = params.toString();
return {
props: { csrfToken: csrfToken, callbackUrl: url.toString() },
props: { csrfToken: csrfToken, callbackUrl: url.toString() }
};
}