Merge branch 'Development' into SIPS-Development
This commit is contained in:
@@ -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