fix: alert -> sweetalert2 로 변경 적용

main
minuk926 2 years ago
parent b3a7fe76d4
commit 4756afcd69

@ -55,6 +55,8 @@
rel="stylesheet" rel="stylesheet"
crossorigin="anonymous" crossorigin="anonymous"
/> />
<link rel="stylesheet" href="@sweetalert2/themes/dark/dark.css">
<script src="sweetalert2/dist/sweetalert2.min.js"></script>
<style> <style>
.alert-swal{ .alert-swal{
z-index: 100000; z-index: 100000;

@ -311,3 +311,35 @@
margin-right:0px !important; margin-right:0px !important;
border:0px solid red; border:0px solid red;
} }
.colored-toast {
z-index: 9999999999;
}
.colored-toast.swal2-icon-error {
background-color: #f27474 !important;
}
.colored-toast.swal2-icon-warning {
background-color: #f8bb86 !important;
}
.colored-toast.swal2-icon-info {
background-color: #3fc3ee !important;
}
.colored-toast.swal2-icon-question {
background-color: #87adbd !important;
}
.colored-toast .swal2-title {
color: white;
}
.colored-toast .swal2-close {
color: white;
}
.colored-toast .swal2-html-container {
color: white;
}

@ -1,6 +1,10 @@
import Swal from 'sweetalert2'; import Swal from 'sweetalert2';
import withReactContent from 'sweetalert2-react-content';
import format from 'date-fns/format'; import format from 'date-fns/format';
const swal = withReactContent(Swal);
const XitCmm = { const XitCmm = {
/** /**
* validation check error message * validation check error message
@ -136,4 +140,77 @@ const XitCmm = {
else document.cookie = `${name}=${encodeURIComponent(value)}${{ expires: 'Sun, 01-May-2019 14:00:00 UTC' }}`; else document.cookie = `${name}=${encodeURIComponent(value)}${{ expires: 'Sun, 01-May-2019 14:00:00 UTC' }}`;
} }
}; };
export const confirmAlert = (text, confirmProcess, dismissProcess) => {
swal
.fire({
backdrop: true,
icon: 'warning',
text,
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
cancelButtonText: '취소',
confirmButtonText: '승인'
})
.then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
confirmProcess();
// swal.close();
} else if (result.dismiss === Swal.DismissReason.cancel) {
if (dismissProcess) dismissProcess();
// swal.close();
}
});
};
export const saveAlert = (confirmProcess, dismissProcess) => {
confirmAlert('저장 하시겠습니까?', confirmProcess, dismissProcess);
};
export const removeAlert = (confirmProcess, dismissProcess) => {
confirmAlert('삭제 하시겠습니까?', confirmProcess, dismissProcess);
};
export const Toast = swal.mixin({
toast: true,
backdrop: true,
position: 'center-center', // 'bottom', 'center-center',
showConfirmButton: true,
iconColor: 'white',
customClass: {
popup: 'colored-toast'
},
timer: 2000,
timerProgressBar: true
// didOpen: (toast) => {
// toast.addEventListener('mouseenter', Swal.stopTimer);
// toast.addEventListener('mouseleave', Swal.resumeTimer);
// }
// toast: true,
// backdrop: true,
// position: 'bottom',
// iconColor: 'white',
// customClass: {
// popup: 'colored-toast'
// },
// showConfirmButton: true,
// timer: 1500,
// timerProgressBar: true
});
export const ErrorToast = swal.mixin({
toast: true,
icon: 'error',
backdrop: true,
position: 'center-center', // 'bottom', 'center-center',
showConfirmButton: true,
iconColor: 'white',
customClass: {
popup: 'colored-toast'
}
});
export default XitCmm; export default XitCmm;

@ -12,8 +12,9 @@ import { Delete, List } from '@mui/icons-material';
import { judgeFileDownload, judgeImgDownload } from 'apis/judge'; import { judgeFileDownload, judgeImgDownload } from 'apis/judge';
import ImageFileViewForm from '../../../cmm/file-ctl/ImageFileViewForm'; import ImageFileViewForm from '../../../cmm/file-ctl/ImageFileViewForm';
import CmmImgViewModal from '../../../cmm/CmmImgViewModal'; import CmmImgViewModal from '../../../cmm/CmmImgViewModal';
import { removeAlert } from '../../../../commons/XitCmm';
const ModifyJudgeDataForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSave, onModify }) => { const ModifyJudgeDataForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSave, onModify, setDetail }) => {
const showAlert = useAlert(); const showAlert = useAlert();
const [selectedContDoc, setSelectedContDoc] = useState(rowData?.scContDoc); const [selectedContDoc, setSelectedContDoc] = useState(rowData?.scContDoc);
@ -24,15 +25,20 @@ const ModifyJudgeDataForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSav
const [imgName, setImgName] = useState(); const [imgName, setImgName] = useState();
const onList = () => { const onList = () => {
setDetail(false);
setOpen(false); setOpen(false);
}; };
const onRemove = () => { const onRemove = () => {
if (window.confirm('삭제 하시겠습니까?')) { setOpen(false);
handleModalSave('DELETE', { scCode: rowData.scCode }); setDetail(false);
} else { removeAlert(
window.close(); () => handleModalSave('DELETE', { scCode: rowData.scCode }),
() => {
setOpen(true);
setDetail(true);
} }
);
}; };
const viewImg = async (methodName, labelName, fileName) => { const viewImg = async (methodName, labelName, fileName) => {

@ -11,8 +11,9 @@ import { IconSearch } from '@tabler/icons';
import ImageFileInputForms from 'views/cmm/file-ctl/ImageFileInputForms'; import ImageFileInputForms from 'views/cmm/file-ctl/ImageFileInputForms';
import DaumPost from '../../../cmm/DaumPost'; import DaumPost from '../../../cmm/DaumPost';
import { removeAlert, saveAlert } from '../../../../commons/XitCmm';
const JudgeDataModifyForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSave }) => { const JudgeDataModifyForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSave, setModify }) => {
const alert = useAlert(); const alert = useAlert();
const [isPostOpen, setIsPostOpen] = useState(false); const [isPostOpen, setIsPostOpen] = useState(false);
@ -128,7 +129,19 @@ const JudgeDataModifyForm = ({ rowData, contDocs, ingbs, setOpen, handleModalSav
return; return;
} }
setOpen(false);
setModify(false);
saveAlert(
() => {
handleModalSave('SAVE', formData); handleModalSave('SAVE', formData);
},
() => {
setOpen(true);
setModify(true);
}
);
// handleModalSave('SAVE', formData);
}; };
const handleChangeFile = (e) => { const handleChangeFile = (e) => {

@ -12,10 +12,11 @@ import { IconSearch } from '@tabler/icons';
import ImageFileInputForms from 'views/cmm/file-ctl/ImageFileInputForms'; import ImageFileInputForms from 'views/cmm/file-ctl/ImageFileInputForms';
import DaumPost from '../../../cmm/DaumPost'; import DaumPost from '../../../cmm/DaumPost';
import { saveAlert, Toast } from '../../../../commons/XitCmm';
const toDate = new Date(); const toDate = new Date();
const JudgeDataNewForm = ({ scDatagb, contDocs, ingbs, handleModalSave }) => { const JudgeDataNewForm = ({ scDatagb, contDocs, ingbs, handleModalSave, setOpen, setCreate }) => {
const alert = useAlert(); const alert = useAlert();
const [isPostOpen, setIsPostOpen] = useState(false); const [isPostOpen, setIsPostOpen] = useState(false);
@ -66,10 +67,12 @@ const JudgeDataNewForm = ({ scDatagb, contDocs, ingbs, handleModalSave }) => {
formData.append('contadFiles', v); formData.append('contadFiles', v);
}); });
// console.log(Object.values(picads)[0]);
// //
if (scCarnum.length < 1) { if (scCarnum.length < 1) {
// Toast.fire({
// icon: 'warning',
// title: ' .'
// });
alert.show('차량번호는 필수입니다.'); alert.show('차량번호는 필수입니다.');
return; return;
} }
@ -106,7 +109,15 @@ const JudgeDataNewForm = ({ scDatagb, contDocs, ingbs, handleModalSave }) => {
return; return;
} }
handleModalSave('SAVE', formData); setOpen(false);
setCreate(false);
saveAlert(
() => handleModalSave('SAVE', formData),
() => {
setOpen(true);
setCreate(true);
}
);
}; };
const handleChangeFile = (e) => { const handleChangeFile = (e) => {
@ -352,6 +363,8 @@ JudgeDataNewForm.propTypes = {
scDatagb: PropTypes.string.isRequired, scDatagb: PropTypes.string.isRequired,
contDocs: PropTypes.array.isRequired, contDocs: PropTypes.array.isRequired,
ingbs: PropTypes.array.isRequired, ingbs: PropTypes.array.isRequired,
handleModalSave: PropTypes.func.isRequired handleModalSave: PropTypes.func.isRequired,
setOpen: PropTypes.func,
setCreate: PropTypes.func
}; };
export default JudgeDataNewForm; export default JudgeDataNewForm;

@ -22,7 +22,9 @@ const JudgeDataReview = ({ scDatagb, menuName }) => {
const [scContDocs, setScContDocs] = useState([]); const [scContDocs, setScContDocs] = useState([]);
const [scIngbs, setScIngbs] = useState([]); const [scIngbs, setScIngbs] = useState([]);
const [open, setOpen] = useState(false); const [newOpen, setNewOpen] = useState(false);
const [dtlOpen, setDtlOpen] = useState(false);
const [modOpen, setModOpen] = useState(false);
const [create, setCreate] = useState(false); const [create, setCreate] = useState(false);
const [detail, setDetail] = useState(false); const [detail, setDetail] = useState(false);
const [modify, setModify] = useState(false); const [modify, setModify] = useState(false);
@ -103,13 +105,11 @@ const JudgeDataReview = ({ scDatagb, menuName }) => {
}, []); }, []);
const handleCreate = () => { const handleCreate = () => {
// setIsPostOpen(true);
setModify(false); setModify(false);
setDetail(false); setDetail(false);
setCreate(true); setCreate(true);
setTitle(`${menuName} 의견진술 자료 신규 등록`); setTitle(`${menuName} 의견진술 자료 신규 등록`);
setOpen(true); setNewOpen(true);
}; };
const handleOnCellClick = (e) => { const handleOnCellClick = (e) => {
@ -120,37 +120,30 @@ const JudgeDataReview = ({ scDatagb, menuName }) => {
setDetail(true); setDetail(true);
setRowData(res.data); setRowData(res.data);
setTitle(`${menuName} 의견진술 자료 상세`); setTitle(`${menuName} 의견진술 자료 상세`);
setOpen(true); setDtlOpen(true);
}); });
} }
}; };
const handleSaveResident = (type, payload) => { const handleJudgeData = (type, payload) => {
switch (type) { switch (type) {
case 'SAVE': case 'SAVE':
if (window.confirm('저장 하시겠습니까?')) {
saveJudgeData(payload).then((res) => { saveJudgeData(payload).then((res) => {
if (res?.success) { if (res?.success) {
setCreate(false); setCreate(false);
setModify(false);
setDetail(false); setDetail(false);
setOpen(false);
search(); search();
} else { } else {
showAlert.show(`${res?.data.message}`); showAlert.show(`${res?.data.message}`);
} }
}); });
} else {
window.close();
}
break; break;
case 'DELETE': case 'DELETE':
removeJudgeData(payload).then((res) => { removeJudgeData(payload).then((res) => {
if (res?.success) { if (res?.success) {
setCreate(false); setCreate(false);
setModify(false); setModify(false);
setDetail(false);
setOpen(false);
search(); search();
} else { } else {
showAlert.show(`${res?.data.message}`); showAlert.show(`${res?.data.message}`);
@ -162,13 +155,13 @@ const JudgeDataReview = ({ scDatagb, menuName }) => {
}; };
const openModify = () => { const openModify = () => {
setOpen(false); setDtlOpen(false);
setCreate(false); setCreate(false);
setDetail(false); setDetail(false);
setModify(true); setModify(true);
setTitle(`${menuName} 의견진술 자료 변경`); setTitle(`${menuName} 의견진술 자료 변경`);
setOpen(true); setModOpen(true);
}; };
return ( return (
@ -192,30 +185,44 @@ const JudgeDataReview = ({ scDatagb, menuName }) => {
setRowsState={setRowsState} setRowsState={setRowsState}
handleCellClick={handleOnCellClick} handleCellClick={handleOnCellClick}
/> />
<CmmModal isBackdrop title={title} open={open} setOpen={setOpen}> {create && (
{create && <JudgeDataNewForm handleModalSave={handleSaveResident} scDatagb={scDatagb} contDocs={scContDocs} ingbs={scIngbs} />} <CmmModal isBackdrop title={title} open={newOpen} setOpen={setNewOpen}>
{/* {!create && <JudgeDataModifyForm handleModalSave={handleSaveResident} rowData={rowData} />} */} <JudgeDataNewForm
handleModalSave={handleJudgeData}
scDatagb={scDatagb}
contDocs={scContDocs}
ingbs={scIngbs}
setOpen={setNewOpen}
setCreate={setCreate}
/>
</CmmModal>
)}
{detail && ( {detail && (
<CmmModal isBackdrop title={title} open={dtlOpen} setOpen={setDtlOpen}>
<JudgeDataDetailForm <JudgeDataDetailForm
rowData={rowData} rowData={rowData}
contDocs={scContDocs} contDocs={scContDocs}
ingbs={scIngbs} ingbs={scIngbs}
setOpen={setOpen} setDetail={setDetail}
handleModalSave={handleSaveResident} handleModalSave={handleJudgeData}
onModify={openModify} onModify={openModify}
setOpen={setDtlOpen}
/> />
</CmmModal>
)} )}
{modify && ( {modify && (
<CmmModal isBackdrop title={title} open={modOpen} setOpen={setModOpen}>
<JudgeDataModifyForm <JudgeDataModifyForm
rowData={rowData} rowData={rowData}
contDocs={scContDocs} contDocs={scContDocs}
ingbs={scIngbs} ingbs={scIngbs}
setOpen={setOpen} setModify={setModify}
handleModalSave={handleSaveResident} handleModalSave={handleJudgeData}
onModify={openModify} onModify={openModify}
setOpen={setModOpen}
/> />
)}
</CmmModal> </CmmModal>
)}
</MainCard> </MainCard>
); );
}; };

@ -9,6 +9,7 @@ import Button from '@mui/material/Button';
import combo from 'commons/combo_data'; import combo from 'commons/combo_data';
import { useState } from 'react'; import { useState } from 'react';
import { saveJudgeStds, saveJudgeTargets } from '../../../../apis/judge'; import { saveJudgeStds, saveJudgeTargets } from '../../../../apis/judge';
import { confirmAlert, saveAlert } from '../../../../commons/XitCmm';
const style = { const style = {
position: 'relative', position: 'relative',

@ -13,7 +13,7 @@ import MainCard from 'ui-component/cards/MainCard';
// project imports // project imports
import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid'; import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid';
import xitCmm from 'commons/XitCmm'; import xitCmm, { ErrorToast, saveAlert, Toast } from 'commons/XitCmm';
import CmmModal from 'views/cmm/CmmModal'; import CmmModal from 'views/cmm/CmmModal';
import JudgeTargetSaveForm from 'views/biz/admin/judge/JudgeTargetSaveForm'; import JudgeTargetSaveForm from 'views/biz/admin/judge/JudgeTargetSaveForm';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
@ -84,8 +84,10 @@ const JudgeRegistReview = ({ scDatagb, menuName }) => {
} }
}; };
const submitResidentTargets = (params) => { const submitJudgeTargets = (params) => {
if (window.confirm('저장 하시겠습니까?')) { setOpen(false);
saveAlert(() => {
const param = { const param = {
...params, ...params,
scDatagb, // scDatagb, //
@ -94,18 +96,18 @@ const JudgeRegistReview = ({ scDatagb, menuName }) => {
scSeq2, scSeq2,
scCodes: selectionModel.map((d) => rowsState.rows[d - 1].scCode) scCodes: selectionModel.map((d) => rowsState.rows[d - 1].scCode)
}; };
setOpen(false);
console.log(param);
saveJudgeTargets(param).then((res) => { saveJudgeTargets(param).then((res) => {
if (res?.success) { if (res?.success) {
setSelectionModel([]); setSelectionModel([]);
search(); search();
} else { } else {
showAlert.show(`${res?.data.message}`); ErrorToast.fire({
} title: `${res?.data.message}`
}); });
// showAlert.show(`${res?.data.message}`);
} }
});
});
}; };
const handleSearch = () => { const handleSearch = () => {
@ -221,7 +223,7 @@ const JudgeRegistReview = ({ scDatagb, menuName }) => {
selectionModel={selectionModel} selectionModel={selectionModel}
/> />
<CmmModal isBackdrop title={title} open={open} setOpen={setOpen}> <CmmModal isBackdrop title={title} open={open} setOpen={setOpen}>
<JudgeTargetSaveForm isDisabled={selectionModel.length === 0} handleModalSave={submitResidentTargets} /> <JudgeTargetSaveForm isDisabled={selectionModel.length === 0} handleModalSave={submitJudgeTargets} />
</CmmModal> </CmmModal>
</MainCard> </MainCard>
); );

@ -21,6 +21,7 @@ import CmmModal from 'views/cmm/CmmModal';
import ModalJudgeResult from './ModalJudgeResult'; import ModalJudgeResult from './ModalJudgeResult';
import { findParkings, removeParkingJudge } from '../../../../apis/parking'; import { findParkings, removeParkingJudge } from '../../../../apis/parking';
import { useAlert } from 'react-alert'; import { useAlert } from 'react-alert';
import { removeAlert } from '../../../../commons/XitCmm';
const year = getYear(new Date()); const year = getYear(new Date());
const years = _.range(year, year - 14, -1); const years = _.range(year, year - 14, -1);
@ -74,9 +75,10 @@ const JudgeReview = ({ msDatagb, menuName }) => {
}, [msDatagb, rowsState.page, rowsState.pageSize, selectedYear]); }, [msDatagb, rowsState.page, rowsState.pageSize, selectedYear]);
const removeJudge = useCallback( const removeJudge = useCallback(
(row) => async () => { (row) => () => {
let res = {}; let res = {};
if (window.confirm('삭제 하시겠습니까?')) {
removeAlert(async () => {
if (msDatagb) { if (msDatagb) {
res = await removeJudge(row); res = await removeJudge(row);
} else { } else {
@ -92,9 +94,27 @@ const JudgeReview = ({ msDatagb, menuName }) => {
} else { } else {
showAlert.show(res.message); showAlert.show(res.message);
} }
} else { });
window.close();
} // if (window.confirm(' ?')) {
// if (msDatagb) {
// res = await removeJudge(row);
// } else {
// res = await removeParkingJudge(row);
// }
// console.log(res);
// if (res && res.success) {
// setRowsState({
// ...rowsState,
// page: 0
// });
// search();
// } else {
// showAlert.show(res.message);
// }
// } else {
// window.close();
// }
}, },
[] []
); );

@ -13,12 +13,13 @@ import MainCard from 'ui-component/cards/MainCard';
// project imports // project imports
import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid'; import MuiDataGrid from 'views/cmm/mui-grid/MuiDataGrid';
import xitCmm from 'commons/XitCmm'; import xitCmm, { ErrorToast, saveAlert } from 'commons/XitCmm';
import CmmModal from 'views/cmm/CmmModal'; import CmmModal from 'views/cmm/CmmModal';
import SaveParkingTargetForm from './SaveParkingTargetForm'; import SaveParkingTargetForm from './SaveParkingTargetForm';
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
import ExcelDownload from 'views/cmm/file-ctl/ExcelDownload'; import ExcelDownload from 'views/cmm/file-ctl/ExcelDownload';
import { findParkingJudgeTargets, saveParkingJudgeTargets } from 'apis/parking'; import { findParkingJudgeTargets, saveParkingJudgeTargets } from 'apis/parking';
import { useAlert } from 'react-alert';
const ParkingRegister = () => { const ParkingRegister = () => {
const [rcIrTransfer, setRcIrTransfer] = useState('1'); const [rcIrTransfer, setRcIrTransfer] = useState('1');
@ -32,6 +33,7 @@ const ParkingRegister = () => {
rows: [] rows: []
}); });
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const showAlert = useAlert();
const columns = [ const columns = [
{ headerName: 'No', headerAlign: 'center', field: 'rowId', align: 'center', width: 80 }, { headerName: 'No', headerAlign: 'center', field: 'rowId', align: 'center', width: 80 },
@ -80,7 +82,9 @@ const ParkingRegister = () => {
}; };
const submitParkingTargets = (params) => { const submitParkingTargets = (params) => {
if (window.confirm('저장 하시겠습니까?')) { setOpen(false);
saveAlert(() => {
const param = { const param = {
...params, ...params,
rcIrTransfer, rcIrTransfer,
@ -89,13 +93,19 @@ const ParkingRegister = () => {
rcCodes: selectionModel.map((d) => rowsState.rows[d - 1].rcCode) rcCodes: selectionModel.map((d) => rowsState.rows[d - 1].rcCode)
}; };
setOpen(false); setOpen(false);
// return false;
saveParkingJudgeTargets(param).then(() => { saveParkingJudgeTargets(param).then((res) => {
if (res?.success) {
setSelectionModel([]); setSelectionModel([]);
search(); search();
} else {
ErrorToast.fire({
title: `${res?.data.message}`
}); });
// showAlert.show(`${res?.data.message}`);
} }
});
});
}; };
const handleSearch = () => { const handleSearch = () => {

@ -18,6 +18,7 @@ import ModifyBoardForm from './ModifyBoardForm';
import useAuth from 'hooks/useAuth'; import useAuth from 'hooks/useAuth';
import { Save } from '@mui/icons-material'; import { Save } from '@mui/icons-material';
import NewBoardForm from './NewBoardForm'; import NewBoardForm from './NewBoardForm';
import { removeAlert, saveAlert } from '../../../commons/XitCmm';
const Board = () => { const Board = () => {
const { user } = useAuth(); const { user } = useAuth();
@ -119,32 +120,33 @@ const Board = () => {
const submitBoard = (type, payload) => { const submitBoard = (type, payload) => {
switch (type) { switch (type) {
case 'SAVE': case 'SAVE':
if (window.confirm('저장 하시겠습니까?')) { setOpen(false);
saveAlert(() =>
saveBoard(payload).then((res) => { saveBoard(payload).then((res) => {
if (res?.success) { if (res?.success) {
search(); search();
setOpen(false);
} else { } else {
alert.show(`${res?.data.message}`); alert.show(`${res?.data.message}`);
setOpen(false);
} }
}); // .then((res) => { })
} else { );
window.close();
}
break; break;
case 'DELETE': case 'DELETE':
if (window.confirm('삭제 하시겠습니까?')) { setOpen(false);
removeAlert(() =>
removeBoard(payload).then((res) => { removeBoard(payload).then((res) => {
if (res?.success) { if (res?.success) {
search(); search();
setOpen(false); setOpen(false);
} else { } else {
alert.show(`${res?.data.message}`); alert.show(`${res?.data.message}`);
setOpen(false);
} }
}); // .then((res) => { })
} else { );
window.close();
}
break; break;
default: default:
} }

@ -18,6 +18,7 @@ import { useAlert } from 'react-alert';
import useAuth from 'hooks/useAuth'; import useAuth from 'hooks/useAuth';
import ModifyPublicBoardForm from './ModifyPublicBoardForm'; import ModifyPublicBoardForm from './ModifyPublicBoardForm';
import { removeAlert, saveAlert } from '../../../commons/XitCmm';
const PublicBoard = () => { const PublicBoard = () => {
const { user } = useAuth(); const { user } = useAuth();
@ -103,28 +104,30 @@ const PublicBoard = () => {
const submitPublicBoard = (type, payload) => { const submitPublicBoard = (type, payload) => {
switch (type) { switch (type) {
case 'SAVE': case 'SAVE':
if (window.confirm('저장 하시겠습니까?')) { setOpen(false);
saveAlert(() =>
savePublicBoard(payload).then((res) => { savePublicBoard(payload).then((res) => {
if (res?.success) { if (res?.success) {
search(); search();
setOpen(false);
} else { } else {
alert.show(`${res?.data.message}`); alert.show(`${res?.data.message}`);
} }
}); // .then((res) => { })
} else { );
window.close();
}
break; break;
case 'DELETE': case 'DELETE':
if (window.confirm('삭제 하시겠습니까?')) {
removePublicBoard(payload).then(() => {
search();
setOpen(false); setOpen(false);
}); // .then((res) => {
removeAlert(() =>
removePublicBoard(payload).then((res) => {
if (res?.success) {
search();
} else { } else {
window.close(); alert.show(`${res?.data.message}`);
} }
})
);
break; break;
default: default:
} }

@ -16,6 +16,7 @@ import UserManagerForm from './UserManagerForm';
import { findUsers, removeUser, saveUser } from 'apis/user'; import { findUsers, removeUser, saveUser } from 'apis/user';
import { getComboCodeList } from 'apis/common'; import { getComboCodeList } from 'apis/common';
import { useAlert } from 'react-alert'; import { useAlert } from 'react-alert';
import { Toast } from '../../../commons/XitCmm';
const UserManager = () => { const UserManager = () => {
const [accesstypes, setAccesstypes] = useState(); const [accesstypes, setAccesstypes] = useState();
@ -36,7 +37,6 @@ const UserManager = () => {
const [selectedRow, setSelectedRow] = useState({}); const [selectedRow, setSelectedRow] = useState({});
const [create, setCreate] = useState(false); const [create, setCreate] = useState(false);
const [title, setTitle] = useState(); const [title, setTitle] = useState();
const alert = useAlert();
const columns = [ const columns = [
{ headerName: 'No.', headerAlign: 'center', field: 'rowId', align: 'center', width: 70 }, { headerName: 'No.', headerAlign: 'center', field: 'rowId', align: 'center', width: 70 },
@ -129,7 +129,7 @@ const UserManager = () => {
setRowsState((prevState) => ({ ...prevState, rows: response.data })); setRowsState((prevState) => ({ ...prevState, rows: response.data }));
} }
}); });
}, [rowsState.page, rowsState.pageSize, searchTxt]); }, [rowsState.page, rowsState.pageSize, category, searchTxt]);
const handleSearch = async (event) => { const handleSearch = async (event) => {
if (event.type === 'keydown' && event.key === 'Enter') { if (event.type === 'keydown' && event.key === 'Enter') {
@ -184,7 +184,6 @@ const UserManager = () => {
const handleModalSave = (type, payload) => { const handleModalSave = (type, payload) => {
switch (type) { switch (type) {
case 'SAVE': case 'SAVE':
if (window.confirm('저장 하시겠습니까?')) {
saveUser(payload).then((res) => { saveUser(payload).then((res) => {
if (res?.success) { if (res?.success) {
setRowsState((prevState) => ({ setRowsState((prevState) => ({
@ -192,17 +191,12 @@ const UserManager = () => {
page: 0 page: 0
})); }));
search(); search();
setOpen(false);
} else { } else {
alert.show(`${res?.data.message}`); Toast.fire({ icon: 'error', title: `${res?.data.message}` });
}
}); // .then((res) => {
} else {
window.close();
} }
});
break; break;
case 'DELETE': case 'DELETE':
if (window.confirm('삭제 하시겠습니까?')) {
removeUser(payload).then((res) => { removeUser(payload).then((res) => {
if (res?.success) { if (res?.success) {
setRowsState({ setRowsState({
@ -210,14 +204,10 @@ const UserManager = () => {
page: 0 page: 0
}); });
search(); search();
setOpen(false);
} else { } else {
alert.show(`${res?.data.message}`); Toast.fire({ icon: 'error', title: `${res?.data.message}` });
}
}); // .then((res) => {
} else {
window.close();
} }
});
break; break;
default: default:
} }

@ -9,6 +9,7 @@ import 'react-quill/dist/quill.snow.css';
// project imports // project imports
import { Delete, List, Save } from '@mui/icons-material'; import { Delete, List, Save } from '@mui/icons-material';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { removeAlert, saveAlert } from '../../../commons/XitCmm';
const UserManagementForm = (props) => { const UserManagementForm = (props) => {
// eslint-disable-next-line react/prop-types // eslint-disable-next-line react/prop-types
@ -45,7 +46,11 @@ const UserManagementForm = (props) => {
alert('비밀번호는 필수입니다.'); alert('비밀번호는 필수입니다.');
return; return;
} }
handleModalSave('SAVE', saveParam); setOpen(false);
saveAlert(
() => handleModalSave('SAVE', saveParam),
() => setOpen(true)
);
}; };
const onRemove = () => { const onRemove = () => {
@ -59,7 +64,11 @@ const UserManagementForm = (props) => {
team, team,
isenable isenable
}; };
handleModalSave('DELETE', saveParam); setOpen(false);
removeAlert(
() => handleModalSave('DELETE', saveParam),
() => setOpen(true)
);
}; };
return ( return (

@ -1,5 +1,5 @@
import { InputAdornment, TextField } from '@mui/material'; import { InputAdornment, TextField } from '@mui/material';
import { FileDownload, Info } from '@mui/icons-material'; import { Info } from '@mui/icons-material';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
const ImageFileViewForm = ({ labelName = '', fileName, methodName = '', handleViewImg = () => {} }) => ( const ImageFileViewForm = ({ labelName = '', fileName, methodName = '', handleViewImg = () => {} }) => (

@ -238,6 +238,7 @@ const MuiDataGrid = ({
MuiDataGrid.propTypes = { MuiDataGrid.propTypes = {
// apiRef: PropTypes.func, // apiRef: PropTypes.func,
gridHeight: PropTypes.number,
isToolbar: PropTypes.bool, isToolbar: PropTypes.bool,
children: PropTypes.node, children: PropTypes.node,
isCheckbox: PropTypes.bool, isCheckbox: PropTypes.bool,

Loading…
Cancel
Save