Browse Source

add loader

pull/1/head
wahyuun 1 year ago
parent
commit
8179e6884b
  1. 14
      src/views/SimproV2/ResourceWorker/index.js

14
src/views/SimproV2/ResourceWorker/index.js

@ -8,7 +8,7 @@ import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons'; import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd'; import { Pagination, Table, Button, Tooltip, Spin } from 'antd';
import { import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD, USER_SYNC
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
@ -18,6 +18,7 @@ const proyek_id = localStorage.getItem('proyek_id');
const role_id = localStorage.getItem('role_id'); const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY"; const format = "DD-MM-YYYY";
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
const config = { const config = {
headers: headers:
{ {
@ -53,12 +54,15 @@ const ResourceWorker = ({ params }) => {
const [typeDialogShift, setTypeDialogShift] = useState('Save') const [typeDialogShift, setTypeDialogShift] = useState('Save')
const pageName = params.name; const pageName = params.name;
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(true);
useEffect(() => { useEffect(() => {
getRoleList() getRoleList()
getDivisiList() getDivisiList()
}, []) }, [])
useEffect(() => { useEffect(() => {
setLoading(true);
getDataUser() getDataUser()
}, [search, rowsPerPage, currentPage]) }, [search, rowsPerPage, currentPage])
@ -206,7 +210,9 @@ const ResourceWorker = ({ params }) => {
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
setDatatable(result.data.data); setDatatable(result.data.data);
setTotalPage(result.data.totalRecord); setTotalPage(result.data.totalRecord);
setLoading(false);
} else { } else {
setLoading(false);
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
} }
@ -560,7 +566,7 @@ const ResourceWorker = ({ params }) => {
<Col> <Col>
<Tooltip title={t('hradd')}> <Tooltip title={t('hradd')}>
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="HR Sync"> <Tooltip title="HR Sync">
<Button style={{ background: "#007bff ", color: "#fff", marginLeft: "5px" }} onClick={() => handleSync()}><i className="fa fa-spinner"></i></Button> <Button style={{ background: "#007bff ", color: "#fff", marginLeft: "5px" }} onClick={() => handleSync()}><i className="fa fa-spinner"></i></Button>
</Tooltip> </Tooltip>
@ -571,7 +577,9 @@ const ResourceWorker = ({ params }) => {
</Row> </Row>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
{RenderTable} <Spin tip="Loading..." spinning={loading}>
{RenderTable}
</Spin>
<Pagination <Pagination
style={{ marginTop: "25px" }} style={{ marginTop: "25px" }}
showSizeChanger showSizeChanger

Loading…
Cancel
Save