diff --git a/src/auth/index.js b/src/auth/index.js index 5ee7c76..abb2c55 100644 --- a/src/auth/index.js +++ b/src/auth/index.js @@ -32,6 +32,7 @@ export const handleLogin = data => { localStorage.setItem('accessToken', data.accessToken) localStorage.setItem('refreshToken', data.refreshToken) localStorage.setItem('axiosToken', "Bearer " + data.accessToken) + localStorage.setItem('searchCriteria',"") //localStorage.setItem(config.storageUserRoleKeyName, JSON.stringify(data.role).slice(1).slice(0, -1)) localStorage.setItem(refreshIntervalName, "60") // for demo only @@ -91,6 +92,7 @@ export const handleLogoutFunction = () => { localStorage.removeItem('refreshToken') localStorage.removeItem('webtoken') localStorage.removeItem('transactionid') + localStorage.removeItem('searchCriteria') //localStorage.removeItem(config.storageUserRoleKeyName) localStorage.removeItem('expiredAlertShown') localStorage.removeItem(refreshIntervalName) diff --git a/src/auth/utils.js b/src/auth/utils.js index d42953b..28e527a 100644 --- a/src/auth/utils.js +++ b/src/auth/utils.js @@ -130,4 +130,16 @@ export const getPaymentMethod = (paymentMethod) => { if (paymentMethod == "demandNote") return 'payDnMethod'; if (paymentMethod == "office") return 'payNPGOMethod'; return "other"; +} + +export const getSearchCriteria = (path) =>{ + let searchCriteria = "" + if (localStorage.getItem('searchCriteria')==""){ + return searchCriteria + } else if (Object.keys(localStorage.getItem('searchCriteria')).length>0){ + searchCriteria = JSON.parse(localStorage.getItem("searchCriteria")) + if (searchCriteria.path === path){ + return searchCriteria.data + } + } } \ No newline at end of file diff --git a/src/pages/Proof/Search_GLD/SearchForm.js b/src/pages/Proof/Search_GLD/SearchForm.js index f27481b..ad484aa 100644 --- a/src/pages/Proof/Search_GLD/SearchForm.js +++ b/src/pages/Proof/Search_GLD/SearchForm.js @@ -25,12 +25,12 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss }) => { const [type, setType] = React.useState([]); - const [status, setStatus] = React.useState(ComboData.proofStatus[0]); - const [orgSelected, setOrgSelected] = React.useState({}); + const [status, setStatus] = React.useState(searchCriteria.statusKey!=undefined?ComboData.proofStatus_GLD[searchCriteria.statusKey]:ComboData.proofStatus_GLD[0]); + const [orgSelected, setOrgSelected] = React.useState(searchCriteria.orgId!=undefined?orgComboData && orgComboData.length > 0?orgComboData.find(item => item.key === searchCriteria.orgId):{}:{}); const [orgCombo, setOrgCombo] = React.useState(); - const [issueSelected, setIssueSelected] = React.useState({}); + const [issueSelected, setIssueSelected] = React.useState(searchCriteria.issueId!=undefined?issueComboData && issueComboData.length > 0?issueComboData.find(item => item.id === searchCriteria.issueId):{}:{}); const [issueCombo, setIssueCombo] = React.useState([]); - const [groupSelected, setGroupSelected] = React.useState({}); + const [groupSelected, setGroupSelected] = React.useState(searchCriteria.gazettGroup!=undefined?ComboData.groupTitle.find(item => item.code === searchCriteria.gazettGroup):{}); const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); @@ -73,6 +73,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss dateTo: sentDateTo, contact: data.contact, orgId: (orgSelected?.key && orgSelected?.key > 0) ? orgSelected?.key : "", + statusKey:status?.key, }; @@ -123,6 +124,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) setMaxDate(DateUtils.dateValue(new Date())) reset(); + localStorage.setItem('searchCriteria',"") } function getIssueLabel(data) { diff --git a/src/pages/Proof/Search_GLD/index.js b/src/pages/Proof/Search_GLD/index.js index 3c0c5a5..88092ac 100644 --- a/src/pages/Proof/Search_GLD/index.js +++ b/src/pages/Proof/Search_GLD/index.js @@ -10,6 +10,7 @@ import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; import * as DateUtils from "utils/DateUtils"; import {GET_ORG_COMBO, GET_ISSUE_COMBO} from "utils/ApiPathConst"; +import { getSearchCriteria } from "auth/utils"; import Loadable from 'components/Loadable'; const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); @@ -42,6 +43,11 @@ const UserSearchPage_Individual = () => { React.useEffect(() => { getOrgCombo(); getIssueCombo(); + if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ + setSearchCriteria(getSearchCriteria(window.location.pathname)) + }else{ + localStorage.setItem('searchCriteria',"") + } }, []); React.useEffect(() => { @@ -72,6 +78,7 @@ const UserSearchPage_Individual = () => { function applySearch(input) { setGridOnReady(true) setSearchCriteria(input); + localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) } function applyGridOnReady(input) {