Merge branch 'Development' into SIPS-Development
This commit is contained in:
@@ -939,10 +939,6 @@ export const RenderFileUpload = (field) => {
|
||||
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
||||
return "/assets/images/documenttypes/xlsx.png";
|
||||
break;
|
||||
|
||||
case "application/zip":
|
||||
return "/assets/images/documenttypes/zip.png";
|
||||
break;
|
||||
case "image/jpeg":
|
||||
return "/assets/images/documenttypes/jpg.png";
|
||||
case "image/png":
|
||||
@@ -1091,7 +1087,6 @@ export const RenderFileUpload = (field) => {
|
||||
[".docx"],
|
||||
"image/tiff": [".tif", ".tiff"],
|
||||
"image/jpeg": [".jpg", ".jpeg"],
|
||||
"application/zip": [".zip"],
|
||||
"image/png": [".png"],
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
||||
[".xlsx"],
|
||||
@@ -1338,7 +1333,7 @@ export const RenderFileUpload = (field) => {
|
||||
?.values?.repfile_name
|
||||
) +
|
||||
"&blobname=" +
|
||||
blob.name +
|
||||
encodeURIComponent(blob.name) +
|
||||
blob.hashedfilepath
|
||||
}
|
||||
className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5 govuk-link"
|
||||
|
||||
+103
-195
@@ -104,6 +104,38 @@ const CaseSummary = (props) => {
|
||||
? true
|
||||
: false;
|
||||
|
||||
let ShowDocLinks = false;
|
||||
let checkShowDocLinks = docsOffline != false ? true : false;
|
||||
|
||||
const getDocLink = (docsOffline) => {
|
||||
var startTime = docsOffline.split(",")[0];
|
||||
var endTime = docsOffline.split(",")[1];
|
||||
|
||||
// console.log(startTime);
|
||||
// console.log(endTime);
|
||||
|
||||
var currentDate = new Date();
|
||||
|
||||
var startDate = new Date(currentDate.getTime());
|
||||
startDate.setHours(startTime.split(":")[0]);
|
||||
startDate.setMinutes(startTime.split(":")[1]);
|
||||
startDate.setSeconds(startTime.split(":")[2]);
|
||||
|
||||
var endDate = new Date(currentDate.getTime());
|
||||
endDate.setHours(endTime.split(":")[0]);
|
||||
endDate.setMinutes(endTime.split(":")[1]);
|
||||
endDate.setSeconds(endTime.split(":")[2]);
|
||||
|
||||
// console.log(startDate);
|
||||
// console.log(endDate);
|
||||
// console.log(currentDate);
|
||||
|
||||
var valid = startDate < currentDate && endDate > currentDate;
|
||||
ShowDocLinks = valid;
|
||||
};
|
||||
|
||||
checkShowDocLinks && getDocLink(docsOffline);
|
||||
|
||||
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
||||
let updateBody = {
|
||||
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
||||
@@ -122,7 +154,7 @@ const CaseSummary = (props) => {
|
||||
});
|
||||
});
|
||||
|
||||
setCaseInvolvment(incidentid, loggedInUser);
|
||||
//setCaseInvolvment(incidentid, loggedInUser);
|
||||
};
|
||||
|
||||
const selectEmailNotifications = (
|
||||
@@ -770,115 +802,6 @@ const CaseSummary = (props) => {
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="govuk-button-group">
|
||||
{getFormCollectionByID(
|
||||
appealTypeID
|
||||
).PrimaryIdAttribute ==
|
||||
"pinswg_sipscase" &&
|
||||
showReps(
|
||||
detailsObj.pinswg_consultationopen,
|
||||
detailsObj.pinswg_consultationclose
|
||||
) && (
|
||||
<>
|
||||
{showRepButton(
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType
|
||||
) ? (
|
||||
<>
|
||||
<Link
|
||||
href={{
|
||||
pathname:
|
||||
"/myportal/representation",
|
||||
query: {
|
||||
case:
|
||||
currentType ==
|
||||
"searchResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
: currentType ==
|
||||
"watchedCases"
|
||||
? casesObj.pinswg_title
|
||||
: currentType ==
|
||||
"directResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
: casesObj.reference,
|
||||
},
|
||||
}}
|
||||
className="govuk-button"
|
||||
>
|
||||
{props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType ==
|
||||
846040002
|
||||
? t(
|
||||
"case:summary-make-consultation-label"
|
||||
)
|
||||
: t(
|
||||
"case:summary-make-representation-label"
|
||||
)}
|
||||
</Link>
|
||||
|
||||
<a
|
||||
onClick={() => {
|
||||
//spinnerState();
|
||||
router.back();
|
||||
}}
|
||||
className="govuk-button govuk-button--secondary"
|
||||
>
|
||||
{t(
|
||||
"case:summary-back-button-label"
|
||||
)}
|
||||
</a>
|
||||
</>
|
||||
) : !isLPA &&
|
||||
props.currentView
|
||||
.caseReference
|
||||
.appealType ==
|
||||
846040004 ? (
|
||||
""
|
||||
) : (
|
||||
<>
|
||||
<div className="govuk-grid-column-full govuk-!-padding-left-0">
|
||||
<div className="govuk-button-group">
|
||||
<p className="govuk-body">
|
||||
{t(
|
||||
"case:representation-date-passed-label",
|
||||
{
|
||||
startDate:
|
||||
formatDates(
|
||||
detailsObj.pinswg_consultationopen
|
||||
),
|
||||
endDate:
|
||||
formatDates(
|
||||
detailsObj.pinswg_consultationclose
|
||||
),
|
||||
}
|
||||
)}
|
||||
<br />{" "}
|
||||
{t(
|
||||
"case:representation-date-passed-additional-label"
|
||||
)}{" "}
|
||||
<Link
|
||||
href={
|
||||
"mailto:" +
|
||||
t(
|
||||
"home:login-contact-email"
|
||||
)
|
||||
}
|
||||
>
|
||||
{t(
|
||||
"home:login-contact-email"
|
||||
)}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{(_.has(
|
||||
detailsObj,
|
||||
"pinswg_startdate"
|
||||
@@ -914,29 +837,21 @@ const CaseSummary = (props) => {
|
||||
case:
|
||||
currentType ==
|
||||
"searchResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
? detailsObj.ticketnumber
|
||||
: currentType ==
|
||||
"watchedCases"
|
||||
? casesObj.pinswg_title
|
||||
: currentType ==
|
||||
"directResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
? detailsObj.ticketnumber
|
||||
: casesObj.reference,
|
||||
},
|
||||
}}
|
||||
className="govuk-button"
|
||||
>
|
||||
{props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType ==
|
||||
846040002
|
||||
? t(
|
||||
"case:summary-make-consultation-label"
|
||||
)
|
||||
: t(
|
||||
"case:summary-make-representation-label"
|
||||
)}
|
||||
{t(
|
||||
"case:summary-make-representation-label"
|
||||
)}
|
||||
</Link>
|
||||
|
||||
<a
|
||||
@@ -1015,77 +930,75 @@ const CaseSummary = (props) => {
|
||||
).length >
|
||||
0 ==
|
||||
true ? (
|
||||
<>
|
||||
<button
|
||||
className="govuk-link watchCase"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-have-stopped-watching-label"
|
||||
) +
|
||||
<button
|
||||
className="govuk-link watchCase"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-have-stopped-watching-label"
|
||||
) +
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference +
|
||||
"?"
|
||||
) &&
|
||||
deleteItem(
|
||||
isWatchedCase(
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference +
|
||||
"?"
|
||||
) &&
|
||||
deleteItem(
|
||||
isWatchedCase(
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.incidentid
|
||||
)[0]
|
||||
.pinswg_watchlistid,
|
||||
.incidentid
|
||||
)[0]
|
||||
.pinswg_watchlistid,
|
||||
|
||||
"watchedCases"
|
||||
),
|
||||
setCurrentView(
|
||||
{
|
||||
"viewName":
|
||||
"Watched Cases",
|
||||
"viewKey":
|
||||
"watchedCases",
|
||||
}
|
||||
);
|
||||
setCurrentReference(
|
||||
"watchedCases"
|
||||
),
|
||||
setCurrentView(
|
||||
{
|
||||
"ticketnumber":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference,
|
||||
"currentReference":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference,
|
||||
"currentType":
|
||||
"searchResultsObj",
|
||||
"incidentid":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.incidentid,
|
||||
"appealType":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType,
|
||||
"showMap":
|
||||
showMap,
|
||||
"viewName":
|
||||
"Watched Cases",
|
||||
"viewKey":
|
||||
"watchedCases",
|
||||
}
|
||||
);
|
||||
}}
|
||||
title={t(
|
||||
"case:stop-watching-case-link"
|
||||
)}
|
||||
>
|
||||
{t(
|
||||
"case:stop-watching-case-link"
|
||||
)}{" "}
|
||||
</button>
|
||||
</>
|
||||
setCurrentReference(
|
||||
{
|
||||
"ticketnumber":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference,
|
||||
"currentReference":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference,
|
||||
"currentType":
|
||||
"searchResultsObj",
|
||||
"incidentid":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.incidentid,
|
||||
"appealType":
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType,
|
||||
"showMap":
|
||||
showMap,
|
||||
}
|
||||
);
|
||||
}}
|
||||
title={t(
|
||||
"case:stop-watching-case-link"
|
||||
)}
|
||||
>
|
||||
{t(
|
||||
"case:stop-watching-case-link"
|
||||
)}{" "}
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
@@ -1912,14 +1825,9 @@ const CaseSummary = (props) => {
|
||||
href="/representation"
|
||||
className="govuk-button"
|
||||
>
|
||||
{props.currentView.caseReference
|
||||
.appealType == 846040002
|
||||
? t(
|
||||
"case:summary-make-consultation-label"
|
||||
)
|
||||
: t(
|
||||
"case:summary-make-representation-label"
|
||||
)}
|
||||
{t(
|
||||
"case:summary-make-representation-label"
|
||||
)}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
|
||||
@@ -2378,9 +2378,9 @@ const RenderFileUpload = (field) => {
|
||||
"/api/file/downloadblob?container=" +
|
||||
field.containerID +
|
||||
"&casefolderID=" +
|
||||
field.ticketnumber +
|
||||
encodeURIComponent(field.ticketnumber) +
|
||||
"&blobname=" +
|
||||
blob.name +
|
||||
encodeURIComponent(blob.name) +
|
||||
blob.hashedfilepath
|
||||
}
|
||||
className="govuk-body govuk-!-font-size-14 govuk-!-padding-left-5 govuk-link"
|
||||
|
||||
@@ -150,7 +150,7 @@ const DNSSearchResults = (props) => {
|
||||
};
|
||||
|
||||
const [orderByState, setOrderbyState] = useState("createdon");
|
||||
const [fieldSortState, setfieldSortState] = useState("asc");
|
||||
const [fieldSortState, setfieldSortState] = useState("desc");
|
||||
const [selectedOption, setSelectedOption] = useState(10);
|
||||
|
||||
const cookies = parseCookies();
|
||||
@@ -1009,7 +1009,14 @@ const DNSSearchResults = (props) => {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{resultsArr.length > 0 ? (
|
||||
|
||||
{!searchLoaded ? (
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds">
|
||||
<h3>Loading...</h3>
|
||||
</div>
|
||||
</div>
|
||||
) : resultsArr.length > 0 ? (
|
||||
ResultsView(resultsArr)
|
||||
) : (
|
||||
<div className="govuk-grid-row">
|
||||
@@ -1018,6 +1025,16 @@ const DNSSearchResults = (props) => {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* {resultsArr.length > 0 ? (
|
||||
ResultsView(resultsArr)
|
||||
) : (
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-two-thirds">
|
||||
<h3>{t("search:searchresults-no-records-label")}</h3>
|
||||
</div>
|
||||
</div>
|
||||
)} */}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
+86
-18
@@ -179,6 +179,92 @@ export const getPartSavedDetails = (searchResultsObj) => {
|
||||
* Get the details of a case from the appeal type
|
||||
* @param object searchResultsObj
|
||||
*/
|
||||
// export const getSearchDetailsPaged = (searchResultsObj) => {
|
||||
// let detailsArr = [];
|
||||
// searchResultsObj = searchResultsObj.value;
|
||||
// const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
// if (searchDetail.pinswg_appealcasetype == null) {
|
||||
// console.log(searchDetail.title);
|
||||
// } else {
|
||||
// let formMeta = getFormCollectionByID(
|
||||
// searchDetail.pinswg_appealcasetype
|
||||
// );
|
||||
// formMeta?.LogicalCollectionName &&
|
||||
// formMeta?.LogicalCollectionName != "pinswg_sipses" &&
|
||||
// detailsArr.push(
|
||||
// getBasicSearchDetailsPaged(
|
||||
// formMeta.LogicalCollectionName,
|
||||
// searchDetail.title,
|
||||
// formMeta.PrimaryIdAttribute,
|
||||
// searchDetail.incidentid
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// return Promise.all(detailsArr);
|
||||
// };
|
||||
|
||||
// export const getSearchDetailsPaged = async (searchResultsObj) => {
|
||||
// const searchResults = searchResultsObj.value;
|
||||
|
||||
// //Group incidents by appeal type
|
||||
// const groupedByAppealType = {};
|
||||
|
||||
// searchResults.forEach((incident) => {
|
||||
// const appealType = incident.pinswg_appealcasetype;
|
||||
// if (!appealType) return;
|
||||
|
||||
// const formMeta = getFormCollectionByID(appealType);
|
||||
// if (
|
||||
// !formMeta?.LogicalCollectionName ||
|
||||
// formMeta.LogicalCollectionName === "pinswg_sipses"
|
||||
// )
|
||||
// return;
|
||||
|
||||
// const key = formMeta.LogicalCollectionName;
|
||||
// if (!groupedByAppealType[key]) groupedByAppealType[key] = [];
|
||||
// groupedByAppealType[key].push({
|
||||
// incidentID: incident.incidentid,
|
||||
// caseReference: incident.title,
|
||||
// primaryIdAttribute: formMeta.PrimaryIdAttribute,
|
||||
// });
|
||||
// });
|
||||
|
||||
// // Make all API calls in parallel per appeal type
|
||||
// const allDetails = await Promise.all(
|
||||
// Object.entries(groupedByAppealType).map(
|
||||
// async ([appealTypeName, incidents]) => {
|
||||
// console.log(
|
||||
// `Fetching details for appeal type: ${appealTypeName}, incidents: ${incidents.length}`
|
||||
// );
|
||||
|
||||
// // Fully parallel for each incident
|
||||
// const results = await Promise.all(
|
||||
// incidents.map((i) =>
|
||||
// getBasicSearchDetailsPaged(
|
||||
// appealTypeName,
|
||||
// i.caseReference,
|
||||
// i.primaryIdAttribute,
|
||||
// i.incidentID
|
||||
// ).catch((err) => {
|
||||
// console.error(
|
||||
// `Error fetching incident ${i.caseReference}:`,
|
||||
// err
|
||||
// );
|
||||
// return null; // continue other calls even if one fails
|
||||
// })
|
||||
// )
|
||||
// );
|
||||
|
||||
// return results.filter((r) => r); // remove nulls from failed calls
|
||||
// }
|
||||
// )
|
||||
// );
|
||||
|
||||
// //Flatten all results into a single array
|
||||
// return allDetails.flat();
|
||||
// };
|
||||
|
||||
export const getSearchDetailsPaged = async (searchResultsObj) => {
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
|
||||
@@ -233,24 +319,6 @@ export const getSearchDetailsPaged = async (searchResultsObj) => {
|
||||
return allDetails;
|
||||
};
|
||||
|
||||
// export const absoluteUrl = (req, setLocalhost) => {
|
||||
// var protocol = "https:";
|
||||
// var host = req
|
||||
// ? req.headers["x-forwarded-host"] || req.headers["host"]
|
||||
// : window.location.host;
|
||||
|
||||
// if (host.indexOf("localhost") > -1) {
|
||||
// if (setLocalhost) host = setLocalhost;
|
||||
// protocol = "http:";
|
||||
// }
|
||||
|
||||
// return {
|
||||
// protocol: protocol,
|
||||
// host: host,
|
||||
// origin: protocol + "//" + host,
|
||||
// };
|
||||
// };
|
||||
|
||||
export const getProgressObj = (
|
||||
formObjXML,
|
||||
titleList,
|
||||
|
||||
@@ -90,7 +90,7 @@ export default async function ApiProxy(req, res) {
|
||||
? "pinswg_sipscase_value"
|
||||
: primaryIdAttribute + "s_value");
|
||||
|
||||
//console.log("query: ", queryUrl, "<<<<end query");
|
||||
console.log("query: ", queryUrl, "<<<<end query");
|
||||
|
||||
return axios
|
||||
.get(
|
||||
|
||||
@@ -43,9 +43,11 @@ export default async function ApiProxy(req, res) {
|
||||
console.log(req.body, queryUrl);
|
||||
|
||||
var crmUrl = "https://" + process.env.CRMURL;
|
||||
var crmVersion = process.env.CRMURL_VERSION;
|
||||
|
||||
var data = {
|
||||
"@odata.id": crmUrl + "/api/data/v8.2/contacts(" + contactid + ")",
|
||||
"@odata.id":
|
||||
crmUrl + "/api/data/" + crmVersion + "/contacts(" + contactid + ")",
|
||||
};
|
||||
|
||||
var config = {
|
||||
|
||||
@@ -17,12 +17,9 @@ ApiProxy.get(async (req, res) => {
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
encodeURIComponent(casefolderID) +
|
||||
"&blobname=" +
|
||||
blobName;
|
||||
|
||||
//console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
//console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
encodeURIComponent(blobName);
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await deleteBlob(
|
||||
|
||||
@@ -20,15 +20,9 @@ ApiProxy.get(async (req, res) => {
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
encodeURIComponent(casefolderID) +
|
||||
"&blobname=" +
|
||||
blobName.trim();
|
||||
|
||||
// console.log(checkquerypath);
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath));
|
||||
|
||||
// console.log(req.query);
|
||||
encodeURIComponent(blobName.trim());
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
const bloblocation =
|
||||
|
||||
@@ -107,17 +107,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
const [accountDetails, searchResultsObj, watchedCases] =
|
||||
await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getAdvancedSearch(query),
|
||||
await getWatchedCases(loggedInUser),
|
||||
]);
|
||||
const [accountDetails, watchedCases] = await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getWatchedCases(loggedInUser),
|
||||
]);
|
||||
|
||||
console.log(accountDetails);
|
||||
|
||||
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
|
||||
await getSearchDetails(searchResultsObj),
|
||||
const [watchedCasesDetails] = await Promise.all([
|
||||
await getDetails(watchedCases, "myWatchedCases"),
|
||||
]);
|
||||
|
||||
@@ -126,8 +123,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setShowReps(showReps, showLoginCheck));
|
||||
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setWatchedCases(watchedCases));
|
||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
|
||||
@@ -162,31 +162,28 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
},
|
||||
};
|
||||
} else {
|
||||
let [accountDetails, searchResultsObj, watchedCases] =
|
||||
await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getBasicDNSSearch(),
|
||||
await getWatchedCases(loggedInUser),
|
||||
]);
|
||||
let [accountDetails, watchedCases] = await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getWatchedCases(loggedInUser),
|
||||
]);
|
||||
|
||||
searchResultsObj =
|
||||
searchResultsObj.status == 502
|
||||
? {
|
||||
value: [],
|
||||
errorCode: searchResultsObj.status,
|
||||
errorMsg: searchResultsObj.statusText,
|
||||
}
|
||||
: searchResultsObj;
|
||||
// searchResultsObj =
|
||||
// searchResultsObj.status == 502
|
||||
// ? {
|
||||
// value: [],
|
||||
// errorCode: searchResultsObj.status,
|
||||
// errorMsg: searchResultsObj.statusText,
|
||||
// }
|
||||
// : searchResultsObj;
|
||||
|
||||
const showMapCheck = process.env.SHOWMAPS || false;
|
||||
|
||||
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
|
||||
await getSearchDetails(searchResultsObj),
|
||||
const [watchedCasesDetails] = await Promise.all([
|
||||
await getDetails(watchedCases, "myWatchedCases"),
|
||||
]);
|
||||
const dnsCoords = await getDNSCoords();
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
// store.dispatch(setSearchResults(searchResultsObj));
|
||||
// store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch("DNS"));
|
||||
store.dispatch(setDNSCoords(dnsCoords));
|
||||
store.dispatch(setWatchedCases(watchedCases));
|
||||
|
||||
+42
-36
@@ -3,6 +3,8 @@ import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import pLimit from "p-limit";
|
||||
|
||||
import {
|
||||
createContainerProxy,
|
||||
getAwaitingSubmissionFromBlob,
|
||||
@@ -16,35 +18,42 @@ import {
|
||||
getRepsFromBlob,
|
||||
getWatchedCases,
|
||||
} from "../../actions";
|
||||
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
import Footer from "../../components/footer";
|
||||
import Header from "../../components/header";
|
||||
import MyPortal from "../../components/myportal";
|
||||
import { getFormCollectionByID } from "../../components/utils";
|
||||
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../store/accountDetails/action";
|
||||
|
||||
import {
|
||||
setAwaitingSubmissionDetails,
|
||||
setAwaitingSubmissionFromBlob,
|
||||
} from "../../store/awaitingSubmission/action";
|
||||
|
||||
import { setShowReps, setLocale } from "../../store/currentView/action";
|
||||
|
||||
import { setMyCases, setMyCasesDetails } from "../../store/myCases/action";
|
||||
|
||||
import {
|
||||
setMyRepresentations,
|
||||
setMyRepresentationsDetails,
|
||||
setMySubmittedReps,
|
||||
setMySubmittedRepsDetails,
|
||||
} from "../../store/myRepresentations/action";
|
||||
|
||||
import { wrapper } from "../../store/store";
|
||||
|
||||
import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
import pLimit from "p-limit";
|
||||
|
||||
const Home = (props) => {
|
||||
const {
|
||||
@@ -61,12 +70,12 @@ const Home = (props) => {
|
||||
docsOffline,
|
||||
} = props;
|
||||
|
||||
let { t, lang } = useTranslation();
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const { locale, query } = router;
|
||||
const { appealtypes } = query;
|
||||
|
||||
const { data: session } = useSession();
|
||||
useSession(); // keeping original hook usage, even if not directly referenced
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -94,7 +103,6 @@ const Home = (props) => {
|
||||
property="twitter:site"
|
||||
content="@UKGovWales"
|
||||
/>
|
||||
|
||||
<meta
|
||||
name="description"
|
||||
content={t("common:service-description")}
|
||||
@@ -135,6 +143,7 @@ const Home = (props) => {
|
||||
/>
|
||||
</>
|
||||
</Head>
|
||||
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header />
|
||||
@@ -162,7 +171,7 @@ const Home = (props) => {
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, locale } = ctx;
|
||||
const { req, locale } = ctx;
|
||||
getIP(req);
|
||||
|
||||
const cookies = req.cookies || {};
|
||||
@@ -170,10 +179,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (!thisSession) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false,
|
||||
},
|
||||
redirect: { destination: "/auth/signin", permanent: false },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -199,6 +205,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
await createContainerProxy(thisSession.user.id);
|
||||
const accountDetails = await getPersonalAccount(loggedInUser);
|
||||
|
||||
if (accountDetails?.errorCode) {
|
||||
return {
|
||||
redirect: { destination: "/myportal/error", permanent: false },
|
||||
};
|
||||
}
|
||||
|
||||
const lpaId =
|
||||
accountDetails[
|
||||
"pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue"
|
||||
@@ -206,7 +218,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
const isLPA = accountDetails.pinswg_typeofinvolvement === 846040012;
|
||||
|
||||
// Fetch cases, reps, watched cases, awaiting submission concurrently
|
||||
const [
|
||||
myCases,
|
||||
myRepresentations,
|
||||
@@ -219,20 +230,16 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
getAwaitingSubmissionFromBlob(thisSession.user.id),
|
||||
]);
|
||||
|
||||
// Set locale to store
|
||||
// put current locale into store (this is the URL locale)
|
||||
store.dispatch(setLocale(locale));
|
||||
|
||||
// Determine preferred locale (cookie overrides)
|
||||
// Determine preferred locale (cookie overrides account preference)
|
||||
let preferredLocale =
|
||||
accountDetails.pinswg_preferredlanguage === 846040000 ? "cy" : "en";
|
||||
if (cookies.pedw_locale) {
|
||||
preferredLocale = cookies.pedw_locale;
|
||||
}
|
||||
|
||||
// Strip the current locale from the URL path
|
||||
const pathWithoutLocale = ctx.resolvedUrl.replace(/^\/(cy|en)/, "");
|
||||
//console.log("==============================", pathWithoutLocale);
|
||||
if (cookies.pedw_locale) preferredLocale = cookies.pedw_locale;
|
||||
|
||||
// (Optional) redirect logic (kept commented as in your newer file)
|
||||
// const pathWithoutLocale = ctx.resolvedUrl.replace(/^\/(cy|en)/, "");
|
||||
// if (preferredLocale !== locale) {
|
||||
// return {
|
||||
// redirect: {
|
||||
@@ -246,7 +253,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const showReps = Boolean(process.env.SHOWREPRESENTATIONS);
|
||||
store.dispatch(setShowReps(showReps, showLoginCheck));
|
||||
|
||||
// Filter watched cases where reps not submitted
|
||||
// watched cases that are NOT submitted
|
||||
const filteredWatchedCases = {
|
||||
"@odata.count": watchedCases.value.filter(
|
||||
(c) => c.pinswg_representationsubmitted == null
|
||||
@@ -256,37 +263,31 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
),
|
||||
};
|
||||
|
||||
// Get submitted reps from watched cases
|
||||
const mySubmittedReps = watchedCases.value.filter((el) => {
|
||||
return el.pinswg_representationsubmitted != null;
|
||||
});
|
||||
// submitted reps derived from watched cases
|
||||
const mySubmittedReps = watchedCases.value.filter(
|
||||
(el) => el.pinswg_representationsubmitted != null
|
||||
);
|
||||
|
||||
if (accountDetails.errorCode) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/myportal/error",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Helper function for fetching details with concurrency limit
|
||||
// Newer getDetails implementation (bounded concurrency, fewer edge-case bugs)
|
||||
const getDetails = async (resultsObj, detailsType) => {
|
||||
const limitRequests = pLimit(5);
|
||||
const arr = [];
|
||||
resultsObj =
|
||||
|
||||
const list =
|
||||
detailsType === "mySubmittedReps"
|
||||
? resultsObj
|
||||
: resultsObj.value;
|
||||
|
||||
const tasks = resultsObj.map((item) =>
|
||||
const tasks = list.map((item) =>
|
||||
limitRequests(async () => {
|
||||
try {
|
||||
let caseID = "";
|
||||
|
||||
switch (detailsType) {
|
||||
case "myCases":
|
||||
caseID = item.pinswg_title;
|
||||
break;
|
||||
|
||||
case "myWatchedCases":
|
||||
case "mySubmittedReps":
|
||||
caseID =
|
||||
@@ -294,12 +295,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
];
|
||||
break;
|
||||
|
||||
case "awaitingSubmission":
|
||||
caseID = item.ticketnumber;
|
||||
break;
|
||||
|
||||
case "myRepresentations":
|
||||
caseID = item.casereference;
|
||||
break;
|
||||
|
||||
default:
|
||||
caseID = item.pinswg_title;
|
||||
}
|
||||
@@ -309,10 +313,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const collectionName = getFormCollectionByID(
|
||||
item.pinswg_appealcasetype
|
||||
).LogicalCollectionName;
|
||||
|
||||
const details = await getPortalModuleDetails(
|
||||
collectionName,
|
||||
caseID
|
||||
);
|
||||
|
||||
arr.push(details);
|
||||
} catch (err) {
|
||||
console.error("Error fetching details:", err);
|
||||
|
||||
@@ -317,7 +317,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
const repsFileListObj = await getRepsFilesBlobs(
|
||||
result.containerID,
|
||||
result.caseRef,
|
||||
result.ticketnumber,
|
||||
result.repfile_name
|
||||
);
|
||||
|
||||
|
||||
@@ -100,20 +100,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
},
|
||||
};
|
||||
} else {
|
||||
let [searchResultsObj, loggedInUser] = await Promise.all([
|
||||
await getBasicSearch(query.q),
|
||||
let [loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
searchResultsObj =
|
||||
searchResultsObj.status == 502
|
||||
? {
|
||||
value: [],
|
||||
errorCode: searchResultsObj.status,
|
||||
errorMsg: searchResultsObj.statusText,
|
||||
}
|
||||
: searchResultsObj;
|
||||
|
||||
//console.log("sssss", searchResultsObj);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
@@ -122,15 +112,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
//console.log("sssss", loggedInUser);
|
||||
|
||||
const [accountDetails, searchDetailsObj, watchedCasesDetails] =
|
||||
await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getSearchDetails(searchResultsObj),
|
||||
await getDetails(watchedCases, "myWatchedCases"),
|
||||
]);
|
||||
const [accountDetails, watchedCasesDetails] = await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getDetails(watchedCases, "myWatchedCases"),
|
||||
]);
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch(query.q));
|
||||
store.dispatch(setWatchedCases(watchedCases));
|
||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
|
||||
Reference in New Issue
Block a user