14769 search by project type
This commit is contained in:
@@ -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 = () => {
|
export const getAppealsTypesForNewAppeal = () => {
|
||||||
return axios
|
return axios
|
||||||
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function Search(props) {
|
|||||||
id="main-content"
|
id="main-content"
|
||||||
role="main"
|
role="main"
|
||||||
>
|
>
|
||||||
<AdvancedSearch myportal={props.myportal || false} />
|
<AdvancedSearch props={props} myportal={props.myportal || false} />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,16 @@ let AdvancedSearch = (props) => {
|
|||||||
? [{}]
|
? [{}]
|
||||||
: props.appealType.appealTypeOptions.value;
|
: 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)
|
let lpaOptionsObj = _.isEmpty(props)
|
||||||
? [{}]
|
? [{}]
|
||||||
: _.isEmpty(props.LPAData)
|
: _.isEmpty(props.LPAData)
|
||||||
@@ -362,9 +372,117 @@ let AdvancedSearch = (props) => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const RenderProjectTypeList = ({
|
||||||
|
name,
|
||||||
|
id,
|
||||||
|
input,
|
||||||
|
optionsObj,
|
||||||
|
meta: { touched, error },
|
||||||
|
label,
|
||||||
|
errormsg,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
touched && error
|
||||||
|
? "govuk-form-group govuk-form-group--error"
|
||||||
|
: "govuk-form-group "
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<label className="govuk-label" htmlFor={id}>
|
||||||
|
{label}
|
||||||
|
{name}
|
||||||
|
</label>
|
||||||
|
{touched && error && (
|
||||||
|
<span
|
||||||
|
id={name + "-error"}
|
||||||
|
className="govuk-error-message"
|
||||||
|
>
|
||||||
|
<span className="govuk-visually-hidden">
|
||||||
|
Error:
|
||||||
|
</span>{" "}
|
||||||
|
{errormsg}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<select
|
||||||
|
{...input}
|
||||||
|
className="govuk-select"
|
||||||
|
id={id}
|
||||||
|
name={name}
|
||||||
|
//onChange={(e) => props.onChangeSelectAppealType(e)}
|
||||||
|
>
|
||||||
|
<option value="" disabled defaultValue>
|
||||||
|
{t("common:drop-down-select")}
|
||||||
|
</option>
|
||||||
|
{_.isEmpty(optionsObj)
|
||||||
|
? ""
|
||||||
|
: Object.keys(optionsObj).map((key, index) => {
|
||||||
|
return (
|
||||||
|
<option
|
||||||
|
key={key}
|
||||||
|
value={
|
||||||
|
_.isEmpty(optionsObj[key])
|
||||||
|
? ""
|
||||||
|
: _.isEmpty(
|
||||||
|
optionsObj[key]
|
||||||
|
)
|
||||||
|
? ""
|
||||||
|
: _.isEmpty(
|
||||||
|
optionsObj[key]
|
||||||
|
.pinswg_sipsprojecttypeid
|
||||||
|
)
|
||||||
|
? ""
|
||||||
|
: optionsObj[key]
|
||||||
|
.pinswg_sipsprojecttypeid +
|
||||||
|
"," +
|
||||||
|
optionsObj[
|
||||||
|
key
|
||||||
|
].pinswg_name
|
||||||
|
.replace(
|
||||||
|
/(\band|[\s\-\+\(\)\,\&])/g,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
.toLowerCase()
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{_.isEmpty(optionsObj[key])
|
||||||
|
? ""
|
||||||
|
: _.isEmpty(optionsObj[key])
|
||||||
|
? ""
|
||||||
|
: _.isEmpty(
|
||||||
|
optionsObj[key]
|
||||||
|
.pinswg_name
|
||||||
|
)
|
||||||
|
? ""
|
||||||
|
: router.locale == "cy"
|
||||||
|
? jsonpath(
|
||||||
|
'$..[?(@.value=="' +
|
||||||
|
optionsObj[key]
|
||||||
|
.pinswg_name +
|
||||||
|
'")].value_cy',
|
||||||
|
transLookup
|
||||||
|
)
|
||||||
|
: optionsObj[key]
|
||||||
|
.pinswg_name ||
|
||||||
|
t(
|
||||||
|
"case:summary-no-date-entered-label"
|
||||||
|
)}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
//const [showSpinnerState, setShowSpinnerState] = useState(false);
|
//const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||||
|
|
||||||
|
const selectAppealTypesValue = props.formValues?.appealTypes || "";
|
||||||
|
|
||||||
// let spinnerState = () => {
|
// let spinnerState = () => {
|
||||||
// showSpinnerState == true
|
// showSpinnerState == true
|
||||||
// ? setShowSpinnerState(false)
|
// ? setShowSpinnerState(false)
|
||||||
@@ -390,7 +508,12 @@ let AdvancedSearch = (props) => {
|
|||||||
|
|
||||||
searchString +=
|
searchString +=
|
||||||
values.statusCode != null
|
values.statusCode != null
|
||||||
? "statuscode=" + values.statusCode + "&"
|
? "statuscode=" + values.projecttype + "&"
|
||||||
|
: "";
|
||||||
|
|
||||||
|
searchString +=
|
||||||
|
values.projecttype != null
|
||||||
|
? "projecttype=" + values.projecttype.split(",")[0] + "&"
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
searchString = "?" + searchString.slice(0, -1);
|
searchString = "?" + searchString.slice(0, -1);
|
||||||
@@ -457,6 +580,26 @@ let AdvancedSearch = (props) => {
|
|||||||
label={t("search:appealtype-label")}
|
label={t("search:appealtype-label")}
|
||||||
errormsg="Appeal type is required"
|
errormsg="Appeal type is required"
|
||||||
/>
|
/>
|
||||||
|
{props.props?.props.form[
|
||||||
|
props.form
|
||||||
|
]?.values?.appealTypes.split(",")[0] ===
|
||||||
|
"846040002" && (
|
||||||
|
<Field
|
||||||
|
name="projecttype"
|
||||||
|
id="projecttype"
|
||||||
|
component={
|
||||||
|
RenderProjectTypeList
|
||||||
|
}
|
||||||
|
optionsObj={
|
||||||
|
projecttypeOptionsObj
|
||||||
|
}
|
||||||
|
// validate={[required]}
|
||||||
|
label={t(
|
||||||
|
"search:project-type-label"
|
||||||
|
)}
|
||||||
|
errormsg="Project type is required"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Field
|
<Field
|
||||||
name="lpaTypes"
|
name="lpaTypes"
|
||||||
id="lpaTypes"
|
id="lpaTypes"
|
||||||
|
|||||||
@@ -317,6 +317,18 @@ const SearchResults = (props) => {
|
|||||||
</span>
|
</span>
|
||||||
{item.title}
|
{item.title}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
{detailsObj.hasOwnProperty(
|
||||||
|
"_pinswg_projecttype_value@OData.Community.Display.V1.FormattedValue"
|
||||||
|
) && (
|
||||||
|
<div className="govuk-!-font-size-14">
|
||||||
|
{
|
||||||
|
detailsObj[
|
||||||
|
"_pinswg_projecttype_value@OData.Community.Display.V1.FormattedValue"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<RepsOnResults
|
<RepsOnResults
|
||||||
detailsObj={detailsObj}
|
detailsObj={detailsObj}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
"norecords-awaiting-submissions": "Nid oes gennych unrhyw gyflwyniadau sy'n aros",
|
"norecords-awaiting-submissions": "Nid oes gennych unrhyw gyflwyniadau sy'n aros",
|
||||||
"on-behalf-of-label": "Ar ran",
|
"on-behalf-of-label": "Ar ran",
|
||||||
"appeal-type-label": "Math o apêl",
|
"appeal-type-label": "Math o apêl",
|
||||||
|
"project-type-label": "Math o brosiect",
|
||||||
"lpa-reference-label": "Cyfeirnod yr ACLl",
|
"lpa-reference-label": "Cyfeirnod yr ACLl",
|
||||||
"raised-by-label": "Codwyd gan",
|
"raised-by-label": "Codwyd gan",
|
||||||
"representation-id": "Cyfeirnod y sylw",
|
"representation-id": "Cyfeirnod y sylw",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"lpa-label": "Awdurdod Cynllunio Lleol",
|
"lpa-label": "Awdurdod Cynllunio Lleol",
|
||||||
"lpa-reference-label": "Cyfeirnod yr Awdurdod Cynllunio Lleol",
|
"lpa-reference-label": "Cyfeirnod yr Awdurdod Cynllunio Lleol",
|
||||||
"appealtype-label": "Dewiswch fath o achos",
|
"appealtype-label": "Dewiswch fath o achos",
|
||||||
|
"project-type-label": "Math o brosiect",
|
||||||
"case-status-label": "Statws yr Achos",
|
"case-status-label": "Statws yr Achos",
|
||||||
"case-type-label": "Math o Achos",
|
"case-type-label": "Math o Achos",
|
||||||
"case-type-option-1": "--Dewiswch--",
|
"case-type-option-1": "--Dewiswch--",
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
"norecords-awaiting-submissions": "You have no awaiting submissions",
|
"norecords-awaiting-submissions": "You have no awaiting submissions",
|
||||||
"on-behalf-of-label": "On behalf of",
|
"on-behalf-of-label": "On behalf of",
|
||||||
"appeal-type-label": "Appeal type",
|
"appeal-type-label": "Appeal type",
|
||||||
|
"project-type-label": "Project type",
|
||||||
"lpa-reference-label": "LPA reference",
|
"lpa-reference-label": "LPA reference",
|
||||||
"raised-by-label": "Raised by",
|
"raised-by-label": "Raised by",
|
||||||
"representation-id": "Representation ID",
|
"representation-id": "Representation ID",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"lpa-label": "Local Planning Authority",
|
"lpa-label": "Local Planning Authority",
|
||||||
"lpa-reference-label": "LPA reference",
|
"lpa-reference-label": "LPA reference",
|
||||||
"appealtype-label": "Select a case type",
|
"appealtype-label": "Select a case type",
|
||||||
|
"project-type-label": "Project type",
|
||||||
"case-status-label": "Case Status",
|
"case-status-label": "Case Status",
|
||||||
"case-type-label": "Case type",
|
"case-type-label": "Case type",
|
||||||
"case-type-option-1": "-- Select --",
|
"case-type-option-1": "-- Select --",
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import useTranslation from "next-translate/useTranslation";
|
|||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { getAppealsTypes, getLPA } from "../actions";
|
import { getAppealsTypes, getProjectTypes, getLPA } from "../actions";
|
||||||
import Breadcrumbs from "../components/breadcrumbs";
|
import Breadcrumbs from "../components/breadcrumbs";
|
||||||
import CookieBanner from "../components/cookieBanner";
|
import CookieBanner from "../components/cookieBanner";
|
||||||
import CRMError from "../components/crmError";
|
import CRMError from "../components/crmError";
|
||||||
import Footer from "../components/footer";
|
import Footer from "../components/footer";
|
||||||
import Header from "../components/header";
|
import Header from "../components/header";
|
||||||
import Search from "../components/search";
|
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 { setLPA } from "../store/lpa/action";
|
||||||
import { wrapper } from "../store/store";
|
import { wrapper } from "../store/store";
|
||||||
import ServiceBanner from "../components/servicebanner";
|
import ServiceBanner from "../components/servicebanner";
|
||||||
@@ -110,6 +110,7 @@ const Home = (props) => {
|
|||||||
<Search
|
<Search
|
||||||
lpadata={props.LPAData}
|
lpadata={props.LPAData}
|
||||||
appealType={props.appealType}
|
appealType={props.appealType}
|
||||||
|
props={props}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -122,8 +123,9 @@ const Home = (props) => {
|
|||||||
export const getServerSideProps = wrapper.getServerSideProps(
|
export const getServerSideProps = wrapper.getServerSideProps(
|
||||||
(store) =>
|
(store) =>
|
||||||
async ({ query, req, res }) => {
|
async ({ query, req, res }) => {
|
||||||
let [appealTypeData, lpaData] = await Promise.all([
|
let [appealTypeData, projectTypeData, lpaData] = await Promise.all([
|
||||||
await getAppealsTypes(),
|
await getAppealsTypes(),
|
||||||
|
await getProjectTypes(),
|
||||||
await getLPA(),
|
await getLPA(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -131,6 +133,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
//const appealTypeData = require("../data/appealtypes.json");
|
//const appealTypeData = require("../data/appealtypes.json");
|
||||||
|
|
||||||
store.dispatch(setAppealType(appealTypeData));
|
store.dispatch(setAppealType(appealTypeData));
|
||||||
|
store.dispatch(setProjectType(projectTypeData));
|
||||||
store.dispatch(setLPA(lpaData));
|
store.dispatch(setLPA(lpaData));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -142,7 +145,7 @@ const mapStateToProps = (state) => {
|
|||||||
formData: state.formData,
|
formData: state.formData,
|
||||||
appealType: state.appealType,
|
appealType: state.appealType,
|
||||||
LPAData: state.LPAData,
|
LPAData: state.LPAData,
|
||||||
//form: state.form,
|
form: state.form,
|
||||||
accountDetails: state.accountDetails,
|
accountDetails: state.accountDetails,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -95,11 +95,74 @@ export default async function ApiProxy(req, res) {
|
|||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
azureHeadersPaged(token.access_token)
|
azureHeadersPaged(token.access_token)
|
||||||
)
|
)
|
||||||
.then(({ data }) => {
|
.then(async ({ data }) => {
|
||||||
var dataStr;
|
var dataStr;
|
||||||
_.has(data, "@odata.nextLink") == true &&
|
_.has(data, "@odata.nextLink") == true &&
|
||||||
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
||||||
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
|
(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);
|
res.status(200).json(data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import CryptoJS from "crypto-js";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import {
|
import {
|
||||||
azureHeadersPagedCustom,
|
azureHeadersPagedCustom,
|
||||||
|
azureHeadersPaged,
|
||||||
consoleLogger,
|
consoleLogger,
|
||||||
getToken,
|
getToken,
|
||||||
} from "../../../actions";
|
} from "../../../actions";
|
||||||
@@ -138,11 +139,72 @@ export default async function ApiProxy(req, res) {
|
|||||||
showNumberOfRecords
|
showNumberOfRecords
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(({ data }) => {
|
.then(async ({ data }) => {
|
||||||
var dataStr;
|
var dataStr;
|
||||||
_.has(data, "@odata.nextLink") == true &&
|
_.has(data, "@odata.nextLink") == true &&
|
||||||
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
||||||
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
|
(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);
|
res.status(200).json(data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ export const appealTypeDataActionTypes = {
|
|||||||
SETFILELIST: "SETFILELIST",
|
SETFILELIST: "SETFILELIST",
|
||||||
SETNEWAPPEALPROGRESS: "SETNEWAPPEALPROGRESS",
|
SETNEWAPPEALPROGRESS: "SETNEWAPPEALPROGRESS",
|
||||||
SETFILECOUNT: "SETFILECOUNT",
|
SETFILECOUNT: "SETFILECOUNT",
|
||||||
|
SETPROJECTTYPEDATA: "SETPROJECTTYPEDATA",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAppealTypeObj = () => (dispatch) => {
|
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) => {
|
export const setAppealTypeTitle = (appealTypeData) => (dispatch) => {
|
||||||
return dispatch({
|
return dispatch({
|
||||||
type: appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA,
|
type: appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { appealTypeDataActionTypes } from "./action";
|
|||||||
|
|
||||||
const appealTypeDataInitialState = {
|
const appealTypeDataInitialState = {
|
||||||
appealTypeOptions: {},
|
appealTypeOptions: {},
|
||||||
|
projectTypeOptions: {},
|
||||||
appealTypeTitle: {},
|
appealTypeTitle: {},
|
||||||
appealTypeID: {},
|
appealTypeID: {},
|
||||||
currentSection: 1,
|
currentSection: 1,
|
||||||
@@ -21,6 +22,11 @@ export default function reducer(state = appealTypeDataInitialState, action) {
|
|||||||
...state,
|
...state,
|
||||||
appealTypeOptions: action.appealTypeOptions,
|
appealTypeOptions: action.appealTypeOptions,
|
||||||
};
|
};
|
||||||
|
case appealTypeDataActionTypes.SETPROJECTTYPEDATA:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
projectTypeOptions: action.projectTypeOptions,
|
||||||
|
};
|
||||||
case appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA:
|
case appealTypeDataActionTypes.SETAPPEALTYPETITLEDATA:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
Reference in New Issue
Block a user