fix: warning code fix

main
Lim Jonguk 3 years ago
parent f6366a6818
commit 6083caf307

@ -1,5 +1,4 @@
import Swal from 'sweetalert2'; import Swal from 'sweetalert2';
import { useCallback, useState } from 'react';
import format from 'date-fns/format'; import format from 'date-fns/format';
const XitCmm = { const XitCmm = {
@ -32,28 +31,6 @@ const XitCmm = {
return false; return false;
}, },
/**
*
* @return [value: string, onchange: (e: ChangeEvent<HTMLInputElement>) => void]
* @param initalValue
* @param validator
*/
useInput(initalValue, validator) {
const [value, setValue] = useState < typeof initalValue > initalValue;
const changer = useCallback(
(e) => {
const v = e.target.value;
if (validator === undefined || validator(v)) {
setValue(v);
}
},
[validator]
);
return [value, setValue, changer];
},
formatDate(dateStr, fmt) { formatDate(dateStr, fmt) {
return format(dateStr, fmt); return format(dateStr, fmt);
}, },

@ -49,7 +49,7 @@ const icons = {
const opst = { const opst = {
id: 'opst', id: 'opst',
title: <FormattedMessage id="opst" />, // title: <FormattedMessage id="opst" />,
type: 'group', type: 'group',
children: [ children: [
{ {

@ -4,7 +4,6 @@ import { lazy } from 'react';
import MainLayout from 'layout/MainLayout'; import MainLayout from 'layout/MainLayout';
import Loadable from 'ui-component/Loadable'; import Loadable from 'ui-component/Loadable';
import AuthGuard from 'utils/route-guard/AuthGuard'; import AuthGuard from 'utils/route-guard/AuthGuard';
import ResidentDataReview from '../views/biz/resident/Review';
// sample page routing // sample page routing
const SamplePage = Loadable(lazy(() => import('views/sample-page'))); const SamplePage = Loadable(lazy(() => import('views/sample-page')));
@ -14,9 +13,15 @@ const DashboardAnalytics = Loadable(lazy(() => import('views/dashboard/Analytics
// opst page routing // opst page routing
const PublicBoard = Loadable(lazy(() => import('views/biz/board/PublicBoard'))); const PublicBoard = Loadable(lazy(() => import('views/biz/board/PublicBoard')));
const Board = Loadable(lazy(() => import('views/biz/board/Board'))); const Board = Loadable(lazy(() => import('views/biz/board/Board')));
const ParkingReview = Loadable(lazy(() => import('views/biz/parking/Review')));
// parking
const ParkingReview = Loadable(lazy(() => import('views/biz/parking/ParkingReview')));
const ParkingDetails = Loadable(lazy(() => import('views/biz/parking/ModalDetails'))); const ParkingDetails = Loadable(lazy(() => import('views/biz/parking/ModalDetails')));
const ParkingRegister = Loadable(lazy(() => import('views/biz/parking/Regist'))); const ParkingRegister = Loadable(lazy(() => import('views/biz/parking/ParkingRegister')));
// resident
const ResidentDataReview = Loadable(lazy(() => import('views/biz/resident/ResidentDataReview')));
const ResidentRegister = Loadable(lazy(() => import('views/biz/resident/ResidentRegist')));
// component // component
const ModalForm = Loadable(lazy(() => import('views/form/Modal'))); const ModalForm = Loadable(lazy(() => import('views/form/Modal')));
@ -61,11 +66,11 @@ const MainRoutes = {
}, },
{ {
path: '/resident/review', path: '/resident/review',
element: <Board /> element: <ResidentRegister />
}, },
{ {
path: '/resident/register', path: '/resident/register',
element: <Board /> element: <ResidentRegister />
}, },
/* 장애인 */ /* 장애인 */
{ {

@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
// material-ui // material-ui
import { Button, Divider, Grid, Link } from '@mui/material'; import { Button, Divider, Grid, Link } from '@mui/material';
@ -11,9 +11,9 @@ import MainCard from 'ui-component/cards/MainCard';
// project imports // project imports
import MuiDataGrid from 'views/form/MuiDataGrid'; import MuiDataGrid from 'views/form/MuiDataGrid';
import CmmModal from '../../form/Modal/CmmModal'; import CmmModal from 'views/form/Modal/CmmModal';
import PublicBoardForm from './PublicBoardForm'; import PublicBoardForm from './PublicBoardForm';
import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from '../../../apis/public'; import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public';
const PublicBoard = () => { const PublicBoard = () => {
const [totalCount, setTotalCount] = useState(0); const [totalCount, setTotalCount] = useState(0);
@ -61,7 +61,7 @@ const PublicBoard = () => {
{ headerName: '조회수', headerAlign: 'center', field: 'inHit', align: 'right' } { headerName: '조회수', headerAlign: 'center', field: 'inHit', align: 'right' }
]; ];
const search = () => { const search = useCallback(() => {
const params = { const params = {
page: rowsState.page, page: rowsState.page,
size: rowsState.pageSize size: rowsState.pageSize
@ -74,11 +74,11 @@ const PublicBoard = () => {
setRowsState((prevState) => ({ ...prevState, rows: response.data })); setRowsState((prevState) => ({ ...prevState, rows: response.data }));
} }
}); });
}; }, [rowsState.page, rowsState.pageSize]);
useEffect(() => { useEffect(() => {
search(); search();
}, [rowsState.page, rowsState.pageSize]); // rowsState.page, rowsState.pageSize, rowsState.rows]); }, [search]); // rowsState.page, rowsState.pageSize, rowsState.rows]);
const handleOnCellClick = (e) => { const handleOnCellClick = (e) => {
if (e?.field === 'inTitle') { if (e?.field === 'inTitle') {

@ -15,7 +15,7 @@ import MuiDataGrid from 'views/form/MuiDataGrid';
import xitCmm from 'commons/XitCmm'; import xitCmm from 'commons/XitCmm';
import CmmModal from 'views/form/Modal/CmmModal'; import CmmModal from 'views/form/Modal/CmmModal';
import SaveParkingSimsaForm from './SaveParkingSimsaForm'; import SaveParkingTargetForm from './SaveParkingTargetForm';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/form/ExcelDownload'; import ExcelDownload from 'views/form/ExcelDownload';
import { findParkingTargets, saveParkingTargets } from 'apis/parking'; import { findParkingTargets, saveParkingTargets } from 'apis/parking';
@ -24,7 +24,7 @@ const ParkingRegister = () => {
const [rcIrTransfer, setRcIrTransfer] = useState('1'); const [rcIrTransfer, setRcIrTransfer] = useState('1');
const [rcSeq1, setRcSeq1] = useState('2022200801'); const [rcSeq1, setRcSeq1] = useState('2022200801');
const [rcSeq2, setRcSeq2] = useState('2022200899'); const [rcSeq2, setRcSeq2] = useState('2022200899');
const [selection, setSelection] = useState([]); const [selectionModel, setSelectionModel] = useState([]);
const [totalCount, setTotalCount] = useState(0); const [totalCount, setTotalCount] = useState(0);
const [rowsStatus, setRowsStatus] = useState({ const [rowsStatus, setRowsStatus] = useState({
page: 0, page: 0,
@ -60,6 +60,7 @@ const ParkingRegister = () => {
findParkingTargets(params).then((response) => { findParkingTargets(params).then((response) => {
if (response && response.data) { if (response && response.data) {
setSelectionModel([]);
setTotalCount(response.count); setTotalCount(response.count);
setRowsStatus((prevRows) => ({ ...prevRows, rows: response.data })); setRowsStatus((prevRows) => ({ ...prevRows, rows: response.data }));
} }
@ -67,7 +68,7 @@ const ParkingRegister = () => {
}; };
const handleSave = () => { const handleSave = () => {
if (selection.length === 0) { if (selectionModel.length === 0) {
xitCmm.alertParam(`처리할 데이타가 없습니다`); xitCmm.alertParam(`처리할 데이타가 없습니다`);
} else { } else {
setOpen(true); setOpen(true);
@ -75,19 +76,19 @@ const ParkingRegister = () => {
} }
}; };
const submitParkingSimsa = (params) => { const submitParkingTargets = (params) => {
const param = { const param = {
...params, ...params,
rcIrTransfer, rcIrTransfer,
rcSeq1, rcSeq1,
rcSeq2, rcSeq2,
rcCodes: selection.map((d) => rowsStatus.rows[d - 1].rcCode) rcCodes: selectionModel.map((d) => rowsStatus.rows[d - 1].rcCode)
}; };
setOpen(false); setOpen(false);
// return false; // return false;
saveParkingTargets(param).then(() => { saveParkingTargets(param).then(() => {
setSelection([]); setSelectionModel([]);
search(); search();
}); });
}; };
@ -105,7 +106,7 @@ const ParkingRegister = () => {
}; };
const handleSelection = (newSelection) => { const handleSelection = (newSelection) => {
setSelection(newSelection); setSelectionModel(newSelection);
}; };
return ( return (
@ -166,7 +167,7 @@ const ParkingRegister = () => {
</Grid> </Grid>
<Grid item> <Grid item>
<Button <Button
disabled={selection.length === 0} disabled={selectionModel.length === 0}
variant="contained" variant="contained"
color="primary" color="primary"
size="small" size="small"
@ -197,9 +198,10 @@ const ParkingRegister = () => {
totalCount={totalCount} totalCount={totalCount}
setRowsStatus={setRowsStatus} setRowsStatus={setRowsStatus}
handleSelection={handleSelection} handleSelection={handleSelection}
selectionModel={selectionModel}
/> />
<CmmModal isBackdrop title="심의등록" open={open} setOpen={setOpen}> <CmmModal isBackdrop title="심의등록" open={open} setOpen={setOpen}>
<SaveParkingSimsaForm isDisabled={selection.length === 0} handleModalSave={submitParkingSimsa} /> <SaveParkingTargetForm isDisabled={selectionModel.length === 0} handleModalSave={submitParkingTargets} />
</CmmModal> </CmmModal>
</MainCard> </MainCard>
); );

@ -109,7 +109,7 @@ const ParkingReview = () => {
} }
]; ];
const search = () => { const search = useCallback(() => {
const params = { const params = {
page: rowsState.page, page: rowsState.page,
size: rowsState.pageSize size: rowsState.pageSize
@ -123,7 +123,7 @@ const ParkingReview = () => {
// apiRef.current.updateRowData([]); // apiRef.current.updateRowData([]);
} }
}); });
}; }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]);
const handleSearch = async (event) => { const handleSearch = async (event) => {
if (!selectedYear) return; if (!selectedYear) return;
@ -141,7 +141,8 @@ const ParkingReview = () => {
return; return;
} }
search(); search();
}, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]); // }, [rowsState.page, rowsState.pageSize, selectedYear, searchTxt]);
}, [search]);
return ( return (
<MainCard> <MainCard>

@ -17,7 +17,7 @@ import combo from 'commons/combo_data';
const toDate = new Date(); const toDate = new Date();
const SaveResidentSimsaForm = ({ handleModalSave }) => { const SaveParkingTargetForm = ({ handleModalSave }) => {
const [msuTeam, setMsuTeam] = useState(combo.teams[0].code); const [msuTeam, setMsuTeam] = useState(combo.teams[0].code);
const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd')); const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd'));
const [msStartsi, setMsStartsi] = useState(getHours(toDate)); const [msStartsi, setMsStartsi] = useState(getHours(toDate));
@ -165,8 +165,8 @@ const SaveResidentSimsaForm = ({ handleModalSave }) => {
</> </>
); );
}; };
SaveResidentSimsaForm.propTypes = { SaveParkingTargetForm.propTypes = {
handleModalSave: PropTypes.func.isRequired handleModalSave: PropTypes.func.isRequired
// isDisabled: PropTypes.bool.isRequired // isDisabled: PropTypes.bool.isRequired
}; };
export default SaveResidentSimsaForm; export default SaveParkingTargetForm;

@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import { useAlert } from 'react-alert'; import { useAlert } from 'react-alert';
import format from 'date-fns/format'; // import format from 'date-fns/format';
import { Grid, TextField, MenuItem, Select, FormControl, InputLabel, InputAdornment } from '@mui/material'; import { Grid, TextField, MenuItem, Select, FormControl, InputLabel, InputAdornment } from '@mui/material';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
@ -12,7 +12,7 @@ import { IconSearch } from '@tabler/icons';
import { getComboCodeList } from 'apis/common'; import { getComboCodeList } from 'apis/common';
import FileInputForms from 'views/form/FileInputForms'; import FileInputForms from 'views/form/FileInputForms';
const toDate = new Date(); // const toDate = new Date();
const ModifyResidentDataForm = ({ rowData, handleModalSave }) => { const ModifyResidentDataForm = ({ rowData, handleModalSave }) => {
const alert = useAlert(); const alert = useAlert();

@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { Button, Divider, Grid, Link } from '@mui/material'; import { Button, Divider, Grid, Link } from '@mui/material';
@ -15,7 +15,7 @@ import ModifyResidentDataForm from './ModifyResidentDataForm';
const ResidentDataReview = () => { const ResidentDataReview = () => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [create, setCreate] = useState(false); const [create, setCreate] = useState(false);
const [selectedRow, setSelectedRow] = useState({}); // const [selectedRow, setSelectedRow] = useState({});
const [title, setTitle] = useState(); const [title, setTitle] = useState();
const [rowData, setRowData] = useState({}); const [rowData, setRowData] = useState({});
@ -54,7 +54,7 @@ const ResidentDataReview = () => {
{ headerName: '접수방법', headerAlign: 'center', field: 'scIngbNm' } { headerName: '접수방법', headerAlign: 'center', field: 'scIngbNm' }
]; ];
const search = () => { const search = useCallback(() => {
const params = { const params = {
page: rowsState.page, page: rowsState.page,
size: rowsState.pageSize size: rowsState.pageSize
@ -69,11 +69,11 @@ const ResidentDataReview = () => {
// apiRef.current.updateRowData([]); // apiRef.current.updateRowData([]);
} }
}); });
}; }, [rowsState.page, rowsState.pageSize]);
useEffect(() => { useEffect(() => {
search(); search();
}, [rowsState.page, rowsState.pageSize]); }, [search]); // search, rowsState.page, rowsState.pageSize]);
const handleCreate = () => { const handleCreate = () => {
setTitle('거주자 의견진술 자료 신규 등록'); setTitle('거주자 의견진술 자료 신규 등록');

@ -15,7 +15,7 @@ import MuiDataGrid from 'views/form/MuiDataGrid';
import xitCmm from 'commons/XitCmm'; import xitCmm from 'commons/XitCmm';
import CmmModal from 'views/form/Modal/CmmModal'; import CmmModal from 'views/form/Modal/CmmModal';
import SaveResidentSimsaForm from './SaveResidentSimsaForm'; import SaveResidentTargetForm from './SaveResidentTargetForm';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/form/ExcelDownload'; import ExcelDownload from 'views/form/ExcelDownload';
import { findParkingTargets, saveParkingTargets } from 'apis/parking'; import { findParkingTargets, saveParkingTargets } from 'apis/parking';
@ -24,7 +24,7 @@ const ResidentRegister = () => {
const [rcIrTransfer, setRcIrTransfer] = useState('1'); const [rcIrTransfer, setRcIrTransfer] = useState('1');
const [rcSeq1, setRcSeq1] = useState('2022200801'); const [rcSeq1, setRcSeq1] = useState('2022200801');
const [rcSeq2, setRcSeq2] = useState('2022200899'); const [rcSeq2, setRcSeq2] = useState('2022200899');
const [selection, setSelection] = useState([]); const [selectionModel, setSelectionModel] = useState([]);
const [totalCount, setTotalCount] = useState(0); const [totalCount, setTotalCount] = useState(0);
const [rowsStatus, setRowsStatus] = useState({ const [rowsStatus, setRowsStatus] = useState({
page: 0, page: 0,
@ -60,6 +60,7 @@ const ResidentRegister = () => {
findParkingTargets(params).then((response) => { findParkingTargets(params).then((response) => {
if (response && response.data) { if (response && response.data) {
setSelectionModel([]);
setTotalCount(response.count); setTotalCount(response.count);
setRowsStatus((prevRows) => ({ ...prevRows, rows: response.data })); setRowsStatus((prevRows) => ({ ...prevRows, rows: response.data }));
} }
@ -67,7 +68,7 @@ const ResidentRegister = () => {
}; };
const handleSave = () => { const handleSave = () => {
if (selection.length === 0) { if (selectionModel.length === 0) {
xitCmm.alertParam(`처리할 데이타가 없습니다`); xitCmm.alertParam(`처리할 데이타가 없습니다`);
} else { } else {
setOpen(true); setOpen(true);
@ -75,19 +76,19 @@ const ResidentRegister = () => {
} }
}; };
const submitParkingSimsa = (params) => { const submitResidentTargets = (params) => {
const param = { const param = {
...params, ...params,
rcIrTransfer, rcIrTransfer,
rcSeq1, rcSeq1,
rcSeq2, rcSeq2,
rcCodes: selection.map((d) => rowsStatus.rows[d - 1].rcCode) rcCodes: selectionModel.map((d) => rowsStatus.rows[d - 1].rcCode)
}; };
setOpen(false); setOpen(false);
// return false; // return false;
saveParkingTargets(param).then(() => { saveParkingTargets(param).then(() => {
setSelection([]); setSelectionModel([]);
search(); search();
}); });
}; };
@ -105,7 +106,7 @@ const ResidentRegister = () => {
}; };
const handleSelection = (newSelection) => { const handleSelection = (newSelection) => {
setSelection(newSelection); setSelectionModel(newSelection);
}; };
return ( return (
@ -166,7 +167,7 @@ const ResidentRegister = () => {
</Grid> </Grid>
<Grid item> <Grid item>
<Button <Button
disabled={selection.length === 0} disabled={selectionModel.length === 0}
variant="contained" variant="contained"
color="primary" color="primary"
size="small" size="small"
@ -199,7 +200,7 @@ const ResidentRegister = () => {
handleSelection={handleSelection} handleSelection={handleSelection}
/> />
<CmmModal isBackdrop title="심의등록" open={open} setOpen={setOpen}> <CmmModal isBackdrop title="심의등록" open={open} setOpen={setOpen}>
<SaveResidentSimsaForm isDisabled={selection.length === 0} handleModalSave={submitResidentSimsa} /> <SaveResidentTargetForm isDisabled={selectionModel.length === 0} handleModalSave={submitResidentTargets} />
</CmmModal> </CmmModal>
</MainCard> </MainCard>
); );

@ -17,7 +17,7 @@ import combo from 'commons/combo_data';
const toDate = new Date(); const toDate = new Date();
const SaveParkingSimsaForm = ({ handleModalSave }) => { const SaveResidentTargetForm = ({ handleModalSave }) => {
const [msuTeam, setMsuTeam] = useState(combo.teams[0].code); const [msuTeam, setMsuTeam] = useState(combo.teams[0].code);
const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd')); const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd'));
const [msStartsi, setMsStartsi] = useState(getHours(toDate)); const [msStartsi, setMsStartsi] = useState(getHours(toDate));
@ -165,8 +165,8 @@ const SaveParkingSimsaForm = ({ handleModalSave }) => {
</> </>
); );
}; };
SaveParkingSimsaForm.propTypes = { SaveResidentTargetForm.propTypes = {
handleModalSave: PropTypes.func.isRequired handleModalSave: PropTypes.func.isRequired
// isDisabled: PropTypes.bool.isRequired // isDisabled: PropTypes.bool.isRequired
}; };
export default SaveParkingSimsaForm; export default SaveResidentTargetForm;

@ -17,7 +17,8 @@ const MuiDataGrid = ({
totalCount = 0, totalCount = 0,
setRowsState = () => {}, setRowsState = () => {},
handleCellClick = () => {}, handleCellClick = () => {},
handleSelection = () => {} handleSelection = () => {},
selectionModel = []
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
const { pageSize } = rowsState; const { pageSize } = rowsState;
@ -64,6 +65,7 @@ const MuiDataGrid = ({
rowsPerPageOptions={[10, 50, 100]} rowsPerPageOptions={[10, 50, 100]}
onCellClick={handleCellClick} onCellClick={handleCellClick}
onSelectionModelChange={handleSelection} onSelectionModelChange={handleSelection}
selectionModel={selectionModel}
// isRowSelectable={(params) => params.row.rowId < 50000} // isRowSelectable={(params) => params.row.rowId < 50000}
pagination pagination
components={{ components={{
@ -89,12 +91,13 @@ MuiDataGrid.propTypes = {
// apiRef: PropTypes.func, // apiRef: PropTypes.func,
isCheckbox: PropTypes.bool, isCheckbox: PropTypes.bool,
// isDisableSelection: PropTypes.bool, // isDisableSelection: PropTypes.bool,
columns: PropTypes.array, columns: PropTypes.array.isRequired,
rowsState: PropTypes.object, rowsState: PropTypes.object.isRequired,
totalCount: PropTypes.number, totalCount: PropTypes.number.isRequired,
setRowsState: PropTypes.func, setRowsState: PropTypes.func.isRequired,
handleCellClick: PropTypes.func, handleCellClick: PropTypes.func,
handleSelection: PropTypes.func handleSelection: PropTypes.func,
selectionModel: PropTypes.array
}; };
export default MuiDataGrid; export default MuiDataGrid;

Loading…
Cancel
Save