advances search on case lpa and appeal

This commit is contained in:
2021-09-22 15:59:34 +01:00
parent 18030111b0
commit 5fa1c4a03f
16 changed files with 824 additions and 988 deletions
View File
+11
View File
@@ -0,0 +1,11 @@
RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/
RELAYURI = "dev-pedw-ns.servicebus.windows.net"
RELAYPATH = "dev-pedw-hc"
SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="
SASKEYNAME = "devpedwnspolicy"
//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/
//RELAYURI = "test-pedw-ns.servicebus.windows.net"
//RELAYPATH = "test-pedw-hc"
//SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4="
//SASKEYNAME = "testpedwhcpolicy"
+46
View File
@@ -143,6 +143,52 @@ export const getBasicDNSSearch = (searchString) => {
});
};
export const getAdvancedSearch = (searchString) => {
console.log(searchString.caseReference);
var queryString = "";
queryString +=
searchString.q != null
? "contains(title, '" + searchString.q + "') "
: "";
queryString +=
searchString.lpa != null
? (typeof searchString.q == "undefined" ? "" : " and ") +
"_customerid_value eq " +
searchString.lpa
: "";
queryString +=
searchString.apt != null
? (typeof searchString.q == "undefined" &&
typeof searchString.lpa == "undefined"
? ""
: " and ") +
"pinswg_appealcasetype eq " +
searchString.apt
: "";
console.log(
"incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" +
queryString +
" &$count=true"
);
return axios
.get(
WEBAPI_URL +
"incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" +
queryString +
" &$count=true",
azureHeaders
)
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
});
};
export const getBasicSearchDetails = (appealType, caseReference) => {
return axios
.get(
+58
View File
@@ -102,6 +102,38 @@ const Breadcrumbs = (props) => {
) : (
""
)}
{router.pathname == "/advancedsearch" ? (
<>
<li className="govuk-breadcrumbs__list-item">
{t("common:breadcrumb-advanced-search")}
</li>
</>
) : (
""
)}
{router.pathname == "/advancedsearchresults" ? (
<>
{" "}
<li className="govuk-breadcrumbs__list-item">
<Link
href={
router.locale != "en"
? router.locale + "/advancedsearch"
: "/advancedsearch"
}
>
<a className="govuk-breadcrumbs__link">
{t("common:breadcrumb-advanced-search")}
</a>
</Link>
</li>
<li className="govuk-breadcrumbs__list-item">
{t("common:breadcrumb-advanced-search-results")}
</li>
</>
) : (
""
)}
{router.pathname == "/newappeal" ? (
<>
<li className="govuk-breadcrumbs__list-item">
@@ -381,6 +413,32 @@ const Breadcrumbs = (props) => {
) : (
""
)}
{router.pathname == "/dnsdetails" ? (
<>
<li className="govuk-breadcrumbs__list-item">
<Link
href={
router.locale != "en"
? router.locale + "/dnsapplications"
: "/dnsapplications"
}
>
<a className="govuk-breadcrumbs__link">
{t("dnsCommon:service-name")}
</a>
</Link>
</li>
<li className="govuk-breadcrumbs__list-item">
{t("common:breadcrumb-case-reference")}:{" "}
{
props.props.currentView.caseReference
.currentReference
}
</li>
</>
) : (
""
)}
{router.pathname == "/dns/application-process" ? (
<>
<li className="govuk-breadcrumbs__list-item">
+2 -1
View File
@@ -20,7 +20,8 @@ const Header = (props) => {
"/dns/application-view",
"/searchresults",
"/case",
"advancedsearch",
"/advancedsearch",
"/advancedsearchresults",
"/dnsapplications",
"/dnsdetails",
];
+10 -1
View File
@@ -118,7 +118,16 @@ let CaseSearch = (props) => {
const mapStateToProps = (state) => {
return {
...state,
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,
};
};
File diff suppressed because it is too large Load Diff
+42 -19
View File
@@ -19,28 +19,18 @@ const DNSSearchResults = (props) => {
const router = useRouter();
const { locale } = router;
var resultsArr = searchResultsObj.value || [{}];
_.isEmpty(searchResultsObj);
return (
<>
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<h1 className="govuk-heading-l">
{t("dnsCommon:service-name")}{" "}
{t("dnsApplications:page-title")}
</h1>
<p className="govuk-body">
{t("dnsApplications:page-intro-paragraph-1")}
</p>
<ul className="govuk-list govuk-list--bullet">
<li> {t("dnsApplications:page-intro-list-item-1")}</li>
let newSearchResultsObj = _.isEmpty(searchResultsObj)
? [{}]
: _.isEmpty(searchResultsObj.value)
? [{}]
: searchResultsObj.value;
<li> {t("dnsApplications:page-intro-list-item-2")}</li>
var resultsArr = newSearchResultsObj || [];
<li> {t("dnsApplications:page-intro-list-item-3")}</li>
</ul>
</div>
</div>
const ResultsView = (resultsArr) => {
return (
<div className="govuk-grid-row govuk-!-margin-top-9">
<div className="govuk-grid-column-full">
<dl className="govuk-summary-list govuk-!-margin-bottom-9 results">
@@ -62,6 +52,7 @@ const DNSSearchResults = (props) => {
{t("search:searchresults-status-label")}
</dd>
</div>
{console.log(newSearchResultsObj.length > 0)}
{resultsArr.map((item, key) => {
let detailsObj = jsonpath.query(
@@ -207,6 +198,38 @@ const DNSSearchResults = (props) => {
</dl>
</div>
</div>
);
};
return (
<>
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<h1 className="govuk-heading-l">
{t("dnsCommon:service-name")}{" "}
{t("dnsApplications:page-title")}
</h1>
<p className="govuk-body">
{t("dnsApplications:page-intro-paragraph-1")}
</p>
<ul className="govuk-list govuk-list--bullet">
<li> {t("dnsApplications:page-intro-list-item-1")}</li>
<li> {t("dnsApplications:page-intro-list-item-2")}</li>
<li> {t("dnsApplications:page-intro-list-item-3")}</li>
</ul>
</div>
</div>
{resultsArr.length > 0 ? (
ResultsView(resultsArr)
) : (
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<h3>There are no records</h3>
</div>
</div>
)}
</>
);
};
+178 -180
View File
@@ -19,8 +19,163 @@ const SearchResults = (props) => {
const router = useRouter();
const { locale } = router;
var resultsArr = searchResultsObj.value || [{}];
var resultsArr = searchResultsObj.value || [];
const ResultsView = (resultsArr) => {
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-14 results_wider ">
{t("search:searchresults-case-reference-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-site-address-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-applicant-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-authority-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-case-type-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-status-label")}
</dd>
</div>
{resultsArr.map((item, key) => {
let detailsObj = jsonpath.query(
searchDetailsObj,
"$..value[?(@.pinswg_name=='" + item.title + "')]"
);
detailsObj = detailsObj[0];
return (
<div className="govuk-summary-list__row" key={key}>
<dd className="govuk-summary-list__value govuk-!-font-size-14 ">
<Link href="/case">
<a
onClick={() => {
setCurrentReference({
"currentReference": item.title,
"currentType":
"searchResultsObj",
});
}}
>
<span className="results-visually-hidden">
{t(
"search:searchresults-case-reference-label"
)}
:
</span>
{item.title}
</a>
</Link>
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<span className="results-visually-hidden">
{t(
"search:searchresults-site-address-label"
)}
:
</span>
{_.has(detailsObj, "pinswg_siteaddressline1")
? detailsObj.pinswg_siteaddressline1
: ""}
<br />
{_.has(detailsObj, "pinswg_siteaddressline1")
? detailsObj.pinswg_siteaddressline2
: ""}
<br />
{_.has(detailsObj, "pinswg_siteaddressline1")
? detailsObj.pinswg_siteaddresstown
: ""}
<br />
{_.has(detailsObj, "pinswg_siteaddressline1")
? detailsObj.pinswg_siteaddresscounty
: ""}
<br />
{_.has(detailsObj, "pinswg_siteaddressline1")
? detailsObj.pinswg_siteaddresspostcode
: ""}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<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-14">
<span className="results-visually-hidden">
{t("search:searchresults-authority-label")}:
</span>
{_.has(item, [
"_customerid_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
item[
"_customerid_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
)
: item[
"_customerid_value@OData.Community.Display.V1.FormattedValue"
] || "N/A"
: ""}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<span className="results-visually-hidden">
{t("search:searchresults-case-type-label")}:
</span>
{router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
)
: item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
] || "N/A"}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<span className="results-visually-hidden">
{t("search:searchresults-status-label")}:
</span>
{router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
item[
"statuscode@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
)
: item[
"statuscode@OData.Community.Display.V1.FormattedValue"
] || "N/A"}
</dd>
</div>
);
})}
</dl>
);
};
return (
<div className="govuk-grid-row">
<div className="govuk-grid-column-full">
@@ -29,188 +184,31 @@ const SearchResults = (props) => {
</h1>
<p className="govuk-body">
{t("search:searchresults-count-label", {
count: searchResultsObj["@odata.count"].toString(),
count: resultsArr.length,
})}
. {t("search:searchresults-case-count-label")}{" "}
<em>&quot;{searchString}&quot;</em>
.
{typeof searchString != "undefined" ? (
<>
<span>
{t("search:searchresults-case-count-label")}{" "}
{" "}
<em>&quot;{searchString}&quot;</em>
</span>
</>
) : (
""
)}
</p>
<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-14 results_wider ">
{t("search:searchresults-case-reference-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-site-address-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-applicant-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-authority-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-case-type-label")}
</dd>
<dd className="govuk-summary-list__key govuk-!-font-size-14">
{t("search:searchresults-status-label")}
</dd>
{resultsArr.length > 0 ? (
ResultsView(resultsArr)
) : (
<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<h3>There are no records</h3>
</div>
</div>
{resultsArr.map((item, key) => {
let detailsObj = jsonpath.query(
searchDetailsObj,
"$..value[?(@.pinswg_name=='" + item.title + "')]"
);
detailsObj = detailsObj[0];
return (
<div className="govuk-summary-list__row" key={key}>
<dd className="govuk-summary-list__value govuk-!-font-size-14 ">
<Link href="/case">
<a
onClick={() => {
setCurrentReference({
"currentReference":
item.title,
"currentType":
"searchResultsObj",
});
}}
>
<span className="results-visually-hidden">
{t(
"search:searchresults-case-reference-label"
)}
:
</span>
{item.title}
</a>
</Link>
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<span className="results-visually-hidden">
{t(
"search:searchresults-site-address-label"
)}
:
</span>
{_.has(
detailsObj,
"pinswg_siteaddressline1"
)
? detailsObj.pinswg_siteaddressline1
: ""}
<br />
{_.has(
detailsObj,
"pinswg_siteaddressline1"
)
? detailsObj.pinswg_siteaddressline2
: ""}
<br />
{_.has(
detailsObj,
"pinswg_siteaddressline1"
)
? detailsObj.pinswg_siteaddresstown
: ""}
<br />
{_.has(
detailsObj,
"pinswg_siteaddressline1"
)
? detailsObj.pinswg_siteaddresscounty
: ""}
<br />
{_.has(
detailsObj,
"pinswg_siteaddressline1"
)
? detailsObj.pinswg_siteaddresspostcode
: ""}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<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-14">
<span className="results-visually-hidden">
{t(
"search:searchresults-authority-label"
)}
:
</span>
{_.has(detailsObj, [
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
])
? router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
detailsObj[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
)
: detailsObj[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] || "N/A"
: ""}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<span className="results-visually-hidden">
{t(
"search:searchresults-case-type-label"
)}
:
</span>
{router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
)
: item[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
] || "N/A"}
</dd>
<dd className="govuk-summary-list__value govuk-!-font-size-14">
<span className="results-visually-hidden">
{t("search:searchresults-status-label")}
:
</span>
{router.locale == "cy"
? jsonpath.query(
transLookup,
'$..[?(@.value=="' +
item[
"statuscode@OData.Community.Display.V1.FormattedValue"
] +
'")].value_cy'
)
: item[
"statuscode@OData.Community.Display.V1.FormattedValue"
] || "N/A"}
</dd>
</div>
);
})}
</dl>
)}
</div>
</div>
);
+2 -2
View File
@@ -35,12 +35,12 @@ export default function Search(props) {
{t("search:searchresults-search-button-label")}
</a>
</Link>
<a
{/* <a
onClick={() => router.back()}
className="govuk-button govuk-button--secondary"
>
{t("search:searchresults-new-search-button-label")}
</a>
</a> */}
</div>
</div>
</div>
+7 -1
View File
@@ -29,6 +29,9 @@
"/advancedsearch": [
"search"
],
"/advancedsearchresults": [
"search"
],
"/searchresults": [
"search"
],
@@ -71,7 +74,10 @@
"dnsApplications"
],
"/dnsdetails": [
"case"
"case",
"search",
"dnsCommon",
"dnsApplications"
]
}
}
+2
View File
@@ -20,6 +20,8 @@
"social-bar-share-link": "Rhannur dudalen hon",
"social-bar-share-via-link": "Rhannur dudalen hon ar",
"breadcrumb-search-results": "Canlyniadau chwilio",
"breadcrumb-advanced-search": "Advanced search",
"breadcrumb-advanced-search-results": "Advanced search results",
"breadcrumb-my-portal": "Fy mhorth",
"breadcrumb-case-reference": "Cyfeirnod Achos"
}
+2
View File
@@ -20,6 +20,8 @@
"social-bar-share-link": "Share this page",
"social-bar-share-via-link": "Share this page via",
"breadcrumb-search-results": "Search results",
"breadcrumb-advanced-search": "Advanced search",
"breadcrumb-advanced-search-results": "Advanced search results",
"breadcrumb-my-portal": "My portal",
"breadcrumb-case-reference": "Case Reference"
}
+35 -1
View File
@@ -14,12 +14,23 @@ import Cookies from "cookies";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import {
setAppealType,
setAppealTypeTitle,
setAppealTypeID,
setAppealLPA,
getAppealTypeObj,
} from "../store/appealType/action";
import { getAppealsTypes, getLPA, updateCase, createCase } from "../actions";
import { setLPA } from "../store/lpa/action";
const Home = (props) => {
const { footerLinks, pages } = props;
let { t, lang } = useTranslation();
const router = useRouter();
const { locale } = router;
const { appealtypes } = router.query;
return (
<div>
@@ -33,7 +44,11 @@ const Home = (props) => {
<Header courseName={t("common:service-name")} />
<div className="govuk-width-container">
<Banner />
<Search />
<Breadcrumbs slug={appealtypes} />
<Search
lpadata={props.LPAData}
appealType={props.appealType}
/>
</div>
<Footer footerLinks={footerLinks} />
</div>
@@ -41,9 +56,28 @@ const Home = (props) => {
);
};
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
const [appealTypeData, lpaData, caseData] = await Promise.all([
await getAppealsTypes(),
await getLPA(),
]);
store.dispatch(setAppealType(appealTypeData));
store.dispatch(setLPA(lpaData));
}
);
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,
};
};
+131
View File
@@ -0,0 +1,131 @@
import _ from "lodash";
import Head from "next/head";
import Header from "../components/header";
import Banner from "../components/banner";
import CookieBanner from "../components/cookieBanner";
import Breadcrumbs from "../components/breadcrumbs";
import SearchResults from "../components/searchresults";
import Footer from "../components/footer";
import Errorpage from "../components/errorpage";
import styles from "../styles/Home.module.css";
import { useSelector, shallowEqual, connect } from "react-redux";
import { wrapper } from "../store/store";
import Cookies from "cookies";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import data from "../data/collections.json";
import { setSearch, getSearchObj } from "../store/search/action";
import {
setSearchResults,
setSearchDetails,
getSearchResultsObj,
} from "../store/searchOutput/action";
import { getAdvancedSearch, getBasicSearchDetails } from "../actions";
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>
</Head>
<div id="page_wrapper">
<CookieBanner />
<Header courseName={t("common:service-name")} />
<div className="govuk-width-container">
<Banner />
<Breadcrumbs slug={appealtypes} />
<SearchResults
searchString={props.search.searchString}
searchResultsObj={props.searchResultsObj}
advancedSearch={true}
/>
</div>
<Footer footerLinks={footerLinks} />
</div>
</div>
);
};
export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
console.log("query-", query);
//console.log("search array:", Object.entries(query));
let querystring;
const searchResultsObj = await getAdvancedSearch(query);
const searchDetailsObj = await getSearchDetails(searchResultsObj);
// console.log(searchDetailsObj);
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
//store.dispatch(setSearch(query.q));
}
);
const getFormCollection = (formtype) => {
const collectionName = jsonpath.query(
data,
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
);
//console.log(collectionName[0]);
return collectionName[0];
};
const getSearchDetails = (searchResultsObj) => {
//console.log(searchResultsObj);
let detailsArr = [];
//console.log("searcg results", searchResultsObj);
searchResultsObj = searchResultsObj.value;
const detailsObj = searchResultsObj.map((searchDetail, index) => {
if (searchDetail.pinswg_appealcasetype == null) {
console.log(searchDetail.ticketnumber);
} else {
detailsArr.push(
getBasicSearchDetails(
getFormCollection(
"pinswg_" +
searchDetail[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
]
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase()
.slice(0, 39)
),
searchDetail.ticketnumber
)
);
}
});
//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);
+1
View File
@@ -87,6 +87,7 @@ const getSearchDetails = (searchResultsObj) => {
//console.log(searchResultsObj);
let detailsArr = [];
console.log("searcg results", searchResultsObj);
searchResultsObj = searchResultsObj.value;
const detailsObj = searchResultsObj.map((searchDetail, index) => {
if (searchDetail.pinswg_appealcasetype == null) {