Merged PR 886: search by case status

search by case status

Related work items: #7867
This commit is contained in:
Robert Bond
2022-08-03 12:37:27 +00:00
3 changed files with 170 additions and 34 deletions
+141 -11
View File
@@ -68,6 +68,91 @@ const RenderTextfield = ({
);
};
const RenderCaseStatusList = ({
name,
id,
input,
optionsObj,
meta: { touched, error },
label,
errormsg,
}) => {
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
return (
<>
<div
className={
touched && error
? "govuk-form-group govuk-form-group--error"
: "govuk-form-group "
}
>
<label className="govuk-label" htmlFor={id}>
{label}
{name}
</label>
{touched && error && (
<span
id="passport-issued-error"
className="govuk-error-message"
>
<span className="govuk-visually-hidden">Error:</span>{" "}
{errormsg}
</span>
)}
<div>
<select
{...input}
className="govuk-select"
id={id}
name={name}
//onChange={(e) => props.onChangeSelectAppealType(e)}
>
<option value="" disabled defaultValue>
{t("common:drop-down-select")}
</option>
{_.isEmpty(optionsObj)
? ""
: Object.keys(optionsObj).map((key, index) => {
return (
<option
key={key}
value={
_.isEmpty(optionsObj[key])
? ""
: optionsObj[key].statuscode
}
>
{_.isEmpty(optionsObj[key])
? ""
: _.isEmpty(optionsObj[key])
? ""
: _.isEmpty(optionsObj[key].value)
? ""
: router.locale == "cy"
? jsonpath.query(
optionsObj,
'$..[?(@.statuscode=="' +
optionsObj[key]
.statuscode +
'")].value_cy'
)
: optionsObj[key].value ||
t(
"case:summary-no-date-entered-label"
)}
</option>
);
})}
</select>
</div>
</div>
</>
);
};
let AdvancedSearch = (props) => {
let { t } = useTranslation();
@@ -299,23 +384,25 @@ let AdvancedSearch = (props) => {
var searchString = "";
searchString +=
values.caseRef != null ? "?q=" + values.caseRef.trim() : "";
values.caseRef != null ? "q=" + values.caseRef.trim() + "&" : "";
searchString +=
values.lpaTypes != null
? (typeof values.caseRef == "undefined" ? "?" : "&") +
"lpa=" +
values.lpaTypes
: "";
values.lpaTypes != null ? "lpa=" + values.lpaTypes + "&" : "";
searchString +=
values.appealTypes != null
? (typeof values.caseRef == "undefined" &&
typeof values.lpaTypes == "undefined"
? "?"
: "&") +
("apt=" + values.appealTypes.split(",")[0])
? "apt=" + values.appealTypes.split(",")[0] + "&"
: "";
searchString +=
values.statusCode != null
? "statuscode=" + values.statusCode + "&"
: "";
searchString = "?" + searchString.slice(0, -1);
console.log(searchString);
router.replace(
router.locale == "cy"
? (myportal == true ? "/fymhorth" : "") +
@@ -385,6 +472,49 @@ let AdvancedSearch = (props) => {
label={t("search:lpa-label")}
errormsg="Local authority is required"
/>
<Field
name="statusCode"
id="statusCode"
component={RenderCaseStatusList}
optionsObj={[
{
"value": "In Progress",
"value_cy": "Ar y gweill",
"statuscode": 1,
},
{
"value": "On Hold",
"value_cy": "Ar Dal",
"statuscode": 2,
},
{
"value":
"Waiting for details",
"value_cy":
"Aros am fanylion",
"statuscode": 3,
},
{
"value": "Researching",
"value_cy": "Ymchwilio",
"statuscode": 4,
},
{
"value": "Case Closed",
"value_cy": "Achos ar Gau",
"statuscode": 5,
},
{
"value": "Canceled",
"value_cy": "Wedi'i ganslo",
"statuscode": 6,
},
]}
//validate={[required]}
label={"Case Status"}
errormsg="Local authority is required"
/>
{/* <fieldset className="govuk-fieldset">
<legend className="govuk-fieldset__legend govuk-fieldset__legend--l">
<h3 className="govuk-heading-m">
+14 -11
View File
@@ -37,29 +37,32 @@ export default async function ApiProxy(req, res) {
searchString.q +
"') or contains(ticketnumber,'" +
searchString.q +
"'))"
"')) and"
: "";
queryString +=
_.has(searchString, "lpa") && searchString.lpa != null
? (typeof searchString.q == "undefined" ? "" : " and ") +
"_pinswg_associatedlpa_value eq " +
searchString.lpa
? " _pinswg_associatedlpa_value eq " + searchString.lpa + " and"
: "";
queryString +=
_.has(searchString, "apt") && searchString.apt != null
? (typeof searchString.q == "undefined" &&
typeof searchString.lpa == "undefined"
? ""
: " and ") +
"pinswg_appealcasetype eq " +
searchString.apt
? " pinswg_appealcasetype eq " + searchString.apt + " and"
: "";
queryString +=
_.has(searchString, "statuscode") && searchString.statuscode != null
? " statuscode eq " + searchString.statuscode + " and"
: "";
console.log(queryString);
var queryUrl =
"incidents?$select=description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
" pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
console.log(queryUrl);
var apiResponse = _.isEmpty(searchString)
? res.status(400).json()
@@ -2,7 +2,11 @@ import axios from "axios";
import CryptoJS from "crypto-js";
import { query } from "jsonpath";
import _ from "lodash";
import { getToken, azureHeadersPagedCustom } from "../../../actions";
import {
getToken,
azureHeadersPagedCustom,
consoleLogger,
} from "../../../actions";
const WORDKEY = process.env.HASHKEY;
@@ -43,29 +47,28 @@ export default async function ApiProxy(req, res) {
searchString.q +
"') or contains(ticketnumber,'" +
searchString.q +
"'))"
"')) and"
: "";
queryString +=
_.has(searchString, "lpa") && searchString.lpa != null
? (typeof searchString.q == "undefined" ? "" : " and ") +
"_pinswg_associatedlpa_value eq " +
searchString.lpa
? " _pinswg_associatedlpa_value eq " + searchString.lpa + " and"
: "";
queryString +=
_.has(searchString, "apt") && searchString.apt != null
? (typeof searchString.q == "undefined" &&
typeof searchString.lpa == "undefined"
? ""
: " and ") +
"pinswg_appealcasetype eq " +
searchString.apt
? " pinswg_appealcasetype eq " + searchString.apt + " and"
: "";
queryString +=
_.has(searchString, "statuscode") && searchString.statuscode != null
? " statuscode eq " + searchString.statuscode + " and"
: "";
var queryUrl =
"incidents?$select=description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=" +
" pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=" +
orderby +
" " +
fieldSort +