From 1664c8ce69775a153dc9073405b940c6f8d58320 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 3 Aug 2022 13:36:48 +0100 Subject: [PATCH] search by case status --- components/search/advancedsearch.js | 152 ++++++++++++++++-- pages/api/endpoint/getadvancedsearch_api.js | 25 +-- .../endpoint/getadvancedsearchpaged_api.js | 27 ++-- 3 files changed, 170 insertions(+), 34 deletions(-) diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js index 1aa9292e..286734f3 100644 --- a/components/search/advancedsearch.js +++ b/components/search/advancedsearch.js @@ -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 ( + <> +
+ + {touched && error && ( + + Error:{" "} + {errormsg} + + )} +
+ +
+
+ + ); +}; + 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" /> + + {/*

diff --git a/pages/api/endpoint/getadvancedsearch_api.js b/pages/api/endpoint/getadvancedsearch_api.js index c0067163..9a44a228 100644 --- a/pages/api/endpoint/getadvancedsearch_api.js +++ b/pages/api/endpoint/getadvancedsearch_api.js @@ -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() diff --git a/pages/api/endpoint/getadvancedsearchpaged_api.js b/pages/api/endpoint/getadvancedsearchpaged_api.js index 6ea0c127..46176f74 100644 --- a/pages/api/endpoint/getadvancedsearchpaged_api.js +++ b/pages/api/endpoint/getadvancedsearchpaged_api.js @@ -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 +