@@ -44,6 +44,28 @@ const SearchDemandNoteForm = ({ applySearch, orgComboData, searchCriteria, issue | |||||
const intl = useIntl(); | const intl = useIntl(); | ||||
const { locale } = intl; | const { locale } = intl; | ||||
React.useEffect(() => { | |||||
if(searchCriteria.status!=undefined){ | |||||
if(searchCriteria.status === ""){ | |||||
ComboData.denmandNoteStatus[0] | |||||
}else{ | |||||
setSelectedStatus(ComboData.denmandNoteStatus.find(item => item.type === searchCriteria.status)) | |||||
} | |||||
if(searchCriteria.dueDateFrom != ""){ | |||||
setMinDueDate(DateUtils.dateValue(searchCriteria.dueDateFrom)) | |||||
}else{ | |||||
setMinDueDate(null) | |||||
} | |||||
if(searchCriteria.dueDateTo != ""){ | |||||
setMaxDueDate(DateUtils.dateValue(searchCriteria.dueDateTo)) | |||||
}else{ | |||||
setMaxDueDate(null); | |||||
} | |||||
}else{ | |||||
setSelectedStatus(ComboData.denmandNoteStatus[0]) | |||||
} | |||||
}, [searchCriteria]); | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
}, [minDate]); | }, [minDate]); | ||||
@@ -101,12 +123,18 @@ const SearchDemandNoteForm = ({ applySearch, orgComboData, searchCriteria, issue | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
if (orgComboData && orgComboData.length > 0) { | if (orgComboData && orgComboData.length > 0) { | ||||
setOrgCombo(orgComboData); | setOrgCombo(orgComboData); | ||||
if(searchCriteria.orgId!=undefined){ | |||||
setOrgSelected(orgComboData.find(item => item.key === searchCriteria.orgId)) | |||||
} | |||||
} | } | ||||
}, [orgComboData]); | }, [orgComboData]); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
if (issueComboData && issueComboData.length > 0) { | if (issueComboData && issueComboData.length > 0) { | ||||
setIssueCombo(issueComboData); | setIssueCombo(issueComboData); | ||||
if(searchCriteria.issueId!=undefined){ | |||||
setIssueSelected(issueComboData.find(item => item.id === searchCriteria.issueId)) | |||||
} | |||||
} | } | ||||
}, [issueComboData]); | }, [issueComboData]); | ||||
@@ -117,9 +145,13 @@ const SearchDemandNoteForm = ({ applySearch, orgComboData, searchCriteria, issue | |||||
setSelectedStatus(ComboData.denmandNoteStatus[0]); | setSelectedStatus(ComboData.denmandNoteStatus[0]); | ||||
setMinDueDate(null); | setMinDueDate(null); | ||||
setMaxDueDate(null); | setMaxDueDate(null); | ||||
setMinDate(searchCriteria.dateFrom); | |||||
setMaxDate(searchCriteria.dateTo); | |||||
reset(); | |||||
setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | |||||
setMaxDate(DateUtils.dateValue(new Date())) | |||||
reset({ | |||||
appNo:"", | |||||
dnNo:"", | |||||
}); | |||||
localStorage.setItem('searchCriteria',"") | |||||
} | } | ||||
function getIssueLabel(data) { | function getIssueLabel(data) { | ||||
@@ -10,6 +10,7 @@ import * as React from "react"; | |||||
import * as UrlUtils from "utils/ApiPathConst"; | import * as UrlUtils from "utils/ApiPathConst"; | ||||
import * as HttpUtils from "utils/HttpUtils"; | import * as HttpUtils from "utils/HttpUtils"; | ||||
import * as DateUtils from "utils/DateUtils"; | import * as DateUtils from "utils/DateUtils"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | ||||
@@ -35,8 +36,8 @@ const UserSearchPage_Individual = () => { | |||||
const [orgCombo, setOrgCombo] = React.useState([]); | const [orgCombo, setOrgCombo] = React.useState([]); | ||||
const [issueCombo, setIssueCombo] = React.useState([]); | const [issueCombo, setIssueCombo] = React.useState([]); | ||||
const [searchCriteria, setSearchCriteria] = React.useState({ | const [searchCriteria, setSearchCriteria] = React.useState({ | ||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)), | |||||
// dateTo: DateUtils.dateValue(new Date()), | |||||
// dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)), | |||||
// dueDateTo: DateUtils.dateValue(new Date()), | // dueDateTo: DateUtils.dateValue(new Date()), | ||||
// dueDateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)), | // dueDateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)), | ||||
}); | }); | ||||
@@ -46,6 +47,15 @@ const UserSearchPage_Individual = () => { | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
getOrgCombo(); | getOrgCombo(); | ||||
getIssueCombo(); | getIssueCombo(); | ||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)), | |||||
}) | |||||
} | |||||
}, []); | }, []); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
@@ -76,6 +86,7 @@ const UserSearchPage_Individual = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -38,6 +38,18 @@ const SearchDemandNoteForm = ({ applySearch, searchCriteria, issueComboData, onG | |||||
const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | ||||
const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | ||||
React.useEffect(() => { | |||||
if(searchCriteria.status!=undefined){ | |||||
if(searchCriteria.status === ""){ | |||||
ComboData.denmandNoteStatus_Public[0] | |||||
}else{ | |||||
setSelectedStatus(ComboData.denmandNoteStatus_Public.find(item => item.type === searchCriteria.status)) | |||||
} | |||||
}else{ | |||||
setSelectedStatus(ComboData.denmandNoteStatus_Public[0]) | |||||
} | |||||
}, [searchCriteria]); | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
}, [minDate]); | }, [minDate]); | ||||
@@ -76,6 +88,9 @@ const SearchDemandNoteForm = ({ applySearch, searchCriteria, issueComboData, onG | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
if (issueComboData && issueComboData.length > 0) { | if (issueComboData && issueComboData.length > 0) { | ||||
setIssueCombo(issueComboData); | setIssueCombo(issueComboData); | ||||
if(searchCriteria.issueId!=undefined){ | |||||
setIssueSelected(issueComboData.find(item => item.id === searchCriteria.issueId)) | |||||
} | |||||
} | } | ||||
}, [issueComboData]); | }, [issueComboData]); | ||||
@@ -86,7 +101,10 @@ const SearchDemandNoteForm = ({ applySearch, searchCriteria, issueComboData, onG | |||||
setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | ||||
setMaxDate(DateUtils.dateValue(new Date())) | setMaxDate(DateUtils.dateValue(new Date())) | ||||
setIssueSelected({}); | setIssueSelected({}); | ||||
reset(); | |||||
reset({ | |||||
appNo:"", | |||||
dnNo:"", | |||||
}); | |||||
} | } | ||||
function getIssueLabel(data) { | function getIssueLabel(data) { | ||||
@@ -10,6 +10,7 @@ import * as React from "react"; | |||||
import {GET_ORG_COMBO, GET_ISSUE_COMBO} from "utils/ApiPathConst"; | import {GET_ORG_COMBO, GET_ISSUE_COMBO} from "utils/ApiPathConst"; | ||||
import * as HttpUtils from "utils/HttpUtils"; | import * as HttpUtils from "utils/HttpUtils"; | ||||
import * as DateUtils from "utils/DateUtils"; | import * as DateUtils from "utils/DateUtils"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | ||||
@@ -34,16 +35,22 @@ const SearchPage_DemandNote_Pub = () => { | |||||
const [orgCombo, setOrgCombo] = React.useState([]); | const [orgCombo, setOrgCombo] = React.useState([]); | ||||
const [issueCombo, setIssueCombo] = React.useState([]); | const [issueCombo, setIssueCombo] = React.useState([]); | ||||
const [searchCriteria, setSearchCriteria] = React.useState({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)), | |||||
}); | |||||
const [searchCriteria, setSearchCriteria] = React.useState({}); | |||||
const [onReady, setOnReady] = React.useState(false); | const [onReady, setOnReady] = React.useState(false); | ||||
const [onGridReady, setGridOnReady] = React.useState(false); | const [onGridReady, setGridOnReady] = React.useState(false); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
getOrgCombo(); | getOrgCombo(); | ||||
getIssueCombo(); | getIssueCombo(); | ||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)), | |||||
}) | |||||
} | |||||
}, []); | }, []); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
@@ -75,6 +82,7 @@ const SearchPage_DemandNote_Pub = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -8,7 +8,7 @@ import { | |||||
import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
import { useForm } from "react-hook-form"; | import { useForm } from "react-hook-form"; | ||||
import { useState } from "react"; | |||||
import { useState,useEffect } from "react"; | |||||
import * as React from "react"; | import * as React from "react"; | ||||
import * as UrlUtils from "utils/ApiPathConst"; | import * as UrlUtils from "utils/ApiPathConst"; | ||||
@@ -19,11 +19,20 @@ import {ThemeProvider} from "@emotion/react"; | |||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
const OrganizationSearchForm = ({ applySearch, onGridReady }) => { | |||||
const OrganizationSearchForm = ({ applySearch, onGridReady, searchCriteria }) => { | |||||
const [type, setType] = useState([]); | const [type, setType] = useState([]); | ||||
const [creditorSelected, setCreditorSelected] = React.useState(ComboData.CreditorStatus[0]); | const [creditorSelected, setCreditorSelected] = React.useState(ComboData.CreditorStatus[0]); | ||||
const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
useEffect(() => { | |||||
if(searchCriteria.creditor!=undefined){ | |||||
setCreditorSelected(ComboData.CreditorStatus.find(item => item.type === searchCriteria.creditor.toString())) | |||||
}else{ | |||||
setCreditorSelected(ComboData.CreditorStatus[0]); | |||||
} | |||||
}, [searchCriteria]); | |||||
const onSubmit = (data) => { | const onSubmit = (data) => { | ||||
let typeArray = []; | let typeArray = []; | ||||
@@ -48,7 +57,11 @@ const OrganizationSearchForm = ({ applySearch, onGridReady }) => { | |||||
function resetForm() { | function resetForm() { | ||||
setType([]); | setType([]); | ||||
setCreditorSelected(ComboData.CreditorStatus[0]); | setCreditorSelected(ComboData.CreditorStatus[0]); | ||||
reset(); | |||||
reset({ | |||||
brNo: "", | |||||
enCompanyName: "", | |||||
chCompanyName: "", | |||||
}); | |||||
} | } | ||||
const doExport=()=>{ | const doExport=()=>{ | ||||
@@ -80,6 +93,7 @@ const OrganizationSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("brNo")} | {...register("brNo")} | ||||
id='brNo' | id='brNo' | ||||
label="BR No." | label="BR No." | ||||
defaultValue={searchCriteria.brNo} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -92,6 +106,7 @@ const OrganizationSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("enCompanyName")} | {...register("enCompanyName")} | ||||
id="enCompanyName" | id="enCompanyName" | ||||
label="Name (English)" | label="Name (English)" | ||||
defaultValue={searchCriteria.enCompanyName} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -104,6 +119,7 @@ const OrganizationSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("chCompanyName")} | {...register("chCompanyName")} | ||||
id="chCompanyName" | id="chCompanyName" | ||||
label="Name (Chinese)" | label="Name (Chinese)" | ||||
defaultValue={searchCriteria.chCompanyName} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -5,7 +5,7 @@ import { | |||||
import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
import { useEffect, useState } from "react"; | import { useEffect, useState } from "react"; | ||||
import * as React from "react"; | import * as React from "react"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
// import LoadingComponent from "../extra-pages/LoadingComponent"; | // import LoadingComponent from "../extra-pages/LoadingComponent"; | ||||
// import SearchForm from "./OrganizationSearchForm"; | // import SearchForm from "./OrganizationSearchForm"; | ||||
@@ -34,6 +34,15 @@ const OrganizationSearchPage = () => { | |||||
const [onReady, setOnReady] = useState(false); | const [onReady, setOnReady] = useState(false); | ||||
const [onGridReady, setGridOnReady] = React.useState(false); | const [onGridReady, setGridOnReady] = React.useState(false); | ||||
useEffect(() => { | |||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({}) | |||||
} | |||||
}, []); | |||||
useEffect(() => { | useEffect(() => { | ||||
setOnReady(true); | setOnReady(true); | ||||
}, [searchCriteria]); | }, [searchCriteria]); | ||||
@@ -41,6 +50,7 @@ const OrganizationSearchPage = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -68,6 +78,7 @@ const OrganizationSearchPage = () => { | |||||
<SearchForm | <SearchForm | ||||
applySearch={applySearch} | applySearch={applySearch} | ||||
onGridReady={onGridReady} | onGridReady={onGridReady} | ||||
searchCriteria={searchCriteria} | |||||
/> | /> | ||||
</Grid> | </Grid> | ||||
{/*row 2*/} | {/*row 2*/} | ||||
@@ -31,6 +31,18 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | ||||
const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | ||||
React.useEffect(() => { | |||||
if(searchCriteria.status!=undefined){ | |||||
if(searchCriteria.status === ""){ | |||||
ComboData.paymentStatus[0] | |||||
}else{ | |||||
setStatus(ComboData.paymentStatus.find(item => item.type === searchCriteria.status)) | |||||
} | |||||
}else{ | |||||
setStatus(ComboData.paymentStatus[0]) | |||||
} | |||||
}, [searchCriteria]); | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
}, [minDate]); | }, [minDate]); | ||||
@@ -62,7 +74,10 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
setStatus(ComboData.paymentStatus[0]); | setStatus(ComboData.paymentStatus[0]); | ||||
setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | ||||
setMaxDate(DateUtils.dateValue(new Date())) | setMaxDate(DateUtils.dateValue(new Date())) | ||||
reset(); | |||||
reset({ | |||||
code:"", | |||||
transNo:"" | |||||
}); | |||||
} | } | ||||
@@ -7,6 +7,7 @@ import { | |||||
import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
import * as React from "react"; | import * as React from "react"; | ||||
import * as DateUtils from "utils/DateUtils"; | import * as DateUtils from "utils/DateUtils"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | ||||
@@ -28,13 +29,22 @@ const BackgroundHead = { | |||||
const Index = () => { | const Index = () => { | ||||
const [searchCriteria, setSearchCriteria] = React.useState({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)), | |||||
}); | |||||
const [searchCriteria, setSearchCriteria] = React.useState({}); | |||||
const [onReady, setOnReady] = React.useState(false); | const [onReady, setOnReady] = React.useState(false); | ||||
const [onGridReady, setGridOnReady] = React.useState(false); | const [onGridReady, setGridOnReady] = React.useState(false); | ||||
React.useEffect(() => { | |||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)), | |||||
}) | |||||
} | |||||
}, []); | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setOnReady(true); | setOnReady(true); | ||||
}, [searchCriteria]); | }, [searchCriteria]); | ||||
@@ -42,6 +52,7 @@ const Index = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -37,6 +37,18 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | ||||
const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | ||||
// React.useEffect(() => { | |||||
// if(searchCriteria.status!=undefined){ | |||||
// if(searchCriteria.status === ""){ | |||||
// ComboData.proofStatus_GLD[0] | |||||
// }else{ | |||||
// setSelectedStatus(ComboData.proofStatus_GLD.find(item => item.type === searchCriteria.status)) | |||||
// } | |||||
// }else{ | |||||
// setSelectedStatus(ComboData.proofStatus_GLD[0]) | |||||
// } | |||||
// }, [searchCriteria]); | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
}, [minDate]); | }, [minDate]); | ||||
@@ -129,7 +141,11 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
setGroupSelected({}); | setGroupSelected({}); | ||||
setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | ||||
setMaxDate(DateUtils.dateValue(new Date())) | setMaxDate(DateUtils.dateValue(new Date())) | ||||
reset(); | |||||
reset({ | |||||
refNo:"", | |||||
code:"", | |||||
contact:"" | |||||
}); | |||||
localStorage.setItem('searchCriteria',"") | localStorage.setItem('searchCriteria',"") | ||||
} | } | ||||
@@ -33,20 +33,21 @@ const BackgroundHead = { | |||||
const UserSearchPage_Individual = () => { | const UserSearchPage_Individual = () => { | ||||
const [orgCombo, setOrgCombo] = React.useState([]); | const [orgCombo, setOrgCombo] = React.useState([]); | ||||
const [issueCombo, setIssueCombo] = React.useState([]); | const [issueCombo, setIssueCombo] = React.useState([]); | ||||
const [searchCriteria, setSearchCriteria] = React.useState({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)), | |||||
}); | |||||
const [searchCriteria, setSearchCriteria] = React.useState({}); | |||||
const [onReady, setOnReady] = React.useState(false); | const [onReady, setOnReady] = React.useState(false); | ||||
const [onGridReady, setGridOnReady] = React.useState(false); | const [onGridReady, setGridOnReady] = React.useState(false); | ||||
React.useEffect(() => { | |||||
React.useEffect(() => { | |||||
getOrgCombo(); | getOrgCombo(); | ||||
getIssueCombo(); | getIssueCombo(); | ||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | ||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | setSearchCriteria(getSearchCriteria(window.location.pathname)) | ||||
}else{ | }else{ | ||||
localStorage.setItem('searchCriteria',"") | localStorage.setItem('searchCriteria',"") | ||||
setSearchCriteria({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)), | |||||
}) | |||||
} | } | ||||
}, []); | }, []); | ||||
@@ -114,7 +114,6 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
function resetForm() { | function resetForm() { | ||||
setType([]); | setType([]); | ||||
// setStatus({ key: 0, label: 'All', type: 'all' }); | // setStatus({ key: 0, label: 'All', type: 'all' }); | ||||
localStorage.setItem('searchCriteria',"") | |||||
setOrgSelected({}); | setOrgSelected({}); | ||||
setIssueSelected({}); | setIssueSelected({}); | ||||
setGroupSelected({}); | setGroupSelected({}); | ||||
@@ -126,6 +125,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
contact:"", | contact:"", | ||||
groupNo:"" | groupNo:"" | ||||
}); | }); | ||||
localStorage.setItem('searchCriteria',"") | |||||
} | } | ||||
const getIssueLabel=(data)=> { | const getIssueLabel=(data)=> { | ||||
@@ -37,6 +37,18 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | const [fromDateValue, setFromDateValue] = React.useState("dd / mm / yyyy"); | ||||
const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | const [toDateValue, setToDateValue] = React.useState("dd / mm / yyyy"); | ||||
React.useEffect(() => { | |||||
if(searchCriteria.status!=undefined){ | |||||
if(searchCriteria.status === ""){ | |||||
ComboData.publicNoticeStatic_GLD[0] | |||||
}else{ | |||||
setSelectedStatus(ComboData.publicNoticeStatic_GLD.find(item => item.type === searchCriteria.status)) | |||||
} | |||||
}else{ | |||||
setSelectedStatus(ComboData.publicNoticeStatic_GLD[0]) | |||||
} | |||||
}, [searchCriteria]); | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
}, [minDate]); | }, [minDate]); | ||||
@@ -81,12 +93,18 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
React.useEffect(() => { | React.useEffect(() => { | ||||
if (orgComboData && orgComboData.length > 0) { | if (orgComboData && orgComboData.length > 0) { | ||||
setOrgCombo(orgComboData); | setOrgCombo(orgComboData); | ||||
if(searchCriteria.orgId!=undefined){ | |||||
setOrgSelected(orgComboData.find(item => item.key === searchCriteria.orgId)) | |||||
} | |||||
} | } | ||||
}, [orgComboData]); | }, [orgComboData]); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
if (issueComboData && issueComboData.length > 0) { | if (issueComboData && issueComboData.length > 0) { | ||||
setIssueCombo(issueComboData); | setIssueCombo(issueComboData); | ||||
if(searchCriteria.issueId!=undefined){ | |||||
setIssueSelected(issueComboData.find(item => item.id === searchCriteria.issueId)) | |||||
} | |||||
} | } | ||||
}, [issueComboData]); | }, [issueComboData]); | ||||
@@ -98,7 +116,12 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
setSelectedStatus({key: 0, label: 'All', type: 'all'}); | setSelectedStatus({key: 0, label: 'All', type: 'all'}); | ||||
setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | ||||
setMaxDate(DateUtils.dateValue(new Date())) | setMaxDate(DateUtils.dateValue(new Date())) | ||||
reset(); | |||||
reset({ | |||||
appNo:"", | |||||
contact:"", | |||||
groupNo:"" | |||||
}); | |||||
localStorage.setItem('searchCriteria',"") | |||||
} | } | ||||
const getIssueLabel=(data)=> { | const getIssueLabel=(data)=> { | ||||
@@ -9,6 +9,7 @@ import * as React from "react"; | |||||
import * as UrlUtils from "utils/ApiPathConst"; | import * as UrlUtils from "utils/ApiPathConst"; | ||||
import * as HttpUtils from "utils/HttpUtils"; | import * as HttpUtils from "utils/HttpUtils"; | ||||
import * as DateUtils from "utils/DateUtils"; | import * as DateUtils from "utils/DateUtils"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | ||||
@@ -31,16 +32,22 @@ const BackgroundHead = { | |||||
const UserSearchPage_Individual = () => { | const UserSearchPage_Individual = () => { | ||||
const [orgCombo, setOrgCombo] = React.useState([]); | const [orgCombo, setOrgCombo] = React.useState([]); | ||||
const [issueCombo, setIssueCombo] = React.useState([]); | const [issueCombo, setIssueCombo] = React.useState([]); | ||||
const [searchCriteria, setSearchCriteria] = React.useState({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)) | |||||
}); | |||||
const [searchCriteria, setSearchCriteria] = React.useState({}); | |||||
const [onReady, setOnReady] = React.useState(false); | const [onReady, setOnReady] = React.useState(false); | ||||
const [onGridReady, setGridOnReady] = React.useState(false); | const [onGridReady, setGridOnReady] = React.useState(false); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
getOrgCombo(); | getOrgCombo(); | ||||
getIssueCombo(); | getIssueCombo(); | ||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({ | |||||
dateTo: DateUtils.dateValue(new Date()), | |||||
dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)), | |||||
}) | |||||
} | |||||
}, []); | }, []); | ||||
React.useEffect(() => { | React.useEffect(() => { | ||||
@@ -70,6 +77,7 @@ const UserSearchPage_Individual = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -11,8 +11,8 @@ import {useState} from "react"; | |||||
import Checkbox from "@mui/material/Checkbox"; | import Checkbox from "@mui/material/Checkbox"; | ||||
import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline'; | import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline'; | ||||
import { useNavigate } from "react-router"; | import { useNavigate } from "react-router"; | ||||
import axios from "axios"; | |||||
import { GET_EMAIL_LIST } from 'utils/ApiPathConst'; | |||||
// import axios from "axios"; | |||||
// import { GET_EMAIL_LIST } from 'utils/ApiPathConst'; | |||||
import { PNSPS_BUTTON_THEME } from "themes/buttonConst"; | import { PNSPS_BUTTON_THEME } from "themes/buttonConst"; | ||||
import { ThemeProvider } from "@emotion/react"; | import { ThemeProvider } from "@emotion/react"; | ||||
@@ -21,14 +21,13 @@ import { isGrantedAny } from "auth/utils"; | |||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
const UserSearchForm = ({ applySearch, onGridReady, searchCriteria }) => { | |||||
const navigate = useNavigate(); | const navigate = useNavigate(); | ||||
const [type, setType] = useState([]); | const [type, setType] = useState([]); | ||||
const [locked, setLocked] = useState(false); | |||||
const [locked, setLocked] = useState(searchCriteria.locked); | |||||
const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
const onSubmit = (data) => { | const onSubmit = (data) => { | ||||
let typeArray = []; | let typeArray = []; | ||||
@@ -51,14 +50,20 @@ const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
function resetForm() { | function resetForm() { | ||||
setType([]); | setType([]); | ||||
setLocked(false); | setLocked(false); | ||||
reset(); | |||||
axios.get(`${GET_EMAIL_LIST}`) | |||||
.then(r => { | |||||
console.log(r) | |||||
}) | |||||
.catch(err => { | |||||
console.log(err) | |||||
}) | |||||
reset({ | |||||
userName:"", | |||||
fullenName:"", | |||||
post:"", | |||||
email:"" | |||||
}); | |||||
localStorage.setItem('searchCriteria',"") | |||||
// axios.get(`${GET_EMAIL_LIST}`) | |||||
// .then(r => { | |||||
// console.log(r) | |||||
// }) | |||||
// .catch(err => { | |||||
// console.log(err) | |||||
// }) | |||||
} | } | ||||
const handleNewUserClick = () => { | const handleNewUserClick = () => { | ||||
@@ -70,7 +75,9 @@ const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
return ( | return ( | ||||
<MainCard xs={12} md={12} lg={12} | <MainCard xs={12} md={12} lg={12} | ||||
border={false} | border={false} | ||||
content={false}> | |||||
content={false} | |||||
sx={{ backgroundColor: '#fff' }} | |||||
> | |||||
<form onSubmit={handleSubmit(onSubmit)}> | <form onSubmit={handleSubmit(onSubmit)}> | ||||
<Grid container sx={{ backgroundColor: '#ffffff', ml: 2, mt: 1 }} width="98%"> | <Grid container sx={{ backgroundColor: '#ffffff', ml: 2, mt: 1 }} width="98%"> | ||||
@@ -89,6 +96,7 @@ const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("userName")} | {...register("userName")} | ||||
id='userName' | id='userName' | ||||
label="Username" | label="Username" | ||||
defaultValue={searchCriteria.username} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -101,6 +109,7 @@ const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("fullenName")} | {...register("fullenName")} | ||||
id="fullenName" | id="fullenName" | ||||
label="Full Name" | label="Full Name" | ||||
defaultValue={searchCriteria.enName} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -113,6 +122,7 @@ const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("post")} | {...register("post")} | ||||
id="post" | id="post" | ||||
label="Post" | label="Post" | ||||
defaultValue={searchCriteria.post} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -125,6 +135,7 @@ const UserSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("email")} | {...register("email")} | ||||
id="email" | id="email" | ||||
label="Email" | label="Email" | ||||
defaultValue={searchCriteria.email} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -7,6 +7,7 @@ import { | |||||
} from '@mui/material'; | } from '@mui/material'; | ||||
import MainCard from "../../../components/MainCard"; | import MainCard from "../../../components/MainCard"; | ||||
import { useEffect, useState, lazy } from "react"; | import { useEffect, useState, lazy } from "react"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); | ||||
@@ -37,6 +38,15 @@ const UserSettingPage = () => { | |||||
// getUserList(); | // getUserList(); | ||||
// }, [changelocked]); | // }, [changelocked]); | ||||
useEffect(() => { | |||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({}) | |||||
} | |||||
}, []); | |||||
useEffect(() => { | useEffect(() => { | ||||
setOnReady(true); | setOnReady(true); | ||||
}, [searchCriteria]); | }, [searchCriteria]); | ||||
@@ -63,6 +73,7 @@ const UserSettingPage = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -91,6 +102,7 @@ const UserSettingPage = () => { | |||||
<SearchForm | <SearchForm | ||||
applySearch={applySearch} | applySearch={applySearch} | ||||
onGridReady={onGridReady} | onGridReady={onGridReady} | ||||
searchCriteria={searchCriteria} | |||||
/> | /> | ||||
</Grid> | </Grid> | ||||
{/*row 2*/} | {/*row 2*/} | ||||
@@ -7,18 +7,31 @@ import { | |||||
} from '@mui/material'; | } from '@mui/material'; | ||||
import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
import { useForm } from "react-hook-form"; | import { useForm } from "react-hook-form"; | ||||
import { useState } from "react"; | |||||
import { useState,useEffect } from "react"; | |||||
import {PNSPS_BUTTON_THEME} from "themes/buttonConst"; | import {PNSPS_BUTTON_THEME} from "themes/buttonConst"; | ||||
import {ThemeProvider} from "@emotion/react"; | import {ThemeProvider} from "@emotion/react"; | ||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
const UserSearchForm_Individual = ({ applySearch, onGridReady }) => { | |||||
const UserSearchForm_Individual = ({ applySearch, onGridReady, searchCriteria }) => { | |||||
const [type, setType] = useState([]); | const [type, setType] = useState([]); | ||||
const [accountFilter, setAccountFilter] = useState("All"); | const [accountFilter, setAccountFilter] = useState("All"); | ||||
const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
useEffect(() => { | |||||
if(searchCriteria.accountFilter!=undefined){ | |||||
if(searchCriteria.accountFilter === ""){ | |||||
setAccountFilter("All") | |||||
}else{ | |||||
setAccountFilter(searchCriteria.accountFilter) | |||||
} | |||||
}else{ | |||||
setAccountFilter("All") | |||||
} | |||||
}, [searchCriteria]); | |||||
const onSubmit = (data) => { | const onSubmit = (data) => { | ||||
let typeArray = []; | let typeArray = []; | ||||
@@ -42,7 +55,12 @@ const UserSearchForm_Individual = ({ applySearch, onGridReady }) => { | |||||
function resetForm() { | function resetForm() { | ||||
setType([]); | setType([]); | ||||
setAccountFilter("All"); | setAccountFilter("All"); | ||||
reset(); | |||||
reset({ | |||||
userName:"", | |||||
fullenName:"", | |||||
email:"", | |||||
phone:"", | |||||
}); | |||||
} | } | ||||
return ( | return ( | ||||
@@ -67,6 +85,7 @@ const UserSearchForm_Individual = ({ applySearch, onGridReady }) => { | |||||
{...register("userName")} | {...register("userName")} | ||||
id='userName' | id='userName' | ||||
label="Username" | label="Username" | ||||
defaultValue={searchCriteria.username} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -79,6 +98,7 @@ const UserSearchForm_Individual = ({ applySearch, onGridReady }) => { | |||||
{...register("fullenName")} | {...register("fullenName")} | ||||
id="fullenName" | id="fullenName" | ||||
label="Full Name" | label="Full Name" | ||||
defaultValue={searchCriteria.fullName} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -91,6 +111,7 @@ const UserSearchForm_Individual = ({ applySearch, onGridReady }) => { | |||||
{...register("email")} | {...register("email")} | ||||
id="email" | id="email" | ||||
label="Email" | label="Email" | ||||
defaultValue={searchCriteria.email} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -103,6 +124,7 @@ const UserSearchForm_Individual = ({ applySearch, onGridReady }) => { | |||||
{...register("phone")} | {...register("phone")} | ||||
id="phone" | id="phone" | ||||
label="Phone" | label="Phone" | ||||
defaultValue={searchCriteria.phone} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -4,6 +4,8 @@ import { | |||||
} from '@mui/material'; | } from '@mui/material'; | ||||
import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
import { useEffect, useState, lazy } from "react"; | import { useEffect, useState, lazy } from "react"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
const LoadingComponent = Loadable(lazy(() => import('pages/extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(lazy(() => import('pages/extra-pages/LoadingComponent'))); | ||||
const SearchForm = Loadable(lazy(() => import('./UserSearchForm_Individual'))); | const SearchForm = Loadable(lazy(() => import('./UserSearchForm_Individual'))); | ||||
@@ -26,6 +28,15 @@ const UserSearchPage_Individual = () => { | |||||
const [searchCriteria, setSearchCriteria] = useState({}); | const [searchCriteria, setSearchCriteria] = useState({}); | ||||
const [onReady, setOnReady] = useState(false); | const [onReady, setOnReady] = useState(false); | ||||
const [onGridReady, setGridOnReady] = useState(false); | const [onGridReady, setGridOnReady] = useState(false); | ||||
useEffect(() => { | |||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({}) | |||||
} | |||||
}, []); | |||||
useEffect(() => { | useEffect(() => { | ||||
setOnReady(true); | setOnReady(true); | ||||
@@ -34,6 +45,7 @@ const UserSearchPage_Individual = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -64,6 +76,7 @@ const UserSearchPage_Individual = () => { | |||||
<SearchForm | <SearchForm | ||||
applySearch={applySearch} | applySearch={applySearch} | ||||
onGridReady={onGridReady} | onGridReady={onGridReady} | ||||
searchCriteria={searchCriteria} | |||||
/> | /> | ||||
</Grid> | </Grid> | ||||
{/*row 2*/} | {/*row 2*/} | ||||
@@ -14,7 +14,7 @@ import {ThemeProvider} from "@emotion/react"; | |||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) => { | |||||
const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady, searchCriteria}) => { | |||||
const [type, setType] = useState([]); | const [type, setType] = useState([]); | ||||
const [accountFilter, setAccountFilter] = useState("All"); | const [accountFilter, setAccountFilter] = useState("All"); | ||||
@@ -22,6 +22,19 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
const [orgSelected, setOrgSelected] = useState({}); | const [orgSelected, setOrgSelected] = useState({}); | ||||
const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
useEffect(() => { | |||||
if(searchCriteria.accountFilter!=undefined){ | |||||
if(searchCriteria.accountFilter === ""){ | |||||
setAccountFilter("All") | |||||
}else{ | |||||
setAccountFilter(searchCriteria.accountFilter) | |||||
} | |||||
}else{ | |||||
setAccountFilter("All") | |||||
} | |||||
}, [searchCriteria]); | |||||
const onSubmit = (data) => { | const onSubmit = (data) => { | ||||
let typeArray = []; | let typeArray = []; | ||||
@@ -46,6 +59,9 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
useEffect(() => { | useEffect(() => { | ||||
if (orgComboData && orgComboData.length > 0) { | if (orgComboData && orgComboData.length > 0) { | ||||
setOrgCombo(orgComboData); | setOrgCombo(orgComboData); | ||||
if(searchCriteria.orgName!=undefined){ | |||||
setOrgSelected(orgComboData.find(item => item.name === searchCriteria.orgName)) | |||||
} | |||||
} | } | ||||
}, [orgComboData]); | }, [orgComboData]); | ||||
@@ -53,7 +69,14 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
setType([]); | setType([]); | ||||
setAccountFilter("All"); | setAccountFilter("All"); | ||||
setOrgSelected({}); | setOrgSelected({}); | ||||
reset(); | |||||
reset({ | |||||
userName:"", | |||||
fullenName:"", | |||||
email:"", | |||||
phone:"", | |||||
contactPerson:"", | |||||
brNoStr:"", | |||||
}); | |||||
} | } | ||||
return ( | return ( | ||||
@@ -120,6 +143,7 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
{...register("brNoStr")} | {...register("brNoStr")} | ||||
id="brNoStr" | id="brNoStr" | ||||
label="BR No." | label="BR No." | ||||
defaultValue={searchCriteria.brNoStr} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -132,6 +156,7 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
{...register("userName")} | {...register("userName")} | ||||
id='userName' | id='userName' | ||||
label="Username" | label="Username" | ||||
defaultValue={searchCriteria.username} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -144,6 +169,7 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
{...register("contactPerson")} | {...register("contactPerson")} | ||||
id="contactPerson" | id="contactPerson" | ||||
label="Name" | label="Name" | ||||
defaultValue={searchCriteria.contactPerson} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -156,6 +182,7 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
{...register("email")} | {...register("email")} | ||||
id="email" | id="email" | ||||
label="Email" | label="Email" | ||||
defaultValue={searchCriteria.email} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -168,6 +195,7 @@ const UserSearchForm_Organization = ({applySearch, orgComboData, onGridReady}) = | |||||
{...register("phone")} | {...register("phone")} | ||||
id="phone" | id="phone" | ||||
label="Phone" | label="Phone" | ||||
defaultValue={searchCriteria.contactTel} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -7,6 +7,7 @@ import { useEffect, useState, lazy } from "react"; | |||||
import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
import * as HttpUtils from "utils/HttpUtils"; | import * as HttpUtils from "utils/HttpUtils"; | ||||
import {GET_ORG_COMBO} from "utils/ApiPathConst"; | import {GET_ORG_COMBO} from "utils/ApiPathConst"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); | ||||
const SearchForm = Loadable(lazy(() => import('./UserSearchForm_Organization'))); | const SearchForm = Loadable(lazy(() => import('./UserSearchForm_Organization'))); | ||||
@@ -34,6 +35,12 @@ const UserSearchPage_Organization = () => { | |||||
useEffect(() => { | useEffect(() => { | ||||
getOrgCombo(); | getOrgCombo(); | ||||
// getIssueCombo(); | // getIssueCombo(); | ||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({}) | |||||
} | |||||
}, []); | }, []); | ||||
function getOrgCombo() { | function getOrgCombo() { | ||||
@@ -53,6 +60,7 @@ const UserSearchPage_Organization = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -81,6 +89,7 @@ const UserSearchPage_Organization = () => { | |||||
applySearch={applySearch} | applySearch={applySearch} | ||||
orgComboData={orgCombo} | orgComboData={orgCombo} | ||||
onGridReady={onGridReady} | onGridReady={onGridReady} | ||||
searchCriteria={searchCriteria} | |||||
/> | /> | ||||
</Grid> | </Grid> | ||||
{/*row 2*/} | {/*row 2*/} | ||||
@@ -14,7 +14,7 @@ import { ThemeProvider } from "@emotion/react"; | |||||
import { isGrantedAny } from "auth/utils"; | import { isGrantedAny } from "auth/utils"; | ||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
const UserGroupSearchForm = ({ applySearch, onGridReady }) => { | |||||
const UserGroupSearchForm = ({ applySearch, onGridReady, searchCriteria }) => { | |||||
const navigate = useNavigate(); | const navigate = useNavigate(); | ||||
const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
@@ -23,7 +23,10 @@ const UserGroupSearchForm = ({ applySearch, onGridReady }) => { | |||||
}; | }; | ||||
function resetForm() { | function resetForm() { | ||||
reset(); | |||||
reset({ | |||||
name:"", | |||||
description:"" | |||||
}); | |||||
} | } | ||||
const handleNewGroupClick = (id) => { | const handleNewGroupClick = (id) => { | ||||
@@ -54,6 +57,7 @@ const UserGroupSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("name")} | {...register("name")} | ||||
id='userGroupName' | id='userGroupName' | ||||
label="User Group Name" | label="User Group Name" | ||||
defaultValue={searchCriteria.name} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -66,6 +70,7 @@ const UserGroupSearchForm = ({ applySearch, onGridReady }) => { | |||||
{...register("description")} | {...register("description")} | ||||
id="userGroupDescription" | id="userGroupDescription" | ||||
label="User Group Description" | label="User Group Description" | ||||
defaultValue={searchCriteria.description} | |||||
InputLabelProps={{ | InputLabelProps={{ | ||||
shrink: true | shrink: true | ||||
}} | }} | ||||
@@ -8,6 +8,7 @@ import { | |||||
import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
import { useEffect, useState } from "react"; | import { useEffect, useState } from "react"; | ||||
import * as React from "react"; | import * as React from "react"; | ||||
import { getSearchCriteria } from "auth/utils"; | |||||
//import LoadingComponent from "../extra-pages/LoadingComponent"; | //import LoadingComponent from "../extra-pages/LoadingComponent"; | ||||
// import UserGroupSearchForm from "./UserGroupSearchForm"; | // import UserGroupSearchForm from "./UserGroupSearchForm"; | ||||
@@ -36,6 +37,15 @@ const UserGroupSearchPanel = () => { | |||||
const [onReady, setOnReady] = useState(false); | const [onReady, setOnReady] = useState(false); | ||||
const [onGridReady, setGridOnReady] = useState(false); | const [onGridReady, setGridOnReady] = useState(false); | ||||
useEffect(() => { | |||||
if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
}else{ | |||||
localStorage.setItem('searchCriteria',"") | |||||
setSearchCriteria({}) | |||||
} | |||||
}, []); | |||||
useEffect(() => { | useEffect(() => { | ||||
setOnReady(true); | setOnReady(true); | ||||
}, [searchCriteria]); | }, [searchCriteria]); | ||||
@@ -43,6 +53,7 @@ const UserGroupSearchPanel = () => { | |||||
function applySearch(input) { | function applySearch(input) { | ||||
setGridOnReady(true) | setGridOnReady(true) | ||||
setSearchCriteria(input); | setSearchCriteria(input); | ||||
localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
} | } | ||||
function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
@@ -73,6 +84,7 @@ const UserGroupSearchPanel = () => { | |||||
<UserGroupSearchForm | <UserGroupSearchForm | ||||
applySearch={applySearch} | applySearch={applySearch} | ||||
onGridReady={onGridReady} | onGridReady={onGridReady} | ||||
searchCriteria={searchCriteria} | |||||
/> | /> | ||||
</Grid> | </Grid> | ||||
{/*row 2*/} | {/*row 2*/} | ||||