diff --git a/actions/index.js b/actions/index.js
index 481ee577..1d933f06 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -646,6 +646,22 @@ export const getAppealsTypes = () => {
});
};
+export const getProjectTypes = () => {
+ return axios
+ .get(BASE_URL + "/api/endpoint/getprojecttypes_api")
+ .then((res) => res.data)
+ .catch((error) => {
+ consoleLogger(error);
+ let ErrResponse = {
+ value: [],
+ errorCode: error.response.status,
+ errorMsg: error.response.statusText,
+ };
+
+ return ErrResponse;
+ });
+};
+
export const getAppealsTypesForNewAppeal = () => {
return axios
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
diff --git a/components/search.js b/components/search.js
index 8b77448c..9e6f950b 100644
--- a/components/search.js
+++ b/components/search.js
@@ -14,7 +14,7 @@ export default function Search(props) {
id="main-content"
role="main"
>
-
+
);
}
diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js
index 5abb21b3..7fc0022c 100644
--- a/components/search/advancedsearch.js
+++ b/components/search/advancedsearch.js
@@ -174,6 +174,16 @@ let AdvancedSearch = (props) => {
? [{}]
: props.appealType.appealTypeOptions.value;
+ const projecttypeOptionsObj = _.isEmpty(props)
+ ? [{}]
+ : _.isEmpty(props.appealType)
+ ? [{}]
+ : _.isEmpty(props.appealType.projectTypeOptions)
+ ? [{}]
+ : _.isEmpty(props.appealType.projectTypeOptions.value)
+ ? [{}]
+ : props.appealType.projectTypeOptions.value;
+
let lpaOptionsObj = _.isEmpty(props)
? [{}]
: _.isEmpty(props.LPAData)
@@ -362,9 +372,117 @@ let AdvancedSearch = (props) => {
>
);
};
+ const RenderProjectTypeList = ({
+ name,
+ id,
+ input,
+ optionsObj,
+ meta: { touched, error },
+ label,
+ errormsg,
+ }) => {
+ return (
+ <>
+
+
+ {touched && error && (
+
+
+ Error:
+ {" "}
+ {errormsg}
+
+ )}
+
+
+
+
+ >
+ );
+ };
//const [showSpinnerState, setShowSpinnerState] = useState(false);
+ const selectAppealTypesValue = props.formValues?.appealTypes || "";
+
// let spinnerState = () => {
// showSpinnerState == true
// ? setShowSpinnerState(false)
@@ -390,7 +508,12 @@ let AdvancedSearch = (props) => {
searchString +=
values.statusCode != null
- ? "statuscode=" + values.statusCode + "&"
+ ? "statuscode=" + values.projecttype + "&"
+ : "";
+
+ searchString +=
+ values.projecttype != null
+ ? "projecttype=" + values.projecttype.split(",")[0] + "&"
: "";
searchString = "?" + searchString.slice(0, -1);
@@ -457,6 +580,26 @@ let AdvancedSearch = (props) => {
label={t("search:appealtype-label")}
errormsg="Appeal type is required"
/>
+ {props.props?.props.form[
+ props.form
+ ]?.values?.appealTypes.split(",")[0] ===
+ "846040002" && (
+
+ )}
{
{item.title}
+
+ {detailsObj.hasOwnProperty(
+ "_pinswg_projecttype_value@OData.Community.Display.V1.FormattedValue"
+ ) && (
+
+ {
+ detailsObj[
+ "_pinswg_projecttype_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ }
+
+ )}
diff --git a/locales/cy/myportal.json b/locales/cy/myportal.json
index be24bbc4..d83cd0b7 100644
--- a/locales/cy/myportal.json
+++ b/locales/cy/myportal.json
@@ -43,6 +43,7 @@
"norecords-awaiting-submissions": "Nid oes gennych unrhyw gyflwyniadau sy'n aros",
"on-behalf-of-label": "Ar ran",
"appeal-type-label": "Math o apĂȘl",
+ "project-type-label": "Math o brosiect",
"lpa-reference-label": "Cyfeirnod yr ACLl",
"raised-by-label": "Codwyd gan",
"representation-id": "Cyfeirnod y sylw",
diff --git a/locales/cy/search.json b/locales/cy/search.json
index 937c7f2f..e8a3c972 100644
--- a/locales/cy/search.json
+++ b/locales/cy/search.json
@@ -10,6 +10,7 @@
"lpa-label": "Awdurdod Cynllunio Lleol",
"lpa-reference-label": "Cyfeirnod yr Awdurdod Cynllunio Lleol",
"appealtype-label": "Dewiswch fath o achos",
+ "project-type-label": "Math o brosiect",
"case-status-label": "Statws yr Achos",
"case-type-label": "Math o Achos",
"case-type-option-1": "--Dewiswch--",
diff --git a/locales/en/myportal.json b/locales/en/myportal.json
index 0d48f908..13631904 100644
--- a/locales/en/myportal.json
+++ b/locales/en/myportal.json
@@ -43,6 +43,7 @@
"norecords-awaiting-submissions": "You have no awaiting submissions",
"on-behalf-of-label": "On behalf of",
"appeal-type-label": "Appeal type",
+ "project-type-label": "Project type",
"lpa-reference-label": "LPA reference",
"raised-by-label": "Raised by",
"representation-id": "Representation ID",
diff --git a/locales/en/search.json b/locales/en/search.json
index 67febd36..0dc2d533 100644
--- a/locales/en/search.json
+++ b/locales/en/search.json
@@ -10,6 +10,7 @@
"lpa-label": "Local Planning Authority",
"lpa-reference-label": "LPA reference",
"appealtype-label": "Select a case type",
+ "project-type-label": "Project type",
"case-status-label": "Case Status",
"case-type-label": "Case type",
"case-type-option-1": "-- Select --",
diff --git a/pages/advancedsearch.js b/pages/advancedsearch.js
index b66bd96e..d30c592d 100644
--- a/pages/advancedsearch.js
+++ b/pages/advancedsearch.js
@@ -3,14 +3,14 @@ import useTranslation from "next-translate/useTranslation";
import Head from "next/head";
import { useRouter } from "next/router";
import { connect } from "react-redux";
-import { getAppealsTypes, getLPA } from "../actions";
+import { getAppealsTypes, getProjectTypes, getLPA } from "../actions";
import Breadcrumbs from "../components/breadcrumbs";
import CookieBanner from "../components/cookieBanner";
import CRMError from "../components/crmError";
import Footer from "../components/footer";
import Header from "../components/header";
import Search from "../components/search";
-import { setAppealType } from "../store/appealType/action";
+import { setAppealType, setProjectType } from "../store/appealType/action";
import { setLPA } from "../store/lpa/action";
import { wrapper } from "../store/store";
import ServiceBanner from "../components/servicebanner";
@@ -110,6 +110,7 @@ const Home = (props) => {
)}
@@ -122,8 +123,9 @@ const Home = (props) => {
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
- let [appealTypeData, lpaData] = await Promise.all([
+ let [appealTypeData, projectTypeData, lpaData] = await Promise.all([
await getAppealsTypes(),
+ await getProjectTypes(),
await getLPA(),
]);
@@ -131,6 +133,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
//const appealTypeData = require("../data/appealtypes.json");
store.dispatch(setAppealType(appealTypeData));
+ store.dispatch(setProjectType(projectTypeData));
store.dispatch(setLPA(lpaData));
}
);
@@ -142,7 +145,7 @@ const mapStateToProps = (state) => {
formData: state.formData,
appealType: state.appealType,
LPAData: state.LPAData,
- //form: state.form,
+ form: state.form,
accountDetails: state.accountDetails,
};
};
diff --git a/pages/api/endpoint/getadvancedsearch_api.js b/pages/api/endpoint/getadvancedsearch_api.js
index cbffa702..0833f72b 100644
--- a/pages/api/endpoint/getadvancedsearch_api.js
+++ b/pages/api/endpoint/getadvancedsearch_api.js
@@ -95,11 +95,74 @@ export default async function ApiProxy(req, res) {
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
- .then(({ data }) => {
+ .then(async ({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
+
+ if (_.has(searchString, "projecttype")) {
+ await updateValueArray(data, token);
+
+ async function updateValueArray(data, token) {
+ for (let i = 0; i < data.value.length; i++) {
+ const item = data.value[i];
+
+ try {
+ // Axios call using the `incidentid` to fetch additional data
+ const response = await axios.get(
+ WEBAPI_URL +
+ "pinswg_sipses?$filter=_pinswg_sipscase_value eq " +
+ item.incidentid +
+ " and _pinswg_projecttype_value eq " +
+ searchString.projecttype +
+ "&$select=_pinswg_projecttype_value" +
+ hashAPIPath(
+ "pinswg_sipses?$filter=_pinswg_sipscase_value eq " +
+ item.incidentid +
+ " and _pinswg_projecttype_value eq " +
+ searchString.projecttype +
+ "&$select=_pinswg_projecttype_value"
+ ),
+ azureHeadersPaged(token.access_token)
+ );
+
+ // Assuming the response contains the additional data you want to add
+ // console.log(response.data.value[0]);
+ console.log(response.data.value);
+
+ if (
+ response.data.value.length > 0 &&
+ response.data.value[0]
+ ._pinswg_projecttype_value != null
+ ) {
+ Object.assign(
+ item,
+ response.data.value[0]
+ ); // Update item with new data
+ } else {
+ console.log(
+ `No project type found for incident ID ${item.incidentid}`
+ );
+ }
+ } catch (error) {
+ console.error(
+ `Error fetching data for incident ID ${item.incidentid}:`,
+ error
+ );
+ }
+ }
+ }
+
+ data.value = data.value.filter(
+ (item) => item._pinswg_projecttype_value != null
+ );
+
+ data["@odata.count"] = data.value.length;
+
+ // console.log(newDataObj);
+ }
+
res.status(200).json(data);
})
.catch((error) => {
diff --git a/pages/api/endpoint/getadvancedsearchpaged_api.js b/pages/api/endpoint/getadvancedsearchpaged_api.js
index 95b03de5..506e13dd 100644
--- a/pages/api/endpoint/getadvancedsearchpaged_api.js
+++ b/pages/api/endpoint/getadvancedsearchpaged_api.js
@@ -52,6 +52,7 @@ import CryptoJS from "crypto-js";
import _ from "lodash";
import {
azureHeadersPagedCustom,
+ azureHeadersPaged,
consoleLogger,
getToken,
} from "../../../actions";
@@ -138,11 +139,72 @@ export default async function ApiProxy(req, res) {
showNumberOfRecords
)
)
- .then(({ data }) => {
+ .then(async ({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
+
+ if (_.has(searchString, "projecttype")) {
+ await updateValueArray(data, token);
+
+ async function updateValueArray(data, token) {
+ for (let i = 0; i < data.value.length; i++) {
+ const item = data.value[i];
+
+ try {
+ // Axios call using the `incidentid` to fetch additional data
+ const response = await axios.get(
+ WEBAPI_URL +
+ "pinswg_sipses?$filter=_pinswg_sipscase_value eq " +
+ item.incidentid +
+ " and _pinswg_projecttype_value eq " +
+ searchString.projecttype +
+ "&$select=_pinswg_projecttype_value" +
+ hashAPIPath(
+ "pinswg_sipses?$filter=_pinswg_sipscase_value eq " +
+ item.incidentid +
+ " and _pinswg_projecttype_value eq " +
+ searchString.projecttype +
+ "&$select=_pinswg_projecttype_value"
+ ),
+ azureHeadersPaged(token.access_token)
+ );
+
+ // Assuming the response contains the additional data you want to add
+ // console.log(response.data.value[0]);
+ console.log(response.data.value);
+
+ if (
+ response.data.value.length > 0 &&
+ response.data.value[0]
+ ._pinswg_projecttype_value != null
+ ) {
+ Object.assign(
+ item,
+ response.data.value[0]
+ ); // Update item with new data
+ } else {
+ console.log(
+ `No project type found for incident ID ${item.incidentid}`
+ );
+ }
+ } catch (error) {
+ console.error(
+ `Error fetching data for incident ID ${item.incidentid}:`,
+ error
+ );
+ }
+ }
+ }
+
+ data.value = data.value.filter(
+ (item) => item._pinswg_projecttype_value != null
+ );
+
+ data["@odata.count"] = data.value.length;
+ }
+
res.status(200).json(data);
})
.catch((error) => {
diff --git a/pages/api/endpoint/getprojecttypes_api.js b/pages/api/endpoint/getprojecttypes_api.js
new file mode 100644
index 00000000..92bfb5d4
--- /dev/null
+++ b/pages/api/endpoint/getprojecttypes_api.js
@@ -0,0 +1,54 @@
+/**
+ * @swagger
+ * /api/endpoint/getappealtypes_api:
+ * get:
+ * tags: [Misc]
+ * description: Get Appeal Types
+ * responses:
+ * 200:
+ * description: Success
+ */
+
+import axios from "axios";
+import CryptoJS from "crypto-js";
+import { azureHeaders, consoleLogger, getToken } from "../../../actions";
+
+const WORDKEY = process.env.HASHKEY;
+
+const WEBAPI_URL =
+ process.env.RELAY_ROOT ||
+ "https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
+
+const hashAPIPath = (queryPath) => {
+ var hashlink = CryptoJS.HmacSHA256(
+ queryPath,
+ CryptoJS.enc.Hex.parse(WORDKEY)
+ );
+ hashlink = hashlink.toString(CryptoJS.enc.Hex);
+
+ //return "&hash=" + hashlink;
+
+ return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
+};
+
+export default async function ApiProxy(req, res) {
+ var token = await getToken();
+
+ var queryUrl =
+ "pinswg_sipsprojecttypes?$select=pinswg_name,pinswg_sector,pinswg_sipsprojecttypeid&$orderby=pinswg_name asc&$count=true";
+
+ //console.log(queryUrl);
+
+ return axios
+ .get(
+ WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
+ azureHeaders(token.access_token)
+ )
+ .then(({ data }) => {
+ res.status(200).json(data);
+ })
+ .catch((error) => {
+ consoleLogger(error);
+ res.status(400).json(error);
+ });
+}
diff --git a/store/appealType/action.js b/store/appealType/action.js
index 34ba914e..a6842598 100644
--- a/store/appealType/action.js
+++ b/store/appealType/action.js
@@ -12,6 +12,7 @@ export const appealTypeDataActionTypes = {
SETFILELIST: "SETFILELIST",
SETNEWAPPEALPROGRESS: "SETNEWAPPEALPROGRESS",
SETFILECOUNT: "SETFILECOUNT",
+ SETPROJECTTYPEDATA: "SETPROJECTTYPEDATA",
};
export const getAppealTypeObj = () => (dispatch) => {
@@ -27,6 +28,13 @@ export const setAppealType = (appealTypeData) => (dispatch) => {
});
};
+export const setProjectType = (projectTypeData) => (dispatch) => {
+ return dispatch({
+ type: appealTypeDataActionTypes.SETPROJECTTYPEDATA,
+ projectTypeOptions: projectTypeData,
+ });
+};
+
export const setAppealTypeTitle = (appealTypeData) => (dispatch) => {
return dispatch({
type: appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA,
diff --git a/store/appealType/reducer.js b/store/appealType/reducer.js
index 1cea7576..dd67226e 100644
--- a/store/appealType/reducer.js
+++ b/store/appealType/reducer.js
@@ -2,6 +2,7 @@ import { appealTypeDataActionTypes } from "./action";
const appealTypeDataInitialState = {
appealTypeOptions: {},
+ projectTypeOptions: {},
appealTypeTitle: {},
appealTypeID: {},
currentSection: 1,
@@ -21,6 +22,11 @@ export default function reducer(state = appealTypeDataInitialState, action) {
...state,
appealTypeOptions: action.appealTypeOptions,
};
+ case appealTypeDataActionTypes.SETPROJECTTYPEDATA:
+ return {
+ ...state,
+ projectTypeOptions: action.projectTypeOptions,
+ };
case appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA:
return {
...state,