Browse Source

add loader

pull/1/head
wahyuun 1 year ago
parent
commit
3eb68dbd0f
  1. 16
      src/views/SimproV2/CreatedProyek/AssignK3Project.js

16
src/views/SimproV2/CreatedProyek/AssignK3Project.js

@ -3,11 +3,14 @@ import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { Button, Form } from 'reactstrap'; import { Button, Form } from 'reactstrap';
import axios from "../../../const/interceptorApi"; import axios from "../../../const/interceptorApi";
import { PROJECT_TO_CHECKLIST_K3_ADDS, PROJECT_TO_CHECKLIST_K3_SEARCH } from '../../../const/ApiConst'; import { PROJECT_TO_CHECKLIST_K3_ADDS, PROJECT_TO_CHECKLIST_K3_SEARCH } from '../../../const/ApiConst';
import { Transfer } from 'antd'; import { Transfer, Spin } from 'antd';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { NotificationManager } from 'react-notifications';
const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3, proyekName }) => { const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3, proyekName }) => {
const token = localStorage.getItem("token") const token = localStorage.getItem("token")
const [loading, setLoading] = useState(true);
const HEADER = { const HEADER = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -30,7 +33,8 @@ const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3
}, [openDialog]) }, [openDialog])
useEffect(() => { useEffect(() => {
if(idTask && idTask > 0){ if (idTask && idTask > 0) {
setLoading(true);
getK3toProject() getK3toProject()
} }
}, [idTask]) }, [idTask])
@ -56,8 +60,10 @@ const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3
}); });
} }
setTargetKeys(newTargetKeys) setTargetKeys(newTargetKeys)
setLoading(false);
}else{ }else{
setLoading(false);
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
} }
@ -126,7 +132,9 @@ const AssignK3Project = ({ openDialog, closeDialog, toggleDialog, idTask, dataK3
<Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}> <Modal size="lg" style={{maxWidth: '600px', width: '100%'}} isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Assign K3 to Project {proyekName !== '' ? `- ${proyekName}` : ''}</ModalHeader> <ModalHeader className="capitalize" toggle={closeDialog}>Assign K3 to Project {proyekName !== '' ? `- ${proyekName}` : ''}</ModalHeader>
<ModalBody> <ModalBody>
{renderForm()} <Spin tip="Loading..." spinning={loading}>
{renderForm()}
</Spin>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="primary" onClick={() => handleSave()}>Save</Button>{' '} <Button color="primary" onClick={() => handleSave()}>Save</Button>{' '}

Loading…
Cancel
Save