feat: MuiAlert 공통 추가

미사용 파일 정리
      패키지 위치 조정
main
Lim Jonguk 3 years ago
parent 3ea29bb96c
commit 15a88f050a

@ -115,3 +115,10 @@ npm i -D react-error-overlay@6.0.9
"react-error-overlay": "6.0.9"
}
```
### prettier 가 자동으로 고치는 코드 skip 하려면
-> material-ui Alert component의 severity 속성(error | warning | info | success)
-> "" double-quote 사용해야만 하는데
```js
// prettier-ignore
severity: "error"
```

@ -10,7 +10,7 @@ import { IconSearch } from '@tabler/icons';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import { findBoars } from '../../../apis/board';
const Board = () => {

@ -10,8 +10,8 @@ import { IconFileText } from '@tabler/icons';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import CmmModal from 'views/form/Modal/CmmModal';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import CmmModal from 'views/cmm/CmmModal';
import PublicBoardForm from './PublicBoardForm';
import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public';

@ -15,7 +15,7 @@ import InputLabel from 'ui-component/extended/Form/InputLabel';
import { Delete, List, Save } from '@mui/icons-material';
import { fileDownload } from '../../../apis/common';
import FileForm from 'views/form/FileForm';
import FileForm from 'views/cmm/FileForm';
const PublicBoardForm = (props) => {
// eslint-disable-next-line react/prop-types

@ -6,8 +6,8 @@ import { Button, Divider, Grid, Link } from '@mui/material';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import CmmModal from 'views/form/Modal/CmmModal';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import CmmModal from 'views/cmm/CmmModal';
import { findJudge, findJudgeDatas, saveJudgeData } from 'apis/judge';
import NewJudgeDataForm from 'views/biz/judge/NewJudgeDataForm';
import ModifyJudgeDataForm from 'views/biz/judge/ModifyJudgeDataForm';

@ -11,13 +11,13 @@ import PersonAddTwoToneIcon from '@mui/icons-material/PersonAddTwoTone';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import xitCmm from 'commons/XitCmm';
import CmmModal from 'views/form/Modal/CmmModal';
import CmmModal from 'views/cmm/CmmModal';
import SaveJudgeTargetForm from 'views/biz/judge/SaveJudgeTargetForm';
import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/form/ExcelDownload';
import ExcelDownload from 'views/cmm/ExcelDownload';
import { findJudgeTargets, saveJudgeTargets } from 'apis/judge';
import PropTypes from 'prop-types';

@ -13,11 +13,11 @@ import { IconSearch } from '@tabler/icons';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import xitCmm from 'commons/XitCmm';
import InputLabel from 'ui-component/extended/Form/InputLabel';
import { findJudgeResults, findJudges } from 'apis/judge';
import CmmModal from 'views/form/Modal/CmmModal';
import CmmModal from 'views/cmm/CmmModal';
import ModalJudgeResult from './ModalJudgeResult';
import PropTypes from 'prop-types';

@ -14,7 +14,7 @@ import { useState } from 'react';
import Button from '@mui/material/Button';
import { IconSearch } from '@tabler/icons';
import { findJudgeResults } from 'apis/judge';
import { useAlert } from 'react-alert';
import MuiAlert from 'views/cmm/MuiAlert';
const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: {
@ -37,13 +37,20 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
}));
const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam }) => {
const alert = useAlert();
const [judgeResult, setJudgeResult] = useState({
totJudgeUserData,
judgeData,
simsaUser
});
const [msuTeam, setMsuTeam] = useState(judgeTeam);
const [alertOpen, setAlertOpen] = useState(false);
const [alertState, setAlertState] = useState({
// prettier-ignore
severity: "warning",
title: '',
message: ''
});
const totLabel = ['부과', '서손', '미부과', '계'];
console.log(totJudgeUserData, judgeData, simsaUser, selectedRow, judgeTeam);
const onSearch = async () => {
@ -65,16 +72,21 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow,
judgeData: [],
simsaUser: []
});
alert.show('조회된 데이타가 없습니다.');
return;
// alert.show(' .');
setAlertState({
...alertState,
message: '조회된 데이타가 없습니다.'
});
setAlertOpen(true);
// descriptionAlertsDescriptionAlerts();
} else {
setJudgeResult({
...judgeResult,
totJudgeUserData: res.totJudgeUserData,
judgeData: res.judgeData,
simsaUser: res.simsaUser
});
}
setJudgeResult({
...judgeResult,
totJudgeUserData: res.totJudgeUserData,
judgeData: res.judgeData,
simsaUser: res.simsaUser
});
// totJudgeUserData = res.totJudgeUserData;
// judgeData = res.judgeData;
// simsaUser = res.simsaUser;
@ -187,6 +199,7 @@ const ModalJudgeResult = ({ totJudgeUserData, judgeData, simsaUser, selectedRow,
</Table>
</TableContainer>
</Paper>
<MuiAlert open={alertOpen} setOpen={setAlertOpen} {...alertState} />
</Box>
);
};

@ -10,7 +10,7 @@ import Button from '@mui/material/Button';
import { IconSearch } from '@tabler/icons';
import { getComboCodeList } from 'apis/common';
import FileInputForms from 'views/form/FileInputForms';
import FileInputForms from 'views/cmm/FileInputForms';
// const toDate = new Date();

@ -10,7 +10,7 @@ import Button from '@mui/material/Button';
import { IconSearch } from '@tabler/icons';
import { getComboCodeList } from 'apis/common';
import FileInputForms from 'views/form/FileInputForms';
import FileInputForms from 'views/cmm/FileInputForms';
const toDate = new Date();

@ -11,13 +11,13 @@ import PersonAddTwoToneIcon from '@mui/icons-material/PersonAddTwoTone';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import xitCmm from 'commons/XitCmm';
import CmmModal from 'views/form/Modal/CmmModal';
import CmmModal from 'views/cmm/CmmModal';
import SaveParkingTargetForm from './SaveParkingTargetForm';
import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/form/ExcelDownload';
import ExcelDownload from 'views/cmm/ExcelDownload';
import { findParkingJudgeTargets, saveParkingJudgeTargets } from 'apis/parking';
const ParkingRegister = () => {

@ -15,13 +15,13 @@ import { IconSearch } from '@tabler/icons';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import xitCmm from 'commons/XitCmm';
import { findParkings } from 'apis/parking';
import { findJudgeResults } from 'apis/judge';
import InputLabel from '../../../ui-component/extended/Form/InputLabel';
import ModalJudgeResult from 'views/biz/judge/ModalJudgeResult';
import CmmModal from 'views/form/Modal/CmmModal';
import CmmModal from 'views/cmm/CmmModal';
const ParkingReview = () => {
const isInit = useRef(true);

@ -10,9 +10,9 @@ import { IconSearch } from '@tabler/icons';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import { getBoardList } from '../../../apis/user';
import CmmModal from '../../form/Modal/CmmModal';
import CmmModal from '../../cmm/CmmModal';
import UserManagerForm from './UserManagerForm';
import { deletePublicBoard, savePublicBoard } from '../../../apis/public';

@ -15,7 +15,7 @@ import InputLabel from 'ui-component/extended/Form/InputLabel';
import { Delete, List, Save } from '@mui/icons-material';
import { fileDownload } from '../../../apis/common';
import FileForm from 'views/form/FileForm';
import FileForm from 'views/cmm/FileForm';
const PublicBoardForm = (props) => {
// eslint-disable-next-line react/prop-types

@ -10,8 +10,8 @@ import { IconSearch } from '@tabler/icons';
import MainCard from 'ui-component/cards/MainCard';
// project imports
import MuiDataGrid from 'views/form/MuiDataGrid';
import CmmModal from '../../form/Modal/CmmModal';
import MuiDataGrid from 'views/cmm/MuiDataGrid';
import CmmModal from '../../cmm/CmmModal';
import UserManagerForm from './UserManagerForm';
import { deletePublicBoard, findPublicBoards, modifyPublicBoardHitCount, savePublicBoard } from 'apis/public';

@ -11,7 +11,7 @@ const style = {
left: '50%',
transform: 'translate(-50%, -50%)',
width: 1050,
maxheight: 700,
minHeight: 500,
bgcolor: 'background.paper',
border: '2px solid #000',
boxShadow: 24,
@ -31,7 +31,7 @@ const CmmModal = ({ isBackdrop = false, open, setOpen, title, children, callback
<MainCard
sx={style}
title={title}
content={false}
content
secondary={
<IconButton size="small" variant="rounded" onClick={handleClose}>
<CloseOutlined fontSize="small" />

@ -0,0 +1,47 @@
import Box from '@mui/material/Box';
import Alert from '@mui/material/Alert';
import IconButton from '@mui/material/IconButton';
import Collapse from '@mui/material/Collapse';
import CloseIcon from '@mui/icons-material/Close';
import AlertTitle from '@mui/material/AlertTitle';
import PropTypes from 'prop-types';
// severity double-quote - prettier-ignore
// prettier-ignore
export default function MuiAlert({ severity = "info", title = '', message, open, setOpen }) {
console.log(severity);
return (
<Box sx={{ width: '100%' }}>
<Collapse in={open}>
<Alert
variant="filled"
severity={severity}
action={
<IconButton
aria-label="close"
color="inherit"
size="small"
onClick={() => {
setOpen(false);
}}
>
<CloseIcon fontSize="inherit" />
</IconButton>
}
sx={{ mb: 2 }}
>
{title && <AlertTitle>{title}</AlertTitle>}
<strong>{message}</strong>
</Alert>
</Collapse>
</Box>
);
}
MuiAlert.propTypes = {
severity: PropTypes.string,
title: PropTypes.string,
message: PropTypes.string.isRequired,
open: PropTypes.bool.isRequired,
setOpen: PropTypes.func.isRequired
};

@ -4,7 +4,7 @@ import MainCard from 'ui-component/cards/MainCard';
import SecondaryAction from 'ui-component/cards/CardSecondaryAction';
import NestedModal from './NestedModal';
import BasicModal from './BasicModal';
import UseGridSelector from '../DataGridPaging';
import UseGridSelector from '../../cmm/DataGridPaging';
// ==============================|| MODAL PAGE ||============================== //

@ -1,42 +0,0 @@
import React from 'react';
import { Dialog, DialogTitle, DialogContent, makeStyles, Typography } from '@mui/material';
import Controls from './controls/Controls';
// import CloseIcon from '@mui/icons-material';
import { IconSquareX } from '@tabler/icons';
const useStyles = makeStyles((theme) => ({
dialogWrapper: {
padding: theme.spacing(2),
position: 'absolute',
top: theme.spacing(5)
},
dialogTitle: {
paddingRight: '0px'
}
}));
export default function Popup(props) {
const { title, children, openPopup, setOpenPopup } = props;
const classes = useStyles();
return (
<Dialog open={openPopup} maxWidth="md" classes={{ paper: classes.dialogWrapper }}>
<DialogTitle className={classes.dialogTitle}>
<div style={{ display: 'flex' }}>
<Typography variant="h6" component="div" style={{ flexGrow: 1 }}>
{title}
</Typography>
<Controls.ActionButton
color="secondary"
onClick={() => {
setOpenPopup(false);
}}
>
<IconSquareX />
</Controls.ActionButton>
</div>
</DialogTitle>
<DialogContent dividers>{children}</DialogContent>
</Dialog>
);
}

@ -1,32 +0,0 @@
import React from 'react';
import { Button, makeStyles } from '@mui/material';
const useStyles = makeStyles((theme) => ({
root: {
minWidth: 0,
margin: theme.spacing(0.5)
},
secondary: {
backgroundColor: theme.palette.secondary.light,
'& .MuiButton-label': {
color: theme.palette.secondary.main
}
},
primary: {
backgroundColor: theme.palette.primary.light,
'& .MuiButton-label': {
color: theme.palette.primary.main
}
}
}));
export default function ActionButton(props) {
const { color, children, onClick } = props;
const classes = useStyles();
return (
<Button className={`${classes.root} ${classes[color]}`} onClick={onClick}>
{children}
</Button>
);
}

@ -1,29 +0,0 @@
import React from 'react';
import { Button as MuiButton, makeStyles } from '@mui/material';
const useStyles = makeStyles((theme) => ({
root: {
margin: theme.spacing(0.5)
},
label: {
textTransform: 'none'
}
}));
export default function Button(props) {
const { text, size, color, variant, onClick, ...other } = props;
const classes = useStyles();
return (
<MuiButton
variant={variant || 'contained'}
size={size || 'large'}
color={color || 'primary'}
onClick={onClick}
{...other}
classes={{ root: classes.root, label: classes.label }}
>
{text}
</MuiButton>
);
}

@ -1,29 +0,0 @@
import React from 'react';
import { FormControl, FormControlLabel, Checkbox as MuiCheckbox } from '@mui/material';
export default function Checkbox(props) {
const { name, label, value, onChange } = props;
const convertToDefEventPara = (name, value) => ({
target: {
name,
value
}
});
return (
<FormControl>
<FormControlLabel
control={
<MuiCheckbox
name={name}
color="primary"
checked={value}
onChange={(e) => onChange(convertToDefEventPara(name, e.target.checked))}
/>
}
label={label}
/>
</FormControl>
);
}

@ -1,17 +0,0 @@
import Input from './Input';
import RadioGroup from './RadioGroup';
import Select from './Select';
import Checkbox from './Checkbox';
import Button from './Button';
import ActionButton from './ActionButton';
const Controls = {
Input,
RadioGroup,
Select,
Checkbox,
Button,
ActionButton
};
export default Controls;

@ -1,17 +0,0 @@
import React from 'react';
import { TextField } from '@mui/material';
export default function Input(props) {
const { name, label, value, error = null, onChange, ...other } = props;
return (
<TextField
variant="outlined"
label={label}
name={name}
value={value}
onChange={onChange}
{...other}
{...(error && { error: true, helperText: error })}
/>
);
}

@ -1,17 +0,0 @@
import React from 'react';
import { FormControl, FormLabel, RadioGroup as MuiRadioGroup, FormControlLabel, Radio } from '@mui/material';
export default function RadioGroup(props) {
const { name, label, value, onChange, items } = props;
return (
<FormControl>
<FormLabel>{label}</FormLabel>
<MuiRadioGroup row name={name} value={value} onChange={onChange}>
{items.map((item) => (
<FormControlLabel key={item.id} value={item.id} control={<Radio />} label={item.title} />
))}
</MuiRadioGroup>
</FormControl>
);
}

@ -1,21 +0,0 @@
import React from 'react';
import { FormControl, InputLabel, Select as MuiSelect, MenuItem, FormHelperText } from '@mui/material';
export default function Select(props) {
const { name, label, value, error = null, onChange, options } = props;
return (
<FormControl variant="outlined" {...(error && { error: true })}>
<InputLabel>{label}</InputLabel>
<MuiSelect label={label} name={name} value={value} onChange={onChange}>
<MenuItem value="">None</MenuItem>
{options.map((item) => (
<MenuItem key={item.id} value={item.id}>
{item.title}
</MenuItem>
))}
</MuiSelect>
{error && <FormHelperText>{error}</FormHelperText>}
</FormControl>
);
}
Loading…
Cancel
Save