added in pagination for search result requests
This commit is contained in:
+35
-80
@@ -19,17 +19,9 @@ import { setSearch, getSearchObj } from "../store/search/action";
|
||||
import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
setDocumentDetails,
|
||||
setDocumentHistory,
|
||||
getSearchResultsObj,
|
||||
} from "../store/searchOutput/action";
|
||||
import {
|
||||
getBasicSearch,
|
||||
getBasicSearchDetails,
|
||||
getSearchDocumentDetails,
|
||||
getSearchDocumentHistory,
|
||||
getSASToken,
|
||||
} from "../actions";
|
||||
import { getBasicSearch, getBasicSearchDetails, getSASToken } from "../actions";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
@@ -87,21 +79,8 @@ 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(setDocumentDetails(searchDocumentResultsObj));
|
||||
//store.dispatch(setDocumentHistory(searchDocumentHistoryObj));
|
||||
store.dispatch(setSearch(query.q));
|
||||
}
|
||||
);
|
||||
@@ -109,7 +88,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
@@ -123,8 +102,22 @@ const getSearchDetails = (token, 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.ticketnumber);
|
||||
console.log(searchDetail.title);
|
||||
} else {
|
||||
// console.log(
|
||||
// "appealtype collection name",
|
||||
@@ -138,21 +131,28 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
// .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
// .toLowerCase()
|
||||
// .slice(0, 39),
|
||||
// searchDetail.ticketnumber
|
||||
// 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,
|
||||
getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
),
|
||||
searchDetail.ticketnumber
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -161,51 +161,6 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const getDocumentDetails = (token, searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
//console.log("search results", searchResultsObj);
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.incidentid);
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getSearchDocumentDetails(token, searchDetail.incidentid)
|
||||
);
|
||||
}
|
||||
});
|
||||
//console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const getDocumentHistory = (token, searchDocumentDetailsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let historyArr = [];
|
||||
//console.log("search results", searchDocumentDetailsObj);
|
||||
searchDocumentDetailsObj = searchDocumentDetailsObj[0].value;
|
||||
|
||||
//console.log(searchDocumentDetailsObj);
|
||||
const detailsObj = searchDocumentDetailsObj.map((historyDetail, index) => {
|
||||
//console.log(historyDetail);
|
||||
if (historyDetail.pinswg_publishtoweb != true) {
|
||||
console.log(historyDetail.pinswg_documentid);
|
||||
} else {
|
||||
// console.log(
|
||||
// "history detail documentid:",
|
||||
// historyDetail.pinswg_documentid
|
||||
// );
|
||||
historyArr.push(
|
||||
getSearchDocumentHistory(token, historyDetail.pinswg_documentid)
|
||||
);
|
||||
}
|
||||
});
|
||||
console.log(historyArr);
|
||||
return Promise.all(historyArr);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
currentView: state.currentView,
|
||||
|
||||
Reference in New Issue
Block a user