wahyuun
1 year ago
4 changed files with 866 additions and 677 deletions
@ -0,0 +1,123 @@
|
||||
import React, { useEffect, useState } from "react"; |
||||
import { Modal, ModalHeader, ModalBody, ModalFooter, Card, CardBody } from "reactstrap"; |
||||
import { Button } from "reactstrap"; |
||||
import axios from "../../../const/interceptorApi"; |
||||
import { |
||||
NotificationManager, |
||||
} from "react-notifications"; |
||||
import { BASE_SIMPRO_LUMEN } from "../../../const/ApiConst"; |
||||
import { Table } from 'antd'; |
||||
import "antd/dist/antd.css"; |
||||
|
||||
const DialogFormAnalysis = ({ |
||||
openDialog, |
||||
closeDialog, |
||||
toggleDialog, |
||||
dataDetail |
||||
}) => { |
||||
const token = localStorage.getItem("token"); |
||||
const [dataTable, setDatatable] = useState([]); |
||||
const HEADER = { |
||||
headers: { |
||||
"Content-Type": "application/json", |
||||
Authorization: `Bearer ${token}`, |
||||
}, |
||||
}; |
||||
|
||||
useEffect(() => { |
||||
if (dataDetail) { |
||||
getReportActivityMaterial(); |
||||
} |
||||
}, [openDialog]); |
||||
|
||||
const columns = [ |
||||
{title: "Human Resource", dataIndex: "join_first_name", key: "join_first_name"}, |
||||
{title: "Report Date", dataIndex: "report_date", key: "report_date"}, |
||||
{title: "Volume Plan", dataIndex: "join_second_qty_planning", key: "join_second_qty_planning"}, |
||||
{title: "Volume Actual", dataIndex: "qty", key: "qty"}, |
||||
{title: "Keterangan", dataIndex: "description", key: "description"}, |
||||
] |
||||
|
||||
const getReportActivityMaterial = async () => { |
||||
const payload = { |
||||
columns: [ |
||||
{ |
||||
name: "assign_material_id", |
||||
logic_operator: "=", |
||||
value: dataDetail.join_third_id, |
||||
operator: "AND", |
||||
} |
||||
], |
||||
joins: [ |
||||
{ |
||||
name: "m_users", |
||||
column_join: "user_id", |
||||
column_results: ["name"] |
||||
}, |
||||
{ |
||||
name: "assign_material_to_activity", |
||||
column_join: "assign_material_id", |
||||
column_results: ["qty_planning"] |
||||
}, |
||||
], |
||||
orders: { columns: ["id"], ascending: false }, |
||||
paging: { start: 0, length: -1 }, |
||||
}; |
||||
|
||||
const result = await axios |
||||
.post(`${BASE_SIMPRO_LUMEN}/report-activity-material/search`, payload, HEADER) |
||||
.then((res) => res) |
||||
.catch((error) => error.response); |
||||
|
||||
if (result && result.data && result.data.code == 200) { |
||||
let dataRes = result.data.data || []; |
||||
setDatatable(dataRes); |
||||
} else { |
||||
NotificationManager.error("Gagal Mengambil Data!!", "Failed"); |
||||
} |
||||
}; |
||||
|
||||
const handleCLearData = () => { |
||||
|
||||
}; |
||||
|
||||
const handleCancel = () => { |
||||
closeDialog("cancel", "none"); |
||||
console.log(dataDetail) |
||||
handleCLearData(); |
||||
}; |
||||
|
||||
return ( |
||||
<> |
||||
<Modal size="lg" isOpen={openDialog} toggle={toggleDialog}> |
||||
<ModalHeader className="capitalize" toggle={closeDialog}> |
||||
Detail Report Analysis |
||||
</ModalHeader> |
||||
<ModalBody> |
||||
<Card> |
||||
<CardBody> |
||||
<Table |
||||
size="small" |
||||
columns={columns} |
||||
dataSource={dataTable} |
||||
pagination={false} |
||||
rowKey={"id"} |
||||
/> |
||||
</CardBody> |
||||
</Card> |
||||
</ModalBody> |
||||
<ModalFooter> |
||||
<Button |
||||
className="capitalize" |
||||
color="secondary" |
||||
onClick={() => handleCancel()} |
||||
> |
||||
Cancel |
||||
</Button> |
||||
</ModalFooter> |
||||
</Modal> |
||||
</> |
||||
); |
||||
}; |
||||
|
||||
export default DialogFormAnalysis; |
Loading…
Reference in new issue