diff --git a/components/addresssearch.js b/components/addresssearch.js
new file mode 100644
index 00000000..d855738f
--- /dev/null
+++ b/components/addresssearch.js
@@ -0,0 +1,24 @@
+import Link from "next/link";
+import { useRouter } from "next/router";
+import { useContext } from "react";
+import useTranslation from "next-translate/useTranslation";
+import SearchForCase from "./search/searchforcase";
+import AddressSearch from "./search/addresssearch";
+
+export default function Search(props) {
+ let { t } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ //console.log("props here:", props.myportal || false);
+
+ return (
+
+
+
+ );
+}
diff --git a/components/addresssearchresults.js b/components/addresssearchresults.js
new file mode 100644
index 00000000..94c15a07
--- /dev/null
+++ b/components/addresssearchresults.js
@@ -0,0 +1,80 @@
+import Link from "next/link";
+import { useRouter } from "next/router";
+import { useContext } from "react";
+import useTranslation from "next-translate/useTranslation";
+import SearchForCase from "./search/searchforcase";
+import SearchResults from "./search/addresssearchresults";
+import CRMError from "./crmError";
+
+export default function Search(props) {
+ const {
+ searchString,
+ searchResultsObj,
+ advancedSearch,
+ myportal,
+ watchedCases,
+ isLinkedCase,
+ showLoginCheck,
+ } = props;
+ let { t } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+
+ var hasError = _.has(searchResultsObj.searchResultsObj, "errorCode")
+ ? true
+ : false;
+
+ //console.log("has an error", hasError);
+
+ return (
+
+ {hasError ? (
+
+ ) : (
+ <>
+
+
+ >
+ )}
+
+ );
+}
diff --git a/components/myportal/addresssearch.js b/components/myportal/addresssearch.js
new file mode 100644
index 00000000..90fba4e7
--- /dev/null
+++ b/components/myportal/addresssearch.js
@@ -0,0 +1,313 @@
+import Link from "next/link";
+import { useState } from "react";
+import { useRouter } from "next/router";
+import useTranslation from "next-translate/useTranslation";
+import { reduxForm, formValueSelector, Field } from "redux-form";
+import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
+import { JSONPath as jsonpath } from "jsonpath-plus";
+import data from "../../data/collections.json";
+
+import transLookup from "../../data/lookuptranslations.json";
+import { values } from "lodash";
+
+const required = (errorMsg) => (value) =>
+ value || typeof value === "number" ? undefined : errorMsg;
+
+export const minLength = (errorMsg) => (value) =>
+ value && value.length < 3
+ ? errorMsg //`Must be ${min} characters or more`
+ : undefined;
+
+export const leastOneValue = (values, errorMsg) => (value) =>
+ value ? console.log(values) : errorMsg;
+
+const validate = (values) => {
+ const errors = {};
+
+ if (values.appellantname) {
+ if (
+ !(
+ values.addressline1 != null ||
+ values.town != null ||
+ values.county != null ||
+ values.postcode != null
+ )
+ ) {
+ errors.appellantname =
+ document.documentElement.lang == "cy"
+ ? "Angen rhan o'r cyfeiriad i chwilio gydag enw"
+ : "Need part of the address to search with a name";
+ }
+ }
+
+ return errors;
+};
+
+const RenderTextfield = ({
+ id,
+ className,
+ rows,
+ datafieldname,
+ name,
+ label,
+ input,
+ hint1,
+ hint2,
+ hint3,
+ meta: { touched, error },
+ ...custom
+}) => {
+ let { t } = useTranslation();
+
+ return (
+ <>
+
+
+
+ {label}
+
+
+
+
+
+ {touched && error && (
+
+
+ Error:
+ {" "}
+ {error}
+
+ )}
+
+
+ >
+ );
+};
+
+let AddressSearch = (props) => {
+ let { t } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+
+ const {
+ LPAData,
+ onSubmit,
+ handleSubmit,
+ myportal,
+ error,
+ pristine,
+ reset,
+ submitting,
+ } = props;
+
+ const onHandleSubmit = (values) => {
+ event.preventDefault();
+ //spinnerState();
+
+ var searchString = "";
+
+ searchString +=
+ values.appellantname != null
+ ? "appellantname=" + values.appellantname + "&"
+ : "";
+
+ searchString +=
+ values.addressline1 != null
+ ? "addressline1=" + values.addressline1.trim() + "&"
+ : "";
+
+ searchString += values.town != null ? "town=" + values.town + "&" : "";
+
+ searchString +=
+ values.county != null ? "county=" + values.county + "&" : "";
+
+ searchString +=
+ values.postcode != null ? "postcode=" + values.postcode + "&" : "";
+
+ searchString = "?" + searchString.slice(0, -1);
+
+ console.log(searchString);
+
+ router.replace(
+ router.locale == "cy"
+ ? (myportal == true ? "/fymhorth" : "") +
+ "/canlyniadaucyfeiriadau" +
+ searchString
+ : (myportal == true ? "/myportal" : "") +
+ "/addresssearchresults" +
+ searchString
+ );
+ };
+
+ return (
+ <>
+
+ >
+ );
+};
+
+const mapStateToProps = (state) => {
+ return {
+ currentView: state.currentView,
+ search: state.search,
+ searchResultsObj: state.searchResultsObj,
+ formData: state.formData,
+ appealType: state.appealType,
+ LPAData: state.LPAData,
+ //form: state.form,
+ myCases: state.myCases,
+ watchedCases: state.watchedCases,
+ myRepresentations: state.myRepresentations,
+ awaitingSubmission: state.awaitingSubmission,
+ };
+};
+
+const mapDispatchToProps = (dispatch) => {
+ return {};
+};
+
+const selector = formValueSelector("addressSearchForm"); // <-- same as form name
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(
+ reduxForm({
+ form: "addressSearchForm",
+ destroyOnUnmount: false,
+ validate,
+ })(AddressSearch)
+);
diff --git a/components/search/addresssearch.js b/components/search/addresssearch.js
new file mode 100644
index 00000000..f3bb6575
--- /dev/null
+++ b/components/search/addresssearch.js
@@ -0,0 +1,317 @@
+import Link from "next/link";
+import { useState } from "react";
+import { useRouter } from "next/router";
+import useTranslation from "next-translate/useTranslation";
+import { reduxForm, formValueSelector, Field } from "redux-form";
+import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
+import { JSONPath as jsonpath } from "jsonpath-plus";
+import data from "../../data/collections.json";
+
+import transLookup from "../../data/lookuptranslations.json";
+import { values } from "lodash";
+
+const required = (errorMsg) => (value) =>
+ value || typeof value === "number" ? undefined : errorMsg;
+
+export const minLength = (errorMsg) => (value) =>
+ value && value.length < 3
+ ? errorMsg //`Must be ${min} characters or more`
+ : undefined;
+
+export const leastOneValue = (values, errorMsg) => (value) =>
+ value ? console.log(values) : errorMsg;
+
+const validate = (values) => {
+ const errors = {};
+
+ console.log(document.documentElement.lang);
+
+ if (values.appellantname) {
+ if (
+ !(
+ values.addressline1 != null ||
+ values.town != null ||
+ values.county != null ||
+ values.postcode != null
+ )
+ ) {
+ errors.appellantname =
+ document.documentElement.lang == "cy"
+ ? "Angen rhan o'r cyfeiriad i chwilio gydag enw"
+ : "Need part of the address to search with a name";
+ }
+ }
+
+ return errors;
+};
+
+const RenderTextfield = ({
+ id,
+ className,
+ rows,
+ datafieldname,
+ name,
+ label,
+ input,
+ hint1,
+ hint2,
+ hint3,
+ meta: { touched, error },
+ ...custom
+}) => {
+ let { t } = useTranslation();
+
+ return (
+ <>
+
+
+
+ {label}
+
+
+
+
+
+ {touched && error && (
+
+
+ Error:
+ {" "}
+ {error}
+
+ )}
+
+
+ >
+ );
+};
+
+let AddressSearch = (props) => {
+ let { t } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+
+ const {
+ LPAData,
+ onSubmit,
+ handleSubmit,
+ myportal,
+ error,
+ pristine,
+ reset,
+ submitting,
+ } = props;
+
+ const onHandleSubmit = (values) => {
+ event.preventDefault();
+ //spinnerState();
+
+ var searchString = "";
+
+ searchString +=
+ values.appellantname != null
+ ? "appellantname=" + values.appellantname + "&"
+ : "";
+
+ searchString +=
+ values.addressline1 != null
+ ? "addressline1=" + values.addressline1.trim() + "&"
+ : "";
+
+ searchString += values.town != null ? "town=" + values.town + "&" : "";
+
+ searchString +=
+ values.county != null ? "county=" + values.county + "&" : "";
+
+ searchString +=
+ values.postcode != null ? "postcode=" + values.postcode + "&" : "";
+
+ searchString = "?" + searchString.slice(0, -1);
+
+ console.log(searchString);
+
+ router.replace(
+ router.locale == "cy"
+ ? (myportal == true ? "/fymhorth" : "") +
+ "/canlyniadaucyfeiriadau" +
+ searchString
+ : (myportal == true ? "/myportal" : "") +
+ "/addresssearchresults" +
+ searchString
+ );
+ };
+
+ return (
+ <>
+
+ >
+ );
+};
+
+const mapStateToProps = (state) => {
+ return {
+ currentView: state.currentView,
+ search: state.search,
+ searchResultsObj: state.searchResultsObj,
+ formData: state.formData,
+ appealType: state.appealType,
+ LPAData: state.LPAData,
+ //form: state.form,
+ myCases: state.myCases,
+ watchedCases: state.watchedCases,
+ myRepresentations: state.myRepresentations,
+ awaitingSubmission: state.awaitingSubmission,
+ };
+};
+
+const mapDispatchToProps = (dispatch) => {
+ return {};
+};
+
+const selector = formValueSelector("addressSearchForm"); // <-- same as form name
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(
+ reduxForm({
+ form: "addressSearchForm",
+ destroyOnUnmount: false,
+ validate,
+ })(AddressSearch)
+);
diff --git a/components/search/addresssearchresults.js b/components/search/addresssearchresults.js
new file mode 100644
index 00000000..24e82054
--- /dev/null
+++ b/components/search/addresssearchresults.js
@@ -0,0 +1,900 @@
+import Link from "next/link";
+import { useRouter } from "next/router";
+import useTranslation from "next-translate/useTranslation";
+import {
+ currentViewActionTypes,
+ setCurrentReference,
+} from "../../store/currentView/action";
+import { connect } from "react-redux";
+import { JSONPath as jsonpath } from "jsonpath-plus";
+import _, { result } from "lodash";
+import transLookup from "../../data/lookuptranslations.json";
+import {
+ getBasicSearchPaged,
+ getSearchDocumentDetails,
+ getBasicSearchDetailsPaged,
+ getAdvancedSearchPaged,
+} from "../../actions";
+import data from "../../data/collections.json";
+import { useCallback, useState } from "react";
+
+import {
+ setSearchResults,
+ setSearchDetails,
+} from "../../store/searchOutput/action";
+import { setLoggedInUserId } from "../../store/accountDetails/action";
+import {
+ setWatchedCases,
+ setWatchedCasesDetails,
+} from "../../store/watchedCases/action";
+import { useEffect } from "react";
+import { parseCookies, setCookie, destroyCookie } from "nookies";
+
+import PaginationControl from "./pagination";
+import {
+ getSearchDetailsPaged,
+ getFormCollection,
+ getFormCollectionByID,
+} from "../utils";
+
+import {
+ createWatchedCases,
+ getWatchedCasesProxy,
+ getPortalModuleDetailsProxy,
+ deleteWatchedCases,
+} from "../../actions";
+import { useSession, signIn, signOut } from "next-auth/react";
+
+const SearchResults = (props) => {
+ const {
+ searchString,
+ searchResultsObj,
+ searchDetailsObj,
+ setCurrentReference,
+ setSearchResults,
+ setSearchDetails,
+ advancedSearch,
+ myportal,
+ watchedCases,
+ setWatchedCases,
+ setWatchedCasesDetails,
+ isLinkedCase,
+ showLoginCheck,
+ } = props;
+ let { t } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { data: session } = useSession();
+
+ let [resultsArr, setResultsArr] = useState(searchResultsObj.value || []);
+
+ const [currentPage, setCurrentPage] = useState(1);
+ const [searchLoaded, setSearchLoaded] = useState(false);
+ const [showSpinnerState, setShowSpinnerState] = useState(false);
+ const [selectedOption, setSelectedOption] = useState(10);
+ const [orderByState, setOrderbyState] = useState("createdon");
+ const [fieldSortState, setfieldSortState] = useState("asc");
+ const [loginToWatch, setLoginToWatch] = useState("true");
+
+ let spinnerState = () => {
+ showSpinnerState == true
+ ? setShowSpinnerState(false)
+ : setShowSpinnerState(true);
+ };
+
+ const cookies = parseCookies();
+
+ const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
+ let updateBody = {
+ "pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
+ "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
+ "pinswg_appealcasetype": +appealType,
+ };
+
+ createWatchedCases(updateBody)
+ .then((data) => data)
+ .then(() => {
+ getWatchedCasesProxy(props.accountDetails.loggedinUserId).then(
+ (data) => {
+ setWatchedCases(data),
+ getDetails(data, "myWatchedCases").then((data) => {
+ setWatchedCasesDetails(data);
+ });
+ }
+ );
+ });
+ };
+
+ const isWatchedCase = (whichIncident) => {
+ let isWatched = jsonpath(
+ "$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]",
+ watchedCases
+ );
+
+ return isWatched;
+ };
+
+ const deleteItem = (caseID, topThreeType) => {
+ let cookies = parseCookies();
+ topThreeType == "watchedCases" &&
+ deleteWatchedCases(caseID)
+ .then((data) => data)
+ .then(() => {
+ getWatchedCasesProxy(
+ props.accountDetails.loggedinUserId
+ ).then((data) => {
+ setWatchedCases(data),
+ getDetails(data, "myWatchedCases").then((data) => {
+ setWatchedCasesDetails(data);
+ });
+ });
+ });
+ };
+
+ const getDetails = (resultsObj, detailsType) => {
+ // console.log(resultsObj);
+ let detailsArr = [];
+ resultsObj = resultsObj.value;
+ const detailsObj = resultsObj.map((searchDetail, index) => {
+ if (searchDetail.pinswg_appealcasetype == null) {
+ console.log(
+ detailsType != "myWatchedCases"
+ ? searchDetail.ticketnumber
+ : searchDetail[
+ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ );
+ } else {
+ detailsArr.push(
+ getPortalModuleDetailsProxy(
+ getFormCollectionByID(
+ searchDetail.pinswg_appealcasetype
+ ).LogicalCollectionName,
+ detailsType != "myWatchedCases"
+ ? searchDetail.ticketnumber
+ : searchDetail[
+ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ )
+ );
+ }
+ });
+ //console.log(detailsArr);
+ return Promise.all(detailsArr);
+ };
+
+ const indexOfLastRecord = currentPage * selectedOption;
+ const indexOfFirstRecord = indexOfLastRecord - selectedOption;
+
+ const ResultsView = (resultsArr) => {
+ var resultsArrPaged = resultsArr.slice(
+ indexOfFirstRecord,
+ indexOfLastRecord
+ );
+ return (
+ <>
+
+
+
+ sortDataBy("pinswg_name")}
+ className={
+ orderByState == "pinswg_name"
+ ? fieldSortState == "asc"
+ ? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
+ }
+ >
+ {t("search:searchresults-case-reference-label")}
+
+
+
+ {t("search:searchresults-site-address-label")}
+
+
+
+ sortDataBy(
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
+ )
+ }
+ className={
+ orderByState ==
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
+ ? fieldSortState == "asc"
+ ? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
+ }
+ >
+ {t("search:searchresults-applicant-label")}
+
+
+
+
+ sortDataBy("_pinswg_associatedlpa_value")
+ }
+ className={
+ orderByState ==
+ "_pinswg_associatedlpa_value"
+ ? fieldSortState == "asc"
+ ? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
+ }
+ >
+ {t("search:searchresults-authority-label")}
+
+
+
+ sortDataBy("pinswg_appealType")}
+ className={
+ orderByState == "pinswg_appealcasetype"
+ ? fieldSortState == "asc"
+ ? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
+ }
+ >
+ {t("search:searchresults-case-type-label")}
+
+
+
+ {/* {t("search:searchresults-status-label")} */}
+ sortDataBy("statuscode")}
+ className={
+ orderByState == "statuscode"
+ ? fieldSortState == "asc"
+ ? `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortAsc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16 sortDesc`
+ : `govuk-link govuk-link--no-underline govuk-!-font-weight-bold govuk-!-font-size-16`
+ }
+ >
+ {t("search:searchresults-status-label")}
+
+
+
+
+
+ {showSpinnerState == true ? (
+
+
+ {t("common:spinner-fetching-data")}
+
+
+
+ ) : (
+ resultsArrPaged.map((item, key) => {
+ let detailsObj = jsonpath(
+ '$..value[?(@.pinswg_name=="' +
+ item.pinswg_name +
+ '")]',
+ searchDetailsObj
+ );
+ detailsObj = detailsObj[0];
+ return (
+
+
+ {
+ // setCurrentReference({
+ // "ticketnumber":
+ // item.ticketnumber,
+ // "currentReference":
+ // item.title,
+ // "currentType":
+ // "searchResultsObj",
+ // "incidentid":
+ // item.incidentid,
+ // "appealType":
+ // item.pinswg_appealcasetype,
+ // "showLoginCheck":
+ // props.showLoginCheck,
+ // });
+ // }}
+ >
+
+ {t(
+ "search:searchresults-case-reference-label"
+ )}
+ :
+
+ {item.pinswg_name}
+
+
+
+
+ {t(
+ "search:searchresults-site-address-label"
+ )}
+ :
+
+ {_.has(
+ detailsObj,
+ "pinswg_projectlocation"
+ )
+ ? detailsObj.pinswg_projectlocation !=
+ null
+ ? detailsObj.pinswg_projectlocation.indexOf(
+ ";"
+ ) < 0
+ ? detailsObj.pinswg_projectlocation
+ : router.locale == "cy"
+ ? detailsObj.pinswg_projectlocation.split(
+ ";"
+ )[1]
+ : detailsObj.pinswg_projectlocation.split(
+ ";"
+ )[0]
+ : ""
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddressline1
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_addressline1"
+ )
+ ? detailsObj.pinswg_addressline1
+ : ""}
+ {/* {detailsObj.pinswg_siteaddressline1 !=
+ null && } */}
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ ) &&
+ detailsObj.pinswg_siteaddressline1 !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_addressline1"
+ ) &&
+ detailsObj.pinswg_addressline1 !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline1"
+ )
+ ? detailsObj.pinswg_siteaddressline2
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_addressline1"
+ )
+ ? detailsObj.pinswg_addressline2
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddressline2"
+ ) &&
+ detailsObj.pinswg_siteaddressline2 !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_addressline2"
+ ) &&
+ detailsObj.pinswg_addressline2 !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddresstown"
+ )
+ ? detailsObj.pinswg_siteaddresstown
+ : ""}
+ {_.has(detailsObj, "pinswg_addresstown")
+ ? detailsObj.pinswg_addresstown
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddresstown"
+ ) &&
+ detailsObj.pinswg_siteaddresstown !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_addresstown"
+ ) &&
+ detailsObj.pinswg_addresstown !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddresscounty"
+ )
+ ? detailsObj.pinswg_siteaddresscounty
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_addresscounty"
+ )
+ ? detailsObj.pinswg_addresscounty
+ : ""}
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddresscounty"
+ ) &&
+ detailsObj.pinswg_siteaddresscounty !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_addresscounty"
+ ) &&
+ detailsObj.pinswg_addresscounty !=
+ null && }
+ {_.has(
+ detailsObj,
+ "pinswg_siteaddresspostcode"
+ )
+ ? detailsObj.pinswg_siteaddresspostcode
+ : ""}
+ {_.has(detailsObj, "pinswg_postcode")
+ ? detailsObj.pinswg_postcode
+ : ""}
+
+
+
+ {t(
+ "search:searchresults-applicant-label"
+ )}
+ :
+
+ {_.has(detailsObj, [
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? detailsObj[
+ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
+
+
+
+ {t(
+ "search:searchresults-authority-label"
+ )}
+ :
+
+ {_.has(item, [
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? router.locale == "cy"
+ ? jsonpath(
+ '$..[?(@.value=="' +
+ item[
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
+ ] +
+ '")].value_cy',
+ transLookup
+ )
+ : item[
+ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
+ ] || "N/A"
+ : ""}
+
+
+
+ {t(
+ "search:searchresults-case-type-label"
+ )}
+ :
+
+ {router.locale == "cy"
+ ? jsonpath(
+ '$..[?(@.value=="' +
+ item[
+ "pinswg_appealType"
+ ] +
+ '")].value_cy',
+ transLookup
+ )
+ : item["pinswg_appealType"] ||
+ "N/A"}
+
+
+
+ {t(
+ "search:searchresults-status-label"
+ )}
+ :
+
+
+ {router.locale == "cy"
+ ? jsonpath(
+ '$..[?(@.value=="' +
+ item[
+ "statuscode@OData.Community.Display.V1.FormattedValue"
+ ] +
+ '")].value_cy',
+ transLookup
+ )
+ : item[
+ "statuscode@OData.Community.Display.V1.FormattedValue"
+ ] || "N/A"}
+
+ {myportal == true && (
+
+ {isWatchedCase(item.incidentid)
+ .length >
+ 0 ==
+ true ? (
+ {
+ confirm(
+ t(
+ "case:you-have-stopped-watching-label"
+ ) +
+ item.pinswg_name +
+ "?"
+ ) &&
+ deleteItem(
+ isWatchedCase(
+ item.incidentid
+ )[0]
+ .pinswg_watchlistid,
+
+ "watchedCases"
+ );
+ }}
+ title={t(
+ "case:stop-watching-case-link"
+ )}
+ >
+
+
+ ) : (
+ {
+ confirm(
+ t(
+ "case:you-are-watching-label"
+ ) +
+ item.pinswg_name +
+ "?"
+ ) &&
+ selectWatchedCase(
+ props
+ .accountDetails
+ .loggedinUserId,
+ item.incidentid,
+ item.pinswg_appealcasetype
+ );
+ }}
+ title={t(
+ "case:watch-this-case-link"
+ )}
+ >
+
+
+ )}
+
+ )}
+
+ {(showLoginCheck == "true" ||
+ showLoginCheck == true) &&
+ !session && (
+
+
+ {t(
+ "case:watch-this-case-link"
+ )}
+
+
+ {
+ confirm(
+ t(
+ "case:trying-to-watch-case-label"
+ ) +
+ item.pinswg_name +
+ "\n\n" +
+ t(
+ "case:trying-to-watch-case-redirect-label"
+ )
+ ) &&
+ // signIn("email");
+ signIn(undefined, {
+ callbackUrl:
+ "/myportal/addresssearchresults?" +
+ new URLSearchParams(
+ searchString
+ ) +
+ "&toWatch=" +
+ item.incidentid +
+ "_" +
+ item.pinswg_appealcasetype,
+ });
+ }}
+ title={t(
+ "case:watch-this-case-link"
+ )}
+ >
+
+
+
+ )}
+
+ );
+ })
+ )}
+
+
+
+ >
+ );
+ };
+
+ const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
+
+ const getSearchPageResults = useCallback(
+ (pageNumber, orderBy, fieldSort) => {
+ // setSearchDetails(data);
+
+ setCurrentPage(pageNumber);
+
+ resultsArr = _.sortBy(resultsArr, [
+ function (o) {
+ return o[orderBy];
+ },
+ ]);
+
+ fieldSort == "desc" && resultsArr.reverse();
+
+ setShowSpinnerState(false);
+ setResultsArr(resultsArr);
+
+ console.log(
+ "================================\n",
+ resultsArr,
+ "sort done",
+ "\n=================================\n"
+ );
+ },
+ []
+ );
+
+ const sortDataBy = (whichField) => {
+ setOrderbyState(whichField);
+ setfieldSortState("asc");
+
+ setShowSpinnerState(true);
+ console.log(
+ "================================\n",
+ "sort start",
+ "\n=================================\n"
+ );
+ getSearchPageResults(1, whichField, fieldSortState);
+ whichField == orderByState
+ ? fieldSortState == "desc"
+ ? setfieldSortState("asc")
+ : setfieldSortState("desc")
+ : setfieldSortState("asc");
+ setCurrentPage(1);
+ };
+
+ useEffect(() => {
+ const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
+ let updateBody = {
+ "pinswg_WatchedCase@odata.bind":
+ "/incidents(" + incidentID + ")",
+ "pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
+ "pinswg_appealcasetype": +appealType,
+ };
+
+ createWatchedCases(updateBody)
+ .then((data) => data)
+ .then(() => {
+ getWatchedCasesProxy(
+ props.accountDetails.loggedinUserId
+ ).then((data) => {
+ setWatchedCases(data),
+ getDetails(data, "myWatchedCases").then((data) => {
+ setWatchedCasesDetails(data);
+ });
+ });
+ });
+ };
+
+ // if (searchLoaded) {
+ // if (selectedOption) {
+ // setShowSpinnerState(true);
+ // getSearchPageResults(1, orderByState, fieldSortState);
+ // }
+ // } else {
+ // setSearchLoaded(true);
+ // }
+ if (loginToWatch && router.query.hasOwnProperty("toWatch")) {
+ console.log("am in here");
+ let now = new Date();
+ let expDate = new Date(now);
+
+ expDate.setDate(now.getDate() + 1);
+
+ setLoggedInUserId(props.accountDetails.loggedinUserId);
+ setCookie(null, "pinsUser", props.accountDetails.loggedinUserId, {
+ path: "/",
+ expires: expDate,
+ });
+ selectWatchedCase(
+ props.accountDetails.loggedinUserId,
+ router.query.toWatch.split("_")[0],
+ router.query.toWatch.split("_")[1]
+ );
+ getSearchPageResults(1, orderByState, fieldSortState);
+ setLoginToWatch(false);
+ } else {
+ //console.log("or am in here");
+ setLoginToWatch(false);
+ }
+ }, [
+ selectedOption,
+ fieldSortState,
+ orderByState,
+ searchLoaded,
+ loginToWatch,
+ setWatchedCases,
+ getSearchPageResults,
+ setWatchedCasesDetails,
+ props.accountDetails.loggedinUserId,
+ router.query,
+ ]);
+
+ return (
+ <>
+
+
+
+ {isLinkedCase
+ ? t("search:searchresults-title-label-linked-case")
+ : t("search:searchresults-title-label")}
+
+
+ {!isLinkedCase && (
+
+ {resultsArr.length > 200
+ ? t("search:searchresults-max-count-label")
+ : t("search:searchresults-count-label", {
+ count: searchResultsObj["@odata.count"],
+ })}
+ .
+ {advancedSearch != true ? (
+ <>
+
+ {t(
+ "search:searchresults-case-count-label"
+ )}{" "}
+ {" "}
+ "{searchString}"
+
+ >
+ ) : (
+ ""
+ )}
+
+ )}
+ {searchResultsObj["@odata.count"] > 5 && (
+
+
+
+ {t(
+ "search:searchresults-show-records-label-a"
+ )}
+ {
+ setSelectedOption(e.target.value);
+ // setCurrentPage(1);
+ }}
+ value={selectedOption}
+ className="govuk-select"
+ id="showNumberOfRecords"
+ name="showNumberOfRecords"
+ >
+ 5
+ 10
+ 20
+ 30
+ 50
+ {" "}
+ {t(
+ "search:searchresults-show-records-label-b"
+ )}
+
+
+
+ )}
+ {resultsArr.length > 0 ? (
+ ResultsView(resultsArr)
+ ) : (
+
+
+
+ {t("search:searchresults-no-records-label")}
+
+
+
+ )}
+
+
+ >
+ );
+};
+
+const mapDispatchToProps = (dispatch) => {
+ return {
+ setCurrentReference: (currentReference) => {
+ dispatch(setCurrentReference(currentReference));
+ },
+ setSearchResults: (searchResultsObj) => {
+ dispatch(setSearchResults(searchResultsObj));
+ },
+ setSearchDetails: (searchDetailsObj) => {
+ dispatch(setSearchDetails(searchDetailsObj));
+ },
+ setWatchedCases: (watchedCases) => {
+ dispatch(setWatchedCases(watchedCases));
+ },
+ setWatchedCasesDetails: (watchedCasesDetails) => {
+ dispatch(setWatchedCasesDetails(watchedCasesDetails));
+ },
+ // setCurrentPage: (currentPage) => {
+ // dispatch(setCurrentPage(currentPage));
+ // },
+ };
+};
+
+const mapStateToProps = (state) => {
+ return {
+ // currentView: state.currentView,
+ accountDetails: state.accountDetails,
+ // search: state.search,
+ // searchResultsObj: state.searchResultsObj,
+ };
+};
+export default connect(mapStateToProps, mapDispatchToProps)(SearchResults);
diff --git a/pages/addresssearch.js b/pages/addresssearch.js
new file mode 100644
index 00000000..cacc729e
--- /dev/null
+++ b/pages/addresssearch.js
@@ -0,0 +1,130 @@
+//import fs from "fs";
+import _ from "lodash";
+import useTranslation from "next-translate/useTranslation";
+import Head from "next/head";
+import { useRouter } from "next/router";
+import { connect } from "react-redux";
+import { getAppealsTypes, getLPA } from "../actions";
+import Breadcrumbs from "../components/breadcrumbs";
+import CookieBanner from "../components/cookieBanner";
+import CRMError from "../components/crmError";
+import Footer from "../components/footer";
+import Header from "../components/header";
+import Search from "../components/addresssearch";
+import { setAppealType } from "../store/appealType/action";
+import { setLPA } from "../store/lpa/action";
+import { wrapper } from "../store/store";
+
+const Home = (props) => {
+ const { footerLinks, pages } = props;
+ let { t, lang } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { appealtypes } = router.query;
+
+ var hasError =
+ _.has(props.LPAData.LPAData, "errorCode") ||
+ _.has(props.appealType.appealType, "errorCode")
+ ? true
+ : false;
+
+ return (
+
+
+
+ {t("search:page-title")} - {t("common:service-name")}
+
+ {/* Language by default is EN, if multilingual site this will need updated */}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+
+
+
+
+
+
+ {hasError ? (
+
+ ) : (
+
+ )}
+
+
+
+
+ );
+};
+
+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,
+ };
+};
+
+export default connect(mapStateToProps)(Home);
diff --git a/pages/addresssearchresults.js b/pages/addresssearchresults.js
new file mode 100644
index 00000000..179c94cf
--- /dev/null
+++ b/pages/addresssearchresults.js
@@ -0,0 +1,160 @@
+import useTranslation from "next-translate/useTranslation";
+import Head from "next/head";
+import { useRouter } from "next/router";
+import { connect } from "react-redux";
+import {
+ getAddressSearch,
+ getIncidentbyID,
+ getIsPublishedbyID,
+} from "../actions";
+import Breadcrumbs from "../components/breadcrumbs";
+import CookieBanner from "../components/cookieBanner";
+import Footer from "../components/footer";
+import Header from "../components/header";
+import SearchResults from "../components/addresssearchresults";
+import { getSearchDetails } from "../components/utils";
+import { setSearch } from "../store/search/action";
+import {
+ setSearchDetails,
+ setSearchResults,
+} from "../store/searchOutput/action";
+import { setShowReps } from "../store/currentView/action";
+
+import { wrapper } from "../store/store";
+
+const Home = (props) => {
+ const { footerLinks, pages } = props;
+ let { t, lang } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { appealtypes } = router.query;
+
+ return (
+
+
+
+ {t("search:page-title")} - {t("common:service-name")}
+
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+
+
+
+ );
+};
+
+export const getServerSideProps = wrapper.getServerSideProps(
+ (store) =>
+ async ({ query, req, res }) => {
+ const searchResultsObj = await getAddressSearch(query);
+ const searchDetailsObj = searchResultsObj;
+ const showLoginCheck = process.env.SHOWLOGIN || false;
+ const showReps = process.env.SHOWREPRESENTATIONS || false;
+ store.dispatch(setShowReps(showReps, showLoginCheck));
+
+ // store.dispatch(setSearchResults(searchResultsObj));
+ // store.dispatch(setSearchDetails(searchDetailsObj));
+ store.dispatch(setSearch(Object.entries(query)));
+
+ return {
+ props: {
+ searchResultsObj: {
+ searchResultsObj: searchResultsObj,
+ searchDetailsObj: searchDetailsObj,
+ },
+ currentType: "directResultsObj",
+ showLoginCheck: showLoginCheck,
+ },
+ };
+ }
+);
+
+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);
diff --git a/pages/case/id/[incident].js b/pages/case/id/[incident].js
new file mode 100644
index 00000000..648cbb92
--- /dev/null
+++ b/pages/case/id/[incident].js
@@ -0,0 +1,221 @@
+import useTranslation from "next-translate/useTranslation";
+import Head from "next/head";
+import { useRouter } from "next/router";
+import { connect } from "react-redux";
+import {
+ getBasicSearch,
+ getIncidentbyID,
+ getIP,
+ getPortalLogin,
+ getPersonalAccount,
+} from "../../../actions";
+import CookieBanner from "../../../components/cookieBanner";
+import Footer from "../../../components/footer";
+import Header from "../../../components/header";
+import { getSearchDetails } from "../../../components/utils";
+import { setCurrentReference } from "../../../store/currentView/action";
+import { setSearch } from "../../../store/search/action";
+import {
+ setSearchDetails,
+ setSearchResults,
+} from "../../../store/searchOutput/action";
+import { wrapper } from "../../../store/store";
+import Case from "../../../components/case";
+import Breadcrumbs from "../../../components/breadcrumbs";
+import { getSession, useSession } from "next-auth/react";
+import {
+ setAccountDetails,
+ setContainerID,
+ setLoggedInUserId,
+} from "../../../store/accountDetails/action";
+
+const CaseHome = (props) => {
+ const { footerLinks, pages } = props;
+ let { t, lang } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { incident } = router.query;
+
+ return (
+
+
+
+ Reference:{" "}
+ {props.currentView.caseReference.currentReference}{" "}
+
+
+
+
+ );
+};
+
+export const getServerSideProps = wrapper.getServerSideProps(
+ (store) => async (ctx) => {
+ const { query, req, res } = ctx;
+ getIP(req);
+ const { cookies } = req;
+
+ console.log(cookies);
+ console.log("the query :", query.incident);
+
+ let thisSession = await getSession(ctx);
+ let loggedInUser = {};
+
+ if (thisSession) {
+ console.log(" has sesssion.......");
+ [loggedInUser] = await Promise.all([
+ await getPortalLogin(thisSession.user.email),
+ ]);
+
+ loggedInUser = loggedInUser.value[0].contactid;
+
+ const accountDetails = await getPersonalAccount(loggedInUser);
+ store.dispatch(setAccountDetails(accountDetails));
+ } else {
+ console.log("not has sesssion.......");
+ }
+
+ const searchResultsObj = await getIncidentbyID(query.incident);
+ const searchDetailsObj = await getSearchDetails(searchResultsObj);
+
+ // console.log(
+ // "\n======================================\n",
+ // searchResultsObj,
+ // "\n======================================\n"
+ // );
+ // console.log(
+ // "\n======================================\n",
+ // searchDetailsObj[0],
+ // "\n======================================\n"
+ // );
+
+ store.dispatch(setSearch(req.headers.referer.split("?")[1]));
+
+ console.log(
+ searchResultsObj["@odata.count"] > 1 ||
+ searchResultsObj["@odata.count"] < 1
+ );
+
+ if (searchResultsObj["@odata.count"] < 1) {
+ return {
+ redirect: {
+ destination: "/404",
+ permanent: false,
+ },
+ };
+ } else {
+ if (searchResultsObj["@odata.count"] > 1) {
+ return {
+ redirect: {
+ //destination: "/dns-not-found",
+ destination: "/404",
+ permanent: false,
+ },
+ };
+ } else {
+ store.dispatch(
+ setCurrentReference({
+ "ticketnumber": searchResultsObj.value[0].ticketnumber,
+ "currentReference": searchResultsObj.value[0].title,
+ "currentType": "searchResultsObj",
+ "incidentid": searchResultsObj.value[0].incidentid,
+ "appealType":
+ searchResultsObj.value[0].pinswg_appealcasetype,
+ })
+ );
+ }
+ }
+ // console.log(searchResultsObj);
+ return {
+ props: {
+ searchResultsObj: {
+ searchResultsObj: searchResultsObj,
+ searchDetailsObj: searchDetailsObj,
+ },
+ currentType: "directResultsObj",
+ },
+ };
+ }
+);
+
+const mapStateToProps = (state) => {
+ return {
+ accountDetails: state.accountDetails,
+ currentView: state.currentView,
+ search: state.search,
+ //searchResultsObj: state.searchResultsObj,
+ documentDetailsObj: state.searchResultsObj.documentDetailsObj,
+ formData: state.formData,
+ appealType: state.appealType,
+ form: state.form,
+ myCases: state.myCases,
+ watchedCases: state.watchedCases,
+ myRepresentations: state.myRepresentations,
+ awaitingSubmission: state.awaitingSubmission,
+ };
+};
+
+const mapDispatchToProps = (dispatch) => {
+ return {
+ setCurrentReference: (currentReference) => {
+ dispatch(setCurrentReference(refno));
+ },
+ };
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(CaseHome);
diff --git a/pages/myportal/addresssearch.js b/pages/myportal/addresssearch.js
new file mode 100644
index 00000000..98470239
--- /dev/null
+++ b/pages/myportal/addresssearch.js
@@ -0,0 +1,129 @@
+//import fs from "fs";
+import _ from "lodash";
+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 CookieBanner from "../../components/cookieBanner";
+import CRMError from "../../components/crmError";
+import Footer from "../../components/footer";
+import Header from "../../components/header";
+import Search from "../../components/myportal/addresssearch";
+import { setAppealType } from "../../store/appealType/action";
+import { setLPA } from "../../store/lpa/action";
+import { wrapper } from "../../store/store";
+
+const Home = (props) => {
+ const { footerLinks, pages } = props;
+ let { t, lang } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { appealtypes } = router.query;
+
+ var hasError =
+ _.has(props.LPAData.LPAData, "errorCode") ||
+ _.has(props.appealType.appealType, "errorCode")
+ ? true
+ : false;
+
+ return (
+
+
+
+ {t("search:page-title")} - {t("common:service-name")}
+
+ {/* Language by default is EN, if multilingual site this will need updated */}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+
+
+
+
+
+
+ {hasError ? (
+
+ ) : (
+
+ )}
+
+
+
+
+ );
+};
+
+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,
+ };
+};
+
+export default connect(mapStateToProps)(Home);
diff --git a/pages/myportal/addresssearchresults.js b/pages/myportal/addresssearchresults.js
new file mode 100644
index 00000000..1e209d8b
--- /dev/null
+++ b/pages/myportal/addresssearchresults.js
@@ -0,0 +1,249 @@
+import useTranslation from "next-translate/useTranslation";
+import Head from "next/head";
+import { useRouter } from "next/router";
+import { connect } from "react-redux";
+import {
+ getAddressSearch,
+ getIncidentbyID,
+ getIsPublishedbyID,
+ getAdvancedSearch,
+ getPortalModuleDetails,
+ getWatchedCases,
+ getPersonalAccount,
+ getIP,
+} from "../../actions";
+import Breadcrumbs from "../../components/breadcrumbs";
+import CookieBanner from "../../components/cookieBanner";
+import Footer from "../../components/footer";
+import Header from "../../components/header";
+import SearchResults from "../../components/addresssearchresults";
+import {
+ getFormCollectionByID,
+ getSearchDetails,
+} from "../../components/utils";
+import { setSearch } from "../../store/search/action";
+import {
+ setSearchDetails,
+ setSearchResults,
+} from "../../store/searchOutput/action";
+import {
+ setAccountDetails,
+ setContainerID,
+ setLoggedInUserId,
+} from "../../store/accountDetails/action";
+import { setShowReps } from "../../store/currentView/action";
+import TimeOut from "../../components/timeout";
+import {
+ setWatchedCases,
+ setWatchedCasesDetails,
+} from "../../store/watchedCases/action";
+import { getSession, useSession, signIn, signOut } from "next-auth/react";
+
+import { wrapper } from "../../store/store";
+
+const Home = (props) => {
+ const { footerLinks, pages } = props;
+ let { t, lang } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { appealtypes } = router.query;
+
+ return (
+
+
+
+ {t("search:page-title")} - {t("common:service-name")}
+
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+
+
+
+ );
+};
+
+export const getServerSideProps = wrapper.getServerSideProps(
+ (store) => async (ctx) => {
+ const { query, req, res } = ctx;
+ getIP(req);
+ const searchResultsObj = await getAddressSearch(query);
+ const searchDetailsObj = searchResultsObj;
+ const showLoginCheck = process.env.SHOWLOGIN || false;
+ const showReps = process.env.SHOWREPRESENTATIONS || false;
+ store.dispatch(setShowReps(showReps, showLoginCheck));
+ store.dispatch(setSearch(Object.entries(query)));
+
+ const { cookies } = req;
+
+ let loggedInUser = cookies.pinsUser;
+ let thisSession = await getSession(ctx);
+
+ if (!thisSession) {
+ console.log("not has sesssion.......");
+ return {
+ redirect: {
+ destination: "/auth/signin",
+ permanent: false,
+ },
+ };
+ } else {
+ thisSession != false &&
+ store.dispatch(setContainerID(thisSession.user.id));
+
+ const [accountDetails, searchResultsObj, watchedCases] =
+ await Promise.all([
+ await getPersonalAccount(loggedInUser),
+ await getAdvancedSearch(query),
+ await getWatchedCases(loggedInUser),
+ ]);
+
+ console.log(accountDetails);
+
+ const [searchDetailsObj, watchedCasesDetails] = await Promise.all([
+ await getSearchDetails(searchResultsObj),
+ await getDetails(watchedCases, "myWatchedCases"),
+ ]);
+
+ store.dispatch(setAccountDetails(accountDetails));
+ store.dispatch(setSearchResults(searchResultsObj));
+ store.dispatch(setSearchDetails(searchDetailsObj));
+ store.dispatch(setWatchedCases(watchedCases));
+ store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
+ store.dispatch(setSearch(Object.entries(query)));
+ }
+
+ return {
+ props: {
+ searchResultsObj: {
+ searchResultsObj: searchResultsObj,
+ searchDetailsObj: searchDetailsObj,
+ },
+ currentType: "directResultsObj",
+ showLoginCheck: showLoginCheck,
+ },
+ };
+ }
+);
+
+const getDetails = (resultsObj, detailsType) => {
+ //console.log(resultsObj);
+ let detailsArr = [];
+ resultsObj = resultsObj.value;
+ const detailsObj = resultsObj.map((searchDetail, index) => {
+ if (searchDetail.pinswg_appealcasetype == null) {
+ console.log(
+ detailsType != "myWatchedCases"
+ ? searchDetail.ticketnumber
+ : searchDetail[
+ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ );
+ } else {
+ detailsArr.push(
+ getPortalModuleDetails(
+ getFormCollectionByID(searchDetail.pinswg_appealcasetype)
+ .LogicalCollectionName,
+ detailsType != "myWatchedCases"
+ ? searchDetail.ticketnumber
+ : searchDetail[
+ "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ )
+ );
+ }
+ });
+ //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);
diff --git a/pages/myportal/case/id/[incident].js b/pages/myportal/case/id/[incident].js
new file mode 100644
index 00000000..6ef2878c
--- /dev/null
+++ b/pages/myportal/case/id/[incident].js
@@ -0,0 +1,216 @@
+import useTranslation from "next-translate/useTranslation";
+import Head from "next/head";
+import { useRouter } from "next/router";
+import { connect } from "react-redux";
+import {
+ getBasicSearch,
+ getIncidentbyID,
+ getIP,
+ getPortalLogin,
+ getPersonalAccount,
+} from "../../../../actions";
+import CookieBanner from "../../../../components/cookieBanner";
+import Footer from "../../../../components/footer";
+import Header from "../../../../components/header";
+import { getSearchDetails } from "../../../../components/utils";
+import { setCurrentReference } from "../../../../store/currentView/action";
+import { setSearch } from "../../../../store/search/action";
+import {
+ setSearchDetails,
+ setSearchResults,
+} from "../../../../store/searchOutput/action";
+import { wrapper } from "../../../../store/store";
+import Case from "../../../../components/case";
+import Breadcrumbs from "../../../../components/breadcrumbs";
+import { getSession, useSession } from "next-auth/react";
+import {
+ setAccountDetails,
+ setContainerID,
+ setLoggedInUserId,
+} from "../../../../store/accountDetails/action";
+
+const CaseHome = (props) => {
+ const { footerLinks, pages } = props;
+ let { t, lang } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+ const { incident } = router.query;
+
+ return (
+
+
+
+ Reference:{" "}
+ {props.currentView.caseReference.currentReference}{" "}
+
+
+
+
+ );
+};
+
+export const getServerSideProps = wrapper.getServerSideProps(
+ (store) => async (ctx) => {
+ const { query, req, res } = ctx;
+ getIP(req);
+ const { cookies } = req;
+
+ console.log(cookies);
+ console.log("the query :", query.incident);
+
+ let thisSession = await getSession(ctx);
+ let loggedInUser = {};
+
+ if (thisSession) {
+ console.log(" has sesssion.......");
+ [loggedInUser] = await Promise.all([
+ await getPortalLogin(thisSession.user.email),
+ ]);
+
+ loggedInUser = loggedInUser.value[0].contactid;
+
+ const accountDetails = await getPersonalAccount(loggedInUser);
+ store.dispatch(setAccountDetails(accountDetails));
+ } else {
+ console.log("not has sesssion.......");
+ }
+
+ const searchResultsObj = await getIncidentbyID(query.incident);
+ const searchDetailsObj = await getSearchDetails(searchResultsObj);
+
+ // console.log(
+ // "\n======================================\n",
+ // searchResultsObj,
+ // "\n======================================\n"
+ // );
+ // console.log(
+ // "\n======================================\n",
+ // searchDetailsObj[0],
+ // "\n======================================\n"
+ // );
+
+ store.dispatch(setSearch(req.headers.referer.split("?")[1]));
+
+ if (searchResultsObj["@odata.count"] < 1) {
+ return {
+ redirect: {
+ destination: "/404",
+ permanent: false,
+ },
+ };
+ } else {
+ if (searchResultsObj["@odata.count"] > 1) {
+ return {
+ redirect: {
+ //destination: "/dns-not-found",
+ destination: "/404",
+ permanent: false,
+ },
+ };
+ } else {
+ store.dispatch(
+ setCurrentReference({
+ "ticketnumber": searchResultsObj.value[0].ticketnumber,
+ "currentReference": searchResultsObj.value[0].title,
+ "currentType": "searchResultsObj",
+ "incidentid": searchResultsObj.value[0].incidentid,
+ "appealType":
+ searchResultsObj.value[0].pinswg_appealcasetype,
+ })
+ );
+ }
+ }
+ // console.log(searchResultsObj);
+ return {
+ props: {
+ searchResultsObj: {
+ searchResultsObj: searchResultsObj,
+ searchDetailsObj: searchDetailsObj,
+ },
+ currentType: "directResultsObj",
+ },
+ };
+ }
+);
+
+const mapStateToProps = (state) => {
+ return {
+ accountDetails: state.accountDetails,
+ currentView: state.currentView,
+ search: state.search,
+ //searchResultsObj: state.searchResultsObj,
+ documentDetailsObj: state.searchResultsObj.documentDetailsObj,
+ formData: state.formData,
+ appealType: state.appealType,
+ form: state.form,
+ myCases: state.myCases,
+ watchedCases: state.watchedCases,
+ myRepresentations: state.myRepresentations,
+ awaitingSubmission: state.awaitingSubmission,
+ };
+};
+
+const mapDispatchToProps = (dispatch) => {
+ return {
+ setCurrentReference: (currentReference) => {
+ dispatch(setCurrentReference(refno));
+ },
+ };
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(CaseHome);