fix: warning code fix

main
Lim Jonguk 3 years ago
parent f6366a6818
commit 6083caf307

@ -1,5 +1,4 @@
import Swal from 'sweetalert2';
import { useCallback, useState } from 'react';
import format from 'date-fns/format';
const XitCmm = {
@ -32,28 +31,6 @@ const XitCmm = {
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) {
return format(dateStr, fmt);
},

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

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

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

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

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

@ -17,7 +17,7 @@ import combo from 'commons/combo_data';
const toDate = new Date();
const SaveResidentSimsaForm = ({ handleModalSave }) => {
const SaveParkingTargetForm = ({ handleModalSave }) => {
const [msuTeam, setMsuTeam] = useState(combo.teams[0].code);
const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd'));
const [msStartsi, setMsStartsi] = useState(getHours(toDate));
@ -165,8 +165,8 @@ const SaveResidentSimsaForm = ({ handleModalSave }) => {
</>
);
};
SaveResidentSimsaForm.propTypes = {
SaveParkingTargetForm.propTypes = {
handleModalSave: PropTypes.func.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 NumberFormat from 'react-number-format';
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 Button from '@mui/material/Button';
@ -12,7 +12,7 @@ import { IconSearch } from '@tabler/icons';
import { getComboCodeList } from 'apis/common';
import FileInputForms from 'views/form/FileInputForms';
const toDate = new Date();
// const toDate = new Date();
const ModifyResidentDataForm = ({ rowData, handleModalSave }) => {
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';
@ -15,7 +15,7 @@ import ModifyResidentDataForm from './ModifyResidentDataForm';
const ResidentDataReview = () => {
const [open, setOpen] = useState(false);
const [create, setCreate] = useState(false);
const [selectedRow, setSelectedRow] = useState({});
// const [selectedRow, setSelectedRow] = useState({});
const [title, setTitle] = useState();
const [rowData, setRowData] = useState({});
@ -54,7 +54,7 @@ const ResidentDataReview = () => {
{ headerName: '접수방법', headerAlign: 'center', field: 'scIngbNm' }
];
const search = () => {
const search = useCallback(() => {
const params = {
page: rowsState.page,
size: rowsState.pageSize
@ -69,11 +69,11 @@ const ResidentDataReview = () => {
// apiRef.current.updateRowData([]);
}
});
};
}, [rowsState.page, rowsState.pageSize]);
useEffect(() => {
search();
}, [rowsState.page, rowsState.pageSize]);
}, [search]); // search, rowsState.page, rowsState.pageSize]);
const handleCreate = () => {
setTitle('거주자 의견진술 자료 신규 등록');

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

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

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

Loading…
Cancel
Save