diff --git a/.env.local b/.env.local index 1a5846f0..1abbff2b 100644 --- a/.env.local +++ b/.env.local @@ -4,7 +4,7 @@ ACCESS_TOKEN_ENDPOINT = https://login.microsoftonline.com/ //ESNR Tenant TENANT = a8d860de-d5e1-45af-8376-d93f02e6b502 //WGO Tenant -//TENANT = 9ac1a5ab-cd58-409e-a1b6-6b10422a68f5 +TENANT = 9ac1a5ab-cd58-409e-a1b6-6b10422a68f5 GRANT_TYPE = "client_credentials" HASHKEY = 028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c @@ -20,19 +20,19 @@ NEXT_PUBLIC_HASHKEY = 028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459 //Test Oauth ESNR -CLIENT_ID = 6619ad85-c908-490d-811b-de8c93c0f2aa -CLIENT_SECRET = qKo7Q~5QvLEplbwnBbint_I5lXqx_-kDm8Vj- -RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -RELAYURI = "test-pedw-ns.servicebus.windows.net" -RELAYPATH = "test-pedw-hc" +//CLIENT_ID = 6619ad85-c908-490d-811b-de8c93c0f2aa +//CLIENT_SECRET = qKo7Q~5QvLEplbwnBbint_I5lXqx_-kDm8Vj- +//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ +//RELAYURI = "test-pedw-ns.servicebus.windows.net" +//RELAYPATH = "test-pedw-hc" //Preprod Oauth WGO -//CLIENT_ID = ab6c4678-b31a-4eb3-b429-e039120e488a -//CLIENT_SECRET = Ioo7Q~RJfhWsE45wPsuHm1CzRk1SppnNN3lZF -//RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/ -//RELAYURI = "pp-pedw-ns.servicebus.windows.net" -//RELAYPATH = "pp-pedw-hc" +CLIENT_ID = ab6c4678-b31a-4eb3-b429-e039120e488a +CLIENT_SECRET = Ioo7Q~RJfhWsE45wPsuHm1CzRk1SppnNN3lZF +RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/ +RELAYURI = "pp-pedw-ns.servicebus.windows.net" +RELAYPATH = "pp-pedw-hc" diff --git a/components/case/documents.js b/components/case/documents.js index d450eaf2..c440fb99 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -9,6 +9,7 @@ import PaginationControl from "./pagination"; import LoadingOverlay from "react-loading-overlay"; import CryptoJS from "crypto-js"; +import { setCurrentPage } from "../../store/currentView/action"; import { getBasicSearch, getBasicSearchDetails, @@ -38,6 +39,7 @@ const DocumentDetails = (props) => { documentHistoryObj, setDocumentDetails, setDocumentHistory, + setCurrentPage, } = props; const router = useRouter(); @@ -65,10 +67,11 @@ const DocumentDetails = (props) => {
@@ -489,6 +492,9 @@ const mapDispatchToProps = (dispatch) => { setDocumentHistory: (historyObj) => { dispatch(setDocumentHistory(historyObj)); }, + setCurrentPage: (currentPage) => { + dispatch(setCurrentPage(currentPage)); + }, }; }; diff --git a/components/case/pagination.js b/components/case/pagination.js index 1a6e6fb7..88d224d3 100644 --- a/components/case/pagination.js +++ b/components/case/pagination.js @@ -1,6 +1,9 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; +import { useState } from "react"; +import { connect } from "react-redux"; +import { setCurrentPage } from "../../store/currentView/action"; const PaginationControl = (props) => { const { @@ -12,6 +15,7 @@ const PaginationControl = (props) => { currentPage, spinnerState, getDocumentResults, + setCurrentPage, } = props; let { t } = useTranslation(); @@ -32,13 +36,14 @@ const PaginationControl = (props) => { const paginationNumbers = (currentPage, pageCount) => { //console.log(currentPage); let delta; - if (pageCount <= showNoOfRecords) { + if (pageCount <= 7) { // delta === 7: [1 2 3 4 5 6 7] - delta = 4; + delta = 7; } else { // delta === 2: [1 ... 4 5 6 ... 10] // delta === 4: [1 2 3 4 5 ... 10] - delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4; + //delta = currentPage > 4 && currentPage < pageCount - 3 ? 4 : 4; + delta = currentPage > 4 && currentPage < pageCount - 3 ? 2 : 4; } const range = { @@ -78,7 +83,7 @@ const PaginationControl = (props) => { return ( <> - {pagesCount > 1 ? ( + {pagesCount > 1 && (
@@ -87,8 +92,13 @@ const PaginationControl = (props) => { className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem leftTextButton" onClick={() => { spinnerState(), + setCurrentPage( + props.currentView.currentPage - + 1 + ), getDocumentResults( - currentPage - 1, + props.currentView.currentPage - + 1, orderBy, fieldSort ); @@ -104,7 +114,7 @@ const PaginationControl = (props) => {
{paginationArray.map((e, i) => - currentPage == i + 1 ? ( + props.currentView.currentPage == i + 1 ? ( { key={i} onClick={() => { spinnerState(); - getDocumentResults( - i + 1, - orderBy, - fieldSort - ); + setCurrentPage(e), + getDocumentResults( + e, + orderBy, + fieldSort + ); }} > {e} @@ -137,13 +148,24 @@ const PaginationControl = (props) => { )}
- {currentPage != pagesCount ? ( + {/* {"current page state: " + + props.currentView.currentPage}{" "} +
+ {"current page: " + currentPage}
+ {"total pages: " + pagesCount} +
*/} + {props.currentView.currentPage < pagesCount ? ( { spinnerState(), + setCurrentPage( + props.currentView.currentPage + + 1 + ), getDocumentResults( - currentPage + 1, + props.currentView.currentPage + + 1, orderBy, fieldSort ); @@ -164,11 +186,23 @@ const PaginationControl = (props) => { {t("common:of-label")} {pagesCount}
- ) : ( - "" )} ); }; -export default PaginationControl; +const mapStateToProps = (state) => { + return { + currentView: state.currentView, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setCurrentPage: (currentPage) => { + dispatch(setCurrentPage(currentPage)); + }, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(PaginationControl); diff --git a/components/search/dnssearchresults.js b/components/search/dnssearchresults.js index 058a9502..0a76257f 100644 --- a/components/search/dnssearchresults.js +++ b/components/search/dnssearchresults.js @@ -1,7 +1,6 @@ import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; -import { setCurrentReference } from "../../store/currentView/action"; import { connect } from "react-redux"; import jsonpath from "jsonpath"; import _ from "lodash"; @@ -20,6 +19,11 @@ import { setSearchDetails, } from "../../store/searchOutput/action"; import { getSearchDetailsPaged } from "../utils"; +import { + currentViewActionTypes, + setCurrentReference, + setCurrentPage, +} from "../../store/currentView/action"; const DNSSearchResults = (props) => { const { @@ -30,6 +34,7 @@ const DNSSearchResults = (props) => { setSearchResults, setSearchDetails, advancedSearch, + setCurrentPage, } = props; let { t } = useTranslation(); @@ -367,6 +372,8 @@ const DNSSearchResults = (props) => {
+ + {searchResultsObj["@odata.count"]} {searchResultsObj["@odata.count"] > 5 && (
@@ -375,6 +382,7 @@ const DNSSearchResults = (props) => { { setSelectedOption(e.target.value); + setCurrentPage(1); }} value={selectedOption} className="govuk-select" @@ -705,6 +708,9 @@ const mapDispatchToProps = (dispatch) => { setWatchedCasesDetails: (watchedCasesDetails) => { dispatch(setWatchedCasesDetails(watchedCasesDetails)); }, + setCurrentPage: (currentPage) => { + dispatch(setCurrentPage(currentPage)); + }, }; }; diff --git a/store/currentView/action.js b/store/currentView/action.js index 028ce0a1..91692b61 100644 --- a/store/currentView/action.js +++ b/store/currentView/action.js @@ -6,6 +6,7 @@ export const currentViewActionTypes = { SETREPRESENTATIONSUBMIT: "SETREPRESENTATIONSUBMIT", SETREPRESENTATIONSUBMITCONFIRMATION: "SETREPRESENTATIONSUBMITCONFIRMATION", SETCURRENTLINKEDCASES: "SETCURRENTLINKEDCASES", + SETCURRENTPAGE: "SETCURRENTPAGE", }; export const getCurrentViewObj = () => (dispatch) => { @@ -64,3 +65,10 @@ export const setCurrentLinkedCases = (linkedCaseReferences) => (dispatch) => { linkedCaseReferences: linkedCaseReferences, }); }; + +export const setCurrentPage = (currentPage) => (dispatch) => { + return dispatch({ + type: currentViewActionTypes.SETCURRENTPAGE, + currentPage: currentPage, + }); +}; diff --git a/store/currentView/reducer.js b/store/currentView/reducer.js index 1e2c4b68..cf6ced8f 100644 --- a/store/currentView/reducer.js +++ b/store/currentView/reducer.js @@ -7,6 +7,7 @@ const currentViewInitialState = { representationSubmit: null, representationSubmitConfirmation: {}, linkedCaseReferences: {}, + currentPage: 1, }; export default function reducer(state = currentViewInitialState, action) { @@ -38,6 +39,11 @@ export default function reducer(state = currentViewInitialState, action) { representationSubmitConfirmation: action.representationSubmitConfirmation, }; + case currentViewActionTypes.SETCURRENTPAGE: + return { + ...state, + currentPage: action.currentPage, + }; default: return state; }