Merged PR 1125: Address Search
Related work items: #10914, #10915, #10916, #10917, #10918, #10919
This commit is contained in:
@@ -198,6 +198,36 @@ export const getBasicSearch = (searchString) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getIncidentbyID = (searchString) => {
|
||||
return axios
|
||||
.get(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getincidentbyid_api?searchString=" +
|
||||
searchString
|
||||
)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
//console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
};
|
||||
|
||||
export const getIsPublishedbyID = (searchString) => {
|
||||
return axios
|
||||
.get(
|
||||
"/api/endpoint/getispublishedbyid_api?searchString=" + searchString
|
||||
)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
//console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
};
|
||||
|
||||
export const getPartSavedAppeal = (searchString) => {
|
||||
return axios
|
||||
.get(
|
||||
@@ -230,6 +260,35 @@ export const getBasicDNSURLSearch = (searchString) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getAddressSearchPaged = (
|
||||
searchString,
|
||||
pageNumber,
|
||||
orderBy,
|
||||
fieldSort,
|
||||
showNumberOfRecords
|
||||
) => {
|
||||
//console.log(queryUrl);
|
||||
return axios
|
||||
.get(
|
||||
"/api/endpoint/getbasicsearch_by_address_paged_api?searchString=" +
|
||||
searchString +
|
||||
"&pageNumber=" +
|
||||
pageNumber +
|
||||
"&orderby=" +
|
||||
orderBy +
|
||||
"&fieldSort=" +
|
||||
fieldSort +
|
||||
"&showNumberOfRecords=" +
|
||||
showNumberOfRecords
|
||||
)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
return error.response;
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicSearchPaged = (
|
||||
searchString,
|
||||
pageNumber,
|
||||
@@ -1732,3 +1791,26 @@ export const sendRepCompleteMessage = async (containerID, caseReference) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getAddressSearch = async (searchString) => {
|
||||
const params = new URLSearchParams(searchString);
|
||||
const str = params.toString();
|
||||
|
||||
console.log(
|
||||
"the url",
|
||||
BASE_URL + "/api/endpoint/getbasicsearch_by_address_api?" + str
|
||||
);
|
||||
try {
|
||||
const res = await axios.get(
|
||||
BASE_URL + "/api/endpoint/getbasicsearch_by_address_api?" + str
|
||||
);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
let ErrResponse = {
|
||||
value: [],
|
||||
errorCode: error.response.status,
|
||||
errorMsg: error.response.statusText,
|
||||
};
|
||||
return ErrResponse;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useContext } from "react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import SearchForCase from "./search/searchforcase";
|
||||
import AddressSearch from "./search/addresssearch";
|
||||
|
||||
export default function Search(props) {
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
//console.log("props here:", props.myportal || false);
|
||||
|
||||
return (
|
||||
<main
|
||||
className="govuk-main-wrapper govuk-main-wrapper--auto-spacing"
|
||||
id="main-content"
|
||||
role="main"
|
||||
>
|
||||
<AddressSearch myportal={props.myportal || false} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useContext } from "react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import SearchForCase from "./search/searchforcase";
|
||||
import SearchResults from "./search/addresssearchresults";
|
||||
import CRMError from "./crmError";
|
||||
|
||||
export default function Search(props) {
|
||||
const {
|
||||
searchString,
|
||||
searchResultsObj,
|
||||
advancedSearch,
|
||||
myportal,
|
||||
watchedCases,
|
||||
isLinkedCase,
|
||||
showLoginCheck,
|
||||
} = props;
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
var hasError = _.has(searchResultsObj.searchResultsObj, "errorCode")
|
||||
? true
|
||||
: false;
|
||||
|
||||
//console.log("has an error", hasError);
|
||||
|
||||
return (
|
||||
<main
|
||||
className="govuk-main-wrapper govuk-main-wrapper--auto-spacing"
|
||||
id="main-content"
|
||||
role="main"
|
||||
>
|
||||
{hasError ? (
|
||||
<CRMError props={props} />
|
||||
) : (
|
||||
<>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<SearchResults
|
||||
advancedSearch={advancedSearch}
|
||||
searchString={searchString}
|
||||
searchResultsObj={
|
||||
searchResultsObj.searchResultsObj
|
||||
}
|
||||
searchDetailsObj={
|
||||
searchResultsObj.searchDetailsObj
|
||||
}
|
||||
myportal={myportal}
|
||||
watchedCases={watchedCases}
|
||||
isLinkedCase={isLinkedCase}
|
||||
showLoginCheck={showLoginCheck}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="govuk-button-group">
|
||||
<Link
|
||||
href="/addresssearch"
|
||||
className="govuk-button"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
{/* <a
|
||||
onClick={() => router.back()}
|
||||
className="govuk-button govuk-button--secondary"
|
||||
>
|
||||
{t("search:searchresults-new-search-button-label")}
|
||||
</a> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -123,6 +123,39 @@ const Breadcrumbs = (props) => {
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/addresssearch" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
{router.pathname == "/myportal/addresssearch" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/myportal/advancedsearch" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
@@ -146,6 +179,31 @@ const Breadcrumbs = (props) => {
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/addresssearchresults" ? (
|
||||
<>
|
||||
{" "}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? router.locale +
|
||||
"/chwiliadcyfeiriadau"
|
||||
: "/addresssearch"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t(
|
||||
"common:breadcrumb-address-search-results"
|
||||
)}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/advancedsearchresults" ? (
|
||||
<>
|
||||
{" "}
|
||||
@@ -210,6 +268,45 @@ const Breadcrumbs = (props) => {
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/myportal/addresssearchresults" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth/chwiliadcyfeiriadau"
|
||||
: "/myportal/addresssearch"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t(
|
||||
"common:breadcrumb-address-search-results"
|
||||
)}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/newappeal" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
@@ -433,6 +530,124 @@ const Breadcrumbs = (props) => {
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
|
||||
{router.pathname == "/case/id/[incident]" ? (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/chwiliadcyfeiriadau"
|
||||
: "/addresssearch"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/canlyniadaucyfeiriadau?" +
|
||||
props.props.search
|
||||
.searchString
|
||||
: "/addresssearchresults?" +
|
||||
props.props.search
|
||||
.searchString
|
||||
}
|
||||
onClick={() => {
|
||||
// spinnerState();
|
||||
router.back();
|
||||
}}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t(
|
||||
"common:breadcrumb-address-search-results"
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/myportal/case/id/[incident]" ? (
|
||||
<>
|
||||
{" "}
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth"
|
||||
: "/myportal"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-my-portal")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth/chwiliadcyfeiriadau"
|
||||
: "/myportal/addresssearch"
|
||||
}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link
|
||||
href={
|
||||
router.locale != "en"
|
||||
? "/" +
|
||||
router.locale +
|
||||
"/fymhorth/canlyniadaucyfeiriadau?" +
|
||||
props.props.search
|
||||
.searchString
|
||||
: "/myportal/addresssearchresults?" +
|
||||
props.props.search
|
||||
.searchString
|
||||
}
|
||||
onClick={() => {
|
||||
// spinnerState();
|
||||
router.back();
|
||||
}}
|
||||
className="govuk-breadcrumbs__link"
|
||||
>
|
||||
{t(
|
||||
"common:breadcrumb-address-search-results"
|
||||
)}
|
||||
</Link>
|
||||
</li>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:breadcrumb-case-reference")}:{" "}
|
||||
{
|
||||
props.props.currentView.caseReference
|
||||
.currentReference
|
||||
}
|
||||
</li>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{router.pathname == "/myportal/dnsapplications" ? (
|
||||
<>
|
||||
{" "}
|
||||
|
||||
@@ -1419,7 +1419,6 @@ export const FieldsTranslations = (label) => {
|
||||
? jsonpath('$..[?(@.value=="' + label + '")].value_cy', formObj)
|
||||
: label;
|
||||
|
||||
console.log(label, labelTrans);
|
||||
return labelTrans;
|
||||
};
|
||||
|
||||
|
||||
+10
-1
@@ -40,8 +40,17 @@ export default function Footer(props) {
|
||||
}
|
||||
};
|
||||
|
||||
const origin =
|
||||
typeof window !== "undefined" && window.location.origin
|
||||
? window.location.origin
|
||||
: "";
|
||||
|
||||
const URL = `${origin}`;
|
||||
|
||||
const shareBodyStr =
|
||||
t("common:service-home-url") +
|
||||
// t("common:service-home-url") +
|
||||
URL +
|
||||
(locale == "cy" ? "/cy" : "") +
|
||||
(router.route == "/case" ||
|
||||
router.route == "/dnsdetails" ||
|
||||
router.route == "/myportal/case"
|
||||
|
||||
@@ -105,11 +105,6 @@ let CaseSearch = (props) => {
|
||||
|
||||
<Field
|
||||
validate={[
|
||||
required(
|
||||
t(
|
||||
"home:casesearch-search-validation-required"
|
||||
)
|
||||
),
|
||||
minLength(
|
||||
t(
|
||||
"home:casesearch-search-validation-minlength"
|
||||
@@ -136,6 +131,18 @@ let CaseSearch = (props) => {
|
||||
{t("home:casesearch-card-button")}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/chwiliadcyfeiriadau"
|
||||
: "/addresssearch"
|
||||
}
|
||||
className="govuk-link--no-underline"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
{router.locale == "cy" ? " neu " : " or "}
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { reduxForm, formValueSelector, Field } from "redux-form";
|
||||
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import data from "../../data/collections.json";
|
||||
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
import { values } from "lodash";
|
||||
|
||||
const required = (errorMsg) => (value) =>
|
||||
value || typeof value === "number" ? undefined : errorMsg;
|
||||
|
||||
export const minLength = (errorMsg) => (value) =>
|
||||
value && value.length < 3
|
||||
? errorMsg //`Must be ${min} characters or more`
|
||||
: undefined;
|
||||
|
||||
export const leastOneValue = (values, errorMsg) => (value) =>
|
||||
value ? console.log(values) : errorMsg;
|
||||
|
||||
const validate = (values) => {
|
||||
const errors = {};
|
||||
|
||||
if (values.appellantname) {
|
||||
if (
|
||||
!(
|
||||
values.addressline1 != null ||
|
||||
values.town != null ||
|
||||
values.county != null ||
|
||||
values.postcode != null
|
||||
)
|
||||
) {
|
||||
errors.appellantname =
|
||||
document.documentElement.lang == "cy"
|
||||
? "Angen rhan o'r cyfeiriad i chwilio gydag enw"
|
||||
: "Need part of the address to search with a name";
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
const RenderTextfield = ({
|
||||
id,
|
||||
className,
|
||||
rows,
|
||||
datafieldname,
|
||||
name,
|
||||
label,
|
||||
input,
|
||||
hint1,
|
||||
hint2,
|
||||
hint3,
|
||||
meta: { touched, error },
|
||||
...custom
|
||||
}) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-form-group">
|
||||
<div id="basicSearch-hint" className="govuk-hint ">
|
||||
<label className="govuk-label" htmlFor="caseRef">
|
||||
{label}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input
|
||||
{...input}
|
||||
className={className}
|
||||
name={name}
|
||||
id={id}
|
||||
/>
|
||||
{touched && error && (
|
||||
<span
|
||||
id={id + "-error"}
|
||||
className="govuk-error-message govuk-form-group--error"
|
||||
>
|
||||
<span className="govuk-visually-hidden">
|
||||
Error:
|
||||
</span>{" "}
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
let AddressSearch = (props) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
const {
|
||||
LPAData,
|
||||
onSubmit,
|
||||
handleSubmit,
|
||||
myportal,
|
||||
error,
|
||||
pristine,
|
||||
reset,
|
||||
submitting,
|
||||
} = props;
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
event.preventDefault();
|
||||
//spinnerState();
|
||||
|
||||
var searchString = "";
|
||||
|
||||
searchString +=
|
||||
values.appellantname != null
|
||||
? "appellantname=" + values.appellantname + "&"
|
||||
: "";
|
||||
|
||||
searchString +=
|
||||
values.addressline1 != null
|
||||
? "addressline1=" + values.addressline1.trim() + "&"
|
||||
: "";
|
||||
|
||||
searchString += values.town != null ? "town=" + values.town + "&" : "";
|
||||
|
||||
searchString +=
|
||||
values.county != null ? "county=" + values.county + "&" : "";
|
||||
|
||||
searchString +=
|
||||
values.postcode != null ? "postcode=" + values.postcode + "&" : "";
|
||||
|
||||
searchString = "?" + searchString.slice(0, -1);
|
||||
|
||||
console.log(searchString);
|
||||
|
||||
router.replace(
|
||||
router.locale == "cy"
|
||||
? (myportal == true ? "/fymhorth" : "") +
|
||||
"/canlyniadaucyfeiriadau" +
|
||||
searchString
|
||||
: (myportal == true ? "/myportal" : "") +
|
||||
"/addresssearchresults" +
|
||||
searchString
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="card" id="searchforcase-card">
|
||||
<div className="card-body">
|
||||
<div className="govuk-body-m ">
|
||||
<legend className="govuk-fieldset__legend govuk-fieldset__legend--l">
|
||||
<h1 className="govuk-fieldset__heading govuk-heading-m">
|
||||
{t(
|
||||
"search:address-search-title-label"
|
||||
)}
|
||||
</h1>
|
||||
</legend>
|
||||
|
||||
<fieldset className="govuk-fieldset">
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="appellantname"
|
||||
name="appellantname"
|
||||
type="text"
|
||||
aria-describedby="appellantname-hint"
|
||||
label={t(
|
||||
"search:applicant-label"
|
||||
)}
|
||||
/>
|
||||
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="addressline1"
|
||||
name="addressline1"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t(
|
||||
"search:address-line-one-label"
|
||||
)}
|
||||
/>
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="town"
|
||||
name="town"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t("search:town-label")}
|
||||
/>
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="county"
|
||||
name="county"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t("search:county-label")}
|
||||
/>
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="postcode"
|
||||
name="postcode"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t(
|
||||
"search:postcode-label"
|
||||
)}
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="govuk-form-group">
|
||||
<button
|
||||
type="submit"
|
||||
name="search"
|
||||
className="govuk-button"
|
||||
disabled={pristine}
|
||||
>
|
||||
{t("common:search-button")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
LPAData: state.LPAData,
|
||||
//form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const selector = formValueSelector("addressSearchForm"); // <-- same as form name
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(
|
||||
reduxForm({
|
||||
form: "addressSearchForm",
|
||||
destroyOnUnmount: false,
|
||||
validate,
|
||||
})(AddressSearch)
|
||||
);
|
||||
@@ -95,62 +95,73 @@ let CaseSearch = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
return <>
|
||||
<div className="card" id="casesearch-card">
|
||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||
<div className="card-body">
|
||||
<h3 className="heading-small card-heading">
|
||||
{t("myportal:searchcases-card-title")}
|
||||
</h3>
|
||||
return (
|
||||
<>
|
||||
<div className="card" id="casesearch-card">
|
||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||
<div className="card-body">
|
||||
<h3 className="heading-small card-heading">
|
||||
{t("myportal:searchcases-card-title")}
|
||||
</h3>
|
||||
|
||||
<Field
|
||||
validate={[
|
||||
required(
|
||||
t(
|
||||
"myportal:searchcases-validation-required"
|
||||
)
|
||||
),
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input"
|
||||
component={RenderTextfield}
|
||||
id="basicSearch"
|
||||
name="basicSearch"
|
||||
type="text"
|
||||
aria-describedby="basicSearch-hint"
|
||||
hint1={t("myportal:searchcases-card-search-hint")}
|
||||
hint2={t(
|
||||
"myportal:searchcases-card-search-example-label-1"
|
||||
)}
|
||||
hint3={t(
|
||||
"myportal:searchcases-card-search-example-label-2"
|
||||
)}
|
||||
/>
|
||||
<Field
|
||||
validate={[
|
||||
required(
|
||||
t(
|
||||
"myportal:searchcases-validation-required"
|
||||
)
|
||||
),
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input"
|
||||
component={RenderTextfield}
|
||||
id="basicSearch"
|
||||
name="basicSearch"
|
||||
type="text"
|
||||
aria-describedby="basicSearch-hint"
|
||||
hint1={t("myportal:searchcases-card-search-hint")}
|
||||
hint2={t(
|
||||
"myportal:searchcases-card-search-example-label-1"
|
||||
)}
|
||||
hint3={t(
|
||||
"myportal:searchcases-card-search-example-label-2"
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="govuk-form-group">
|
||||
<button type="submit" className="govuk-button">
|
||||
{t("myportal:searchcases-card-button")}
|
||||
</button>
|
||||
<div className="govuk-form-group">
|
||||
<button type="submit" className="govuk-button">
|
||||
{t("myportal:searchcases-card-button")}
|
||||
</button>
|
||||
</div>
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/myportal/addresssearch"
|
||||
: "/myportal/addresssearch"
|
||||
}
|
||||
className="govuk-link--no-underline"
|
||||
>
|
||||
{t("common:breadcrumb-address-search")}
|
||||
</Link>
|
||||
{router.locale == "cy" ? " neu " : " or "}
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/fymhorth/chwiliouwch"
|
||||
: "/myportal/advancedsearch"
|
||||
}
|
||||
>
|
||||
{t("myportal:searchcases-card-advanced-link")}
|
||||
</Link>
|
||||
</div>
|
||||
<Link
|
||||
href={
|
||||
router.locale == "cy"
|
||||
? "/fymhorth/chwiliouwch"
|
||||
: "/myportal/advancedsearch"
|
||||
}
|
||||
>
|
||||
|
||||
{t("myportal:searchcases-card-advanced-link")}
|
||||
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</>;
|
||||
</form>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { reduxForm, formValueSelector, Field } from "redux-form";
|
||||
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import data from "../../data/collections.json";
|
||||
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
import { values } from "lodash";
|
||||
|
||||
const required = (errorMsg) => (value) =>
|
||||
value || typeof value === "number" ? undefined : errorMsg;
|
||||
|
||||
export const minLength = (errorMsg) => (value) =>
|
||||
value && value.length < 3
|
||||
? errorMsg //`Must be ${min} characters or more`
|
||||
: undefined;
|
||||
|
||||
export const leastOneValue = (values, errorMsg) => (value) =>
|
||||
value ? console.log(values) : errorMsg;
|
||||
|
||||
const validate = (values) => {
|
||||
const errors = {};
|
||||
|
||||
console.log(document.documentElement.lang);
|
||||
|
||||
if (values.appellantname) {
|
||||
if (
|
||||
!(
|
||||
values.addressline1 != null ||
|
||||
values.town != null ||
|
||||
values.county != null ||
|
||||
values.postcode != null
|
||||
)
|
||||
) {
|
||||
errors.appellantname =
|
||||
document.documentElement.lang == "cy"
|
||||
? "Angen rhan o'r cyfeiriad i chwilio gydag enw"
|
||||
: "Need part of the address to search with a name";
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
const RenderTextfield = ({
|
||||
id,
|
||||
className,
|
||||
rows,
|
||||
datafieldname,
|
||||
name,
|
||||
label,
|
||||
input,
|
||||
hint1,
|
||||
hint2,
|
||||
hint3,
|
||||
meta: { touched, error },
|
||||
...custom
|
||||
}) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-form-group">
|
||||
<div id="basicSearch-hint" className="govuk-hint ">
|
||||
<label className="govuk-label" htmlFor="caseRef">
|
||||
{label}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input
|
||||
{...input}
|
||||
className={className}
|
||||
name={name}
|
||||
id={id}
|
||||
/>
|
||||
{touched && error && (
|
||||
<span
|
||||
id={id + "-error"}
|
||||
className="govuk-error-message govuk-form-group--error"
|
||||
>
|
||||
<span className="govuk-visually-hidden">
|
||||
Error:
|
||||
</span>{" "}
|
||||
{error}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
let AddressSearch = (props) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
const {
|
||||
LPAData,
|
||||
onSubmit,
|
||||
handleSubmit,
|
||||
myportal,
|
||||
error,
|
||||
pristine,
|
||||
reset,
|
||||
submitting,
|
||||
} = props;
|
||||
|
||||
const onHandleSubmit = (values) => {
|
||||
event.preventDefault();
|
||||
//spinnerState();
|
||||
|
||||
var searchString = "";
|
||||
|
||||
searchString +=
|
||||
values.appellantname != null
|
||||
? "appellantname=" + values.appellantname + "&"
|
||||
: "";
|
||||
|
||||
searchString +=
|
||||
values.addressline1 != null
|
||||
? "addressline1=" + values.addressline1.trim() + "&"
|
||||
: "";
|
||||
|
||||
searchString += values.town != null ? "town=" + values.town + "&" : "";
|
||||
|
||||
searchString +=
|
||||
values.county != null ? "county=" + values.county + "&" : "";
|
||||
|
||||
searchString +=
|
||||
values.postcode != null ? "postcode=" + values.postcode + "&" : "";
|
||||
|
||||
searchString = "?" + searchString.slice(0, -1);
|
||||
|
||||
console.log(searchString);
|
||||
|
||||
router.replace(
|
||||
router.locale == "cy"
|
||||
? (myportal == true ? "/fymhorth" : "") +
|
||||
"/canlyniadaucyfeiriadau" +
|
||||
searchString
|
||||
: (myportal == true ? "/myportal" : "") +
|
||||
"/addresssearchresults" +
|
||||
searchString
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<form onSubmit={handleSubmit(onHandleSubmit)}>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="card" id="searchforcase-card">
|
||||
<div className="card-body">
|
||||
<div className="govuk-body-m ">
|
||||
<legend className="govuk-fieldset__legend govuk-fieldset__legend--l">
|
||||
<h1 className="govuk-fieldset__heading govuk-heading-m">
|
||||
{t(
|
||||
"search:address-search-title-label"
|
||||
)}
|
||||
</h1>
|
||||
</legend>
|
||||
|
||||
<fieldset className="govuk-fieldset">
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="appellantname"
|
||||
name="appellantname"
|
||||
type="text"
|
||||
aria-describedby="appellantname-hint"
|
||||
label={t(
|
||||
"search:applicant-label"
|
||||
)}
|
||||
/>
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="addressline1"
|
||||
name="addressline1"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t(
|
||||
"search:address-line-one-label"
|
||||
)}
|
||||
/>
|
||||
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="town"
|
||||
name="town"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t("search:town-label")}
|
||||
/>
|
||||
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="county"
|
||||
name="county"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t("search:county-label")}
|
||||
/>
|
||||
|
||||
<Field
|
||||
validate={[
|
||||
minLength(
|
||||
t(
|
||||
"myportal:searchcases-validation-minlength"
|
||||
)
|
||||
),
|
||||
]}
|
||||
className="govuk-input govuk-!-width-two-thirds"
|
||||
component={RenderTextfield}
|
||||
id="postcode"
|
||||
name="postcode"
|
||||
type="text"
|
||||
aria-describedby="addressline1-hint"
|
||||
label={t(
|
||||
"search:postcode-label"
|
||||
)}
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<div className="govuk-form-group">
|
||||
<button
|
||||
type="submit"
|
||||
name="search"
|
||||
className="govuk-button"
|
||||
disabled={pristine}
|
||||
>
|
||||
{t("common:search-button")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
LPAData: state.LPAData,
|
||||
//form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {};
|
||||
};
|
||||
|
||||
const selector = formValueSelector("addressSearchForm"); // <-- same as form name
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(
|
||||
reduxForm({
|
||||
form: "addressSearchForm",
|
||||
destroyOnUnmount: false,
|
||||
validate,
|
||||
})(AddressSearch)
|
||||
);
|
||||
@@ -0,0 +1,900 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import {
|
||||
currentViewActionTypes,
|
||||
setCurrentReference,
|
||||
} from "../../store/currentView/action";
|
||||
import { connect } from "react-redux";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import _, { result } from "lodash";
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
import {
|
||||
getBasicSearchPaged,
|
||||
getSearchDocumentDetails,
|
||||
getBasicSearchDetailsPaged,
|
||||
getAdvancedSearchPaged,
|
||||
} from "../../actions";
|
||||
import data from "../../data/collections.json";
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
} from "../../store/searchOutput/action";
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
import { useEffect } from "react";
|
||||
import { parseCookies, setCookie, destroyCookie } from "nookies";
|
||||
|
||||
import PaginationControl from "./pagination";
|
||||
import {
|
||||
getSearchDetailsPaged,
|
||||
getFormCollection,
|
||||
getFormCollectionByID,
|
||||
} from "../utils";
|
||||
|
||||
import {
|
||||
createWatchedCases,
|
||||
getWatchedCasesProxy,
|
||||
getPortalModuleDetailsProxy,
|
||||
deleteWatchedCases,
|
||||
} from "../../actions";
|
||||
import { useSession, signIn, signOut } from "next-auth/react";
|
||||
|
||||
const SearchResults = (props) => {
|
||||
const {
|
||||
searchString,
|
||||
searchResultsObj,
|
||||
searchDetailsObj,
|
||||
setCurrentReference,
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
advancedSearch,
|
||||
myportal,
|
||||
watchedCases,
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
isLinkedCase,
|
||||
showLoginCheck,
|
||||
} = props;
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { data: session } = useSession();
|
||||
|
||||
let [resultsArr, setResultsArr] = useState(searchResultsObj.value || []);
|
||||
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [searchLoaded, setSearchLoaded] = useState(false);
|
||||
const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
const [selectedOption, setSelectedOption] = useState(10);
|
||||
const [orderByState, setOrderbyState] = useState("createdon");
|
||||
const [fieldSortState, setfieldSortState] = useState("asc");
|
||||
const [loginToWatch, setLoginToWatch] = useState("true");
|
||||
|
||||
let spinnerState = () => {
|
||||
showSpinnerState == true
|
||||
? setShowSpinnerState(false)
|
||||
: setShowSpinnerState(true);
|
||||
};
|
||||
|
||||
const cookies = parseCookies();
|
||||
|
||||
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
||||
let updateBody = {
|
||||
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
||||
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
|
||||
"pinswg_appealcasetype": +appealType,
|
||||
};
|
||||
|
||||
createWatchedCases(updateBody)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
|
||||
(data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const isWatchedCase = (whichIncident) => {
|
||||
let isWatched = jsonpath(
|
||||
"$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]",
|
||||
watchedCases
|
||||
);
|
||||
|
||||
return isWatched;
|
||||
};
|
||||
|
||||
const deleteItem = (caseID, topThreeType) => {
|
||||
let cookies = parseCookies();
|
||||
topThreeType == "watchedCases" &&
|
||||
deleteWatchedCases(caseID)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(
|
||||
props.accountDetails.loggedinUserId
|
||||
).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
// console.log(resultsObj);
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(
|
||||
detailsType != "myWatchedCases"
|
||||
? searchDetail.ticketnumber
|
||||
: searchDetail[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
);
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getPortalModuleDetailsProxy(
|
||||
getFormCollectionByID(
|
||||
searchDetail.pinswg_appealcasetype
|
||||
).LogicalCollectionName,
|
||||
detailsType != "myWatchedCases"
|
||||
? searchDetail.ticketnumber
|
||||
: searchDetail[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
//console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const indexOfLastRecord = currentPage * selectedOption;
|
||||
const indexOfFirstRecord = indexOfLastRecord - selectedOption;
|
||||
|
||||
const ResultsView = (resultsArr) => {
|
||||
var resultsArrPaged = resultsArr.slice(
|
||||
indexOfFirstRecord,
|
||||
indexOfLastRecord
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<dl className="govuk-summary-list govuk-!-margin-bottom-9 results">
|
||||
<div className="govuk-summary-list__row results-headings">
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16 results_wider ">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => sortDataBy("pinswg_name")}
|
||||
className={
|
||||
orderByState == "pinswg_name"
|
||||
? fieldSortState == "asc"
|
||||
? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
|
||||
}
|
||||
>
|
||||
{t("search:searchresults-case-reference-label")}
|
||||
</button>
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
{t("search:searchresults-site-address-label")}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
sortDataBy(
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
||||
)
|
||||
}
|
||||
className={
|
||||
orderByState ==
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
||||
? fieldSortState == "asc"
|
||||
? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
|
||||
}
|
||||
>
|
||||
{t("search:searchresults-applicant-label")}
|
||||
</button>
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
sortDataBy("_pinswg_associatedlpa_value")
|
||||
}
|
||||
className={
|
||||
orderByState ==
|
||||
"_pinswg_associatedlpa_value"
|
||||
? fieldSortState == "asc"
|
||||
? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
|
||||
}
|
||||
>
|
||||
{t("search:searchresults-authority-label")}
|
||||
</button>
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => sortDataBy("pinswg_appealType")}
|
||||
className={
|
||||
orderByState == "pinswg_appealcasetype"
|
||||
? fieldSortState == "asc"
|
||||
? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
|
||||
}
|
||||
>
|
||||
{t("search:searchresults-case-type-label")}
|
||||
</button>
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||
{/* {t("search:searchresults-status-label")} */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => sortDataBy("statuscode")}
|
||||
className={
|
||||
orderByState == "statuscode"
|
||||
? fieldSortState == "asc"
|
||||
? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
|
||||
: `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
|
||||
}
|
||||
>
|
||||
{t("search:searchresults-status-label")}
|
||||
</button>
|
||||
</dd>
|
||||
|
||||
<dd className="govuk-summary-list__key govuk-!-font-size-16 govuk-summary-list__action"></dd>
|
||||
</div>
|
||||
{showSpinnerState == true ? (
|
||||
<div className="govuk-summary-list__row">
|
||||
<div className="govuk-!-margin-top-9 govuk-!-margin-bottom-9 govuk-!-font-weight-bold govuk-!-font-size-20 ">
|
||||
{t("common:spinner-fetching-data")}
|
||||
<img
|
||||
className="data-loading-icon"
|
||||
src="/assets/images/loading.gif"
|
||||
alt={
|
||||
router.locale == "cy"
|
||||
? "Nôl data"
|
||||
: "Fetching data"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
resultsArrPaged.map((item, key) => {
|
||||
let detailsObj = jsonpath(
|
||||
'$..value[?(@.pinswg_name=="' +
|
||||
item.pinswg_name +
|
||||
'")]',
|
||||
searchDetailsObj
|
||||
);
|
||||
detailsObj = detailsObj[0];
|
||||
return (
|
||||
<div
|
||||
className="govuk-summary-list__row"
|
||||
key={key}
|
||||
>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
|
||||
<Link
|
||||
href={
|
||||
(router.locale == "cy"
|
||||
? myportal == true
|
||||
? "/fymhorth/achos/id"
|
||||
: "/achos/id"
|
||||
: myportal == true
|
||||
? "/myportal/case/id"
|
||||
: "/case/id") +
|
||||
"/" +
|
||||
item.incidentid
|
||||
}
|
||||
className="govuk-link--no-underline"
|
||||
// onClick={() => {
|
||||
// setCurrentReference({
|
||||
// "ticketnumber":
|
||||
// item.ticketnumber,
|
||||
// "currentReference":
|
||||
// item.title,
|
||||
// "currentType":
|
||||
// "searchResultsObj",
|
||||
// "incidentid":
|
||||
// item.incidentid,
|
||||
// "appealType":
|
||||
// item.pinswg_appealcasetype,
|
||||
// "showLoginCheck":
|
||||
// props.showLoginCheck,
|
||||
// });
|
||||
// }}
|
||||
>
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"search:searchresults-case-reference-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
{item.pinswg_name}
|
||||
</Link>
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"search:searchresults-site-address-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_projectlocation"
|
||||
)
|
||||
? detailsObj.pinswg_projectlocation !=
|
||||
null
|
||||
? detailsObj.pinswg_projectlocation.indexOf(
|
||||
";"
|
||||
) < 0
|
||||
? detailsObj.pinswg_projectlocation
|
||||
: router.locale == "cy"
|
||||
? detailsObj.pinswg_projectlocation.split(
|
||||
";"
|
||||
)[1]
|
||||
: detailsObj.pinswg_projectlocation.split(
|
||||
";"
|
||||
)[0]
|
||||
: ""
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddressline1
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addressline1"
|
||||
)
|
||||
? detailsObj.pinswg_addressline1
|
||||
: ""}
|
||||
{/* {detailsObj.pinswg_siteaddressline1 !=
|
||||
null && <br />} */}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddressline1 !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addressline1"
|
||||
) &&
|
||||
detailsObj.pinswg_addressline1 !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddressline2
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addressline1"
|
||||
)
|
||||
? detailsObj.pinswg_addressline2
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline2"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddressline2 !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addressline2"
|
||||
) &&
|
||||
detailsObj.pinswg_addressline2 !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresstown"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddresstown
|
||||
: ""}
|
||||
{_.has(detailsObj, "pinswg_addresstown")
|
||||
? detailsObj.pinswg_addresstown
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresstown"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddresstown !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addresstown"
|
||||
) &&
|
||||
detailsObj.pinswg_addresstown !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresscounty"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddresscounty
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addresscounty"
|
||||
)
|
||||
? detailsObj.pinswg_addresscounty
|
||||
: ""}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresscounty"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddresscounty !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_addresscounty"
|
||||
) &&
|
||||
detailsObj.pinswg_addresscounty !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresspostcode"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddresspostcode
|
||||
: ""}
|
||||
{_.has(detailsObj, "pinswg_postcode")
|
||||
? detailsObj.pinswg_postcode
|
||||
: ""}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"search:searchresults-applicant-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
{_.has(detailsObj, [
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue",
|
||||
])
|
||||
? detailsObj[
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
: ""}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"search:searchresults-authority-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
{_.has(item, [
|
||||
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
|
||||
])
|
||||
? router.locale == "cy"
|
||||
? jsonpath(
|
||||
'$..[?(@.value=="' +
|
||||
item[
|
||||
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
] +
|
||||
'")].value_cy',
|
||||
transLookup
|
||||
)
|
||||
: item[
|
||||
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
|
||||
] || "N/A"
|
||||
: ""}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"search:searchresults-case-type-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
{router.locale == "cy"
|
||||
? jsonpath(
|
||||
'$..[?(@.value=="' +
|
||||
item[
|
||||
"pinswg_appealType"
|
||||
] +
|
||||
'")].value_cy',
|
||||
transLookup
|
||||
)
|
||||
: item["pinswg_appealType"] ||
|
||||
"N/A"}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"search:searchresults-status-label"
|
||||
)}
|
||||
:
|
||||
</span>
|
||||
|
||||
{router.locale == "cy"
|
||||
? jsonpath(
|
||||
'$..[?(@.value=="' +
|
||||
item[
|
||||
"statuscode@OData.Community.Display.V1.FormattedValue"
|
||||
] +
|
||||
'")].value_cy',
|
||||
transLookup
|
||||
)
|
||||
: item[
|
||||
"statuscode@OData.Community.Display.V1.FormattedValue"
|
||||
] || "N/A"}
|
||||
</dd>
|
||||
{myportal == true && (
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-summary-list__action">
|
||||
{isWatchedCase(item.incidentid)
|
||||
.length >
|
||||
0 ==
|
||||
true ? (
|
||||
<button
|
||||
className="govuk-summary-list__actionLink watched_link"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-have-stopped-watching-label"
|
||||
) +
|
||||
item.pinswg_name +
|
||||
"?"
|
||||
) &&
|
||||
deleteItem(
|
||||
isWatchedCase(
|
||||
item.incidentid
|
||||
)[0]
|
||||
.pinswg_watchlistid,
|
||||
|
||||
"watchedCases"
|
||||
);
|
||||
}}
|
||||
title={t(
|
||||
"case:stop-watching-case-link"
|
||||
)}
|
||||
>
|
||||
<span className="eye"></span>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="govuk-summary-list__actionLink watchLink"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-are-watching-label"
|
||||
) +
|
||||
item.pinswg_name +
|
||||
"?"
|
||||
) &&
|
||||
selectWatchedCase(
|
||||
props
|
||||
.accountDetails
|
||||
.loggedinUserId,
|
||||
item.incidentid,
|
||||
item.pinswg_appealcasetype
|
||||
);
|
||||
}}
|
||||
title={t(
|
||||
"case:watch-this-case-link"
|
||||
)}
|
||||
>
|
||||
<span className="eye"></span>
|
||||
</button>
|
||||
)}
|
||||
</dd>
|
||||
)}
|
||||
|
||||
{(showLoginCheck == "true" ||
|
||||
showLoginCheck == true) &&
|
||||
!session && (
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-summary-list__action">
|
||||
<span className="results-visually-hidden">
|
||||
{t(
|
||||
"case:watch-this-case-link"
|
||||
)}
|
||||
</span>
|
||||
|
||||
<button
|
||||
className="govuk-summary-list__actionLink watchLink"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:trying-to-watch-case-label"
|
||||
) +
|
||||
item.pinswg_name +
|
||||
"\n\n" +
|
||||
t(
|
||||
"case:trying-to-watch-case-redirect-label"
|
||||
)
|
||||
) &&
|
||||
// signIn("email");
|
||||
signIn(undefined, {
|
||||
callbackUrl:
|
||||
"/myportal/addresssearchresults?" +
|
||||
new URLSearchParams(
|
||||
searchString
|
||||
) +
|
||||
"&toWatch=" +
|
||||
item.incidentid +
|
||||
"_" +
|
||||
item.pinswg_appealcasetype,
|
||||
});
|
||||
}}
|
||||
title={t(
|
||||
"case:watch-this-case-link"
|
||||
)}
|
||||
>
|
||||
<span className="eye"></span>
|
||||
</button>
|
||||
</dd>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</dl>
|
||||
|
||||
<PaginationControl
|
||||
showNoOfRecords={selectedOption}
|
||||
currentPage={currentPage}
|
||||
searchResultsObj={searchResultsObj}
|
||||
orderBy={orderByState}
|
||||
fieldSort={fieldSortState}
|
||||
spinnerState={spinnerState}
|
||||
getSearchPageResults={getSearchPageResults}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
|
||||
|
||||
const getSearchPageResults = useCallback(
|
||||
(pageNumber, orderBy, fieldSort) => {
|
||||
// setSearchDetails(data);
|
||||
|
||||
setCurrentPage(pageNumber);
|
||||
|
||||
resultsArr = _.sortBy(resultsArr, [
|
||||
function (o) {
|
||||
return o[orderBy];
|
||||
},
|
||||
]);
|
||||
|
||||
fieldSort == "desc" && resultsArr.reverse();
|
||||
|
||||
setShowSpinnerState(false);
|
||||
setResultsArr(resultsArr);
|
||||
|
||||
console.log(
|
||||
"================================\n",
|
||||
resultsArr,
|
||||
"sort done",
|
||||
"\n=================================\n"
|
||||
);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const sortDataBy = (whichField) => {
|
||||
setOrderbyState(whichField);
|
||||
setfieldSortState("asc");
|
||||
|
||||
setShowSpinnerState(true);
|
||||
console.log(
|
||||
"================================\n",
|
||||
"sort start",
|
||||
"\n=================================\n"
|
||||
);
|
||||
getSearchPageResults(1, whichField, fieldSortState);
|
||||
whichField == orderByState
|
||||
? fieldSortState == "desc"
|
||||
? setfieldSortState("asc")
|
||||
: setfieldSortState("desc")
|
||||
: setfieldSortState("asc");
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
||||
let updateBody = {
|
||||
"pinswg_WatchedCase@odata.bind":
|
||||
"/incidents(" + incidentID + ")",
|
||||
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
|
||||
"pinswg_appealcasetype": +appealType,
|
||||
};
|
||||
|
||||
createWatchedCases(updateBody)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getWatchedCasesProxy(
|
||||
props.accountDetails.loggedinUserId
|
||||
).then((data) => {
|
||||
setWatchedCases(data),
|
||||
getDetails(data, "myWatchedCases").then((data) => {
|
||||
setWatchedCasesDetails(data);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// if (searchLoaded) {
|
||||
// if (selectedOption) {
|
||||
// setShowSpinnerState(true);
|
||||
// getSearchPageResults(1, orderByState, fieldSortState);
|
||||
// }
|
||||
// } else {
|
||||
// setSearchLoaded(true);
|
||||
// }
|
||||
if (loginToWatch && router.query.hasOwnProperty("toWatch")) {
|
||||
console.log("am in here");
|
||||
let now = new Date();
|
||||
let expDate = new Date(now);
|
||||
|
||||
expDate.setDate(now.getDate() + 1);
|
||||
|
||||
setLoggedInUserId(props.accountDetails.loggedinUserId);
|
||||
setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
|
||||
path: "/",
|
||||
expires: expDate,
|
||||
});
|
||||
selectWatchedCase(
|
||||
props.accountDetails.loggedinUserId,
|
||||
router.query.toWatch.split("_")[0],
|
||||
router.query.toWatch.split("_")[1]
|
||||
);
|
||||
getSearchPageResults(1, orderByState, fieldSortState);
|
||||
setLoginToWatch(false);
|
||||
} else {
|
||||
//console.log("or am in here");
|
||||
setLoginToWatch(false);
|
||||
}
|
||||
}, [
|
||||
selectedOption,
|
||||
fieldSortState,
|
||||
orderByState,
|
||||
searchLoaded,
|
||||
loginToWatch,
|
||||
setWatchedCases,
|
||||
getSearchPageResults,
|
||||
setWatchedCasesDetails,
|
||||
props.accountDetails.loggedinUserId,
|
||||
router.query,
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-grid-row">
|
||||
<div className="govuk-grid-column-full">
|
||||
<h1 className="govuk-heading-xl govuk-!-margin-bottom-7">
|
||||
{isLinkedCase
|
||||
? t("search:searchresults-title-label-linked-case")
|
||||
: t("search:searchresults-title-label")}
|
||||
</h1>
|
||||
|
||||
{!isLinkedCase && (
|
||||
<p className="govuk-body">
|
||||
{resultsArr.length > 200
|
||||
? t("search:searchresults-max-count-label")
|
||||
: t("search:searchresults-count-label", {
|
||||
count: searchResultsObj["@odata.count"],
|
||||
})}
|
||||
.
|
||||
{advancedSearch != true ? (
|
||||
<>
|
||||
<span>
|
||||
{t(
|
||||
"search:searchresults-case-count-label"
|
||||
)}{" "}
|
||||
{" "}
|
||||
<em>"{searchString}"</em>
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
{searchResultsObj["@odata.count"] > 5 && (
|
||||
<div id="recordCountSelect" className="">
|
||||
<div className="govuk-form-group">
|
||||
<label
|
||||
className="govuk-label-s "
|
||||
htmlFor="showNumberOfRecords"
|
||||
>
|
||||
{t(
|
||||
"search:searchresults-show-records-label-a"
|
||||
)}
|
||||
<select
|
||||
onChange={(e) => {
|
||||
setSelectedOption(e.target.value);
|
||||
// setCurrentPage(1);
|
||||
}}
|
||||
value={selectedOption}
|
||||
className="govuk-select"
|
||||
id="showNumberOfRecords"
|
||||
name="showNumberOfRecords"
|
||||
>
|
||||
<option value="5">5</option>
|
||||
<option value="10">10</option>
|
||||
<option value="20">20</option>
|
||||
<option value="30">30</option>
|
||||
<option value="50">50</option>
|
||||
</select>{" "}
|
||||
{t(
|
||||
"search:searchresults-show-records-label-b"
|
||||
)}
|
||||
</label>
|
||||
</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>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(currentReference));
|
||||
},
|
||||
setSearchResults: (searchResultsObj) => {
|
||||
dispatch(setSearchResults(searchResultsObj));
|
||||
},
|
||||
setSearchDetails: (searchDetailsObj) => {
|
||||
dispatch(setSearchDetails(searchDetailsObj));
|
||||
},
|
||||
setWatchedCases: (watchedCases) => {
|
||||
dispatch(setWatchedCases(watchedCases));
|
||||
},
|
||||
setWatchedCasesDetails: (watchedCasesDetails) => {
|
||||
dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||
},
|
||||
// setCurrentPage: (currentPage) => {
|
||||
// dispatch(setCurrentPage(currentPage));
|
||||
// },
|
||||
};
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
// currentView: state.currentView,
|
||||
accountDetails: state.accountDetails,
|
||||
// search: state.search,
|
||||
// searchResultsObj: state.searchResultsObj,
|
||||
};
|
||||
};
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(SearchResults);
|
||||
@@ -29,6 +29,14 @@ export const getFormCollectionByID = (appealTypeID) => {
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
export const getFormIDByLogicalName = (appealTypeLogicalName) => {
|
||||
const collectionName = jsonpath(
|
||||
"$..[?(@.LogicalName =='" + appealTypeLogicalName + "')]",
|
||||
data
|
||||
);
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
export const getPickListLabel = (data, picklistType, picklistID) => {
|
||||
const pickListData = jsonpath(
|
||||
"$..[?(@.LogicalName=='" + picklistType + "')]",
|
||||
@@ -63,6 +71,7 @@ export const getSearchDetails = (searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenant" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -755,7 +755,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenant" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenant" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
<labels>
|
||||
<label description="Tenants name" />
|
||||
</labels>
|
||||
<control id="pinswg_agriculturaltenantname" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
<control id="pinswg_agriculturaltenant" parentField="pinswg_agriculturalholding" parentFieldShowOnValue="846040002" classid="{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" datafieldname="pinswg_agriculturaltenantname" disabled="false" />
|
||||
</row>
|
||||
</rows>
|
||||
</section>
|
||||
|
||||
@@ -28,12 +28,18 @@ module.exports = {
|
||||
"/advancedsearch": ["search", "myportal"],
|
||||
"/advancedsearchresults": ["search"],
|
||||
"/searchresults": ["search", "case"],
|
||||
"/addresssearch": ["search", "case", "myportal"],
|
||||
"/addresssearchresults": ["search", "case", "myportal"],
|
||||
"/viewall": ["search"],
|
||||
"/case": ["case"],
|
||||
"/case/*": ["case"],
|
||||
"/case/[ticketnumber]": ["case"],
|
||||
"/case/id/[incident]": ["case"],
|
||||
"/myportal/representation": ["case", "myrepresentations", "common"],
|
||||
"/myportal/error": ["myportal", "common"],
|
||||
"/myportal/case/id/[incident]": ["case"],
|
||||
"/myportal/addresssearch": ["search", "case", "myportal"],
|
||||
"/myportal/addresssearchresults": ["search", "case", "myportal"],
|
||||
"/newappeal": ["newappeal"],
|
||||
"/newappeal/*": ["newappeal"],
|
||||
"/newappeal/selectappeal": ["newappeal"],
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
"breadcrumb-search-results": "Canlyniadau chwilio",
|
||||
"breadcrumb-advanced-search": "Chwilio uwch",
|
||||
"breadcrumb-advanced-search-results": "Canlyniadau chwilio uwch",
|
||||
"breadcrumb-address-search": "Chwiliad cyfeiriad",
|
||||
"breadcrumb-address-search-results": "Cyfeiriad canlyniadau chwilio",
|
||||
"breadcrumb-my-portal": "Fy mhorth",
|
||||
"breadcrumb-new-appeal": "Apêl newydd",
|
||||
"breadcrumb-case-reference": "Cyfeirnod Achos",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"case-type-option-11": "Apeliadau Rhwymedigaethau Cynllunio",
|
||||
"case-type-option-12": "Apeliadau cynllunio adeiladau rhestredig ac ardal gadwraeth",
|
||||
"advanced-search-title-label": "Chwiliad manwl",
|
||||
"address-search-title-label": "Chwilio am achosion yn ôl cyfeiriad",
|
||||
"applicant-label": "Apelydd/Ymgeisydd",
|
||||
"other-party-label": "Parti Arall",
|
||||
"hearing-date-label": "Dyddiad y Gwrandawaid/Ymchwiliad",
|
||||
@@ -64,5 +65,6 @@
|
||||
"searchresults-no-records-label": "Nid oes unrhyw gofnodion",
|
||||
"searchresults-show-records-label-a": "Dangoswch",
|
||||
"searchresults-show-records-label-b": "cofnod",
|
||||
"searchresults-created-on-label": "Creu ymlaen"
|
||||
"searchresults-created-on-label": "Creu ymlaen",
|
||||
"address-search-appellant-validation": "Angen rhan o'r cyfeiriad i chwilio gydag enw"
|
||||
}
|
||||
@@ -47,6 +47,8 @@
|
||||
"breadcrumb-search-results": "Search results",
|
||||
"breadcrumb-advanced-search": "Advanced search",
|
||||
"breadcrumb-advanced-search-results": "Advanced search results",
|
||||
"breadcrumb-address-search": "Address search",
|
||||
"breadcrumb-address-search-results": "Address search results",
|
||||
"breadcrumb-my-portal": "My portal",
|
||||
"breadcrumb-new-appeal": "New appeal",
|
||||
"breadcrumb-case-reference": "Case Reference",
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"case-type-option-11": "Planning Obligation Appeals",
|
||||
"case-type-option-12": "Planning Listed Building and Conservation Area Appeals",
|
||||
"advanced-search-title-label": "Advanced search",
|
||||
"address-search-title-label": "Search for cases by address",
|
||||
"applicant-label": "Appellant/Applicant",
|
||||
"other-party-label": "Other Party",
|
||||
"hearing-date-label": "Hearing/Enquiry date",
|
||||
@@ -64,5 +65,6 @@
|
||||
"searchresults-no-records-label": "There are no records",
|
||||
"searchresults-show-records-label-a": "Show",
|
||||
"searchresults-show-records-label-b": "records",
|
||||
"searchresults-created-on-label": "Created on"
|
||||
"searchresults-created-on-label": "Created on",
|
||||
"address-search-appellant-validation": "Need part of the address to search with a name"
|
||||
}
|
||||
@@ -103,18 +103,34 @@ module.exports = {
|
||||
source: "/chwiliouwch",
|
||||
destination: "/advancedsearch",
|
||||
},
|
||||
{
|
||||
source: "/chwiliadcyfeiriadau",
|
||||
destination: "/addresssearch",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/chwiliouwch",
|
||||
destination: "/myportal/advancedsearch",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/chwiliadcyfeiriadau",
|
||||
destination: "/myportal/addresssearch",
|
||||
},
|
||||
{
|
||||
source: "/canlyniadauchwiliouwch",
|
||||
destination: "/advancedsearchresults",
|
||||
},
|
||||
{
|
||||
source: "/canlyniadaucyfeiriadau",
|
||||
destination: "/addresssearchresults",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/canlyniadauchwiliouwch",
|
||||
destination: "/myportal/advancedsearchresults",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/canlyniadaucyfeiriadau",
|
||||
destination: "/myportal/addresssearchresults",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth",
|
||||
destination: "/myportal",
|
||||
@@ -123,10 +139,18 @@ module.exports = {
|
||||
source: "/achos",
|
||||
destination: "/case",
|
||||
},
|
||||
{
|
||||
source: "/achos/id/:slug",
|
||||
destination: "/case/id/:slug",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/achos",
|
||||
destination: "/myportal/case",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/achos/id/:slug",
|
||||
destination: "/myportal/case/id/:slug",
|
||||
},
|
||||
{
|
||||
source: "/fymhorth/gweldpopeth",
|
||||
destination: "/myportal/viewall",
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
//import fs from "fs";
|
||||
import _ from "lodash";
|
||||
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 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/addresssearch";
|
||||
import { setAppealType } from "../store/appealType/action";
|
||||
import { setLPA } from "../store/lpa/action";
|
||||
import { wrapper } from "../store/store";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
var hasError =
|
||||
_.has(props.LPAData.LPAData, "errorCode") ||
|
||||
_.has(props.appealType.appealType, "errorCode")
|
||||
? true
|
||||
: false;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("search:page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
{/* Language by default is EN, if multilingual site this will need updated */}
|
||||
<>
|
||||
<link
|
||||
rel="canonical"
|
||||
href={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
key="og:locale"
|
||||
property="og:locale"
|
||||
content={router.locale}
|
||||
/>
|
||||
{/* If they have a Twitter Handle, include the meta details below */}
|
||||
<meta
|
||||
key="og:site_name"
|
||||
property="og:site_name"
|
||||
content={t("common:service-name")}
|
||||
/>
|
||||
<meta
|
||||
key="twitter:site"
|
||||
property="twitter:site"
|
||||
content="@UKGovWales"
|
||||
/>
|
||||
|
||||
<meta
|
||||
name="description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta
|
||||
property="og:site_name"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
property="og:title"
|
||||
content={t("search:page-title")}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<meta
|
||||
property="og:url"
|
||||
content={t("common:gov-wales-link")}
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
|
||||
/>
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta
|
||||
name="twitter:title"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:url"
|
||||
content={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
|
||||
/>
|
||||
</>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header courseName={t("common:service-name")} />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={appealtypes} />
|
||||
{hasError ? (
|
||||
<CRMError props={props} whichError="advancedSearch" />
|
||||
) : (
|
||||
<Search />
|
||||
)}
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
search: state.search,
|
||||
searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
LPAData: state.LPAData,
|
||||
//form: state.form,
|
||||
accountDetails: state.accountDetails,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
@@ -0,0 +1,160 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
getAddressSearch,
|
||||
getIncidentbyID,
|
||||
getIsPublishedbyID,
|
||||
} from "../actions";
|
||||
import Breadcrumbs from "../components/breadcrumbs";
|
||||
import CookieBanner from "../components/cookieBanner";
|
||||
import Footer from "../components/footer";
|
||||
import Header from "../components/header";
|
||||
import SearchResults from "../components/addresssearchresults";
|
||||
import { getSearchDetails } from "../components/utils";
|
||||
import { setSearch } from "../store/search/action";
|
||||
import {
|
||||
setSearchDetails,
|
||||
setSearchResults,
|
||||
} from "../store/searchOutput/action";
|
||||
import { setShowReps } from "../store/currentView/action";
|
||||
|
||||
import { wrapper } from "../store/store";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("search:page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
<>
|
||||
<link
|
||||
rel="canonical"
|
||||
href={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
key="og:locale"
|
||||
property="og:locale"
|
||||
content={router.locale}
|
||||
/>
|
||||
{/* If they have a Twitter Handle, include the meta details below */}
|
||||
<meta
|
||||
key="og:site_name"
|
||||
property="og:site_name"
|
||||
content={t("common:service-name")}
|
||||
/>
|
||||
<meta
|
||||
key="twitter:site"
|
||||
property="twitter:site"
|
||||
content="@UKGovWales"
|
||||
/>
|
||||
|
||||
<meta
|
||||
name="description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta
|
||||
property="og:site_name"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
property="og:title"
|
||||
content={t("search:page-title")}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<meta
|
||||
property="og:url"
|
||||
content={t("common:gov-wales-link")}
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
|
||||
/>
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta
|
||||
name="twitter:title"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:url"
|
||||
content={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
|
||||
/>
|
||||
</>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header courseName={t("common:service-name")} />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={appealtypes} />
|
||||
<SearchResults
|
||||
searchString={props.search.searchString}
|
||||
searchResultsObj={props.searchResultsObj}
|
||||
advancedSearch={true}
|
||||
showLoginCheck={props.showLoginCheck}
|
||||
/>
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
const searchResultsObj = await getAddressSearch(query);
|
||||
const searchDetailsObj = searchResultsObj;
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
const showReps = process.env.SHOWREPRESENTATIONS || false;
|
||||
store.dispatch(setShowReps(showReps, showLoginCheck));
|
||||
|
||||
// store.dispatch(setSearchResults(searchResultsObj));
|
||||
// store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
|
||||
return {
|
||||
props: {
|
||||
searchResultsObj: {
|
||||
searchResultsObj: searchResultsObj,
|
||||
searchDetailsObj: searchDetailsObj,
|
||||
},
|
||||
currentType: "directResultsObj",
|
||||
showLoginCheck: showLoginCheck,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
//searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
@@ -103,6 +103,7 @@ const Home = (props) => {
|
||||
searchString={props.search.searchString}
|
||||
searchResultsObj={props.searchResultsObj}
|
||||
advancedSearch={true}
|
||||
showLoginCheck={props.showLoginCheck}
|
||||
/>
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
||||
@@ -126,6 +127,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
return {
|
||||
props: {
|
||||
showLoginCheck: showLoginCheck,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,508 @@
|
||||
/**
|
||||
* @swagger
|
||||
* /api/endpoint/getbasicsearch_api:
|
||||
* get:
|
||||
* tags: [Search]
|
||||
* description: Basic search
|
||||
* parameters:
|
||||
* - name: searchString
|
||||
* in: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Success
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
getIncidentbyID,
|
||||
} from "../../../actions";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import { object } from "prop-types";
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
const getIncident = async (incidentID) => {
|
||||
const queryUrl =
|
||||
process.env.API_ROOT +
|
||||
"/api/endpoint/getincidentbyid_api?searchString=" +
|
||||
incidentID;
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
url: queryUrl,
|
||||
};
|
||||
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var addressline1 = req.query.addressline1 || "";
|
||||
var town = req.query.town || "";
|
||||
var postcode = req.query.postcode || "";
|
||||
var token = await getToken();
|
||||
|
||||
console.log("whats my parmas:", req.query);
|
||||
|
||||
addressline1 = addressline1.replace(/\'/g, "''");
|
||||
typeof town != "undefined" && (town = town.replace(/\'/g, "''"));
|
||||
|
||||
var searchResultsObj = [];
|
||||
|
||||
var appealTypeArray = [
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_advertses",
|
||||
"LogicalName": "pinswg_adverts",
|
||||
"PrimaryIdAttribute": "pinswg_advertsid",
|
||||
"UrlName": "adverts",
|
||||
"MetadataId": "0735866b-5482-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040018",
|
||||
"NavigationProperty": "pinswg_AdvertsIds",
|
||||
"value": "Adverts",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_callinss77s",
|
||||
"LogicalName": "pinswg_callinss77",
|
||||
"PrimaryIdAttribute": "pinswg_callinss77id",
|
||||
"UrlName": "callinss77",
|
||||
"MetadataId": "dd309e51-4982-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040010",
|
||||
"NavigationProperty": "pinswg_CallInsS77Ids",
|
||||
"value": "Called In Applications - S77",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_commonlands",
|
||||
"LogicalName": "pinswg_commonland",
|
||||
"PrimaryIdAttribute": "pinswg_commonlandid",
|
||||
"UrlName": "commonland",
|
||||
"MetadataId": "4161a618-5082-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040016",
|
||||
"NavigationProperty": "pinswg_CommonLandIds",
|
||||
"value": "Common Land",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_communityinfrastructurelevys117118119s",
|
||||
"LogicalName": "pinswg_communityinfrastructurelevys117118119",
|
||||
"PrimaryIdAttribute": "pinswg_communityinfrastructurelevyid",
|
||||
"UrlName": "communityinfrastructurelevys117118119",
|
||||
"MetadataId": "0c309f3c-4882-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040009",
|
||||
"NavigationProperty": "pinswg_CommunityInfrastructureLevyIds",
|
||||
"value": "Community Infrastructure Levy - S117, 118, & 119",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_compulsorypurchaseorderses",
|
||||
"LogicalName": "pinswg_compulsorypurchaseorders",
|
||||
"PrimaryIdAttribute": "pinswg_compulsorypurchaseordersid",
|
||||
"UrlName": "compulsorypurchaseorders",
|
||||
"MetadataId": "054da4c7-5582-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040019",
|
||||
"NavigationProperty": "pinswg_CompulsoryPurchaseOrdersIds",
|
||||
"value": "Compulsory Purchase Orders",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_dnses",
|
||||
"LogicalName": "pinswg_dns",
|
||||
"PrimaryIdAttribute": "pinswg_dnsid",
|
||||
"UrlName": "dns",
|
||||
"MetadataId": "36f07225-4a82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040011",
|
||||
"NavigationProperty": "pinswg_DNSIds",
|
||||
"value": "Developments of National Significance",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_electricityacts",
|
||||
"LogicalName": "pinswg_electricityact",
|
||||
"PrimaryIdAttribute": "pinswg_electricityactid",
|
||||
"UrlName": "electricityact",
|
||||
"MetadataId": "6aedaab1-4a82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040012",
|
||||
"NavigationProperty": "pinswg_ElectricityActIds",
|
||||
"value": "Electricity Act",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_enforcementlistedbuildingconservationaps",
|
||||
"LogicalName":
|
||||
"pinswg_enforcementlistedbuildingandconservationappeals39",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementlistedbuildingconseid",
|
||||
"UrlName": "enforcementlistedbuildingconservationap",
|
||||
"MetadataId": "c697be96-9481-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040006",
|
||||
"NavigationProperty": "pinswg_EnforcementListedBuildingConseIds",
|
||||
"value":
|
||||
"Enforcement Listed Building and Conservation Appeal - S39",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_enforcementnoticeappeals174s",
|
||||
"LogicalName": "pinswg_enforcementnoticeappeals174",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementnoticeappeals174id",
|
||||
"UrlName": "enforcementnoticeappeals174",
|
||||
"MetadataId": "930a3cc4-9181-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040005",
|
||||
"NavigationProperty": "pinswg_EnforcementNoticeAppealS174Ids",
|
||||
"value": "Enforcement Notice Appeal - S174",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_environmentalpermittings",
|
||||
"LogicalName": "pinswg_environmentalpermitting",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementpermittingid",
|
||||
"UrlName": "environmentalpermitting",
|
||||
"MetadataId": "62d4aa9a-5682-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040020",
|
||||
"NavigationProperty": "pinswg_EnforcementPermittingIds",
|
||||
"value": "Environmental Permitting",
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_harbourrevisionorders",
|
||||
// "LogicalName": "pinswg_harbourrevisionorder",
|
||||
// "PrimaryIdAttribute": "pinswg_harbourrevisionorderid",
|
||||
// "UrlName": "harbourrevisionorder",
|
||||
// "MetadataId": "dc8dcd0d-4f82-eb11-aac0-00224800be9c",
|
||||
// "appealTypeID": "846040014",
|
||||
// "NavigationProperty": "pinswg_HarbourRevisionOrderIds",
|
||||
// "value": "Harbour Revision Order",
|
||||
// },
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_hedgeshedgerowstreepreservationreplacems",
|
||||
"LogicalName": "pinswg_hedgeshedgerowstreepreservationreplacem",
|
||||
"PrimaryIdAttribute": "pinswg_hedgeshedgerowstreepreservatioid",
|
||||
"UrlName": "hedgeshedgerowstreepreservationreplacem",
|
||||
"MetadataId": "60f38fed-5382-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040017",
|
||||
"NavigationProperty": "pinswg_HedgesHedgerowsTreePreservatioIds",
|
||||
"value":
|
||||
"High Hedges, Tree Preservation orders, Hedgerows, Tree Replacement Notice.",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_householderappealhases",
|
||||
"LogicalName": "pinswg_householderappealhas",
|
||||
"PrimaryIdAttribute": "pinswg_householderappealhasid",
|
||||
"UrlName": "householderappealhas",
|
||||
"MetadataId": "a6c728b0-9081-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040004",
|
||||
"NavigationProperty": "pinswg_HouseholderAppealHASIds",
|
||||
"value": "Householder and Minor Commercial Appeals - HAS/CAS",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates",
|
||||
"LogicalName": "pinswg_lawfuldevelopmentcertificateappeals194195",
|
||||
"PrimaryIdAttribute": "pinswg_lawfuldevelopmentcertificatappid",
|
||||
"UrlName": "lawfuldevelopmentcertificateappeals1941",
|
||||
"MetadataId": "184e4861-9681-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040008",
|
||||
"NavigationProperty": "pinswg_LawfulDevelopmentCertificatAppIds",
|
||||
"value": "Lawful Development Certificate Appeal - S194 + 195",
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_ldps",
|
||||
// "LogicalName": "pinswg_ldp",
|
||||
// "PrimaryIdAttribute": "pinswg_ldpid",
|
||||
// "UrlName": "ldp",
|
||||
// "MetadataId": "af424d4d-5882-eb11-aac0-00224800be9c",
|
||||
// "appealTypeID": "846040023",
|
||||
// "NavigationProperty": "pinswg_LDPIds",
|
||||
// },
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_enforcementlistedbuildingconservationaps",
|
||||
"LogicalName": "pinswg_enforcementlistedbuildingandconservationap",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementlistedbuildingconseid",
|
||||
"UrlName": "enforcementlistedbuildingconservationap",
|
||||
"MetadataId": "c697be96-9481-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040006",
|
||||
"NavigationProperty": "pinswg_EnforcementListedBuildingConseIds",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_maintenanceoflands217s",
|
||||
"LogicalName": "pinswg_maintenanceoflands217",
|
||||
"PrimaryIdAttribute": "pinswg_maintenanceoflands217id",
|
||||
"UrlName": "maintenanceoflands217",
|
||||
"MetadataId": "bb302784-9581-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040007",
|
||||
"NavigationProperty": "pinswg_MaintenanceofLandS217Ids",
|
||||
"value": "Maintenance of Land - S217",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_miscellaneouscaseworks",
|
||||
"LogicalName": "pinswg_misccasework",
|
||||
"PrimaryIdAttribute": "pinswg_miscellaneouscasewordid",
|
||||
"UrlName": "miscellaneouscasework",
|
||||
"MetadataId": "f519aa8e-5782-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040022",
|
||||
"NavigationProperty": "pinswg_MiscellaneousCasewordIds",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_nonvalidations",
|
||||
"LogicalName": "pinswg_nonvalidation",
|
||||
"PrimaryIdAttribute": "pinswg_nonvalidationid",
|
||||
"UrlName": "nonvalidation",
|
||||
"MetadataId": "37f31a93-5882-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040024",
|
||||
"NavigationProperty": "pinswg_NonValidationIds",
|
||||
"value": "Non-Validation",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningappeals78s",
|
||||
"LogicalName": "pinswg_planningappeals78",
|
||||
"PrimaryIdAttribute": "pinswg_planningappeals78id",
|
||||
"UrlName": "planningappeals78",
|
||||
"MetadataId": "8d7f813a-4183-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040000",
|
||||
"NavigationProperty": "pinswg_PlanningAppealS78Ids",
|
||||
"value": "Planning Appeal - S78",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningconditionss73s79s",
|
||||
"LogicalName": "pinswg_planningconditionss73s79",
|
||||
"PrimaryIdAttribute": "pinswg_planningconditionss73s79id",
|
||||
"UrlName": "planningconditionss73s79",
|
||||
"MetadataId": "093bf9ff-8d81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040001",
|
||||
"NavigationProperty": "pinswg_PlanningConditionsS73S79Ids",
|
||||
"value": "Planning Conditions - S73 + S79",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningobligationappeals106s",
|
||||
"LogicalName": "pinswg_planningobligationappeals106",
|
||||
"PrimaryIdAttribute": "pinswg_planningobligationappeals106id",
|
||||
"UrlName": "planningobligationappeals106",
|
||||
"MetadataId": "cb8beeae-8f81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040003",
|
||||
"NavigationProperty": "pinswg_PlanningObligationAppealS106Ids",
|
||||
"value": "Planning Obligation Appeal - S106",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_rows",
|
||||
"LogicalName": "pinswg_row",
|
||||
"PrimaryIdAttribute": "pinswg_rowid",
|
||||
"UrlName": "row",
|
||||
"MetadataId": "4ccc6e93-4f82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040015",
|
||||
"NavigationProperty": "pinswg_ROWIds",
|
||||
"value": "Rights of Way",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_transportandworkacts",
|
||||
"LogicalName": "pinswg_transportandworksact",
|
||||
"PrimaryIdAttribute": "pinswg_transportandworkactid",
|
||||
"UrlName": "transportandworksact",
|
||||
"MetadataId": "bc3edc4b-7d82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040013",
|
||||
"NavigationProperty": "pinswg_TransportandWorkActIds",
|
||||
"value": "Transport and Works Act",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_wayleaves",
|
||||
"LogicalName": "pinswg_wayleave",
|
||||
"PrimaryIdAttribute": "pinswg_wayleaveid",
|
||||
"UrlName": "wayleave",
|
||||
"MetadataId": "a0652117-5782-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040021",
|
||||
"NavigationProperty": "pinswg_WayleaveIds",
|
||||
"value": "Wayleave",
|
||||
},
|
||||
];
|
||||
|
||||
const getSearchResultsObj = await Promise.all(
|
||||
appealTypeArray.map(async (item) => {
|
||||
let container = {};
|
||||
|
||||
var queryUrl =
|
||||
item.LogicalCollectionName +
|
||||
"?$count=true&$filter=" +
|
||||
(addressline1 != ""
|
||||
? "(contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders" ||
|
||||
item.LogicalCollectionName == "pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_addressline1"
|
||||
: "pinswg_siteaddressline1") +
|
||||
", '" +
|
||||
addressline1 +
|
||||
"')) "
|
||||
: "") +
|
||||
(town != ""
|
||||
? (addressline1 != "" ? " and " : "") +
|
||||
" (contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_town"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_addresstown"
|
||||
: "pinswg_siteaddresstown") +
|
||||
", '" +
|
||||
town +
|
||||
"')) "
|
||||
: "") +
|
||||
(postcode != ""
|
||||
? (addressline1 != "" || town != "" ? " and " : "") +
|
||||
" (contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_postcode"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_postcode"
|
||||
: "pinswg_siteaddresspostcode") +
|
||||
", '" +
|
||||
postcode +
|
||||
"')) "
|
||||
: "") +
|
||||
"&$orderby=createdon desc&$select=modifiedon,_pinswg_appellant_value,pinswg_name," +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName == "pinswg_harbourrevisionorders"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_addresspostcode"
|
||||
: item.LogicalCollectionName == "pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_postcode"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_sitecounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode"
|
||||
: "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_siteaddresscounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName == "pinswg_transportandworkacts"
|
||||
? "pinswg_dateofdecision"
|
||||
: item.LogicalCollectionName == "pinswg_nonvalidations"
|
||||
? "pinswg_decisionissueddate"
|
||||
: item.LogicalCollectionName == "pinswg_electricityacts"
|
||||
? "pinswg_datedecision"
|
||||
: "pinswg_casedecisiondate") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_planningappeals78s"
|
||||
? "pinswg_dicision"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_decsision"
|
||||
: item.LogicalCollectionName == "pinswg_nonvalidations"
|
||||
? "pinswg_decisionissued"
|
||||
: "pinswg_decision") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_nonvalidations"
|
||||
? ""
|
||||
: "pinswg_dateeventrequested,") +
|
||||
"statuscode,_" +
|
||||
item.NavigationProperty.toLowerCase() +
|
||||
"_value";
|
||||
|
||||
// console.log(
|
||||
// "\n==========================================\n",
|
||||
// "basic search: " + queryUrl,
|
||||
// "\n\n",
|
||||
// item.LogicalCollectionName,
|
||||
// "\n\n",
|
||||
// WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
// "\n==========================================\n"
|
||||
// );
|
||||
|
||||
const resultObj = axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
data.value.map(async (key) => {
|
||||
Object.assign(key, {
|
||||
"pinswg_appealType": item.value,
|
||||
"incidentid":
|
||||
key[
|
||||
"_" +
|
||||
item.NavigationProperty.toLowerCase() +
|
||||
"_value"
|
||||
],
|
||||
});
|
||||
});
|
||||
return searchResultsObj.push(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
});
|
||||
|
||||
return resultObj;
|
||||
})
|
||||
);
|
||||
|
||||
searchResultsObj = jsonpath("$..[?(@ && @.pinswg_name)]", searchResultsObj);
|
||||
|
||||
const getIncidentResultsObj = await Promise.all(
|
||||
searchResultsObj.map(async (key) => {
|
||||
var queryUrl =
|
||||
"incidents?$select=pinswg_publishtoweb,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference&$expand=primarycontactid($select=fullname)&$filter=incidentid eq " +
|
||||
key.incidentid +
|
||||
" and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true";
|
||||
|
||||
const incidentObj = await axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
return data.value[0].pinswg_publishtoweb;
|
||||
});
|
||||
Object.assign(key, {
|
||||
"pinswg_publishtoweb": incidentObj,
|
||||
});
|
||||
|
||||
return incidentObj;
|
||||
})
|
||||
);
|
||||
|
||||
searchResultsObj = searchResultsObj.filter(
|
||||
(arr) => arr.pinswg_publishtoweb
|
||||
);
|
||||
|
||||
let searchResultsOutputObj = {};
|
||||
Object.assign(searchResultsOutputObj, {
|
||||
"@odata.count": searchResultsObj.length,
|
||||
"value": searchResultsObj,
|
||||
});
|
||||
|
||||
return res.status(200).json(searchResultsOutputObj);
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
/**
|
||||
* @swagger
|
||||
* /api/endpoint/getbasicsearch_api:
|
||||
* get:
|
||||
* tags: [Search]
|
||||
* description: Basic search
|
||||
* parameters:
|
||||
* - name: searchString
|
||||
* in: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Success
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
getToken,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
getIncidentbyID,
|
||||
} from "../../../actions";
|
||||
import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
import { object } from "prop-types";
|
||||
import { query } from "express";
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
const getIncident = async (incidentID) => {
|
||||
const queryUrl =
|
||||
process.env.API_ROOT +
|
||||
"/api/endpoint/getincidentbyid_api?searchString=" +
|
||||
incidentID;
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
url: queryUrl,
|
||||
};
|
||||
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var appellantname = req.query.appellantname || "";
|
||||
var addressline1 = req.query.addressline1 || "";
|
||||
var town = req.query.town || "";
|
||||
var county = req.query.county || "";
|
||||
var postcode = req.query.postcode || "";
|
||||
var token = await getToken();
|
||||
|
||||
console.log("whats my parmas:", req.query);
|
||||
|
||||
addressline1 = addressline1.replace(/\'/g, "''");
|
||||
typeof town != "undefined" && (town = town.replace(/\'/g, "''"));
|
||||
|
||||
var searchResultsObj = [];
|
||||
|
||||
var appealTypeArray = [
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_advertses",
|
||||
"LogicalName": "pinswg_adverts",
|
||||
"PrimaryIdAttribute": "pinswg_advertsid",
|
||||
"UrlName": "adverts",
|
||||
"MetadataId": "0735866b-5482-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040018",
|
||||
"NavigationProperty": "pinswg_AdvertsIds",
|
||||
"value": "Adverts",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_callinss77s",
|
||||
"LogicalName": "pinswg_callinss77",
|
||||
"PrimaryIdAttribute": "pinswg_callinss77id",
|
||||
"UrlName": "callinss77",
|
||||
"MetadataId": "dd309e51-4982-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040010",
|
||||
"NavigationProperty": "pinswg_CallInsS77Ids",
|
||||
"value": "Called In Applications - S77",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_commonlands",
|
||||
"LogicalName": "pinswg_commonland",
|
||||
"PrimaryIdAttribute": "pinswg_commonlandid",
|
||||
"UrlName": "commonland",
|
||||
"MetadataId": "4161a618-5082-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040016",
|
||||
"NavigationProperty": "pinswg_CommonLandIds",
|
||||
"value": "Common Land",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_communityinfrastructurelevys117118119s",
|
||||
"LogicalName": "pinswg_communityinfrastructurelevys117118119",
|
||||
"PrimaryIdAttribute": "pinswg_communityinfrastructurelevyid",
|
||||
"UrlName": "communityinfrastructurelevys117118119",
|
||||
"MetadataId": "0c309f3c-4882-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040009",
|
||||
"NavigationProperty": "pinswg_CommunityInfrastructureLevyIds",
|
||||
"value": "Community Infrastructure Levy - S117, 118, & 119",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_compulsorypurchaseorderses",
|
||||
"LogicalName": "pinswg_compulsorypurchaseorders",
|
||||
"PrimaryIdAttribute": "pinswg_compulsorypurchaseordersid",
|
||||
"UrlName": "compulsorypurchaseorders",
|
||||
"MetadataId": "054da4c7-5582-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040019",
|
||||
"NavigationProperty": "pinswg_CompulsoryPurchaseOrdersIds",
|
||||
"value": "Compulsory Purchase Orders",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_dnses",
|
||||
"LogicalName": "pinswg_dns",
|
||||
"PrimaryIdAttribute": "pinswg_dnsid",
|
||||
"UrlName": "dns",
|
||||
"MetadataId": "36f07225-4a82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040011",
|
||||
"NavigationProperty": "pinswg_DNSIds",
|
||||
"value": "Developments of National Significance",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_electricityacts",
|
||||
"LogicalName": "pinswg_electricityact",
|
||||
"PrimaryIdAttribute": "pinswg_electricityactid",
|
||||
"UrlName": "electricityact",
|
||||
"MetadataId": "6aedaab1-4a82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040012",
|
||||
"NavigationProperty": "pinswg_ElectricityActIds",
|
||||
"value": "Electricity Act",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_enforcementlistedbuildingconservationaps",
|
||||
"LogicalName":
|
||||
"pinswg_enforcementlistedbuildingandconservationappeals39",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementlistedbuildingconseid",
|
||||
"UrlName": "enforcementlistedbuildingconservationap",
|
||||
"MetadataId": "c697be96-9481-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040006",
|
||||
"NavigationProperty": "pinswg_EnforcementListedBuildingConseIds",
|
||||
"value":
|
||||
"Enforcement Listed Building and Conservation Appeal - S39",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_enforcementnoticeappeals174s",
|
||||
"LogicalName": "pinswg_enforcementnoticeappeals174",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementnoticeappeals174id",
|
||||
"UrlName": "enforcementnoticeappeals174",
|
||||
"MetadataId": "930a3cc4-9181-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040005",
|
||||
"NavigationProperty": "pinswg_EnforcementNoticeAppealS174Ids",
|
||||
"value": "Enforcement Notice Appeal - S174",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_environmentalpermittings",
|
||||
"LogicalName": "pinswg_environmentalpermitting",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementpermittingid",
|
||||
"UrlName": "environmentalpermitting",
|
||||
"MetadataId": "62d4aa9a-5682-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040020",
|
||||
"NavigationProperty": "pinswg_EnforcementPermittingIds",
|
||||
"value": "Environmental Permitting",
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_harbourrevisionorders",
|
||||
// "LogicalName": "pinswg_harbourrevisionorder",
|
||||
// "PrimaryIdAttribute": "pinswg_harbourrevisionorderid",
|
||||
// "UrlName": "harbourrevisionorder",
|
||||
// "MetadataId": "dc8dcd0d-4f82-eb11-aac0-00224800be9c",
|
||||
// "appealTypeID": "846040014",
|
||||
// "NavigationProperty": "pinswg_HarbourRevisionOrderIds",
|
||||
// "value": "Harbour Revision Order",
|
||||
// },
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_hedgeshedgerowstreepreservationreplacems",
|
||||
"LogicalName": "pinswg_hedgeshedgerowstreepreservationreplacem",
|
||||
"PrimaryIdAttribute": "pinswg_hedgeshedgerowstreepreservatioid",
|
||||
"UrlName": "hedgeshedgerowstreepreservationreplacem",
|
||||
"MetadataId": "60f38fed-5382-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040017",
|
||||
"NavigationProperty": "pinswg_HedgesHedgerowsTreePreservatioIds",
|
||||
"value":
|
||||
"High Hedges, Tree Preservation orders, Hedgerows, Tree Replacement Notice.",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_householderappealhases",
|
||||
"LogicalName": "pinswg_householderappealhas",
|
||||
"PrimaryIdAttribute": "pinswg_householderappealhasid",
|
||||
"UrlName": "householderappealhas",
|
||||
"MetadataId": "a6c728b0-9081-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040004",
|
||||
"NavigationProperty": "pinswg_HouseholderAppealHASIds",
|
||||
"value": "Householder and Minor Commercial Appeals - HAS/CAS",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates",
|
||||
"LogicalName": "pinswg_lawfuldevelopmentcertificateappeals194195",
|
||||
"PrimaryIdAttribute": "pinswg_lawfuldevelopmentcertificatappid",
|
||||
"UrlName": "lawfuldevelopmentcertificateappeals1941",
|
||||
"MetadataId": "184e4861-9681-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040008",
|
||||
"NavigationProperty": "pinswg_LawfulDevelopmentCertificatAppIds",
|
||||
"value": "Lawful Development Certificate Appeal - S194 + 195",
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_ldps",
|
||||
// "LogicalName": "pinswg_ldp",
|
||||
// "PrimaryIdAttribute": "pinswg_ldpid",
|
||||
// "UrlName": "ldp",
|
||||
// "MetadataId": "af424d4d-5882-eb11-aac0-00224800be9c",
|
||||
// "appealTypeID": "846040023",
|
||||
// "NavigationProperty": "pinswg_LDPIds",
|
||||
// },
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
"pinswg_enforcementlistedbuildingconservationaps",
|
||||
"LogicalName": "pinswg_enforcementlistedbuildingandconservationap",
|
||||
"PrimaryIdAttribute": "pinswg_enforcementlistedbuildingconseid",
|
||||
"UrlName": "enforcementlistedbuildingconservationap",
|
||||
"MetadataId": "c697be96-9481-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040006",
|
||||
"NavigationProperty": "pinswg_EnforcementListedBuildingConseIds",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_maintenanceoflands217s",
|
||||
"LogicalName": "pinswg_maintenanceoflands217",
|
||||
"PrimaryIdAttribute": "pinswg_maintenanceoflands217id",
|
||||
"UrlName": "maintenanceoflands217",
|
||||
"MetadataId": "bb302784-9581-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040007",
|
||||
"NavigationProperty": "pinswg_MaintenanceofLandS217Ids",
|
||||
"value": "Maintenance of Land - S217",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_miscellaneouscaseworks",
|
||||
"LogicalName": "pinswg_misccasework",
|
||||
"PrimaryIdAttribute": "pinswg_miscellaneouscasewordid",
|
||||
"UrlName": "miscellaneouscasework",
|
||||
"MetadataId": "f519aa8e-5782-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040022",
|
||||
"NavigationProperty": "pinswg_MiscellaneousCasewordIds",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_nonvalidations",
|
||||
"LogicalName": "pinswg_nonvalidation",
|
||||
"PrimaryIdAttribute": "pinswg_nonvalidationid",
|
||||
"UrlName": "nonvalidation",
|
||||
"MetadataId": "37f31a93-5882-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040024",
|
||||
"NavigationProperty": "pinswg_NonValidationIds",
|
||||
"value": "Non-Validation",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningappeals78s",
|
||||
"LogicalName": "pinswg_planningappeals78",
|
||||
"PrimaryIdAttribute": "pinswg_planningappeals78id",
|
||||
"UrlName": "planningappeals78",
|
||||
"MetadataId": "8d7f813a-4183-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040000",
|
||||
"NavigationProperty": "pinswg_PlanningAppealS78Ids",
|
||||
"value": "Planning Appeal - S78",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningconditionss73s79s",
|
||||
"LogicalName": "pinswg_planningconditionss73s79",
|
||||
"PrimaryIdAttribute": "pinswg_planningconditionss73s79id",
|
||||
"UrlName": "planningconditionss73s79",
|
||||
"MetadataId": "093bf9ff-8d81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040001",
|
||||
"NavigationProperty": "pinswg_PlanningConditionsS73S79Ids",
|
||||
"value": "Planning Conditions - S73 + S79",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningobligationappeals106s",
|
||||
"LogicalName": "pinswg_planningobligationappeals106",
|
||||
"PrimaryIdAttribute": "pinswg_planningobligationappeals106id",
|
||||
"UrlName": "planningobligationappeals106",
|
||||
"MetadataId": "cb8beeae-8f81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040003",
|
||||
"NavigationProperty": "pinswg_PlanningObligationAppealS106Ids",
|
||||
"value": "Planning Obligation Appeal - S106",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_rows",
|
||||
"LogicalName": "pinswg_row",
|
||||
"PrimaryIdAttribute": "pinswg_rowid",
|
||||
"UrlName": "row",
|
||||
"MetadataId": "4ccc6e93-4f82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040015",
|
||||
"NavigationProperty": "pinswg_ROWIds",
|
||||
"value": "Rights of Way",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_transportandworkacts",
|
||||
"LogicalName": "pinswg_transportandworksact",
|
||||
"PrimaryIdAttribute": "pinswg_transportandworkactid",
|
||||
"UrlName": "transportandworksact",
|
||||
"MetadataId": "bc3edc4b-7d82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040013",
|
||||
"NavigationProperty": "pinswg_TransportandWorkActIds",
|
||||
"value": "Transport and Works Act",
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_wayleaves",
|
||||
"LogicalName": "pinswg_wayleave",
|
||||
"PrimaryIdAttribute": "pinswg_wayleaveid",
|
||||
"UrlName": "wayleave",
|
||||
"MetadataId": "a0652117-5782-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040021",
|
||||
"NavigationProperty": "pinswg_WayleaveIds",
|
||||
"value": "Wayleave",
|
||||
},
|
||||
];
|
||||
|
||||
const getSearchResultsObj = await Promise.all(
|
||||
appealTypeArray.map(async (item) => {
|
||||
let container = {};
|
||||
|
||||
var queryUrl =
|
||||
item.LogicalCollectionName +
|
||||
"?$count=true&$filter=" +
|
||||
(addressline1 != ""
|
||||
? "(contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders" ||
|
||||
item.LogicalCollectionName == "pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_addressline1"
|
||||
: "pinswg_siteaddressline1") +
|
||||
", '" +
|
||||
addressline1 +
|
||||
"')) "
|
||||
: "") +
|
||||
(town != ""
|
||||
? (addressline1 != "" ? " and " : "") +
|
||||
" (contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_town"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_addresstown"
|
||||
: "pinswg_siteaddresstown") +
|
||||
", '" +
|
||||
town +
|
||||
"')) "
|
||||
: "") +
|
||||
(county != ""
|
||||
? (addressline1 != "" || town != "" || postcode != ""
|
||||
? " and "
|
||||
: "") +
|
||||
" (contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_county"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_addresscounty"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_sitecounty"
|
||||
: "pinswg_siteaddresscounty") +
|
||||
", '" +
|
||||
county +
|
||||
"')) "
|
||||
: "") +
|
||||
(postcode != ""
|
||||
? (addressline1 != "" || town != "" || county != ""
|
||||
? " and "
|
||||
: "") +
|
||||
" (contains(" +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_postcode"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_postcode"
|
||||
: "pinswg_siteaddresspostcode") +
|
||||
", '" +
|
||||
postcode +
|
||||
"')) "
|
||||
: "") +
|
||||
"&$orderby=createdon desc&$select=modifiedon,_pinswg_appellant_value,pinswg_name," +
|
||||
(item.LogicalCollectionName == "pinswg_ldps" ||
|
||||
item.LogicalCollectionName == "pinswg_harbourrevisionorders"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_addresspostcode"
|
||||
: item.LogicalCollectionName == "pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_postcode"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_sitecounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode"
|
||||
: "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_siteaddresscounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName == "pinswg_transportandworkacts"
|
||||
? "pinswg_dateofdecision"
|
||||
: item.LogicalCollectionName == "pinswg_nonvalidations"
|
||||
? "pinswg_decisionissueddate"
|
||||
: item.LogicalCollectionName == "pinswg_electricityacts"
|
||||
? "pinswg_datedecision"
|
||||
: "pinswg_casedecisiondate") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_planningappeals78s"
|
||||
? "pinswg_dicision"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_decsision"
|
||||
: item.LogicalCollectionName == "pinswg_nonvalidations"
|
||||
? "pinswg_decisionissued"
|
||||
: "pinswg_decision") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_nonvalidations"
|
||||
? ""
|
||||
: "pinswg_dateeventrequested,") +
|
||||
"statuscode,_" +
|
||||
item.NavigationProperty.toLowerCase() +
|
||||
"_value";
|
||||
|
||||
// console.log(
|
||||
// "\n==========================================\n",
|
||||
// "basic search: " + queryUrl,
|
||||
// "\n\n",
|
||||
// item.LogicalCollectionName,
|
||||
// "\n\n",
|
||||
// WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
// "\n==========================================\n"
|
||||
// );
|
||||
|
||||
const resultObj = axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
data.value.map(async (key) => {
|
||||
Object.assign(key, {
|
||||
"pinswg_appealType": item.value,
|
||||
"incidentid":
|
||||
key[
|
||||
"_" +
|
||||
item.NavigationProperty.toLowerCase() +
|
||||
"_value"
|
||||
],
|
||||
});
|
||||
});
|
||||
return searchResultsObj.push(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
});
|
||||
|
||||
return resultObj;
|
||||
})
|
||||
);
|
||||
|
||||
searchResultsObj = jsonpath("$..[?(@ && @.pinswg_name)]", searchResultsObj);
|
||||
|
||||
searchResultsObj = searchResultsObj.filter((arr) => arr.incidentid != null);
|
||||
|
||||
const getIncidentResultsObj = await Promise.all(
|
||||
searchResultsObj.map(async (key) => {
|
||||
var queryUrl =
|
||||
"incidents?$select=pinswg_publishtoweb,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference&$expand=primarycontactid($select=fullname)&$filter=incidentid eq " +
|
||||
key.incidentid +
|
||||
" and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true";
|
||||
|
||||
//console.log(key.incidentid == null && key);
|
||||
|
||||
const incidentObj = await axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
return data.value[0].pinswg_publishtoweb;
|
||||
});
|
||||
Object.assign(key, {
|
||||
"pinswg_publishtoweb": incidentObj,
|
||||
});
|
||||
|
||||
return incidentObj;
|
||||
})
|
||||
);
|
||||
|
||||
console.log(
|
||||
"===========n\n appellant name:",
|
||||
appellantname,
|
||||
addressline1,
|
||||
county
|
||||
);
|
||||
|
||||
if (req.query.hasOwnProperty("appellantname")) {
|
||||
searchResultsObj = searchResultsObj.filter(
|
||||
(arr) =>
|
||||
arr[
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
||||
] != undefined
|
||||
);
|
||||
|
||||
searchResultsObj = searchResultsObj.filter(
|
||||
(arr) =>
|
||||
arr[
|
||||
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.toLowerCase()
|
||||
.indexOf(appellantname) > -1
|
||||
);
|
||||
}
|
||||
|
||||
searchResultsObj = searchResultsObj.filter(
|
||||
(arr) => arr.pinswg_publishtoweb
|
||||
);
|
||||
|
||||
let searchResultsOutputObj = {};
|
||||
Object.assign(searchResultsOutputObj, {
|
||||
"@odata.count": searchResultsObj.length,
|
||||
"value": searchResultsObj,
|
||||
});
|
||||
|
||||
return res.status(200).json(searchResultsOutputObj);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @swagger
|
||||
* /api/endpoint/getbasicsearch_api:
|
||||
* get:
|
||||
* tags: [Search]
|
||||
* description: Basic search
|
||||
* parameters:
|
||||
* - name: searchString
|
||||
* in: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Success
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import { getToken, azureHeaders, consoleLogger } 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 searchString = req.query.searchString;
|
||||
var token = await getToken();
|
||||
|
||||
searchString = searchString.replace(/\'/g, "''");
|
||||
|
||||
var queryUrl =
|
||||
"incidents?$select=pinswg_publishtoweb,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference&$expand=primarycontactid($select=fullname)&$filter=incidentid eq " +
|
||||
searchString +
|
||||
" and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true";
|
||||
|
||||
var apiResponse = _.isEmpty(req.query)
|
||||
? res.status(400).json()
|
||||
: searchString.length > 0
|
||||
? axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
//console.log(
|
||||
"\n==========================================\n",
|
||||
// "basic search incident: " + queryUrl,
|
||||
// "\n\n",
|
||||
// "data: " + JSON.stringify(data),
|
||||
// "\n\n",
|
||||
"publihs:" + JSON.stringify(data.value[0]),
|
||||
"\n==========================================\n";
|
||||
//);
|
||||
return res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
})
|
||||
: res.status(400).json();
|
||||
|
||||
return apiResponse;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @swagger
|
||||
* /api/endpoint/getbasicsearch_api:
|
||||
* get:
|
||||
* tags: [Search]
|
||||
* description: Basic search
|
||||
* parameters:
|
||||
* - name: searchString
|
||||
* in: query
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Success
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import {
|
||||
getToken,
|
||||
azureHeadersPaged,
|
||||
azureHeaders,
|
||||
consoleLogger,
|
||||
} 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 searchString = req.query.searchString;
|
||||
var token = await getToken();
|
||||
|
||||
searchString = searchString.replace(/\'/g, "''");
|
||||
|
||||
var queryUrl =
|
||||
"incidents?$select=pinswg_publishtoweb,ticketnumber,title, _primarycontactid_value&$filter=incidentid eq " +
|
||||
searchString +
|
||||
" and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true";
|
||||
|
||||
console.log(
|
||||
"\n==========================================\n",
|
||||
"basic search: " + queryUrl,
|
||||
"\n\n",
|
||||
"basic search relay link: " +
|
||||
WEBAPI_URL +
|
||||
queryUrl +
|
||||
hashAPIPath(queryUrl),
|
||||
"\n==========================================\n"
|
||||
);
|
||||
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
getBasicSearch,
|
||||
getIncidentbyID,
|
||||
getIP,
|
||||
getPortalLogin,
|
||||
getPersonalAccount,
|
||||
} from "../../../actions";
|
||||
import CookieBanner from "../../../components/cookieBanner";
|
||||
import Footer from "../../../components/footer";
|
||||
import Header from "../../../components/header";
|
||||
import { getSearchDetails } from "../../../components/utils";
|
||||
import { setCurrentReference } from "../../../store/currentView/action";
|
||||
import { setSearch } from "../../../store/search/action";
|
||||
import {
|
||||
setSearchDetails,
|
||||
setSearchResults,
|
||||
} from "../../../store/searchOutput/action";
|
||||
import { wrapper } from "../../../store/store";
|
||||
import Case from "../../../components/case";
|
||||
import Breadcrumbs from "../../../components/breadcrumbs";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../../store/accountDetails/action";
|
||||
|
||||
const CaseHome = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { incident } = router.query;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
Reference:{" "}
|
||||
{props.currentView.caseReference.currentReference}{" "}
|
||||
</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header serviceName="Developments of National Significance" />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={props.ticketnumber} props={props} />
|
||||
|
||||
<Case
|
||||
props={props}
|
||||
myCases={props.myCases.myCases}
|
||||
myCasesDetails={props.myCases.myCasesDetails}
|
||||
directSearchResultsObj={
|
||||
props.searchResultsObj.searchResultsObj
|
||||
}
|
||||
searchDetailsObj={
|
||||
props.searchResultsObj.searchDetailsObj
|
||||
}
|
||||
documentDetailsObj={props.documentDetailsObj}
|
||||
myRepresentations={
|
||||
props.myRepresentations.myRepresentations
|
||||
}
|
||||
watchedCases={props.watchedCases.watchedCases}
|
||||
watchedCasesDetails={
|
||||
props.watchedCases.watchedCasesDetails
|
||||
}
|
||||
awaitingSubmission={
|
||||
props.awaitingSubmission.awaitingSubmission
|
||||
}
|
||||
caseReference={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.ticketnumber
|
||||
}
|
||||
currentType={props.currentType}
|
||||
appealTypeID={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.pinswg_appealcasetype
|
||||
}
|
||||
incidentid={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.incidentid
|
||||
}
|
||||
representationsObj={
|
||||
props.searchResultsObj.representationsObj
|
||||
}
|
||||
showLoginCheck={true}
|
||||
/>
|
||||
</div>
|
||||
<Footer
|
||||
footerLinks={footerLinks}
|
||||
props={props}
|
||||
ticketnumber={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.ticketnumber
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
getIP(req);
|
||||
const { cookies } = req;
|
||||
|
||||
console.log(cookies);
|
||||
console.log("the query :", query.incident);
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
let loggedInUser = {};
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
const accountDetails = await getPersonalAccount(loggedInUser);
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
} else {
|
||||
console.log("not has sesssion.......");
|
||||
}
|
||||
|
||||
const searchResultsObj = await getIncidentbyID(query.incident);
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
|
||||
// console.log(
|
||||
// "\n======================================\n",
|
||||
// searchResultsObj,
|
||||
// "\n======================================\n"
|
||||
// );
|
||||
// console.log(
|
||||
// "\n======================================\n",
|
||||
// searchDetailsObj[0],
|
||||
// "\n======================================\n"
|
||||
// );
|
||||
|
||||
store.dispatch(setSearch(req.headers.referer.split("?")[1]));
|
||||
|
||||
console.log(
|
||||
searchResultsObj["@odata.count"] > 1 ||
|
||||
searchResultsObj["@odata.count"] < 1
|
||||
);
|
||||
|
||||
if (searchResultsObj["@odata.count"] < 1) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/404",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
if (searchResultsObj["@odata.count"] > 1) {
|
||||
return {
|
||||
redirect: {
|
||||
//destination: "/dns-not-found",
|
||||
destination: "/404",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
store.dispatch(
|
||||
setCurrentReference({
|
||||
"ticketnumber": searchResultsObj.value[0].ticketnumber,
|
||||
"currentReference": searchResultsObj.value[0].title,
|
||||
"currentType": "searchResultsObj",
|
||||
"incidentid": searchResultsObj.value[0].incidentid,
|
||||
"appealType":
|
||||
searchResultsObj.value[0].pinswg_appealcasetype,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
// console.log(searchResultsObj);
|
||||
return {
|
||||
props: {
|
||||
searchResultsObj: {
|
||||
searchResultsObj: searchResultsObj,
|
||||
searchDetailsObj: searchDetailsObj,
|
||||
},
|
||||
currentType: "directResultsObj",
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
accountDetails: state.accountDetails,
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
//searchResultsObj: state.searchResultsObj,
|
||||
documentDetailsObj: state.searchResultsObj.documentDetailsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(refno));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CaseHome);
|
||||
@@ -0,0 +1,129 @@
|
||||
//import fs from "fs";
|
||||
import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
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/myportal/addresssearch";
|
||||
import { setAppealType } from "../../store/appealType/action";
|
||||
import { setLPA } from "../../store/lpa/action";
|
||||
import { wrapper } from "../../store/store";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
var hasError =
|
||||
_.has(props.LPAData.LPAData, "errorCode") ||
|
||||
_.has(props.appealType.appealType, "errorCode")
|
||||
? true
|
||||
: false;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("search:page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
{/* Language by default is EN, if multilingual site this will need updated */}
|
||||
<>
|
||||
<link
|
||||
rel="canonical"
|
||||
href={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
key="og:locale"
|
||||
property="og:locale"
|
||||
content={router.locale}
|
||||
/>
|
||||
{/* If they have a Twitter Handle, include the meta details below */}
|
||||
<meta
|
||||
key="og:site_name"
|
||||
property="og:site_name"
|
||||
content={t("common:service-name")}
|
||||
/>
|
||||
<meta
|
||||
key="twitter:site"
|
||||
property="twitter:site"
|
||||
content="@UKGovWales"
|
||||
/>
|
||||
|
||||
<meta
|
||||
name="description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta
|
||||
property="og:site_name"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
property="og:title"
|
||||
content={t("search:page-title")}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<meta
|
||||
property="og:url"
|
||||
content={t("common:gov-wales-link")}
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
|
||||
/>
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta
|
||||
name="twitter:title"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:url"
|
||||
content={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
|
||||
/>
|
||||
</>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header courseName={t("common:service-name")} />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={appealtypes} />
|
||||
{hasError ? (
|
||||
<CRMError props={props} whichError="advancedSearch" />
|
||||
) : (
|
||||
<Search myportal={true} />
|
||||
)}
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
search: state.search,
|
||||
searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
LPAData: state.LPAData,
|
||||
//form: state.form,
|
||||
accountDetails: state.accountDetails,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
@@ -0,0 +1,249 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
getAddressSearch,
|
||||
getIncidentbyID,
|
||||
getIsPublishedbyID,
|
||||
getAdvancedSearch,
|
||||
getPortalModuleDetails,
|
||||
getWatchedCases,
|
||||
getPersonalAccount,
|
||||
getIP,
|
||||
} from "../../actions";
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
import Footer from "../../components/footer";
|
||||
import Header from "../../components/header";
|
||||
import SearchResults from "../../components/addresssearchresults";
|
||||
import {
|
||||
getFormCollectionByID,
|
||||
getSearchDetails,
|
||||
} from "../../components/utils";
|
||||
import { setSearch } from "../../store/search/action";
|
||||
import {
|
||||
setSearchDetails,
|
||||
setSearchResults,
|
||||
} from "../../store/searchOutput/action";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../store/accountDetails/action";
|
||||
import { setShowReps } from "../../store/currentView/action";
|
||||
import TimeOut from "../../components/timeout";
|
||||
import {
|
||||
setWatchedCases,
|
||||
setWatchedCasesDetails,
|
||||
} from "../../store/watchedCases/action";
|
||||
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
||||
|
||||
import { wrapper } from "../../store/store";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("search:page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
<>
|
||||
<link
|
||||
rel="canonical"
|
||||
href={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
key="og:locale"
|
||||
property="og:locale"
|
||||
content={router.locale}
|
||||
/>
|
||||
{/* If they have a Twitter Handle, include the meta details below */}
|
||||
<meta
|
||||
key="og:site_name"
|
||||
property="og:site_name"
|
||||
content={t("common:service-name")}
|
||||
/>
|
||||
<meta
|
||||
key="twitter:site"
|
||||
property="twitter:site"
|
||||
content="@UKGovWales"
|
||||
/>
|
||||
|
||||
<meta
|
||||
name="description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta
|
||||
property="og:site_name"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
property="og:title"
|
||||
content={t("search:page-title")}
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content={t("common:service-description")}
|
||||
/>
|
||||
<meta property="og:type" content="website" />
|
||||
<meta
|
||||
property="og:url"
|
||||
content={t("common:gov-wales-link")}
|
||||
/>
|
||||
<meta
|
||||
property="og:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-1200.png"
|
||||
/>
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta
|
||||
name="twitter:title"
|
||||
content={t("common:gov-wales-label")}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:url"
|
||||
content={t("common:gov-wales-link") + router.asPath}
|
||||
/>
|
||||
<meta
|
||||
name="twitter:image"
|
||||
content="https://gov.wales/themes/custom/govwales/images/content/og-global-120.png"
|
||||
/>
|
||||
</>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header courseName={t("common:service-name")} />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={appealtypes} props={props} />
|
||||
<SearchResults
|
||||
searchString={props.search.searchString}
|
||||
searchResultsObj={props.searchResultsObj}
|
||||
advancedSearch={true}
|
||||
watchedCases={props.watchedCases}
|
||||
showLoginCheck={props.showLoginCheck}
|
||||
myportal={true}
|
||||
/>
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} ticketnumber={props} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
getIP(req);
|
||||
const searchResultsObj = await getAddressSearch(query);
|
||||
const searchDetailsObj = searchResultsObj;
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
const showReps = process.env.SHOWREPRESENTATIONS || false;
|
||||
store.dispatch(setShowReps(showReps, showLoginCheck));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
|
||||
const { cookies } = req;
|
||||
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
if (!thisSession) {
|
||||
console.log("not has sesssion.......");
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/auth/signin",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
thisSession != false &&
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
|
||||
const [accountDetails, searchResultsObj, watchedCases] =
|
||||
await Promise.all([
|
||||
await getPersonalAccount(loggedInUser),
|
||||
await getAdvancedSearch(query),
|
||||
await getWatchedCases(loggedInUser),
|
||||
]);
|
||||
|
||||
console.log(accountDetails);
|
||||
|
||||
const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
|
||||
await getSearchDetails(searchResultsObj),
|
||||
await getDetails(watchedCases, "myWatchedCases"),
|
||||
]);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
searchResultsObj: {
|
||||
searchResultsObj: searchResultsObj,
|
||||
searchDetailsObj: searchDetailsObj,
|
||||
},
|
||||
currentType: "directResultsObj",
|
||||
showLoginCheck: showLoginCheck,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const getDetails = (resultsObj, detailsType) => {
|
||||
//console.log(resultsObj);
|
||||
let detailsArr = [];
|
||||
resultsObj = resultsObj.value;
|
||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(
|
||||
detailsType != "myWatchedCases"
|
||||
? searchDetail.ticketnumber
|
||||
: searchDetail[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
);
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getPortalModuleDetails(
|
||||
getFormCollectionByID(searchDetail.pinswg_appealcasetype)
|
||||
.LogicalCollectionName,
|
||||
detailsType != "myWatchedCases"
|
||||
? searchDetail.ticketnumber
|
||||
: searchDetail[
|
||||
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
//console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
//searchResultsObj: state.searchResultsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
@@ -78,6 +78,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const { cookies } = req;
|
||||
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
@@ -109,6 +110,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
thisSession != false &&
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
showLoginCheck: showLoginCheck,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
getBasicSearch,
|
||||
getIncidentbyID,
|
||||
getIP,
|
||||
getPortalLogin,
|
||||
getPersonalAccount,
|
||||
} from "../../../../actions";
|
||||
import CookieBanner from "../../../../components/cookieBanner";
|
||||
import Footer from "../../../../components/footer";
|
||||
import Header from "../../../../components/header";
|
||||
import { getSearchDetails } from "../../../../components/utils";
|
||||
import { setCurrentReference } from "../../../../store/currentView/action";
|
||||
import { setSearch } from "../../../../store/search/action";
|
||||
import {
|
||||
setSearchDetails,
|
||||
setSearchResults,
|
||||
} from "../../../../store/searchOutput/action";
|
||||
import { wrapper } from "../../../../store/store";
|
||||
import Case from "../../../../components/case";
|
||||
import Breadcrumbs from "../../../../components/breadcrumbs";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../../../store/accountDetails/action";
|
||||
|
||||
const CaseHome = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
const { incident } = router.query;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
Reference:{" "}
|
||||
{props.currentView.caseReference.currentReference}{" "}
|
||||
</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
<CookieBanner />
|
||||
<Header serviceName="Developments of National Significance" />
|
||||
<div className="govuk-width-container">
|
||||
<Breadcrumbs slug={props.ticketnumber} props={props} />
|
||||
|
||||
<Case
|
||||
props={props}
|
||||
myCases={props.myCases.myCases}
|
||||
myCasesDetails={props.myCases.myCasesDetails}
|
||||
directSearchResultsObj={
|
||||
props.searchResultsObj.searchResultsObj
|
||||
}
|
||||
searchDetailsObj={
|
||||
props.searchResultsObj.searchDetailsObj
|
||||
}
|
||||
documentDetailsObj={props.documentDetailsObj}
|
||||
myRepresentations={
|
||||
props.myRepresentations.myRepresentations
|
||||
}
|
||||
watchedCases={props.watchedCases.watchedCases}
|
||||
watchedCasesDetails={
|
||||
props.watchedCases.watchedCasesDetails
|
||||
}
|
||||
awaitingSubmission={
|
||||
props.awaitingSubmission.awaitingSubmission
|
||||
}
|
||||
caseReference={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.ticketnumber
|
||||
}
|
||||
currentType={props.currentType}
|
||||
appealTypeID={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.pinswg_appealcasetype
|
||||
}
|
||||
incidentid={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.incidentid
|
||||
}
|
||||
representationsObj={
|
||||
props.searchResultsObj.representationsObj
|
||||
}
|
||||
showLoginCheck={true}
|
||||
/>
|
||||
</div>
|
||||
<Footer
|
||||
footerLinks={footerLinks}
|
||||
props={props}
|
||||
ticketnumber={
|
||||
props.searchResultsObj.searchResultsObj.value[0]
|
||||
.ticketnumber
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
getIP(req);
|
||||
const { cookies } = req;
|
||||
|
||||
console.log(cookies);
|
||||
console.log("the query :", query.incident);
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
let loggedInUser = {};
|
||||
|
||||
if (thisSession) {
|
||||
console.log(" has sesssion.......");
|
||||
[loggedInUser] = await Promise.all([
|
||||
await getPortalLogin(thisSession.user.email),
|
||||
]);
|
||||
|
||||
loggedInUser = loggedInUser.value[0].contactid;
|
||||
|
||||
const accountDetails = await getPersonalAccount(loggedInUser);
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
} else {
|
||||
console.log("not has sesssion.......");
|
||||
}
|
||||
|
||||
const searchResultsObj = await getIncidentbyID(query.incident);
|
||||
const searchDetailsObj = await getSearchDetails(searchResultsObj);
|
||||
|
||||
// console.log(
|
||||
// "\n======================================\n",
|
||||
// searchResultsObj,
|
||||
// "\n======================================\n"
|
||||
// );
|
||||
// console.log(
|
||||
// "\n======================================\n",
|
||||
// searchDetailsObj[0],
|
||||
// "\n======================================\n"
|
||||
// );
|
||||
|
||||
store.dispatch(setSearch(req.headers.referer.split("?")[1]));
|
||||
|
||||
if (searchResultsObj["@odata.count"] < 1) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/404",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
if (searchResultsObj["@odata.count"] > 1) {
|
||||
return {
|
||||
redirect: {
|
||||
//destination: "/dns-not-found",
|
||||
destination: "/404",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
store.dispatch(
|
||||
setCurrentReference({
|
||||
"ticketnumber": searchResultsObj.value[0].ticketnumber,
|
||||
"currentReference": searchResultsObj.value[0].title,
|
||||
"currentType": "searchResultsObj",
|
||||
"incidentid": searchResultsObj.value[0].incidentid,
|
||||
"appealType":
|
||||
searchResultsObj.value[0].pinswg_appealcasetype,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
// console.log(searchResultsObj);
|
||||
return {
|
||||
props: {
|
||||
searchResultsObj: {
|
||||
searchResultsObj: searchResultsObj,
|
||||
searchDetailsObj: searchDetailsObj,
|
||||
},
|
||||
currentType: "directResultsObj",
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
accountDetails: state.accountDetails,
|
||||
currentView: state.currentView,
|
||||
search: state.search,
|
||||
//searchResultsObj: state.searchResultsObj,
|
||||
documentDetailsObj: state.searchResultsObj.documentDetailsObj,
|
||||
formData: state.formData,
|
||||
appealType: state.appealType,
|
||||
form: state.form,
|
||||
myCases: state.myCases,
|
||||
watchedCases: state.watchedCases,
|
||||
myRepresentations: state.myRepresentations,
|
||||
awaitingSubmission: state.awaitingSubmission,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(refno));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CaseHome);
|
||||
Reference in New Issue
Block a user