Merged PR 2442: remove lodash dependecies on _.has

Related work items: #23754
This commit is contained in:
Robert Bond
2026-06-29 13:08:06 +00:00
parent 7b6af58065
commit ff699735c7
85 changed files with 870 additions and 952 deletions
+4 -4
View File
@@ -1,4 +1,3 @@
import _ from "lodash";
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { useRouter } from "next/router";
@@ -10,6 +9,7 @@ import CRMError from "../components/crmError";
import Footer from "../components/footer";
import Header from "../components/header";
import ServiceBanner from "../components/servicebanner";
import { hasOwn } from "../components/utils";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -20,8 +20,8 @@ const Home = (props) => {
const { appealtypes } = router.query;
var hasError =
_.has(props.LPAData.LPAData, "errorCode") ||
_.has(props.appealType.appealType, "errorCode")
hasOwn(props.LPAData.LPAData, "errorCode") ||
hasOwn(props.appealType.appealType, "errorCode")
? true
: false;
@@ -120,7 +120,7 @@ const mapStateToProps = (state) => {
appealType: state.appealType,
LPAData: state.LPAData,
//form: state.form,
accountDetails: state.accountDetails,
accountDetails: state.accountDetails
};
};
+3 -3
View File
@@ -1,4 +1,3 @@
import _ from "lodash";
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { useRouter } from "next/router";
@@ -19,6 +18,7 @@ import { setLPA, setCaseStatus } from "../store/lpa/action";
import { wrapper } from "../store/store";
import ServiceBanner from "../components/servicebanner";
import { getCaseStatus } from "../actions/services/caseDirectService";
import { hasOwn } from "../components/utils";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -29,8 +29,8 @@ const Home = (props) => {
const { appealtypes } = router.query;
var hasError =
_.has(props.LPAData.LPAData, "errorCode") ||
_.has(props.appealType.appealType, "errorCode")
hasOwn(props.LPAData.LPAData, "errorCode") ||
hasOwn(props.appealType.appealType, "errorCode")
? true
: false;
+3 -3
View File
@@ -17,10 +17,10 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { consoleLogger } from "../../../actions/core/logger";
import { getToken } from "../../../actions/core/token";
import { hasOwn } from "../../../components/utils";
import { hashAPIPath } from "../../../actions/core/hash";
import { respondError, respondSuccess } from "../middleware/apiResponse";
const WORDKEY = process.env.HASHKEY;
@@ -152,9 +152,9 @@ export default async function ApiProxy(req, res) {
let dataStr;
_.has(data, "@odata.nextLink") == true &&
hasOwn(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
(data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]));
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
+3 -3
View File
@@ -16,11 +16,11 @@
*/
import axios from "axios";
import _ from "lodash";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { getToken } from "../../../actions/core/token";
import { consoleLogger } from "../../../actions/core/logger";
import { hashAPIPath } from "../../../actions/core/hash";
import { hasOwn } from "../../../components/utils";
import { respondError, respondSuccess } from "../middleware/apiResponse";
const WEBAPI_URL =
@@ -60,9 +60,9 @@ export default async function ApiProxy(req, res) {
);
let dataStr;
_.has(data, "@odata.nextLink") == true &&
hasOwn(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
(data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]));
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
@@ -47,10 +47,10 @@
// * description: Success
// */
import _ from "lodash";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
import { hasOwn } from "../../../components/utils";
import { RELAY_POLICY_SEARCH_PAGED } from "../middleware/relayPolicyPresets";
export default async function ApiProxy(req, res) {
@@ -109,7 +109,7 @@ export default async function ApiProxy(req, res) {
var queryString = "";
queryString +=
_.has(searchString, "q") && searchString.q != null
hasOwn(searchString, "q") && searchString.q != null
? "(contains(title, '" +
searchString.q.replace(/\'/g, "''") +
"') or contains(ticketnumber,'" +
@@ -118,25 +118,25 @@ export default async function ApiProxy(req, res) {
: "";
queryString +=
_.has(searchString, "lpaRef") && searchString.lpaRef != null
hasOwn(searchString, "lpaRef") && searchString.lpaRef != null
? "(contains(pinswg_lpareference, '" +
searchString.lpaRef.replace(/\'/g, "''") +
"')) and"
: "";
queryString +=
(_.has(searchString, "lpa") || _.has(searchString, "LPA")) &&
(hasOwn(searchString, "lpa") || hasOwn(searchString, "LPA")) &&
searchString.lpa != null
? " _pinswg_associatedlpa_value eq " + searchString.lpa + " and"
: "";
queryString +=
_.has(searchString, "apt") && searchString.apt != null
hasOwn(searchString, "apt") && searchString.apt != null
? " pinswg_appealcasetype eq " + searchString.apt + " and"
: "";
queryString +=
_.has(searchString, "statuscode") && searchString.statuscode != null
hasOwn(searchString, "statuscode") && searchString.statuscode != null
? " statuscode eq " + searchString.statuscode + " and"
: "";
@@ -152,7 +152,7 @@ export default async function ApiProxy(req, res) {
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
: "");
if (_.has(searchString, "projecttype")) {
if (hasOwn(searchString, "projecttype")) {
const sipsFilters = [
"pinswg_sips_pinswg_sipsprojecttype/any(pt: pt/pinswg_sipsprojecttypeid eq " +
searchString.projecttype +
@@ -215,7 +215,7 @@ export default async function ApiProxy(req, res) {
relayPolicy,
transformData: (data) => {
let dataStr;
_.has(data, "@odata.nextLink") === true &&
hasOwn(data, "@odata.nextLink") === true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]));
+3 -3
View File
@@ -16,8 +16,8 @@
* description: Success
*/
import _ from "lodash";
import { azureHeadersPaged } from "../../../actions/core/headers";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -30,9 +30,9 @@ export default async function ApiProxy(req, res) {
res,
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
transformData: (data) => {
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
@@ -9,9 +9,9 @@
* 200:
* description: Success
*/
import _ from "lodash";
import { azureHeadersPaged } from "../../../actions/core/headers";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -41,9 +41,9 @@ export default async function ApiProxy(req, res) {
res,
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
transformData: (data) => {
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
@@ -41,8 +41,7 @@
* 200:
* description: Success
*/
import _ from "lodash";
import { hasOwn } from "../../../components/utils";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -96,9 +95,9 @@ export default async function ApiProxy(req, res) {
requestOptionsBuilder: (accessToken) =>
azureHeadersPagedCustom(accessToken, showNumberOfRecords),
transformData: (data) => {
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
@@ -16,8 +16,8 @@
* description: Success
*/
import _ from "lodash";
import { azureHeadersPaged } from "../../../actions/core/headers";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -47,9 +47,9 @@ export default async function ApiProxy(req, res) {
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
transformData: (data) => {
let dataStr;
_.has(data, "@odata.nextLink") === true &&
hasOwn(data, "@odata.nextLink") === true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
(data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]));
return data;
},
@@ -29,10 +29,10 @@
* description: Success
*/
import _ from "lodash";
import { azureHeaders, azureHeadersPaged } from "../../../actions/core/headers";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
import { hasOwn } from "../../../components/utils";
import { respondError, respondSuccess } from "../middleware/apiResponse";
import { relayGetData } from "../middleware/relayForwarding";
@@ -138,7 +138,7 @@ export default async function ApiProxy(req, res) {
additionalLPAs
}));
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
@@ -42,10 +42,10 @@
* description: Success
*/
import _ from "lodash";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
import { hasOwn } from "../../../components/utils";
import { RELAY_POLICY_SEARCH_PAGED } from "../middleware/relayPolicyPresets";
export default async function ApiProxy(req, res) {
@@ -121,9 +121,9 @@ export default async function ApiProxy(req, res) {
azureHeadersPagedCustom(accessToken, showNumberOfRecords),
relayPolicy,
transformData: (data) => {
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
+3 -3
View File
@@ -10,7 +10,7 @@
* description: Success
*/
import _ from "lodash";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -34,9 +34,9 @@ export default async function ApiProxy(req, res) {
queryUrl,
res,
transformData: (data) => {
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
+3 -3
View File
@@ -10,7 +10,7 @@
* description: Success
*/
import _ from "lodash";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -31,9 +31,9 @@ export default async function ApiProxy(req, res) {
queryUrl,
res,
transformData: (data) => {
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return [data];
+3 -3
View File
@@ -1,5 +1,5 @@
import _ from "lodash";
import { azureHeaders } from "../../../actions/core/headers";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -14,9 +14,9 @@ export default async function ApiProxy(req, res) {
transformData: (data) => {
let dataStr;
_.has(data, "@odata.nextLink") === true &&
hasOwn(data, "@odata.nextLink") === true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
(data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]));
return data;
},
+3 -3
View File
@@ -1,5 +1,5 @@
import _ from "lodash";
import { azureHeadersPaged } from "../../../actions/core/headers";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -29,9 +29,9 @@ export default async function ApiProxy(req, res) {
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
transformData: (data) => {
let dataStr;
_.has(data, "@odata.nextLink") === true &&
hasOwn(data, "@odata.nextLink") === true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
(data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]));
return data;
},
@@ -19,6 +19,7 @@
import CryptoJS from "crypto-js";
import _ from "lodash";
import { azureHeadersPaged } from "../../../actions/core/headers";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -70,9 +71,9 @@ export default async function ApiProxy(req, res) {
);
});
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
@@ -43,8 +43,8 @@
*/
import CryptoJS from "crypto-js";
import _ from "lodash";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { hasOwn } from "../../../components/utils";
import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
@@ -175,9 +175,9 @@ export default async function ApiProxy(req, res) {
);
});
if (_.has(data, "@odata.nextLink") === true) {
if (hasOwn(data, "@odata.nextLink") === true) {
const dataStr = JSON.stringify(data["@odata.nextLink"]);
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
data["@odata.nextLink"] = dataStr.split("/v9.2/")[1];
}
return data;
+1 -1
View File
@@ -45,7 +45,7 @@ export default async function ApiProxy(req, res) {
const crmUrl = "https://" + process.env.CRMURL;
const data = {
"@odata.id": crmUrl + "/api/data/v8.2/contacts(" + contactid + ")"
"@odata.id": crmUrl + "/api/data/v9.2/contacts(" + contactid + ")"
};
const config = {
+1 -1
View File
@@ -30,4 +30,4 @@ pinswg_ldp
pinswg_maintenanceoflands217
pinswg_electricityact
https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/EntityDefinitions(LogicalName='incident')/Attributes(LogicalName='pinswg_appealcasetype')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)
https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v9.2/EntityDefinitions(LogicalName='incident')/Attributes(LogicalName='pinswg_appealcasetype')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)
+2 -3
View File
@@ -9,9 +9,8 @@ import Footer from "../../components/footer";
import Header from "../../components/header";
import { wrapper } from "../../store/store";
import _ from "lodash";
import Breadcrumbs from "../../components/breadcrumbs";
import { getSearchDetails } from "../../components/utils";
import { getSearchDetails, hasOwn } from "../../components/utils";
import { setSearch } from "../../store/search/action";
import {
setSearchDetails,
@@ -58,7 +57,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
);
let searchResultsObj = await getDNSList();
if (_.has(searchResultsObj, "status") != false) {
if (hasOwn(searchResultsObj, "status") != false) {
if (searchResultsObj.status == 400) {
return {
redirect: {
+2 -2
View File
@@ -12,7 +12,7 @@ import CookieBanner from "../components/cookieBanner";
import DNSSearchResults from "../components/dnssearchresults";
import Footer from "../components/footer";
import Header from "../components/header";
import { getSearchDetails } from "../components/utils";
import { getSearchDetails, hasOwn } from "../components/utils";
import { setSearch } from "../store/search/action";
import {
setSearchDetails,
@@ -143,7 +143,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
const showMapCheck = process.env.SHOWMAPS || false;
const mapTarget = process.env.MAP_TARGET || "pedw-dev";
// if (_.has(searchResultsObj, "status") == true) {
// if (hasOwn(searchResultsObj, "status") == true) {
// return {
// redirect: {
// //destination: "/dns-not-found",
+2 -1
View File
@@ -18,6 +18,7 @@ import AIPolicyNotice from "../components/AIPolicyNotice";
import { setContainerID } from "../store/accountDetails/action";
import { setShowReps } from "../store/currentView/action";
import { wrapper } from "../store/store";
import { hasOwn } from "../components/utils";
const Home = (props) => {
const {
@@ -49,7 +50,7 @@ const Home = (props) => {
hasLoginCode == false
? "" //console.log("no session")
: _.has(loggedInUserId, "value")
: hasOwn(loggedInUserId, "value")
? _.isEmpty(loggedInUserId.value)
? router.replace({
pathname:
+4 -4
View File
@@ -1,5 +1,4 @@
//import fs from "fs";
import _ from "lodash";
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { useRouter } from "next/router";
@@ -12,6 +11,7 @@ import Header from "../../components/header";
import Search from "../../components/myportal/addresssearch";
import ServiceBanner from "../../components/myportal/servicebanner";
import TimeOut from "../../components/timeout";
import { hasOwn } from "../../components/utils";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -22,8 +22,8 @@ const Home = (props) => {
const { appealtypes } = router.query;
var hasError =
_.has(props.LPAData.LPAData, "errorCode") ||
_.has(props.appealType.appealType, "errorCode")
hasOwn(props.LPAData.LPAData, "errorCode") ||
hasOwn(props.appealType.appealType, "errorCode")
? true
: false;
@@ -123,7 +123,7 @@ const mapStateToProps = (state) => {
appealType: state.appealType,
LPAData: state.LPAData,
//form: state.form,
accountDetails: state.accountDetails,
accountDetails: state.accountDetails
};
};
+3 -3
View File
@@ -1,4 +1,3 @@
import _ from "lodash";
import { getSession } from "next-auth/react";
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
@@ -28,6 +27,7 @@ import { setLPA, setCaseStatus } from "../../store/lpa/action";
import { wrapper } from "../../store/store";
import ServiceBanner from "../../components/myportal/servicebanner";
import { getCaseStatus } from "../../actions/services/caseDirectService";
import { hasOwn } from "../../components/utils";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -38,8 +38,8 @@ const Home = (props) => {
const { appealtypes } = router.query;
var hasError =
_.has(props.LPAData.LPAData, "errorCode") ||
_.has(props.appealType.appealType, "errorCode")
hasOwn(props.LPAData.LPAData, "errorCode") ||
hasOwn(props.appealType.appealType, "errorCode")
? true
: false;
-10
View File
@@ -1,7 +1,6 @@
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { getSession, useSession } from "next-auth/react";
import _ from "lodash";
import { useRouter } from "next/router";
import { connect } from "react-redux";
@@ -148,15 +147,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
let thisSession = await getSession(ctx);
//console.log("nextAuth Session:", thisSession);
// if (_.has(thisSession, "user") == false) {
// return {
// redirect: {
// destination: "/error",
// permanent: false,
// },
// };
// }
if (!thisSession) {
console.log("not has sesssion.......");
return {
-29
View File
@@ -1,4 +1,3 @@
import _ from "lodash";
import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { useRouter } from "next/router";
@@ -132,34 +131,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
const showLoginCheck = process.env.SHOWLOGIN || false;
const showReps = process.env.SHOWREPRESENTATIONS || false;
store.dispatch(setShowReps(showReps, showLoginCheck));
// let searchResultsObj = await getBasicSearch(query.q);
// searchResultsObj =
// searchResultsObj.status == 502
// ? {
// value: [],
// errorCode: searchResultsObj.status,
// errorMsg: searchResultsObj.statusText,
// }
// : searchResultsObj;
// if (_.has(searchResultsObj, "status") == true) {
// return {
// redirect: {
// //destination: "/dns-not-found",
// destination: "/error",
// permanent: false,
// },
// };
// } else {
// // const searchDetailsObj = await getSearchDetails(searchResultsObj);
// store.dispatch(setSearchResults(searchResultsObj));
// // store.dispatch(setSearchDetails(searchDetailsObj));
// store.dispatch(setSearch(query.q));
// }
store.dispatch(setSearch(query?.q || ""));
return {
props: {