From f347a0d73bc0784608848af160e1af1c4cc8a9a1 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 25 Jan 2022 10:09:11 +0000 Subject: [PATCH] Added service stage status and delete functions --- actions/index.js | 64 +++++++- components/case/summary.js | 11 +- .../pinswg_miscellaneouscasewordid.js | 8 +- components/myportal/makenewappeal.js | 6 +- components/myportal/topthree.js | 67 +++++++- components/myportal/viewall.js | 144 +++++++++++++----- components/newappeal/buildcheckrow.js | 14 ++ components/newappeal/complete.js | 19 ++- components/newappeal/createCase.js | 24 +-- components/utils/index.js | 13 ++ data/lookuptranslations.json | 10 ++ pages/api/endpoint/createcase_api.js | 3 + .../endpoint/deleteawaitingsubmissions_api.js | 49 ++++++ .../api/endpoint/getawaitingsubmission_api.js | 45 ++++++ .../getawaitingsubmissionproxy_api.js | 44 ++++++ .../api/endpoint/getbasicsearchdetails_api.js | 5 +- .../getbasicsearchdetailspaged_api.js | 2 +- pages/api/endpoint/getmycases_api.js | 9 +- pages/api/endpoint/getpicklists_api.js | 2 + .../endpoint/getportalmoduledetails_api.js | 3 + pages/api/endpoint/getwatchedcases_api.js | 33 +++- .../api/endpoint/getwatchedcasesproxy_api.js | 2 +- pages/api/endpoint/patchcase_api.js | 60 ++++++++ pages/api/endpoint/updatecase_api.js | 7 +- pages/case/index.js | 24 ++- pages/myportal/case.js | 15 -- pages/myportal/index.js | 17 ++- 27 files changed, 575 insertions(+), 125 deletions(-) create mode 100644 pages/api/endpoint/deleteawaitingsubmissions_api.js create mode 100644 pages/api/endpoint/getawaitingsubmission_api.js create mode 100644 pages/api/endpoint/getawaitingsubmissionproxy_api.js create mode 100644 pages/api/endpoint/patchcase_api.js diff --git a/actions/index.js b/actions/index.js index 98e0e574..662a7b9c 100644 --- a/actions/index.js +++ b/actions/index.js @@ -464,7 +464,7 @@ export const createCase = (appealTypeId, lpaID, contactid) => { contactid; var config = { - method: "post", + method: "get", url: BASE_URL + queryUrl, }; @@ -566,17 +566,34 @@ export const getWatchedCasesProxy = (loggedInUserId) => { }); }; -export const getAwaitingSubmission = () => { +export const getAwaitingSubmissionProxy = (loggedInUserId) => { return axios - .get(BASE_URL + "/api/lookups/awaitingSubmission", { - httpsAgent: new https.Agent({ rejectUnauthorized: false }), - }) + .get( + BASE_URL + + "/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" + + loggedInUserId + ) .then((res) => res.data) .catch((error) => { console.log("API call error", error); }); }; +export const getAwaitingSubmission = (loggedInUserId) => { + return axios + .get( + BASE_URL + + "/api/endpoint/getawaitingsubmission_api?loggedInUserId=" + + loggedInUserId + ) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("API call error", error); + }); +}; + export const getPortalModuleDetails = (appealType, caseReference) => { return axios .get( @@ -699,7 +716,7 @@ export const updateCase = async ( var config = { method: "post", - url: queryUrl + hashAPIPath(queryUrl), + url: queryUrl, data: data, }; @@ -712,6 +729,22 @@ export const updateCase = async ( }); }; +export const patchCase = async (incidentid) => { + var queryUrl = "/api/endpoint/patchcase_api?incidentid=" + incidentid; + var config = { + method: "get", + url: queryUrl, + }; + + return axios(config) + .then((res) => { + return res.data; + }) + .catch((error) => { + console.log("this error:", error); + }); +}; + export const deleteMyRepresentations = (myRepresentationsID) => { var queryUrl = "/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" + @@ -739,6 +772,25 @@ export const deleteMyRepresentations = (myRepresentationsID) => { }); }; +export const deleteAwaitingSubmissions = (incidentID) => { + var queryUrl = + "/api/endpoint/deleteawaitingsubmissions_api?incidentID=" + incidentID; + + var config = { + method: "delete", + url: queryUrl, + }; + // console.log(config); + return axios(config) + .then((res) => { + //console.log("deleted ", res.data); + return res.data; + }) + .catch((error) => { + console.log("this serror", error); + }); +}; + export const deleteWatchedCases = (watchedCaseID) => { var queryUrl = "/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID; diff --git a/components/case/summary.js b/components/case/summary.js index 6a597d12..0ba86772 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -75,6 +75,16 @@ const CaseSummary = (props) => { searchResultsObj, '$..[?(@.title=="' + caseReference + '")]' )) + : currentType == "watchedCases" + ? (casesObj = jsonpath.query( + setCaseQueryObj, + '$..[?(@.pinswg_title=="' + caseReference + '")]' + )) + : currentType == "myCases" + ? (casesObj = jsonpath.query( + setCaseQueryObj, + '$..[?(@.pinswg_title=="' + caseReference + '")]' + )) : (casesObj = jsonpath.query( setCaseQueryObj, '$..[?(@.reference=="' + caseReference + '")]' @@ -232,7 +242,6 @@ const CaseSummary = (props) => { - {showSummary(casesObj, detailsObj)} ) : ( diff --git a/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js b/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js index 5a62e29c..e56c49b2 100644 --- a/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js +++ b/components/case/summaryTypes/pinswg_miscellaneouscasewordid.js @@ -201,10 +201,14 @@ const Pinswg_miscellaneouscasewordid = (props) => { ? jsonpath.query( transLookup, '$..[?(@.value=="' + - detailsObj.pinswg_relevantauthorityname + + detailsObj[ + "pinswg_relevantauthorityname@OData.Community.Display.V1.FormattedValue" + ] + '")].value_cy' ) - : detailsObj.pinswg_relevantauthorityname || + : detailsObj[ + "pinswg_relevantauthorityname@OData.Community.Display.V1.FormattedValue" + ] || t( "case:summary-no-date-entered-label" )} diff --git a/components/myportal/makenewappeal.js b/components/myportal/makenewappeal.js index d2476b86..74733e48 100644 --- a/components/myportal/makenewappeal.js +++ b/components/myportal/makenewappeal.js @@ -20,11 +20,7 @@ export default function MakeNewAppeal() { {t("myportal:makenewappeal-card-paragraph-two")}

- + {t("myportal:makenewappeal-card-button-label")} diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js index 1a15d62a..0e510925 100644 --- a/components/myportal/topthree.js +++ b/components/myportal/topthree.js @@ -9,12 +9,18 @@ import { getWatchedCasesProxy, getPortalModuleDetailsProxy, deleteWatchedCases, + deleteAwaitingSubmissions, + getAwaitingSubmissionProxy, } from "../../actions"; import { setWatchedCases, setWatchedCasesDetails, } from "../../store/watchedCases/action"; +import { + setAwaitingSubmission, + setAwaitingSubmissionDetails, +} from "../../store/awaitingSubmission/action"; import { getFormCollectionByID } from "../../components/utils"; const TopThree = (props) => { @@ -26,6 +32,8 @@ const TopThree = (props) => { topThreeType, setWatchedCases, setWatchedCasesDetails, + setAwaitingSubmission, + setAwaitingSubmissionDetails, } = props; const router = useRouter(); @@ -37,6 +45,7 @@ const TopThree = (props) => { const deleteItem = (caseID, topThreeType) => { let cookies = parseCookies(); + //console.log("sssss", caseID, topThreeType); topThreeType == "watchedCases" && deleteWatchedCases(caseID) .then((data) => data) @@ -48,6 +57,32 @@ const TopThree = (props) => { }); }); }); + + topThreeType == "awaitingSubmission" && + deleteAwaitingSubmissions(caseID) + .then((data) => { + console.log("zzzzz"); + + return data; + }) + .then(() => { + console.log("qqqqqq"); + getAwaitingSubmissionProxy(cookies.pinsUser).then( + (data) => { + console.log("assss", data); + setAwaitingSubmission(data), + getDetails(data, "awaitingSubmission").then( + (data) => { + console.log( + "submission get details:", + data + ); + setAwaitingSubmissionDetails(data); + } + ); + } + ); + }); }; const getDetails = (resultsObj, detailsType) => { @@ -94,6 +129,7 @@ const TopThree = (props) => { return objArr.ticketnumber; break; case "awaitingSubmission": + return objArr.ticketnumber; break; default: // code block @@ -183,14 +219,12 @@ const TopThree = (props) => { {topThreeType == "awaitingSubmission" ? (
- Make Representation on Case Incomplete, not - submitted + Case Incomplete, not submitted
) : ( "" )}
- {topThreeType == "watchedCases" && (
{
)} + {topThreeType == "awaitingSubmission" && ( +
+ { + event.preventDefault(); + deleteItem( + showTopThreeArr[key].incidentid, + "awaitingSubmission" + ); + alert( + "You have deleted case " + + showTopThreeArr[key].ticketnumber + ); + }} + > + — + +
+ )} ); }); @@ -255,6 +310,12 @@ const mapDispatchToProps = (dispatch) => { setWatchedCasesDetails: (watchedCasesDetails) => { dispatch(setWatchedCasesDetails(watchedCasesDetails)); }, + setAwaitingSubmission: (awaitingSubmission) => { + dispatch(setAwaitingSubmission(awaitingSubmission)); + }, + setAwaitingSubmissionDetails: (awaitingSubmissionDetails) => { + dispatch(setAwaitingSubmissionDetails(awaitingSubmissionDetails)); + }, }; }; diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js index abea855a..0d050c8f 100644 --- a/components/myportal/viewall.js +++ b/components/myportal/viewall.js @@ -3,6 +3,8 @@ import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { setCurrentReference } from "../../store/currentView/action"; import { connect } from "react-redux"; +import jsonpath from "jsonpath"; +import transLookup from "../../data/lookuptranslations.json"; const ViewAllResults = (props) => { const { @@ -21,8 +23,16 @@ const ViewAllResults = (props) => { var resultsArr = props[currentView.viewKey][currentView.viewKey].value || [ {}, ]; + var searchDetailsObj = + props[currentView.viewKey][currentView.viewKey + "Details"] || {}; let resultsRowArr = []; - Object.keys(resultsArr).map((key, index) => { + resultsArr.map((item, key) => { + let detailsObj = jsonpath.query( + searchDetailsObj, + "$..value[?(@.pinswg_name=='" + item.pinswg_title + "')]" + ); + detailsObj = detailsObj[0]; + resultsRowArr.push(
@@ -42,21 +52,21 @@ const ViewAllResults = (props) => { setCurrentReference({ "currentReference": currentView.viewKey != "watchedCases" - ? resultsArr[index].ticketnumber - : resultsArr[index][ + ? resultsArr[key].ticketnumber + : resultsArr[key][ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue" ], "currentType": currentView.viewKey, "incidentid": currentView.viewKey != "watchedCases" - ? resultsArr[index].incidentid - : resultsArr[index][ - " _pinswg_watchedcase_value" + ? resultsArr[key].incidentid + : resultsArr[key][ + "_pinswg_watchedcase_value" ], "appealType": - resultsArr[index].pinswg_appealcasetype, + resultsArr[key].pinswg_appealcasetype, }); }} > @@ -65,8 +75,8 @@ const ViewAllResults = (props) => { {currentView.viewKey != "watchedCases" - ? resultsArr[index].ticketnumber - : resultsArr[index][ + ? resultsArr[key].ticketnumber + : resultsArr[key][ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue" ]} @@ -74,42 +84,108 @@ const ViewAllResults = (props) => {
- Site Address:{" "} + {t("search:searchresults-site-address-label")}: - {resultsArr[index].address1} -
{resultsArr[index].town} -
- {resultsArr[index].postcode} + {_.has(detailsObj, "pinswg_siteaddressline1") + ? detailsObj.pinswg_siteaddressline1 + : ""} + + {/* {detailsObj.pinswg_siteaddressline1 != + null &&
} */} + + {_.has(detailsObj, "pinswg_siteaddressline1") && + detailsObj.pinswg_siteaddressline1 != null &&
} + + {_.has(detailsObj, "pinswg_siteaddressline1") + ? detailsObj.pinswg_siteaddressline2 + : ""} + + {_.has(detailsObj, "pinswg_siteaddressline2") && + detailsObj.pinswg_siteaddressline2 != null &&
} + {_.has(detailsObj, "pinswg_siteaddresstown") + ? detailsObj.pinswg_siteaddresstown + : ""} + {_.has(detailsObj, "pinswg_siteaddresstown") && + detailsObj.pinswg_siteaddresstown != null &&
} + + {_.has(detailsObj, "pinswg_siteaddresscounty") + ? detailsObj.pinswg_siteaddresscounty + : ""} + {_.has(detailsObj, "pinswg_siteaddresscounty") && + detailsObj.pinswg_siteaddresscounty != null &&
} + {_.has(detailsObj, "pinswg_siteaddresspostcode") + ? detailsObj.pinswg_siteaddresspostcode + : ""}
- Appellant/Applicant: + {t("search:searchresults-applicant-label")}: - Mr smith + + {_.has(detailsObj, [ + "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue", + ]) + ? detailsObj[ + "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" + ] + : resultsArr[key][ + "_customerid_value@OData.Community.Display.V1.FormattedValue" + ]}
- Authority: - { - resultsArr[index][ - "_customerid_value@OData.Community.Display.V1.FormattedValue" - ] - } + + {t("search:searchresults-authority-label")}: + + {_.has(detailsObj, [ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue", + ]) + ? router.locale == "cy" + ? jsonpath.query( + transLookup, + '$..[?(@.value=="' + + item[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] + + '")].value_cy' + ) + : detailsObj[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] || "N/A" + : ""}
- Case Type: - { - resultsArr[index][ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] - } + + {t("search:searchresults-case-type-label")}: + + {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"}
- Status: - { - resultsArr[index][ - "statuscode@OData.Community.Display.V1.FormattedValue" - ] - } + + {t("search:searchresults-status-label")}: + + {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"}
); diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js index 3568267f..699de42c 100644 --- a/components/newappeal/buildcheckrow.js +++ b/components/newappeal/buildcheckrow.js @@ -6,6 +6,10 @@ import jsonpath from "jsonpath"; import BuildCheckField from "./buildCheckfield"; import { useSelector, shallowEqual, connect } from "react-redux"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; +import { + getFormCollectionByID, + getPickListLabel, +} from "../../components/utils"; import { setCaseReference, @@ -105,6 +109,16 @@ let BuildCheckRow = (props) => { datafieldname[0].value ] ) + : fieldtype[0].value == + "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}" + ? getPickListLabel( + props.props.formData.pickListData, + datafieldname[0].value, + props.props.form["appealForm"] + .values[ + datafieldname[0].value + ] + ) : props.props.form["appealForm"].values[ datafieldname[0].value ]} diff --git a/components/newappeal/complete.js b/components/newappeal/complete.js index 1dced394..6acb0b31 100644 --- a/components/newappeal/complete.js +++ b/components/newappeal/complete.js @@ -1,20 +1,17 @@ +import jsonpath from "jsonpath"; +import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; import { useRouter } from "next/router"; -import useTranslation from "next-translate/useTranslation"; -import { useState, useEffect } from "react"; +import { useEffect } from "react"; +import { connect } from "react-redux"; +import { formValueSelector } from "redux-form"; import xpath from "xpath"; -import BuildRow from "./buildrow"; -import { reduxForm, formValueSelector } from "redux-form"; -import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; +import { updateCase, patchCase } from "../../actions"; +import data from "../../data/collections.json"; import { setCurrentSection } from "../../store/appealType/action"; -import { updateCase } from "../../actions"; -import jsonpath from "jsonpath"; import { getFormCollectionByID } from "../utils"; -import data from "../../data/collections.json"; - let CompleteAppeal = (props) => { - // un comment to update incident with an appealtype id useEffect(() => { let incidentId = props.appealType.caseReference.incidentid; let updateBody = props.props.form.appealForm.values; @@ -51,6 +48,8 @@ let CompleteAppeal = (props) => { primaryAttribute, props.appealType.caseReference.ticketnumber ); + console.log("patching////////"); + patchCase(incidentId); }, [ props.appealType.caseReference, props.props.form.appealForm.values, diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index 949f7e71..c37fcb5b 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -1,23 +1,15 @@ -import Link from "next/link"; -import { useRouter } from "next/router"; -import useTranslation from "next-translate/useTranslation"; -import { useState, useEffect } from "react"; -import xpath from "xpath"; -import BuildRow from "./buildrow"; -import { reduxForm, formValueSelector, Field } from "redux-form"; -import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import jsonpath from "jsonpath"; +import useTranslation from "next-translate/useTranslation"; +import { useRouter } from "next/router"; +import { connect } from "react-redux"; +import { Field, formValueSelector, reduxForm } from "redux-form"; import transLookup from "../../data/lookuptranslations.json"; -import { getFormCollectionByID } from "../utils"; - -import data from "../../data/collections.json"; import { - setAppealType, - setAppealTypeTitle, - setAppealTypeID, setAppealLPA, - getAppealTypeObj, + setAppealTypeID, + setAppealTypeTitle, } from "../../store/appealType/action"; +import { getFormCollectionByID } from "../utils"; let CreateCase = (props) => { // useEffect(() => { @@ -222,7 +214,7 @@ let CreateCase = (props) => { appTypeCollection = getFormCollectionByID(appTypeCollection); router.replace( - (router.locale = "cy" ? "/apelnewydd" : "/newappeal") + + "/newappeal" + "/" + appTypeCollection.UrlName + "?lpa=" + diff --git a/components/utils/index.js b/components/utils/index.js index a6cf57fe..14530bd4 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -25,6 +25,19 @@ export const getFormCollectionByID = (appealTypeID) => { return collectionName[0]; }; +export const getPickListLabel = (data, picklistType, picklistID) => { + const pickListData = jsonpath.query( + data, + "$..[?(@.LogicalName=='" + picklistType + "')]" + ); + + const pickListLabel = jsonpath.query( + pickListData, + "$..[?(@.Value=='" + picklistID + "')].Label.LocalizedLabels..Label" + ); + return pickListLabel[0]; +}; + /* * Get the details of a case from the appeal type * @param object searchResultsObj diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index 401644b2..c4882e34 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -214,6 +214,16 @@ } ], "pinswg_decision": [ + { + "value": "Allowed", + "value_cy": "Caniateir", + "pinswg_decision": 846040000 + }, + { + "value": "Non Determination", + "value_cy": "Amhenderfyniad", + "pinswg_decision": 846040001 + }, { "value": "Dismissed", "value_cy": "Gwrthodwyd", diff --git a/pages/api/endpoint/createcase_api.js b/pages/api/endpoint/createcase_api.js index 74d5fc86..a90f5222 100644 --- a/pages/api/endpoint/createcase_api.js +++ b/pages/api/endpoint/createcase_api.js @@ -31,11 +31,14 @@ export default async function ApiProxy(req, res) { var data = JSON.stringify({ "title": "insertion test case", "caseorigincode": 3, + "servicestage": 1, "customerid_contact@odata.bind": "/contacts(" + contactid + ")", "pinswg_appealcasetype": appealTypeId, "pinswg_AssociatedLPA@odata.bind": "/accounts(" + lpaID + ")", }); + console.log(data); + var config = { method: "post", url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), diff --git a/pages/api/endpoint/deleteawaitingsubmissions_api.js b/pages/api/endpoint/deleteawaitingsubmissions_api.js new file mode 100644 index 00000000..e2015b2e --- /dev/null +++ b/pages/api/endpoint/deleteawaitingsubmissions_api.js @@ -0,0 +1,49 @@ +import axios from "axios"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeadersPaged } 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 incidentID = req.query.incidentID; + var token = await getToken(); + var queryUrl = "incidents(" + incidentID + ")"; + + var config = { + method: "delete", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*"', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + }; + + return axios(config) + .then(({ data }) => { + console.log("deleted awaitingsubmission case - " + incidentID); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getawaitingsubmission_api.js b/pages/api/endpoint/getawaitingsubmission_api.js new file mode 100644 index 00000000..318ce831 --- /dev/null +++ b/pages/api/endpoint/getawaitingsubmission_api.js @@ -0,0 +1,45 @@ +import axios from "axios"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } 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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = await getToken(); + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " + + loggedInUserId + + " and servicestage eq 1 and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true"; + + console.log(queryUrl); + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + data.value.forEach(function (element) { + element.pinswg_title = element.title; + }); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getawaitingsubmissionproxy_api.js b/pages/api/endpoint/getawaitingsubmissionproxy_api.js new file mode 100644 index 00000000..3fbdf43b --- /dev/null +++ b/pages/api/endpoint/getawaitingsubmissionproxy_api.js @@ -0,0 +1,44 @@ +import axios from "axios"; +import CryptoJS from "crypto-js"; +import { getToken, azureHeaders } 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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; +}; + +export default async function ApiProxy(req, res) { + var loggedInUserId = req.query.loggedInUserId; + var token = await getToken(); + + var queryUrl = + "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " + + loggedInUserId + + " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true"; + + return axios + .get( + WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + azureHeaders(token.access_token) + ) + .then(({ data }) => { + data.value.forEach(function (element) { + element.pinswg_title = element.title; + }); + console.log(data); + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); +} diff --git a/pages/api/endpoint/getbasicsearchdetails_api.js b/pages/api/endpoint/getbasicsearchdetails_api.js index 7998860e..608efbfa 100644 --- a/pages/api/endpoint/getbasicsearchdetails_api.js +++ b/pages/api/endpoint/getbasicsearchdetails_api.js @@ -15,9 +15,6 @@ const hashAPIPath = (queryPath) => { CryptoJS.enc.Hex.parse(WORDKEY) ); hashlink = hashlink.toString(CryptoJS.enc.Hex); - - //return "&hash=" + hashlink; - return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; }; @@ -37,7 +34,7 @@ export default async function ApiProxy(req, res) { queryUrl = queryUrl + getSelectQuery(appealTypeName); - console.log("query: ", queryUrl, "<<< { + data.value.forEach(function (element) { + element.pinswg_title = element.title; + }); res.status(200).json(data); }) .catch(({ err }) => { diff --git a/pages/api/endpoint/getpicklists_api.js b/pages/api/endpoint/getpicklists_api.js index 5b54ff63..e2978d5d 100644 --- a/pages/api/endpoint/getpicklists_api.js +++ b/pages/api/endpoint/getpicklists_api.js @@ -26,6 +26,8 @@ export default async function ApiProxy(req, res) { whichForm + "')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true"; + console.log("get pick list for " + whichForm + ": ", queryUrl); + return axios .get( WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), diff --git a/pages/api/endpoint/getportalmoduledetails_api.js b/pages/api/endpoint/getportalmoduledetails_api.js index 943ab28b..4b6401d7 100644 --- a/pages/api/endpoint/getportalmoduledetails_api.js +++ b/pages/api/endpoint/getportalmoduledetails_api.js @@ -1,6 +1,7 @@ import axios from "axios"; import CryptoJS from "crypto-js"; import { getToken, azureHeaders } from "../../../actions"; +import { getSelectQuery } from "../../../actions/selectQueryTypes"; const WORDKEY = process.env.HASHKEY; @@ -28,6 +29,8 @@ export default async function ApiProxy(req, res) { caseReference + "'&$count=true"; + queryUrl = queryUrl + getSelectQuery(appealType); + return axios .get( WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), diff --git a/pages/api/endpoint/getwatchedcases_api.js b/pages/api/endpoint/getwatchedcases_api.js index a7763975..726bb769 100644 --- a/pages/api/endpoint/getwatchedcases_api.js +++ b/pages/api/endpoint/getwatchedcases_api.js @@ -1,6 +1,10 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken, azureHeaders } from "../../../actions"; +import { + getToken, + azureHeaders, + getBasicSearchDetails, +} from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -24,7 +28,7 @@ export default async function ApiProxy(req, res) { var queryUrl = "pinswg_watchlists?$filter= _pinswg_contact_value eq " + loggedInUserId + - "&$count=true&$orderby=createdon desc"; + "&$select=pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)"; return axios .get( @@ -32,6 +36,31 @@ export default async function ApiProxy(req, res) { azureHeaders(token.access_token) ) .then(({ data }) => { + data.value.forEach(function (element) { + element.pinswg_title = + element[ + "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue" + ]; + + element[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ] = + element.pinswg_WatchedCase[ + "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" + ]; + element._pinswg_associatedlpa_value = + element.pinswg_WatchedCase._pinswg_associatedlpa_value; + element[ + "_ownerid_value@OData.Community.Display.V1.FormattedValue" + ] = + element.pinswg_WatchedCase[ + "_ownerid_value@OData.Community.Display.V1.FormattedValue" + ]; + element._ownerid_value = + element.pinswg_WatchedCase._ownerid_value; + + delete element.pinswg_WatchedCase; + }); res.status(200).json(data); }) .catch(({ err }) => { diff --git a/pages/api/endpoint/getwatchedcasesproxy_api.js b/pages/api/endpoint/getwatchedcasesproxy_api.js index 47106318..d070540c 100644 --- a/pages/api/endpoint/getwatchedcasesproxy_api.js +++ b/pages/api/endpoint/getwatchedcasesproxy_api.js @@ -24,7 +24,7 @@ export default async function ApiProxy(req, res) { var queryUrl = "pinswg_watchlists?$filter= _pinswg_contact_value eq " + loggedInUserId + - "&$count=true&$orderby=createdon desc"; + "&$select=pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)"; return axios .get( diff --git a/pages/api/endpoint/patchcase_api.js b/pages/api/endpoint/patchcase_api.js new file mode 100644 index 00000000..68a514d1 --- /dev/null +++ b/pages/api/endpoint/patchcase_api.js @@ -0,0 +1,60 @@ +import axios from "axios"; +import CryptoJS from "crypto-js"; +import _ from "lodash"; +import { getToken, azureHeadersPaged } 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 incidentID = req.query.incidentid; + var queryUrl = "incidents(" + incidentID + ")"; + var token = await getToken(); + + var data = JSON.stringify({ + "servicestage": 0, + }); + + //console.log(data, WEBAPI_URL + queryUrl); + + var config = { + method: "patch", + url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*",return=representation', + "Authorization": "Bearer " + token.access_token, + "Content-Type": "application/json", + }, + data: data, + }; + + var apiResponse = _.isEmpty(req.query) + ? res.status(400).json() + : axios(config) + .then(({ data }) => { + res.status(200).json(data); + }) + .catch(({ err }) => { + res.status(400).json(err); + }); + + return apiResponse; +} diff --git a/pages/api/endpoint/updatecase_api.js b/pages/api/endpoint/updatecase_api.js index 03074357..0a36bce2 100644 --- a/pages/api/endpoint/updatecase_api.js +++ b/pages/api/endpoint/updatecase_api.js @@ -1,6 +1,6 @@ import axios from "axios"; import CryptoJS from "crypto-js"; -import { getToken } from "../../../actions"; +import { getToken, patchCase } from "../../../actions"; const WORDKEY = process.env.HASHKEY; @@ -22,7 +22,9 @@ const hashAPIPath = (queryPath) => { export default async function ApiProxy(req, res) { var data = JSON.stringify(req.body); - var appealObj = rea.query.appealObj; + var appealObj = req.query.appealObj; + var incidentID = req.query.incident; + var updateFormCollection = req.query.updateFormCollection; var queryUrl = updateFormCollection + "(" + appealObj + ")"; @@ -47,6 +49,7 @@ export default async function ApiProxy(req, res) { res.status(200).json(data); }) .catch(({ err }) => { + console.log(err); res.status(400).json(err); }); } diff --git a/pages/case/index.js b/pages/case/index.js index 667ccbf5..1fa8e41c 100644 --- a/pages/case/index.js +++ b/pages/case/index.js @@ -1,19 +1,12 @@ -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 CaseSummary from "../../components/case"; -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 { useRouter } from "next/router"; 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 Case from "../../components/case"; +import CookieBanner from "../../components/cookieBanner"; +import Footer from "../../components/footer"; +import Header from "../../components/header"; const Home = (props) => { const { footerLinks, pages } = props; @@ -57,6 +50,9 @@ const Home = (props) => { props.myRepresentations.myRepresentations } watchedCases={props.watchedCases.watchedCases} + watchedCasesDetails={ + props.watchedCases.watchedCasesDetails + } awaitingSubmission={ props.awaitingSubmission.awaitingSubmission } diff --git a/pages/myportal/case.js b/pages/myportal/case.js index c3b6ac9e..2e35faf8 100644 --- a/pages/myportal/case.js +++ b/pages/myportal/case.js @@ -78,21 +78,6 @@ const Home = (props) => { ); }; -// export const getServerSideProps = wrapper.getServerSideProps( -// (store) => async (ctx) => { -// const { query, req, res } = ctx; - -// const showRepresentationsCheck = -// process.env.SHOWREPRESENTATIONS || false; - -// console.log("Show representation module: ", showRepresentationsCheck); - -// return { -// props: { showRepresentations: showRepresentationsCheck }, -// }; -// } -// ); - const mapStateToProps = (state) => { //console.log(state); diff --git a/pages/myportal/index.js b/pages/myportal/index.js index 6f003444..dbf7b7ff 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -22,7 +22,10 @@ import { setAccountDetails, setLoggedInUserId, } from "../../store/accountDetails/action"; -import { setAwaitingSubmission } from "../../store/awaitingSubmission/action"; +import { + setAwaitingSubmission, + setAwaitingSubmissionDetails, +} from "../../store/awaitingSubmission/action"; import { getGovGatewayConfig } from "../../store/govgateway/action"; import { setMyCases, setMyCasesDetails } from "../../store/myCases/action"; import { @@ -172,7 +175,7 @@ export const getServerSideProps = wrapper.getServerSideProps( await getMyCases(loggedInUser), await getMyRepresentations(loggedInUser), await getWatchedCases(loggedInUser), - await getAwaitingSubmission(), + await getAwaitingSubmission(loggedInUser), ]); //const cookiesMaker = nookies.get(ctx) @@ -194,12 +197,12 @@ export const getServerSideProps = wrapper.getServerSideProps( myCasesDetails, myRepresentationsDetails, watchedCasesDetails, - // awaitingSubmissionDetails, + awaitingSubmissionDetails, ] = await Promise.all([ await getDetails(myCases, "myCases"), await getDetails(myRepresentations, "myRepresentations"), await getDetails(watchedCases, "myWatchedCases"), - //await getDetails(awaitingSubmission), + await getDetails(awaitingSubmission, "awaitingSubmission"), ]); store.dispatch(setAccountDetails(accountDetails)); @@ -213,9 +216,9 @@ export const getServerSideProps = wrapper.getServerSideProps( store.dispatch(setWatchedCases(watchedCases)); store.dispatch(setWatchedCasesDetails(watchedCasesDetails)); store.dispatch(setAwaitingSubmission(awaitingSubmission)); - // store.dispatch( - // setAwaitingSubmissionDetails(awaitingSubmissionDetails) - // ); + store.dispatch( + setAwaitingSubmissionDetails(awaitingSubmissionDetails) + ); } } );