Browse Source

add sum

pull/1/head
wahyu 1 year ago
parent
commit
11fff21f3e
  1. 21
      src/views/SimproV2/CreatedProyek/ReportAnalysis.js

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

@ -16,6 +16,7 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
const token = localStorage.getItem("token");
const [activeTab, setActiveTab] = useState('1');
const [search, setSearch] = useState('');
const [avgActivity, setAvgActivity] = useState(0);
const [dataTable, setDatatable] = useState([]);
const [dataTableActivityToHr, setDataTableActivityToHr] = useState([]);
const [hrList, setHrList] = useState([]);
@ -77,6 +78,8 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
}
}
const getDataActivityToHr = async () => {
setAvgActivity(0);
let sum = 0;
const payload = {
columns: [
{
@ -104,6 +107,10 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
dataRes.forEach(element => {
element.persentase_progress ? sum += parseInt(element.persentase_progress) : sum += 0;
});
setAvgActivity(sum / dataRes.length);
setDataTableActivityToHr(dataRes);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
@ -111,6 +118,8 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
};
const getDataActivity = async () => {
setAvgActivity(0);
let sum = 0;
const payload = {
columns: [
{
@ -132,6 +141,10 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
dataRes.forEach(element => {
element.persentase_progress ? sum += parseInt(element.persentase_progress) : sum += 0;
});
setAvgActivity(sum / dataRes.length);
setDatatable(dataRes);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
@ -186,7 +199,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
<CardBody>
<div style={{ textAlign: 'center' }}>
<h1>
Hello World
{
search && avgActivity ? `Activity ${search} adalah ${avgActivity.toFixed(2)} %` : null
}
</h1>
</div>
<Table
@ -217,7 +232,9 @@ const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog }) => {
<CardBody>
<div style={{ textAlign: 'center' }}>
<h1>
Hello World
{
selectedHr && avgActivity ? `Activity user ini adalah ${avgActivity.toFixed(2)} %` : null
}
</h1>
</div>
<Table

Loading…
Cancel
Save