| @@ -140,6 +140,8 @@ export const getSearchCriteria = (path) =>{ | |||||
| searchCriteria = JSON.parse(localStorage.getItem("searchCriteria")) | searchCriteria = JSON.parse(localStorage.getItem("searchCriteria")) | ||||
| if (searchCriteria.path === path){ | if (searchCriteria.path === path){ | ||||
| return searchCriteria.data | return searchCriteria.data | ||||
| } else { | |||||
| return "" | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -39,6 +39,22 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| setToDateValue(maxDate); | setToDateValue(maxDate); | ||||
| }, [maxDate]); | }, [maxDate]); | ||||
| const _sx = { | |||||
| padding: "4 2 4 2", | |||||
| boxShadow: 1, | |||||
| border: 1, | |||||
| borderColor: '#DDD', | |||||
| '& .MuiDataGrid-cell': { | |||||
| borderTop: 1, | |||||
| borderBottom: 1, | |||||
| borderColor: "#EEE" | |||||
| }, | |||||
| '& .MuiDataGrid-footerContainer': { | |||||
| border: 1, | |||||
| borderColor: "#EEE" | |||||
| } | |||||
| } | |||||
| const marginBottom = 2.5; | const marginBottom = 2.5; | ||||
| const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
| const onSubmit = (data) => { | const onSubmit = (data) => { | ||||
| @@ -61,6 +77,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| 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(); | ||||
| localStorage.setItem('searchCriteria',"") | |||||
| } | } | ||||
| @@ -68,7 +85,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| <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' }} | |||||
| sx={_sx} | |||||
| > | > | ||||
| <form onSubmit={handleSubmit(onSubmit)}> | <form onSubmit={handleSubmit(onSubmit)}> | ||||
| @@ -187,6 +204,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| variant="contained" | variant="contained" | ||||
| type="submit" | type="submit" | ||||
| disabled={onGridReady} | disabled={onGridReady} | ||||
| aria-label={intl.formatMessage({id: 'submit'})} | |||||
| > | > | ||||
| <FormattedMessage id="submit"></FormattedMessage> | <FormattedMessage id="submit"></FormattedMessage> | ||||
| </Button> | </Button> | ||||
| @@ -14,6 +14,7 @@ const SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); | |||||
| const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | ||||
| import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | ||||
| import { FormattedMessage } from "react-intl"; | import { FormattedMessage } from "react-intl"; | ||||
| import { getSearchCriteria } from "auth/utils"; | |||||
| const BackgroundHead = { | const BackgroundHead = { | ||||
| backgroundImage: `url(${titleBackgroundImg})`, | backgroundImage: `url(${titleBackgroundImg})`, | ||||
| @@ -29,21 +30,32 @@ const BackgroundHead = { | |||||
| const UserSearchPage_Individual = () => { | const UserSearchPage_Individual = () => { | ||||
| const [searchCriteria, setSearchCriteria] = React.useState({ | |||||
| dateTo: DateUtils.dateValue(new Date()), | |||||
| dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 90)), | |||||
| }); | |||||
| 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(() => { | ||||
| setOnReady(true); | |||||
| 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(() => { | |||||
| if(Object.keys(searchCriteria).length>0){ | |||||
| setOnReady(true); | |||||
| } | |||||
| }, [searchCriteria]); | }, [searchCriteria]); | ||||
| function applySearch(input) { | function applySearch(input) { | ||||
| setGridOnReady(true) | |||||
| setSearchCriteria(input); | setSearchCriteria(input); | ||||
| localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
| } | } | ||||
| function applyGridOnReady(input) { | function applyGridOnReady(input) { | ||||
| @@ -5,13 +5,21 @@ import { useNavigate } from "react-router-dom"; | |||||
| import { FiDataGrid } from "components/FiDataGrid"; | import { FiDataGrid } from "components/FiDataGrid"; | ||||
| import {useIntl} from "react-intl"; | import {useIntl} from "react-intl"; | ||||
| import { clickableLink } from 'utils/CommonFunction'; | import { clickableLink } from 'utils/CommonFunction'; | ||||
| import {GET_MSG_LIST} from "utils/ApiPathConst"; | |||||
| // ==============================|| EVENT TABLE ||============================== // | // ==============================|| EVENT TABLE ||============================== // | ||||
| export default function MsgTable({ recordList }) { | |||||
| const [rows, setRows] = React.useState(recordList); | |||||
| export default function MsgTable({ searchCriteria, applyGridOnReady }) { | |||||
| const navigate = useNavigate() | const navigate = useNavigate() | ||||
| const intl = useIntl(); | const intl = useIntl(); | ||||
| const [_searchCriteria, set_searchCriteria] = React.useState(searchCriteria); | |||||
| React.useEffect(() => { | |||||
| set_searchCriteria(searchCriteria); | |||||
| }, [searchCriteria]); | |||||
| const _sx = { | const _sx = { | ||||
| padding: "4 2 4 2", | padding: "4 2 4 2", | ||||
| boxShadow: 1, | boxShadow: 1, | ||||
| @@ -25,25 +33,24 @@ export default function MsgTable({ recordList }) { | |||||
| '& .MuiDataGrid-footerContainer': { | '& .MuiDataGrid-footerContainer': { | ||||
| border: 1, | border: 1, | ||||
| borderColor: "#EEE" | borderColor: "#EEE" | ||||
| } | |||||
| }, | |||||
| "& .MuiDataGrid-columnHeaderTitle": { | |||||
| whiteSpace: "normal", | |||||
| lineHeight: "normal" | |||||
| }, | |||||
| "& .MuiDataGrid-columnHeader": { | |||||
| // Forced to use important since overriding inline styles | |||||
| height: "unset !important" | |||||
| }, | |||||
| } | } | ||||
| React.useEffect(() => { | |||||
| setRows(recordList); | |||||
| }, [recordList]); | |||||
| const handleEditClick = (params) => () => { | |||||
| navigate('/msg/details/' + params.row.id); | |||||
| }; | |||||
| const columns = [ | const columns = [ | ||||
| { | { | ||||
| id: 'sentDate', | id: 'sentDate', | ||||
| field: 'sentDate', | field: 'sentDate', | ||||
| headerName: intl.formatMessage({id: 'date'}), | headerName: intl.formatMessage({id: 'date'}), | ||||
| width: 170, | width: 170, | ||||
| renderCell: (params) => { | |||||
| return DateUtils.datetimeStr(params.row.sentDate); | |||||
| valueGetter: (params) => { | |||||
| return DateUtils.datetimeStr(params?.value); | |||||
| }, | }, | ||||
| }, | }, | ||||
| { | { | ||||
| @@ -57,16 +64,24 @@ export default function MsgTable({ recordList }) { | |||||
| }, | }, | ||||
| ]; | ]; | ||||
| function handleEditClick(params) { | |||||
| navigate('/msg/details/' + params.row.id); | |||||
| } | |||||
| return ( | return ( | ||||
| <div style={{ minHeight: 400, width: '100%' }}> | |||||
| <div style={{ width: '100%', overflowX: 'auto'}}> | |||||
| <FiDataGrid | <FiDataGrid | ||||
| sx={_sx} | sx={_sx} | ||||
| rowHeight={80} | |||||
| rows={rows} | |||||
| columns={columns} | columns={columns} | ||||
| customPageSize={20} | |||||
| customPageSize={10} | |||||
| getRowHeight={() => 'auto'} | |||||
| onRowDoubleClick={handleEditClick} | onRowDoubleClick={handleEditClick} | ||||
| applyGridOnReady={applyGridOnReady} | |||||
| doLoad={React.useMemo(() => ({ | |||||
| url: GET_MSG_LIST, | |||||
| params: _searchCriteria, | |||||
| }), [_searchCriteria])} | |||||
| /> | /> | ||||
| </div> | </div> | ||||
| ); | ); | ||||
| @@ -21,7 +21,7 @@ import {AdapterDayjs} from "@mui/x-date-pickers/AdapterDayjs"; | |||||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
| const SearchForm = ({ applySearch, searchCriteria }) => { | |||||
| const SearchForm = ({ applySearch, searchCriteria, onGridReady }) => { | |||||
| const intl = useIntl(); | const intl = useIntl(); | ||||
| const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); | const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); | ||||
| const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); | const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); | ||||
| @@ -64,7 +64,7 @@ const SearchForm = ({ applySearch, searchCriteria }) => { | |||||
| sentDateTo = DateUtils.dateValue(toDateValue) | sentDateTo = DateUtils.dateValue(toDateValue) | ||||
| } | } | ||||
| const temp = { | const temp = { | ||||
| keywork: data.keywork, | |||||
| keyword: data.keyword, | |||||
| dateFrom: sentDateFrom, | dateFrom: sentDateFrom, | ||||
| dateTo: sentDateTo, | dateTo: sentDateTo, | ||||
| }; | }; | ||||
| @@ -75,6 +75,8 @@ const SearchForm = ({ applySearch, searchCriteria }) => { | |||||
| 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(); | ||||
| localStorage.setItem('searchCriteria',"") | |||||
| } | } | ||||
| @@ -196,6 +198,7 @@ const SearchForm = ({ applySearch, searchCriteria }) => { | |||||
| <Button | <Button | ||||
| variant="contained" | variant="contained" | ||||
| type="submit" | type="submit" | ||||
| disabled={onGridReady} | |||||
| aria-label={intl.formatMessage({id: 'submit'})} | aria-label={intl.formatMessage({id: 'submit'})} | ||||
| > | > | ||||
| <FormattedMessage id="submit"/> | <FormattedMessage id="submit"/> | ||||
| @@ -5,9 +5,9 @@ import { | |||||
| Stack | Stack | ||||
| } from '@mui/material'; | } from '@mui/material'; | ||||
| import MainCard from "components/MainCard"; | import MainCard from "components/MainCard"; | ||||
| import * as UrlUtils from "utils/ApiPathConst"; | |||||
| // import * as UrlUtils from "utils/ApiPathConst"; | |||||
| import * as React from "react"; | import * as React from "react"; | ||||
| 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 Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
| @@ -16,6 +16,7 @@ const SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); | |||||
| const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | ||||
| import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | ||||
| import {FormattedMessage} from "react-intl"; | import {FormattedMessage} from "react-intl"; | ||||
| import { getSearchCriteria } from "auth/utils"; | |||||
| const BackgroundHead = { | const BackgroundHead = { | ||||
| backgroundImage: `url(${titleBackgroundImg})`, | backgroundImage: `url(${titleBackgroundImg})`, | ||||
| @@ -31,41 +32,58 @@ const BackgroundHead = { | |||||
| const Index = () => { | const Index = () => { | ||||
| const [record,setRecord] = 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); | |||||
| React.useEffect(() => { | React.useEffect(() => { | ||||
| setOnReady(true); | |||||
| }, [record]); | |||||
| 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(() => { | ||||
| loadGrid(); | |||||
| if(Object.keys(searchCriteria).length>0){ | |||||
| setOnReady(true); | |||||
| } | |||||
| }, [searchCriteria]); | }, [searchCriteria]); | ||||
| function loadGrid(){ | |||||
| HttpUtils.get({ | |||||
| url: UrlUtils.GET_MSG_LIST, | |||||
| params: searchCriteria, | |||||
| onSuccess: function(responseData){ | |||||
| setRecord(responseData); | |||||
| } | |||||
| }); | |||||
| } | |||||
| // function loadGrid(){ | |||||
| // HttpUtils.get({ | |||||
| // url: UrlUtils.GET_MSG_LIST, | |||||
| // params: searchCriteria, | |||||
| // onSuccess: function(responseData){ | |||||
| // setRecord(responseData); | |||||
| // } | |||||
| // }); | |||||
| // } | |||||
| function applySearch(input) { | function applySearch(input) { | ||||
| setGridOnReady(true) | |||||
| setSearchCriteria(input); | setSearchCriteria(input); | ||||
| localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
| } | |||||
| function applyGridOnReady(input) { | |||||
| setGridOnReady(input); | |||||
| } | } | ||||
| return ( | return ( | ||||
| !onReady ? | !onReady ? | ||||
| <LoadingComponent/> | |||||
| <Grid container sx={{ minHeight: '95vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center"> | |||||
| <Grid item> | |||||
| <LoadingComponent /> | |||||
| </Grid> | |||||
| </Grid> | |||||
| : | : | ||||
| <Grid container sx={{minHeight: '85vh',backgroundColor:'#ffffff'}} direction="column"> | |||||
| <Grid container sx={{ minHeight: '95vh',backgroundColor: 'backgroundColor.default' }} direction="column"> | |||||
| <Grid item xs={12}> | <Grid item xs={12}> | ||||
| <div style={BackgroundHead}> | <div style={BackgroundHead}> | ||||
| <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center"> | <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center"> | ||||
| @@ -78,8 +96,9 @@ const Index = () => { | |||||
| {/*row 1*/} | {/*row 1*/} | ||||
| <Grid item xs={12} md={12} lg={12}> | <Grid item xs={12} md={12} lg={12}> | ||||
| <SearchForm | <SearchForm | ||||
| applySearch={applySearch} | |||||
| searchCriteria={searchCriteria} | |||||
| applySearch={applySearch} | |||||
| searchCriteria={searchCriteria} | |||||
| onGridReady={onGridReady} | |||||
| /> | /> | ||||
| </Grid> | </Grid> | ||||
| {/*row 2*/} | {/*row 2*/} | ||||
| @@ -90,7 +109,9 @@ const Index = () => { | |||||
| sx={{width: "-webkit-fill-available"}} | sx={{width: "-webkit-fill-available"}} | ||||
| > | > | ||||
| <EventTable | <EventTable | ||||
| recordList={record} | |||||
| // recordList={record} | |||||
| searchCriteria={searchCriteria} | |||||
| applyGridOnReady={applyGridOnReady} | |||||
| /> | /> | ||||
| </MainCard> | </MainCard> | ||||
| </Grid> | </Grid> | ||||
| @@ -25,7 +25,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| const intl = useIntl(); | const intl = useIntl(); | ||||
| const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); | const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); | ||||
| const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); | const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); | ||||
| const [status, setStatus] = React.useState(ComboData.paymentStatus[0]); | |||||
| const [status, setStatus] = React.useState(searchCriteria.status!=undefined?ComboData.paymentStatus.find(item => item.type === searchCriteria.status):ComboData.paymentStatus[0]); | |||||
| 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"); | ||||
| @@ -79,6 +79,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| 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(); | ||||
| localStorage.setItem('searchCriteria',"") | |||||
| } | } | ||||
| @@ -14,6 +14,7 @@ const SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); | |||||
| const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | ||||
| import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | ||||
| import {FormattedMessage} from "react-intl"; | import {FormattedMessage} from "react-intl"; | ||||
| import { getSearchCriteria } from "auth/utils"; | |||||
| const BackgroundHead = { | const BackgroundHead = { | ||||
| backgroundImage: `url(${titleBackgroundImg})`, | backgroundImage: `url(${titleBackgroundImg})`, | ||||
| @@ -36,12 +37,27 @@ const Index = () => { | |||||
| const [onGridReady, setGridOnReady] = React.useState(false); | const [onGridReady, setGridOnReady] = React.useState(false); | ||||
| React.useEffect(() => { | React.useEffect(() => { | ||||
| setOnReady(true); | |||||
| 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(() => { | |||||
| if(Object.keys(searchCriteria).length>0){ | |||||
| setOnReady(true); | |||||
| } | |||||
| }, [searchCriteria]); | }, [searchCriteria]); | ||||
| 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) { | ||||
| @@ -26,9 +26,9 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria, iss | |||||
| const [type, setType] = React.useState([]); | const [type, setType] = React.useState([]); | ||||
| const [status, setStatus] = React.useState(searchCriteria.statusKey!=undefined?ComboData.proofStatus_GLD[searchCriteria.statusKey]:ComboData.proofStatus_GLD[0]); | 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 [orgSelected, setOrgSelected] = React.useState({}); | |||||
| const [orgCombo, setOrgCombo] = React.useState(); | const [orgCombo, setOrgCombo] = React.useState(); | ||||
| const [issueSelected, setIssueSelected] = React.useState(searchCriteria.issueId!=undefined?issueComboData && issueComboData.length > 0?issueComboData.find(item => item.id === searchCriteria.issueId):{}:{}); | |||||
| const [issueSelected, setIssueSelected] = React.useState({}); | |||||
| const [issueCombo, setIssueCombo] = React.useState([]); | const [issueCombo, setIssueCombo] = React.useState([]); | ||||
| const [groupSelected, setGroupSelected] = React.useState(searchCriteria.gazettGroup!=undefined?ComboData.groupTitle.find(item => item.code === searchCriteria.gazettGroup):{}); | const [groupSelected, setGroupSelected] = React.useState(searchCriteria.gazettGroup!=undefined?ComboData.groupTitle.find(item => item.code === searchCriteria.gazettGroup):{}); | ||||
| @@ -106,12 +106,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]); | ||||
| @@ -28,10 +28,10 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, issueComboData, o | |||||
| const { locale } = intl; | const { locale } = intl; | ||||
| const [type, setType] = React.useState([]); | const [type, setType] = React.useState([]); | ||||
| const [status, setStatus] = React.useState(ComboData.proofStatus[0]); | |||||
| const [status, setStatus] = React.useState(searchCriteria.statusKey!=undefined?ComboData.proofStatusFull[searchCriteria.statusKey]:ComboData.proofStatusFull[0]); | |||||
| const [issueSelected, setIssueSelected] = React.useState({}); | const [issueSelected, setIssueSelected] = React.useState({}); | ||||
| const [issueCombo, setIssueCombo] = React.useState([]); | 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 [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); | ||||
| const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); | const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); | ||||
| @@ -84,6 +84,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, issueComboData, o | |||||
| gazettGroup: groupSelected?.type, | gazettGroup: groupSelected?.type, | ||||
| dateFrom: sentDateFrom, | dateFrom: sentDateFrom, | ||||
| dateTo: sentDateTo, | dateTo: sentDateTo, | ||||
| statusKey:status?.key, | |||||
| }; | }; | ||||
| if(status?.type && status?.type != 'all'){ | if(status?.type && status?.type != 'all'){ | ||||
| if (status?.type == "Confirmed"){ | if (status?.type == "Confirmed"){ | ||||
| @@ -108,6 +109,9 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, issueComboData, o | |||||
| 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]); | ||||
| @@ -119,6 +123,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, issueComboData, o | |||||
| 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(); | ||||
| localStorage.setItem('searchCriteria',"") | |||||
| } | } | ||||
| function getIssueLabel(data) { | function getIssueLabel(data) { | ||||
| @@ -9,6 +9,7 @@ import * as UrlUtils from "utils/ApiPathConst"; | |||||
| import * as React from "react"; | import * as React from "react"; | ||||
| 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'))); | ||||
| @@ -41,6 +42,11 @@ const UserSearchPage_Individual = () => { | |||||
| React.useEffect(() => { | React.useEffect(() => { | ||||
| getIssueCombo(); | getIssueCombo(); | ||||
| if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){ | |||||
| setSearchCriteria(getSearchCriteria(window.location.pathname)) | |||||
| }else{ | |||||
| localStorage.setItem('searchCriteria',"") | |||||
| } | |||||
| }, []); | }, []); | ||||
| React.useEffect(() => { | React.useEffect(() => { | ||||
| @@ -62,6 +68,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,22 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { | |||||
| const { reset, register, handleSubmit } = useForm() | const { reset, register, handleSubmit } = useForm() | ||||
| const marginBottom = 2.5; | const marginBottom = 2.5; | ||||
| React.useEffect(() => { | |||||
| if(searchCriteria.status!=undefined){ | |||||
| if(localStorage.getItem('userData').creditor){ | |||||
| setStatus(ComboData.publicNoticeStatic_Creditor.find(item => item.type === searchCriteria.status)) | |||||
| }else{ | |||||
| setStatus(ComboData.publicNoticeStatic.find(item => item.type === searchCriteria.status)) | |||||
| } | |||||
| }else{ | |||||
| if(localStorage.getItem('userData').creditor){ | |||||
| setStatus(ComboData.publicNoticeStatic_Creditor[0]) | |||||
| }else{ | |||||
| setStatus(ComboData.publicNoticeStatic[0]) | |||||
| } | |||||
| } | |||||
| }, [searchCriteria]); | |||||
| React.useEffect(() => { | React.useEffect(() => { | ||||
| setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
| }, [minDate]); | }, [minDate]); | ||||
| @@ -5,50 +5,76 @@ 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 SearchForm = Loadable(React.lazy(() => import('./SearchPublicNoticeForm'))); | const SearchForm = Loadable(React.lazy(() => import('./SearchPublicNoticeForm'))); | ||||
| const EventTable = Loadable(React.lazy(() => import('./SearchPublicNoticeTable'))); | const EventTable = Loadable(React.lazy(() => import('./SearchPublicNoticeTable'))); | ||||
| const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); | |||||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
| const UserSearchPage_Individual = () => { | const UserSearchPage_Individual = () => { | ||||
| 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); | |||||
| 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(() => { | |||||
| if(Object.keys(searchCriteria).length>0){ | |||||
| setOnReady(true); | |||||
| } | |||||
| }, [searchCriteria]); | |||||
| function applySearch(input) { | function applySearch(input) { | ||||
| setSearchCriteria(input); | setSearchCriteria(input); | ||||
| localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input})) | |||||
| } | } | ||||
| return ( | return ( | ||||
| <Grid container sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}> | |||||
| {/*row 1*/} | |||||
| <Grid item xs={12} md={12} lg={12} sx={{mb:-3}}> | |||||
| <SearchForm | |||||
| applySearch={applySearch} | |||||
| searchCriteria={searchCriteria} | |||||
| /> | |||||
| </Grid> | |||||
| {/*row 2*/} | |||||
| <Grid item xs={12} md={12} lg={12} > | |||||
| <MainCard elevation={0} | |||||
| border={false} | |||||
| content={false} | |||||
| sx={{width: "-webkit-fill-available",height: "100%", minHeight:'100%'}} | |||||
| > | |||||
| <div style={{height: '100%', width: '100%' }}> | |||||
| <EventTable | |||||
| autoHeight | |||||
| searchCriteria={searchCriteria} | |||||
| /> | |||||
| </div> | |||||
| </MainCard> | |||||
| !onReady ? | |||||
| <Grid container sx={{ height: '100%' }} direction="column" justifyContent="center" alignItems="center"> | |||||
| <Grid item> | |||||
| <LoadingComponent /> | |||||
| </Grid> | |||||
| </Grid> | </Grid> | ||||
| : | |||||
| <Grid container sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}> | |||||
| {/*row 1*/} | |||||
| <Grid item xs={12} md={12} lg={12} sx={{mb:-3}}> | |||||
| <SearchForm | |||||
| applySearch={applySearch} | |||||
| searchCriteria={searchCriteria} | |||||
| /> | |||||
| </Grid> | |||||
| {/*row 2*/} | |||||
| <Grid item xs={12} md={12} lg={12} > | |||||
| <MainCard elevation={0} | |||||
| border={false} | |||||
| content={false} | |||||
| sx={{width: "-webkit-fill-available",height: "100%", minHeight:'100%'}} | |||||
| > | |||||
| <div style={{height: '100%', width: '100%' }}> | |||||
| <EventTable | |||||
| autoHeight | |||||
| searchCriteria={searchCriteria} | |||||
| /> | |||||
| </div> | |||||
| </MainCard> | |||||
| </Grid> | |||||
| </Grid> | |||||
| </Grid> | |||||
| ); | ); | ||||
| }; | }; | ||||