Browse Source

add loader

pull/1/head
wahyuun 1 year ago
parent
commit
8356d02ab6
  1. 61
      src/views/SimproV2/CreatedProyek/ReportAnalysis.js

61
src/views/SimproV2/CreatedProyek/ReportAnalysis.js

@ -1,7 +1,21 @@
import React, {useState, useEffect} from 'react' import React, {useState, useEffect} from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Card, CardHeader, CardBody } from 'reactstrap'; import {
import { TabContent, TabPane, Nav, NavItem, NavLink, Row, Col, Input } from 'reactstrap'; Modal,
import { Button } from 'reactstrap'; ModalHeader,
ModalBody,
ModalFooter,
Card,
CardHeader,
CardBody,
TabContent,
TabPane,
Nav,
NavItem,
NavLink,
Row,
Col,
Button
} from 'reactstrap';
import axios from "../../../const/interceptorApi"; import axios from "../../../const/interceptorApi";
import { import {
NotificationManager, NotificationManager,
@ -9,7 +23,7 @@ import {
import { BASE_SIMPRO_LUMEN } from "../../../const/ApiConst"; import { BASE_SIMPRO_LUMEN } from "../../../const/ApiConst";
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import './style.css' import './style.css'
import { Select, Table, Tooltip } from 'antd'; import { Select, Table, Tooltip, Spin } from 'antd';
import DialogFormAnalysis from './DialogFormAnalysis'; import DialogFormAnalysis from './DialogFormAnalysis';
import moment from "moment"; import moment from "moment";
const { Option } = Select const { Option } = Select
@ -29,6 +43,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
const [hrList, setHrList] = useState([]); const [hrList, setHrList] = useState([]);
const [groupedActivity, setGroupedActivity] = useState([]); const [groupedActivity, setGroupedActivity] = useState([]);
const [selectedHr, setSelectedHr] = useState(null); const [selectedHr, setSelectedHr] = useState(null);
const [loading, setLoading] = useState(false);
const toggle = (tab) => { const toggle = (tab) => {
if (activeTab !== tab) { if (activeTab !== tab) {
@ -235,12 +250,14 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
useEffect(() => { useEffect(() => {
if (search) { if (search) {
setLoading(true);
getDataActivity() getDataActivity()
} }
}, [search]); }, [search]);
useEffect(() => { useEffect(() => {
if (selectedHr) { if (selectedHr) {
setLoading(true);
getDataActivityToHr() getDataActivityToHr()
} }
}, [selectedHr]); }, [selectedHr]);
@ -398,7 +415,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
}); });
setAvgActivityHr(sum / dataRes.length); setAvgActivityHr(sum / dataRes.length);
setDataTableActivityToHr(dataRes); setDataTableActivityToHr(dataRes);
setLoading(false);
} else { } else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
} }
}; };
@ -474,7 +493,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
setSumVolPlan(sumPlan); setSumVolPlan(sumPlan);
setSumVolAct(sumAct); setSumVolAct(sumAct);
setDatatable(dataRes); setDatatable(dataRes);
setLoading(false);
} else { } else {
setLoading(false);
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); NotificationManager.error("Gagal Mengambil Data!!", "Failed");
} }
}; };
@ -531,13 +552,15 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
</h1> </h1>
</div> </div>
<div style={{ width: '100%', overflowX: 'auto' }}> <div style={{ width: '100%', overflowX: 'auto' }}>
<Table <Spin tip="Loading..." spinning={loading}>
size="small" <Table
columns={columns} size="small"
dataSource={dataTable} columns={columns}
pagination={false} dataSource={dataTable}
rowKey="id" pagination={false}
/> rowKey="id"
/>
</Spin>
</div> </div>
</CardBody> </CardBody>
</Card> </Card>
@ -559,13 +582,15 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) =>
</CardHeader> </CardHeader>
<CardBody style={{ width: '100%' }}> <CardBody style={{ width: '100%' }}>
<div style={{ width: '100%', overflowX: 'auto' }}> <div style={{ width: '100%', overflowX: 'auto' }}>
<Table <Spin tip="Loading..." spinning={loading}>
size="small" <Table
columns={columnActivityToHr} size="small"
dataSource={dataTableActivityToHr} columns={columnActivityToHr}
pagination={false} dataSource={dataTableActivityToHr}
rowKey={"id"} pagination={false}
/> rowKey={"id"}
/>
</Spin>
</div> </div>
</CardBody> </CardBody>
</Card> </Card>

Loading…
Cancel
Save