diff --git a/actions/index.js b/actions/index.js
index a5c11e14..8e9d0c3f 100644
--- a/actions/index.js
+++ b/actions/index.js
@@ -137,9 +137,11 @@ export const getBasicSearch = (token, searchString) => {
return axios
.get(
WEBAPI_URL +
- "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" +
+ "incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
- "') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
+ "') or contains(ticketnumber, '" +
+ searchString +
+ "')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
azureHeadersPaged(token)
)
.then((res) => {
@@ -163,9 +165,11 @@ export const getBasicSearchPaged = (searchString, pageNumber) => {
console.log(typeof pageNumber != "undefined");
return axios
.get(
- "/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" +
+ "/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
- "') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
+ "') or contains(ticketnumber, '" +
+ searchString +
+ "')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI(' ')
@@ -218,13 +222,17 @@ export const getBasicDNSSearchPaged = (pageNumber) => {
};
export const getAdvancedSearch = (token, searchString) => {
- //console.log(searchString.caseReference);
+ console.log(searchString.caseReference);
var queryString = "";
queryString +=
searchString.q != null
- ? "contains(title, '" + searchString.q + "') "
+ ? "(contains(title, '" +
+ searchString.q +
+ "') or contains(ticketnumber,'" +
+ searchString.q +
+ "'))"
: "";
queryString +=
@@ -248,7 +256,7 @@ export const getAdvancedSearch = (token, searchString) => {
WEBAPI_URL +
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
- " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201",
+ " and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
azureHeadersPaged(token)
)
@@ -265,14 +273,18 @@ export const getAdvancedSearch = (token, searchString) => {
};
export const getAdvancedSearchPaged = (searchString, pageNumber) => {
- console.log(searchString);
+ //console.log(searchString);
var token = getSASToken();
var queryString = "";
queryString +=
searchString.q != null
- ? "contains(title, '" + searchString.q + "') "
+ ? "(contains(title, '" +
+ searchString.q +
+ "') or contains(ticketnumber,'" +
+ searchString.q +
+ "'))"
: "";
queryString +=
@@ -373,7 +385,7 @@ export const getSearchDocumentDetails = (token, incidentID) => {
"pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference",
- azureHeaders(token)
+ azureHeadersPaged(token)
)
.then((res) => res.data)
.catch((error) => {
@@ -387,7 +399,47 @@ export const getSearchDocumentHistory = (token, documentID) => {
WEBAPI_URL +
"pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID,
- azureHeaders(token)
+ azureHeadersPaged(token)
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
+
+export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
+ console.log(incidentID);
+ var token = getSASToken();
+
+ return axios
+ .get(
+ "/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
+ incidentID +
+ " and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
+ (typeof pageNumber != "undefined"
+ ? "&$skiptoken=" +
+ encodeURI(' ')
+ : ""),
+ azureHeadersPaged(token)
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
+
+export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
+ var token = getSASToken();
+
+ return axios
+ .get(
+ "/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
+ documentID +
+ (typeof pageNumber != "undefined"
+ ? "&$skiptoken=" +
+ encodeURI(' ')
+ : ""),
+ azureHeadersPaged(token)
)
.then((res) => res.data)
.catch((error) => {
@@ -409,9 +461,27 @@ export const getSearchDocumentDetails1 = (incidentID) => {
console.log("thiserror", error);
});
};
+export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
+ //console.log(incidentID);
+ var token = getSASToken();
+ return axios
+ .get(
+ "/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
+ incidentID +
+ "&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
+ (typeof pageNumber != "undefined"
+ ? "&$skiptoken=" +
+ encodeURI(' ')
+ : "")
+ )
+ .then((res) => res.data)
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
export const getSearchDocumentHistory1 = (documentID) => {
- // console.log(documentID);
+ //console.log(documentID);
var token = getSASToken();
return axios
.get(
@@ -426,6 +496,26 @@ export const getSearchDocumentHistory1 = (documentID) => {
});
};
+export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => {
+ //console.log(documentID);
+ var token = getSASToken();
+ return axios
+ .get(
+ "/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
+ documentID +
+ (typeof pageNumber != "undefined"
+ ? "&$skiptoken=" +
+ encodeURI(' ')
+ : "")
+ )
+ .then((res) => {
+ return res.data;
+ })
+ .catch((error) => {
+ console.log("thiserror", error);
+ });
+};
+
export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
return axios
.get(
diff --git a/components/case/documents.js b/components/case/documents.js
index 181882fc..0b6c5226 100644
--- a/components/case/documents.js
+++ b/components/case/documents.js
@@ -5,12 +5,16 @@ import jsonpath from "jsonpath";
import { useState, useEffect, useRef } from "react";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import transLookup from "../../data/lookuptranslations.json";
+import PaginationControl from "./pagination";
+import LoadingOverlay from "react-loading-overlay";
import {
getBasicSearch,
getBasicSearchDetails,
getSearchDocumentDetails1,
getSearchDocumentHistory1,
+ getSearchDocumentHistory1Paged,
+ getSearchDocumentDetails1Paged,
getSASToken,
} from "../../actions";
@@ -45,123 +49,141 @@ const DocumentDetails = (props) => {
//console.log(documentDetailsArr);
documentDetailsArr = documentDetailsArr.value;
-
return (
-
-
-
- {t("case:documents-name-label")}
-
-
- {t("case:documents-doc-type-label")}
-
-
- {t("case:documents-date-published-label")}
-
- {/*
+ <>
+
+ {t("case:documents-count-label-1")}{" "}
+ {documentDetailsObj["@odata.count"]}{" "}
+ {t("case:documents-count-label-2")}
+
+
+
+
+ {t("case:documents-name-label")}
+
+
+ {t("case:documents-doc-type-label")}
+
+
+ {t("case:documents-date-published-label")}
+
+ {/*
{t("case:documents-size-label")}
*/}
-
+
- {documentDetailsArr.map((item) => {
- let detailsObj = jsonpath.query(
- item,
- "$..[?(@._pinswg_documentids_value=='" +
- incidentid +
- "')]"
- );
- detailsObj = item;
+ {documentDetailsArr.map((item) => {
+ let detailsObj = jsonpath.query(
+ item,
+ "$..[?(@._pinswg_documentids_value=='" +
+ incidentid +
+ "')]"
+ );
+ detailsObj = item;
- if (typeof detailsObj != "undefined") {
- var documentHistoryArr = documentHistoryObj || [];
- return documentHistoryArr.map((historyItem, key) => {
- let historyObj = jsonpath.query(
- documentHistoryObj[key],
- "$..value[?(@._pinswg_documentid_value=='" +
- detailsObj.pinswg_documentid +
- "')]"
- );
+ if (typeof detailsObj != "undefined") {
+ var documentHistoryArr = documentHistoryObj || [];
+ return documentHistoryArr.map(
+ (historyItem, key) => {
+ let historyObj = jsonpath.query(
+ documentHistoryObj[key],
+ "$..value[?(@._pinswg_documentid_value=='" +
+ detailsObj.pinswg_documentid +
+ "')]"
+ );
- historyObj = historyObj[0];
- return !_.isEmpty(historyObj) ? (
-
-
-
-
- {t("case:documents-name-label")}
- :
-
- {_.has(historyObj, [
- "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue",
- ])
- ? historyObj[
- "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue"
- ]
- : ""}
-
-
-
-
- {t("case:documents-doc-type-label")}
- :
-
+
+
+
+ {t(
+ "case:documents-name-label"
+ )}
+ :
+
+ {_.has(historyObj, [
+ "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? historyObj[
+ "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue"
+ ]
+ : ""}
+
+
+
+
+ {t(
+ "case:documents-doc-type-label"
+ )}
+ :
+
- {router.locale == "cy"
- ? jsonpath.query(
- transLookup,
- '$..[?(@.value=="' +
- detailsObj[
+ {router.locale == "cy"
+ ? jsonpath.query(
+ transLookup,
+ '$..[?(@.value=="' +
+ detailsObj[
+ "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue"
+ ] +
+ '")].value_cy'
+ )
+ : detailsObj[
"pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue"
- ] +
- '")].value_cy'
- )
- : detailsObj[
- "pinswg_isharedocumentlocations@OData.Community.Display.V1.FormattedValue"
- ] ||
- t(
- "case:summary-no-date-entered-label"
- )}
-
-
-
- {t(
- "case:documents-date-published-label"
- )}
- :
-
+ ] ||
+ t(
+ "case:summary-no-date-entered-label"
+ )}
+
+
+
+ {t(
+ "case:documents-date-published-label"
+ )}
+ :
+
- {_.has(historyObj, [
- "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue",
- ])
- ? formatDates(
- historyObj[
- "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue"
- ]
- )
- : ""}
-
- {/*
+ {_.has(historyObj, [
+ "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue",
+ ])
+ ? formatDates(
+ historyObj[
+ "pinswg_publisheddate@OData.Community.Display.V1.FormattedValue"
+ ]
+ )
+ : ""}
+
+ {/*
{t("case:documents-size-label")}:
92
*/}
-
- ) : (
- ""
+
+ ) : (
+ ""
+ );
+ }
);
- });
- }
- })}
-
+ }
+ })}
+
+
+ >
);
};
@@ -177,6 +199,8 @@ const DocumentDetails = (props) => {
let historyObj = getDocumentHistory(data.value).then(
(result) => {
setDocumentHistory(result);
+ setDocumentSearchState(true);
+
return result;
}
);
@@ -206,10 +230,72 @@ const DocumentDetails = (props) => {
);
return Promise.all(historyArr);
};
-
const searchDocumentResultsObj = docDetailsObj();
}, [incidentid, setDocumentHistory, setDocumentDetails]);
+ const getDocumentResults = (pageNumber) => {
+ //console.log(advancedSearch, searchString, pageNumber);
+ getSearchDocumentDetails1Paged(incidentid, pageNumber)
+ .then((data) => {
+ //console.log(data);
+ setDocumentDetails(data);
+ return data;
+ })
+ .then((data) => {
+ //console.log("getting details", data);
+ return getDocumentHistory(data.value).then((data) => {
+ setDocumentHistory(data);
+ setShowSpinnerState(false);
+ });
+ });
+ };
+
+ const getDocumentDetails = async () => {
+ let docObj = await getSearchDocumentDetails1Paged(
+ incidentid,
+ pageNumber
+ )
+ .then((data) => {
+ //console.log(data);
+ setDocumentDetails(data);
+ return data;
+ })
+ .then((data) => {
+ let historyObj = getDocumentHistory(
+ data.value,
+ pageNumber
+ ).then((result) => {
+ setDocumentHistory(result);
+ return result;
+ });
+
+ return data;
+ });
+
+ return docObj;
+ };
+
+ const getDocumentHistory = async (searchDocumentDetailsObj, pageNumber) => {
+ let historyArr = [];
+ searchDocumentDetailsObj = searchDocumentDetailsObj || [];
+
+ const detailsObj = searchDocumentDetailsObj.map(
+ (historyDetail, index) => {
+ if (historyDetail.pinswg_publishtoweb != true) {
+ console.log(historyDetail.pinswg_documentid);
+ } else {
+ historyArr.push(
+ getSearchDocumentHistory1Paged(
+ historyDetail.pinswg_documentid,
+ pageNumber
+ )
+ );
+ }
+ }
+ );
+ return Promise.all(historyArr);
+ };
+
function formatDates(dateObj) {
var dateObj = new Date(dateObj);
var dd = String(dateObj.getDate()).padStart(2, "0");
@@ -219,25 +305,73 @@ const DocumentDetails = (props) => {
return dd + "/" + mm + "/" + yyyy;
}
+ const pagesCount = Math.ceil(documentDetailsObj["@odata.count"] / 10);
+
+ let currentPage = 0;
+
+ currentPage = decodeURI(documentDetailsObj["@odata.nextLink"]).split(
+ "skiptoken="
+ )[1];
+ currentPage =
+ typeof currentPage != "undefined"
+ ? parseInt(
+ decodeURI(currentPage)
+ .split('pagenumber="')[1]
+ .slice(
+ 0,
+ decodeURI(currentPage)
+ .split('pagenumber="')[1]
+ .indexOf('"')
+ ) - 1
+ )
+ : pagesCount;
+
+ const [showSpinnerState, setShowSpinnerState] = useState(false);
+
+ let spinnerState = () => {
+ showSpinnerState == true
+ ? setShowSpinnerState(false)
+ : setShowSpinnerState(true);
+ };
+
+ const [showDocumentSearchState, setDocumentSearchState] = useState(false);
+
+ let documentSearchState = () => {
+ showDocumentSearchState == true
+ ? setDocumentSearchState(false)
+ : setDocumentSearchState(true);
+ };
+
return (
-
-
-
-
{t("case:documents-heading-label")}
- {_.isEmpty(documentHistoryObj) ? (
-
-
-
- {t("case:documents-non-available-label")}
-
+ <>
+
+
+
+
{t("case:documents-heading-label")}
+ {_.isEmpty(documentHistoryObj) ? (
+
+
+
+ {showDocumentSearchState == false
+ ? t("case:documents-checking-label")
+ : t(
+ "case:documents-non-available-label"
+ )}
+
+
-
- ) : (
- DocumentView(documentDetailsArr)
- )}
+ ) : (
+ DocumentView(documentDetailsArr)
+ )}
+
-
+
+ >
);
};
diff --git a/components/case/pagination.js b/components/case/pagination.js
new file mode 100644
index 00000000..4d2a6600
--- /dev/null
+++ b/components/case/pagination.js
@@ -0,0 +1,155 @@
+import Link from "next/link";
+import { useRouter } from "next/router";
+import useTranslation from "next-translate/useTranslation";
+
+const PaginationControl = (props) => {
+ const {
+ searchString,
+ searchResultsObj,
+ currentPage,
+ spinnerState,
+ getDocumentResults,
+ } = props;
+ let { t } = useTranslation();
+
+ const router = useRouter();
+ const { locale } = router;
+
+ const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
+
+ const getRange = (start, end) => {
+ //console.log(start, end);
+ return Array(end - start + 1)
+ .fill()
+ .map((v, i) => i + start);
+ };
+
+ const paginationNumbers = (currentPage, pageCount) => {
+ //console.log(currentPage);
+ let delta;
+ if (pageCount <= 10) {
+ // delta === 7: [1 2 3 4 5 6 7]
+ delta = 10;
+ } else {
+ // delta === 2: [1 ... 4 5 6 ... 10]
+ // delta === 4: [1 2 3 4 5 ... 10]
+ delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 6;
+ }
+
+ const range = {
+ start: Math.round(currentPage - delta / 2),
+ end: Math.round(currentPage + delta / 2),
+ };
+
+ if (range.start - 1 === 1 || range.end + 1 === pageCount) {
+ range.start += 1;
+ range.end += 1;
+ }
+
+ let pages =
+ currentPage > delta
+ ? getRange(
+ Math.min(range.start, pageCount - delta),
+ Math.min(range.end, pageCount)
+ )
+ : getRange(1, Math.min(pageCount, delta + 1));
+
+ const withDots = (value, pair) =>
+ pages.length + 1 !== pageCount ? pair : [value];
+
+ if (pages[0] !== 1) {
+ pages = withDots(1, [1, "..."]).concat(pages);
+ }
+
+ if (pages[pages.length - 1] < pageCount) {
+ pages = pages.concat(withDots(pageCount, ["...", pageCount]));
+ }
+
+ //console.log(pages);
+ return pages;
+ };
+
+ const paginationArray = paginationNumbers(currentPage, pagesCount);
+
+ return (
+ <>
+ {" "}
+
+
+
+ {currentPage != 1 ? (
+ {
+ spinnerState(),
+ getDocumentResults(currentPage - 1);
+ }}
+ >
+ {t("common:previous-link-button")}
+
+ ) : (
+
+ {t("common:previous-link-button")}
+
+ )}
+
+
+ {paginationArray.map((e, i) =>
+ currentPage == i + 1 ? (
+
+ {e}
+
+ ) : e == "..." ? (
+
+ {e}
+
+ ) : (
+ {
+ spinnerState();
+ console.log(i + 1);
+ getDocumentResults(i + 1);
+ }}
+ >
+ {e}
+
+ )
+ )}
+
+
+ {currentPage != pagesCount ? (
+ {
+ spinnerState(),
+ getDocumentResults(currentPage + 1);
+ }}
+ >
+ {t("common:next-link-button")}
+
+ ) : (
+
+ {" "}
+ {t("common:next-link-button")}
+
+ )}
+
+
+
+ {t("common:pages-label")} {currentPage}{" "}
+ {t("common:of-label")} {pagesCount}
+
+
+ >
+ );
+};
+
+export default PaginationControl;
diff --git a/components/homepage/login.js b/components/homepage/login.js
index 09c9b6a6..5f08265e 100644
--- a/components/homepage/login.js
+++ b/components/homepage/login.js
@@ -198,7 +198,13 @@ let Login = (props) => {
{t("home:login-card-register-label")}{" "}
-
+
{t("home:login-card-register-link")}
diff --git a/components/main.js b/components/main.js
index 50a6c56f..0e6f53dd 100644
--- a/components/main.js
+++ b/components/main.js
@@ -28,8 +28,8 @@ export default function Home({ children, pages }) {
- {/*
-
*/}
+
+ {/*}
*/}
diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js
index 9cb171c0..1b4be97f 100644
--- a/components/search/advancedsearch.js
+++ b/components/search/advancedsearch.js
@@ -218,19 +218,6 @@ let AdvancedSearch = (props) => {
const required = (value) => (value ? undefined : "Required");
- const getFormCollection = (formtype) => {
- formtype =
- "pinswg_" +
- (formtype.length > 39 ? formtype.slice(0, 39) : formtype);
-
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')].UrlName"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
- };
-
const [showSpinnerState, setShowSpinnerState] = useState(false);
let spinnerState = () => {
@@ -243,15 +230,6 @@ let AdvancedSearch = (props) => {
event.preventDefault();
spinnerState();
- //console.log(values);
- // var appTypeCollection = values.appealTypes.split(",")[1];
-
- // appTypeCollection = getFormCollection(
- // appTypeCollection.length > 39
- // ? appTypeCollection.slice(0, 39)
- // : appTypeCollection
- // );
-
var searchString = "";
searchString += values.caseRef != null ? "?q=" + values.caseRef : "";
diff --git a/components/search/dnssearchresults.js b/components/search/dnssearchresults.js
index 791ba788..3d330650 100644
--- a/components/search/dnssearchresults.js
+++ b/components/search/dnssearchresults.js
@@ -19,6 +19,7 @@ import {
setSearchResults,
setSearchDetails,
} from "../../store/searchOutput/action";
+import { getSearchDetailsPaged } from "../utils";
const DNSSearchResults = (props) => {
const {
@@ -250,66 +251,23 @@ const DNSSearchResults = (props) => {
: pagesCount;
const getSearchPageResults = (pageNumber) => {
- console.log(advancedSearch, searchString, pageNumber);
+ //console.log(advancedSearch, searchString, pageNumber);
getBasicDNSSearchPaged(pageNumber)
.then((data) => {
- console.log(data);
+ //console.log(data);
setSearchResults(data);
return data;
})
.then((data) => {
- console.log("getting details", data);
- return getSearchDetails(data).then((data) => {
+ //console.log("getting details", data);
+ return getSearchDetailsPaged(data).then((data) => {
setSearchDetails(data);
setShowSpinnerState(false);
});
});
};
- const getSearchDetails = (searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- //console.log("search results", searchResultsObj);
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- //console.log(searchDetail);
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.title);
- } else {
- let formMeta = getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- );
-
- detailsArr.push(
- getBasicSearchDetailsPaged(
- formMeta.LogicalCollectionName,
- searchDetail.title,
- formMeta.PrimaryIdAttribute,
- searchDetail.incidentid
- )
- );
- }
- });
- // console.log(detailsArr);
- return Promise.all(detailsArr);
- };
-
- const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')]"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
- };
return (
<>
diff --git a/components/search/pagination.js b/components/search/pagination.js
index cc6e91e5..a2b1297c 100644
--- a/components/search/pagination.js
+++ b/components/search/pagination.js
@@ -15,17 +15,17 @@ const PaginationControl = (props) => {
const router = useRouter();
const { locale } = router;
- const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
+ const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 5);
const getRange = (start, end) => {
- console.log(start, end);
+ //console.log(start, end);
return Array(end - start + 1)
.fill()
.map((v, i) => i + start);
};
const paginationNumbers = (currentPage, pageCount) => {
- console.log(currentPage);
+ //console.log(currentPage);
let delta;
if (pageCount <= 10) {
// delta === 7: [1 2 3 4 5 6 7]
@@ -65,7 +65,7 @@ const PaginationControl = (props) => {
pages = pages.concat(withDots(pageCount, ["...", pageCount]));
}
- console.log(pages);
+ //console.log(pages);
return pages;
};
@@ -82,8 +82,7 @@ const PaginationControl = (props) => {
className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem leftTextButton"
onClick={() => {
spinnerState(),
- getSearchPageResults(currentPage - 1),
- console.log(currentPage - 1);
+ getSearchPageResults(currentPage - 1);
}}
>
{t("common:previous-link-button")}
@@ -131,8 +130,7 @@ const PaginationControl = (props) => {
className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem rightTextButton"
onClick={() => {
spinnerState(),
- getSearchPageResults(currentPage + 1),
- console.log(currentPage + 1);
+ getSearchPageResults(currentPage + 1);
}}
>
{t("common:next-link-button")}
diff --git a/components/search/searchresults.js b/components/search/searchresults.js
index 534e63d2..8492c121 100644
--- a/components/search/searchresults.js
+++ b/components/search/searchresults.js
@@ -26,6 +26,7 @@ import {
import { useEffect } from "react";
import PaginationControl from "./pagination";
+import { getSearchDetailsPaged } from "../utils";
const SearchResults = (props) => {
const {
@@ -296,7 +297,7 @@ const SearchResults = (props) => {
: pagesCount;
const getSearchPageResults = (pageNumber) => {
- console.log(advancedSearch, searchString, pageNumber);
+ //console.log(advancedSearch, searchString, pageNumber);
if (advancedSearch) {
var searchoObj = Object.assign(
@@ -311,7 +312,7 @@ const SearchResults = (props) => {
})
.then((data) => {
//console.log("getting details", data);
- return getSearchDetails(data).then((data) => {
+ return getSearchDetailsPaged(data).then((data) => {
setSearchDetails(data);
setShowSpinnerState(false);
});
@@ -325,7 +326,7 @@ const SearchResults = (props) => {
})
.then((data) => {
//console.log("getting details", data);
- return getSearchDetails(data).then((data) => {
+ return getSearchDetailsPaged(data).then((data) => {
setSearchDetails(data);
setShowSpinnerState(false);
});
@@ -333,50 +334,6 @@ const SearchResults = (props) => {
}
};
- const getSearchDetails = (searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- //console.log("search results", searchResultsObj);
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- //console.log(searchDetail);
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.title);
- } else {
- let formMeta = getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- );
-
- detailsArr.push(
- getBasicSearchDetailsPaged(
- formMeta.LogicalCollectionName,
- searchDetail.title,
- formMeta.PrimaryIdAttribute,
- searchDetail.incidentid
- )
- );
- }
- });
- // console.log(detailsArr);
- return Promise.all(detailsArr);
- };
-
- const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')]"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
- };
-
return (
<>
diff --git a/components/seo/Global.js b/components/seo/Global.js
new file mode 100644
index 00000000..8239404c
--- /dev/null
+++ b/components/seo/Global.js
@@ -0,0 +1,45 @@
+import React from "react";
+import useTranslation from "next-translate/useTranslation";
+
+const GlobalMetaTags = () => {
+ let { t } = useTranslation();
+ return (
+ <>
+ {console.log(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 */}
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default GlobalMetaTags;
diff --git a/components/seo/Page.js b/components/seo/Page.js
new file mode 100644
index 00000000..a3b9fb44
--- /dev/null
+++ b/components/seo/Page.js
@@ -0,0 +1,119 @@
+import Head from "next/head";
+import { string } from "prop-types";
+
+// ALl options are conditional apart from title
+const PageMeta = ({
+ title,
+ imageWidth,
+ imageHeight,
+ ogImage,
+ ogUrl,
+ ogTitle,
+ ogType,
+ ogDescription,
+ canonicalURL,
+ description,
+ keywords,
+ createdAt,
+ updatedAt,
+ robots,
+ twitterDescription,
+ twitterTitle,
+ twitterImage,
+}) => {
+ const facebookPage = "https://www.facebook.com/IFPMA";
+
+ return (
+ <>
+
+ {title &&
{title} }
+
+ {createdAt && (
+
+ )}
+ {updatedAt && (
+
+ )}
+ {description && (
+
+ )}
+ {keywords && (
+
+ )}
+
+ {canonicalURL &&
}
+ {ogUrl &&
}
+ {ogTitle &&
}
+ {ogType &&
}
+ {ogDescription && (
+
+ )}
+ {ogImage &&
}
+ {imageWidth && (
+
+ )}
+ {imageHeight && (
+
+ )}
+
+
+ {twitterDescription && (
+
+ )}
+ {twitterTitle && (
+
+ )}
+ {twitterImage && (
+
+ )}
+
+ >
+ );
+};
+
+PageMeta.propTypes = {
+ title: string,
+ createdAt: string,
+ updatedAt: string,
+ ogImage: string,
+ ogUrl: string,
+ ogTitle: string,
+ ogType: string,
+ ogDescription: string,
+ canonicalURL: string,
+ description: string,
+ keywords: string,
+ createdAt: string,
+ updatedAt: string,
+ robots: string,
+ twitterDescription: string,
+ twitterTitle: string,
+ twitterImage: string,
+};
+
+export default PageMeta;
diff --git a/components/utils/index.js b/components/utils/index.js
new file mode 100644
index 00000000..ad9fb381
--- /dev/null
+++ b/components/utils/index.js
@@ -0,0 +1,96 @@
+import jsonpath from "jsonpath";
+import data from "../../data/collections.json";
+import {
+ getBasicSearchDetails,
+ getBasicSearchDetailsPaged,
+} from "../../actions";
+
+/*
+ * Get the lookup collection by the appeal type entity
+ * @param String formtype - string from appeal entity name
+ */
+export const getFormCollection = (formtype) => {
+ const collectionName = jsonpath.query(
+ data,
+ "$..[?(@.LogicalName=='" + formtype + "')]"
+ );
+ return collectionName[0];
+};
+
+/*
+ * Get the details of a case from the appeal type
+ * @param String token
+ * @param object searchResultsObj
+ */
+export const getSearchDetails = (token, searchResultsObj) => {
+ //console.log(searchResultsObj);
+
+ let detailsArr = [];
+ searchResultsObj = searchResultsObj.value;
+ const detailsObj = searchResultsObj.map((searchDetail, index) => {
+ if (searchDetail.pinswg_appealcasetype == null) {
+ console.log(searchDetail.title);
+ } else {
+ let formMeta = getFormCollection(
+ "pinswg_" +
+ searchDetail[
+ "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ ]
+ .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
+ .toLowerCase()
+ .slice(0, 39)
+ );
+
+ detailsArr.push(
+ getBasicSearchDetails(
+ token,
+ formMeta.LogicalCollectionName,
+ searchDetail.title,
+ formMeta.PrimaryIdAttribute,
+ searchDetail.incidentid
+ )
+ );
+ }
+ });
+ //console.log(detailsArr);
+ return Promise.all(detailsArr);
+};
+
+/*
+ * Get the details of a case from the appeal type
+ * @param object searchResultsObj
+ */
+export const getSearchDetailsPaged = (searchResultsObj) => {
+ //console.log(searchResultsObj);
+
+ let detailsArr = [];
+ //console.log("search results", searchResultsObj);
+ searchResultsObj = searchResultsObj.value;
+ const detailsObj = searchResultsObj.map((searchDetail, index) => {
+ //console.log(searchDetail);
+ if (searchDetail.pinswg_appealcasetype == null) {
+ console.log(searchDetail.title);
+ } else {
+ let formMeta = getFormCollection(
+ "pinswg_" +
+ searchDetail[
+ "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
+ ]
+ .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
+ .toLowerCase()
+ .slice(0, 39)
+ );
+
+ detailsArr.push(
+ getBasicSearchDetailsPaged(
+ formMeta.LogicalCollectionName,
+ searchDetail.title,
+ formMeta.PrimaryIdAttribute,
+ searchDetail.incidentid
+ )
+ );
+ }
+ });
+ // console.log(detailsArr);
+ return Promise.all(detailsArr);
+};
diff --git a/locales/cy/case.json b/locales/cy/case.json
index 67ffb6b7..4d0e8417 100644
--- a/locales/cy/case.json
+++ b/locales/cy/case.json
@@ -36,5 +36,8 @@
"documents-date-published-label": "Dyddiad cyhoeddi",
"documents-size-label": "Maint y ffeil (kb)",
"documents-non-available-label": "Nid oes unrhyw ddogfennau ar gyfer yr apĂȘl hon",
- "documents-heading-label": "Dogfennau"
+ "documents-heading-label": "Dogfennau",
+ "documents-checking-label": "Gwirio am ddogfennau",
+ "documents-count-label-1": "Mae yna",
+ "documents-count-label-2": "dogfennau"
}
\ No newline at end of file
diff --git a/locales/cy/common.json b/locales/cy/common.json
index 8d05dda2..300b7b74 100644
--- a/locales/cy/common.json
+++ b/locales/cy/common.json
@@ -3,6 +3,7 @@
"enable-js-label": "Os gwelwch yn dda galluogi javascript",
"gov-wales-link": "https://llyw.cymru",
"gov-wales-label": "LLYW.CYMRU",
+ "service-description": "Mae'r gwasanaeth hwn yn cael ei ddatblygu i gefnogi apeliadau a cheisiadau ar-lein.",
"service-name": "Cynllunio gwaith achos",
"service-name-breadcrumb": "Hafan",
"new-service-beta": "Mae hwn yn wasanaeth newydd",
diff --git a/locales/en/case.json b/locales/en/case.json
index 7f4129eb..2488954e 100644
--- a/locales/en/case.json
+++ b/locales/en/case.json
@@ -36,5 +36,8 @@
"documents-date-published-label": "Date published",
"documents-size-label": "Size (KB)",
"documents-non-available-label": "There are no documents for this appeal",
- "documents-heading-label": "Documents"
+ "documents-heading-label": "Documents",
+ "documents-checking-label": "Checking for documents",
+ "documents-count-label-1": "There are",
+ "documents-count-label-2": "documents"
}
\ No newline at end of file
diff --git a/locales/en/common.json b/locales/en/common.json
index bd659d88..f5abfe1c 100644
--- a/locales/en/common.json
+++ b/locales/en/common.json
@@ -3,6 +3,7 @@
"enable-js-label": "Please enable javascript",
"gov-wales-link": "https://www.gov.wales",
"gov-wales-label": "GOV.WALES",
+ "service-description": "This service is being developed to support online appeals and applications.",
"service-name": "Planning casework",
"service-name-breadcrumb": "Home",
"new-service-beta": "This is a new service",
diff --git a/next.config.js b/next.config.js
index d9a76642..2b37f394 100644
--- a/next.config.js
+++ b/next.config.js
@@ -73,6 +73,10 @@ module.exports = {
source: "/apelnewydd/:path*",
destination: "/newappeal/:path*",
},
+ {
+ source: "/cyfrif/cofrestr",
+ destination: "/account/register",
+ },
// {
// source: "/cy:path*",
diff --git a/pages/advancedsearch.js b/pages/advancedsearch.js
index 081732fc..51fd6a79 100644
--- a/pages/advancedsearch.js
+++ b/pages/advancedsearch.js
@@ -53,6 +53,68 @@ const Home = (props) => {
{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 */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
diff --git a/pages/advancedsearchresults.js b/pages/advancedsearchresults.js
index d129d6f3..4cbe73c1 100644
--- a/pages/advancedsearchresults.js
+++ b/pages/advancedsearchresults.js
@@ -15,7 +15,7 @@ import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import data from "../data/collections.json";
-
+import { getSearchDetails } from "../components/utils";
import { setSearch, getSearchObj } from "../store/search/action";
import {
setSearchResults,
@@ -42,6 +42,67 @@ const Home = (props) => {
{t("search:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
@@ -80,50 +141,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
}
);
-const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')]"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
-};
-
-const getSearchDetails = (token, searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- //console.log("searcg results", searchResultsObj);
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.ticketnumber);
- } else {
- let formMeta = getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- );
-
- detailsArr.push(
- getBasicSearchDetails(
- token,
- formMeta.LogicalCollectionName,
- searchDetail.title,
- formMeta.PrimaryIdAttribute,
- searchDetail.incidentid
- )
- );
- }
- });
- //console.log(detailsArr);
- return Promise.all(detailsArr);
-};
-
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
diff --git a/pages/case.js b/pages/case/index.js
similarity index 86%
rename from pages/case.js
rename to pages/case/index.js
index 7d16fb6a..84cfcfd5 100644
--- a/pages/case.js
+++ b/pages/case/index.js
@@ -1,19 +1,19 @@
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 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 { wrapper } from "../../store/store";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
-import Case from "../components/case";
+import Case from "../../components/case";
const Home = (props) => {
const { footerLinks, pages } = props;
diff --git a/pages/dnsapplications.js b/pages/dnsapplications.js
index c33d1d62..3c64f92a 100644
--- a/pages/dnsapplications.js
+++ b/pages/dnsapplications.js
@@ -16,6 +16,8 @@ import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import data from "../data/collections.json";
+import { getSearchDetails } from "../components/utils";
+
import { setSearch, getSearchObj } from "../store/search/action";
import {
setSearchResults,
@@ -42,6 +44,67 @@ const Home = (props) => {
{t("search:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
@@ -87,49 +150,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
}
);
-const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')]"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
-};
-
-const getSearchDetails = (token, searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.title);
- } else {
- let formMeta = getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- );
-
- detailsArr.push(
- getBasicSearchDetails(
- token,
- formMeta.LogicalCollectionName,
- searchDetail.title,
- formMeta.PrimaryIdAttribute,
- searchDetail.incidentid
- )
- );
- }
- });
- //console.log(detailsArr);
- return Promise.all(detailsArr);
-};
-
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
diff --git a/pages/index.js b/pages/index.js
index 09d6a25c..226f6ad6 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -20,11 +20,57 @@ const Home = (props) => {
const router = useRouter();
const { locale } = router;
-
+ console.log(router);
return (
{t("common:service-name")}
+ {console.log(router.pathname)}
+ {/* Language by default is EN, if multilingual site this will need updated */}
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/logout.js b/pages/logout.js
index bccf5e70..3e802678 100644
--- a/pages/logout.js
+++ b/pages/logout.js
@@ -26,6 +26,67 @@ const LogOut = (props) => {
{t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
diff --git a/pages/myportal/advancedsearchresults.js b/pages/myportal/advancedsearchresults.js
index 6ae5cac9..9345c787 100644
--- a/pages/myportal/advancedsearchresults.js
+++ b/pages/myportal/advancedsearchresults.js
@@ -16,21 +16,13 @@ import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import data from "../../data/collections.json";
+import { getSearchDetails } from "../../components/utils";
import { setSearch, getSearchObj } from "../../store/search/action";
import {
setSearchResults,
setSearchDetails,
- setDocumentDetails,
- setDocumentHistory,
- getSearchResultsObj,
} from "../../store/searchOutput/action";
-import {
- getAdvancedSearch,
- getBasicSearchDetails,
- getSearchDocumentDetails,
- getSearchDocumentHistory,
- getSASToken,
-} from "../../actions";
+import { getAdvancedSearch, getSASToken } from "../../actions";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -83,46 +75,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
}
);
-const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
-};
-
-const getSearchDetails = (token, searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- //console.log("searcg results", searchResultsObj);
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.ticketnumber);
- } else {
- detailsArr.push(
- getBasicSearchDetails(
- token,
- getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- ),
- searchDetail.ticketnumber
- )
- );
- }
- });
- //console.log(detailsArr);
- return Promise.all(detailsArr);
-};
-
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
diff --git a/pages/myportal/index.js b/pages/myportal/index.js
index 6cf0ff7e..684e6354 100644
--- a/pages/myportal/index.js
+++ b/pages/myportal/index.js
@@ -62,6 +62,67 @@ const Home = (props) => {
{t("myportal:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
diff --git a/pages/myportal/searchresults.js b/pages/myportal/searchresults.js
index 66055f10..f57fd500 100644
--- a/pages/myportal/searchresults.js
+++ b/pages/myportal/searchresults.js
@@ -16,6 +16,7 @@ import useTranslation from "next-translate/useTranslation";
import jsonpath from "jsonpath";
import data from "../../data/collections.json";
+import { getSearchDetails } from "../../components/utils";
import { setSearch, getSearchObj } from "../../store/search/action";
import {
setSearchResults,
@@ -89,62 +90,12 @@ export const getServerSideProps = wrapper.getServerSideProps(
searchResultsObj
);
- // const searchDocumentResultsObj = await getDocumentDetails(
- // token,
- // searchResultsObj
- // );
-
- // const searchDocumentHistoryObj = await getDocumentHistory(
- // token,
- // searchDocumentResultsObj
- // );
- // console.log(searchDocumentHistoryObj);
-
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setSearch(query.q));
}
);
-const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
-};
-
-const getSearchDetails = (token, searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.ticketnumber);
- } else {
- detailsArr.push(
- getBasicSearchDetails(
- token,
- getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- ),
- searchDetail.ticketnumber
- )
- );
- }
- });
- //console.log(detailsArr);
- return Promise.all(detailsArr);
-};
-
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js
index 7f27e959..818db1ca 100644
--- a/pages/newappeal/[appealtypes].js
+++ b/pages/newappeal/[appealtypes].js
@@ -206,6 +206,67 @@ let Home = (props) => {
{t("newappeal:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
diff --git a/pages/newappeal/index.js b/pages/newappeal/index.js
index 2aaa70de..d2f49738 100644
--- a/pages/newappeal/index.js
+++ b/pages/newappeal/index.js
@@ -54,6 +54,67 @@ const Home = (props) => {
{t("newappeal:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
diff --git a/pages/representation.js b/pages/representation.js
index 17805512..cc2ee023 100644
--- a/pages/representation.js
+++ b/pages/representation.js
@@ -29,6 +29,64 @@ const Home = (props) => {
{t("case:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
diff --git a/pages/searchresults.js b/pages/searchresults.js
index 9fccb39c..5a8c563f 100644
--- a/pages/searchresults.js
+++ b/pages/searchresults.js
@@ -22,6 +22,7 @@ import {
getSearchResultsObj,
} from "../store/searchOutput/action";
import { getBasicSearch, getBasicSearchDetails, getSASToken } from "../actions";
+import { getSearchDetails } from "../components/utils";
const Home = (props) => {
const { footerLinks, pages } = props;
@@ -37,6 +38,67 @@ const Home = (props) => {
{t("search:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
@@ -85,82 +147,6 @@ export const getServerSideProps = wrapper.getServerSideProps(
}
);
-const getFormCollection = (formtype) => {
- const collectionName = jsonpath.query(
- data,
- "$..[?(@.LogicalName=='" + formtype + "')]"
- );
- //console.log(collectionName[0]);
- return collectionName[0];
-};
-
-const getSearchDetails = (token, searchResultsObj) => {
- //console.log(searchResultsObj);
-
- let detailsArr = [];
- //console.log("search results", searchResultsObj);
- searchResultsObj = searchResultsObj.value;
- const detailsObj = searchResultsObj.map((searchDetail, index) => {
- //console.log(searchDetail);
-
- // console.log(
- // "the collect",
- // getFormCollection(
- // "pinswg_" +
- // searchDetail[
- // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- // ]
- // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- // .toLowerCase()
- // .slice(0, 39)
- // )
- // );
-
- if (searchDetail.pinswg_appealcasetype == null) {
- console.log(searchDetail.title);
- } else {
- // console.log(
- // "appealtype collection name",
- // searchDetail[
- // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- // ],
- // "pinswg_" +
- // searchDetail[
- // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- // ]
- // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- // .toLowerCase()
- // .slice(0, 39),
- // searchDetail.title,
- // searchDetail.ticketnumber,
- // searchDetail.incidentid
- // );
-
- let formMeta = getFormCollection(
- "pinswg_" +
- searchDetail[
- "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
- ]
- .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
- .toLowerCase()
- .slice(0, 39)
- );
-
- detailsArr.push(
- getBasicSearchDetails(
- token,
- formMeta.LogicalCollectionName,
- searchDetail.title,
- formMeta.PrimaryIdAttribute,
- searchDetail.incidentid
- )
- );
- }
- });
- //console.log(detailsArr);
- return Promise.all(detailsArr);
-};
-
const mapStateToProps = (state) => {
return {
currentView: state.currentView,
diff --git a/pages/viewall.js b/pages/viewall.js
index c389b10f..9542cc93 100644
--- a/pages/viewall.js
+++ b/pages/viewall.js
@@ -35,6 +35,67 @@ const Home = (props) => {
{t("search:page-title")} - {t("common:service-name")}
+ <>
+
+
+ {/* If they have a Twitter Handle, include the meta details below */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >