From fb27d72ed3831ecbb356a69a13517b06db5eeac4 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 23 Sep 2021 15:14:20 +0100 Subject: [PATCH] added spinner to advanced search --- actions/index.js | 114 +++++----- components/homepage/casecomment.js | 35 +-- components/homepage/casesearch.js | 99 +++++---- components/homepage/dns.js | 20 +- components/homepage/login.js | 3 +- components/homepage/loginSoon.js | 12 +- components/search/advancedsearch.js | 287 +++++++++++++------------ components/search/searchresults.js | 8 +- i18n.json | 1 + locales/cy/common.json | 8 +- locales/cy/home.json | 26 +-- locales/cy/search.json | 1 + locales/en/common.json | 4 +- locales/en/home.json | 28 +-- locales/en/search.json | 1 + package.json | 1 + pages/advancedsearch.js | 15 +- pages/advancedsearchresults.js | 18 +- pages/searchresults.js | 6 +- styles/sass/welshgov/_application.scss | 21 +- 20 files changed, 409 insertions(+), 299 deletions(-) diff --git a/actions/index.js b/actions/index.js index 9be1c68f..9d01abf4 100644 --- a/actions/index.js +++ b/actions/index.js @@ -62,17 +62,17 @@ export const getSASToken = () => { "&skn=" + m_SasKeyName; - console.log("///////////////////////"); - console.log( - "encodedURI:" + "https://" + m_ResourceURI + "/" + m_Path + "/" - ); - console.log("WEBAPI_URL: " + WEBAPI_URL); - console.log("m_ResourceURI: " + m_ResourceURI); - console.log("m_Path: " + m_Path); - console.log("m_SasKey: " + m_SasKey); - console.log("m_SasKeyName: " + m_SasKeyName); - console.log("token: " + token); - console.log("///////////////////////"); + // console.log("///////////////////////"); + // console.log( + // "encodedURI:" + "https://" + m_ResourceURI + "/" + m_Path + "/" + // ); + // console.log("WEBAPI_URL: " + WEBAPI_URL); + // console.log("m_ResourceURI: " + m_ResourceURI); + // console.log("m_Path: " + m_Path); + // console.log("m_SasKey: " + m_SasKey); + // console.log("m_SasKeyName: " + m_SasKeyName); + // console.log("token: " + token); + // console.log("///////////////////////"); return token; }; @@ -105,16 +105,16 @@ const crmHeadersReturn = { }; const azureHeaders = (SASToken) => { - console.log({ - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - "ServiceBusAuthorization": SASToken, - }, - }); + // console.log({ + // headers: { + // "OData-MaxVersion": "4.0", + // "OData-Version": "4.0", + // "Accept": "application/json", + // "Prefer": 'odata.include-annotations="*",return=representation', + // "Content-Type": "application/json", + // "ServiceBusAuthorization": SASToken, + // }, + // }); return { headers: { "OData-MaxVersion": "4.0", @@ -139,13 +139,13 @@ const azureHeaders = (SASToken) => { // }; export const getBasicSearch = (token, searchString) => { - console.log("\n\n", token, searchString); + //console.log("\n\n", token, searchString); return axios .get( WEBAPI_URL + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" + searchString + - "') and pinswg_appealcasetype ne null &$count=true", + "') and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true&$top=201", azureHeaders(token) ) .then((res) => { @@ -165,7 +165,7 @@ export const getBasicDNSSearch = (token, searchString) => { return axios .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011&$count=true", + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011&$orderby=createdon desc&$count=true", azureHeaders(token) ) .then((res) => res.data) @@ -174,8 +174,8 @@ export const getBasicDNSSearch = (token, searchString) => { }); }; -export const getAdvancedSearch = (searchString) => { - console.log(searchString.caseReference); +export const getAdvancedSearch = (token, searchString) => { + //console.log(searchString.caseReference); var queryString = ""; @@ -200,19 +200,19 @@ export const getAdvancedSearch = (searchString) => { searchString.apt : ""; - console.log( - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title&$filter=" + - queryString + - " &$count=true" - ); + // 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", + " and pinswg_appealcasetype ne null &$orderby=createdon desc&$count=true&$top=201", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -251,7 +251,7 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { }); }; -export const getFormData = (whichForm) => { +export const getFormData = (token, whichForm) => { //console.log("got to axios", whichForm); //console.log("api_root: ", BASE_URL); return axios @@ -259,8 +259,8 @@ export const getFormData = (whichForm) => { WEBAPI_URL + "systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode%20eq%20%27pinswg_" + whichForm + - "%27and%20type%20eq%202)&$count=true", - azureHeaders + "%27and%20type%20eq%202)&$count=true&$top=201", + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -268,14 +268,14 @@ export const getFormData = (whichForm) => { }); }; -export const getMandatoryFields = (whichForm) => { +export const getMandatoryFields = (token, whichForm) => { return axios .get( WEBAPI_URL + "EntityDefinitions(LogicalName='pinswg_" + whichForm + "')/Attributes?$count=true&$select=LogicalName,RequiredLevel", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -283,14 +283,14 @@ export const getMandatoryFields = (whichForm) => { }); }; -export const getPickLists = (whichForm) => { +export const getPickLists = (token, whichForm) => { return axios .get( WEBAPI_URL + "EntityDefinitions(LogicalName='pinswg_" + whichForm + "')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -298,12 +298,12 @@ export const getPickLists = (whichForm) => { }); }; -export const getAppealsTypes = () => { +export const getAppealsTypes = (token) => { return axios .get( WEBAPI_URL + "stringmaps?$filter=attributename%20eq%20%27pinswg_appealcasetype%27&$count=true&$select=value,stringmapid,organizationid,attributevalue", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -413,10 +413,13 @@ export const getAppealTypeDetail = (caseReference, appealcasetype) => { }; //https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/pinswg_planningappeals78s?$filter=pinswg_name eq 'CAS-00015-L7J9H1' -export const getLPA = () => { +export const getLPA = (token) => { // console.log("api_root: ", BASE_URL); return axios - .get(WEBAPI_URL + "accounts?$count=true&$select=name", azureHeaders) + .get( + WEBAPI_URL + "accounts?$count=true&$select=name", + azureHeaders(token) + ) .then((res) => res.data) .catch((error) => { console.log("thi serror", error); @@ -439,6 +442,7 @@ export const getPersonalAccount = () => { }; export const getAppealID = ( + token, caseReference, updateFormCollection, primaryAttribute @@ -454,7 +458,7 @@ export const getAppealID = ( console.log("proxy url", weburl); return axios - .get(weburl, azureHeaders) + .get(weburl, azureHeaders(token)) .then((res) => { var appealID = res.data.value[0][primaryAttribute]; return appealID; @@ -540,14 +544,14 @@ export const updateCase = async ( }); }; -export const getMyCases = (loggedInUserId) => { +export const getMyCases = (token, loggedInUserId) => { return axios .get( WEBAPI_URL + "incidents?$select=ticketnumber,casetypecode,createdon,_customerid_value,description,incidentid,pinswg_appealcasetype,_pinswg_assignedinspectrids_value,statecode,statuscode,title&$filter=_customerid_value eq " + loggedInUserId + - " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3", - azureHeaders + " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3", + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -555,7 +559,7 @@ export const getMyCases = (loggedInUserId) => { }); }; -export const getMyRepresentations = () => { +export const getMyRepresentations = (token) => { return ( axios // .get(BASE_URL + "/api/lookups/myRepresentations", { @@ -564,7 +568,7 @@ export const getMyRepresentations = () => { .get( WEBAPI_URL + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true&$top=3", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -573,7 +577,7 @@ export const getMyRepresentations = () => { ); }; -export const getWatchedCases = () => { +export const getWatchedCases = (token) => { return ( axios @@ -583,7 +587,7 @@ export const getWatchedCases = () => { .get( WEBAPI_URL + "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true&$top=3", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { @@ -592,7 +596,7 @@ export const getWatchedCases = () => { ); }; -export const getAwaitingSubmission = () => { +export const getAwaitingSubmission = (token) => { return axios .get(BASE_URL + "/api/lookups/awaitingSubmission", { httpsAgent: new https.Agent({ rejectUnauthorized: false }), @@ -603,7 +607,7 @@ export const getAwaitingSubmission = () => { }); }; -export const getPortalModuelDetails = (appealType, caseReference) => { +export const getPortalModuelDetails = (token, appealType, caseReference) => { return axios .get( WEBAPI_URL + @@ -611,7 +615,7 @@ export const getPortalModuelDetails = (appealType, caseReference) => { "?$filter=pinswg_name eq '" + caseReference + "'&$count=true", - azureHeaders + azureHeaders(token) ) .then((res) => res.data) .catch((error) => { diff --git a/components/homepage/casecomment.js b/components/homepage/casecomment.js index 32101655..50e342c2 100644 --- a/components/homepage/casecomment.js +++ b/components/homepage/casecomment.js @@ -3,19 +3,26 @@ import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; export default function CaseComment() { - let { t } = useTranslation(); + let { t } = useTranslation(); - const router = useRouter(); - const { locale } = router; - return ( -
-
-

- {t("home:casescomment-card-title")} -

-

{t("home:casescomment-card-paragraph-one")}

-

{t("home:casescomment-card-paragraph-two")}

-
-
- ); + const router = useRouter(); + const { locale } = router; + return ( +
+
+

+ {t("home:casescomment-card-title")} +

+

+ {t("home:casescomment-card-paragraph-one")}{" "} + + Casework.PEDW@gov.wales + +

+

+ {t("home:casescomment-card-paragraph-two")} +

+
+
+ ); } diff --git a/components/homepage/casesearch.js b/components/homepage/casesearch.js index 6698d0c3..99f4c4b0 100644 --- a/components/homepage/casesearch.js +++ b/components/homepage/casesearch.js @@ -4,6 +4,7 @@ import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { connect } from "react-redux"; import { Field, reduxForm } from "redux-form"; +import LoadingOverlay from "react-loading-overlay"; const required = (errorMsg) => (value) => value || typeof value === "number" ? undefined : errorMsg; @@ -36,13 +37,11 @@ const RenderTextfield = ({ } >
- {hint1} + {hint1} +
- - {hint2} - {" "} - CAS-00009-W8N6W4 + {hint2} CAS-00009-W8N6W4