Browse Source

Merge pull request 'Task #860qcewky check hierarchy' (#3) from dev-wahyu into staging

Reviewed-on: ordo/adw-frontend#3
pull/2/head
ibnu 2 years ago
parent
commit
6be3524f42
  1. 7
      src/const/ApiConst.js
  2. 246
      src/views/SimproV2/CreatedProyek/DIalogHierarchy.js
  3. 116
      src/views/SimproV2/CreatedProyek/index.js

7
src/const/ApiConst.js

@ -460,4 +460,11 @@ export const API_PANIC_BUTTON_SIMPRO = `${BASE_SIMPRO_LUMEN}/panic-button`
export const PANIC_BUTTON_SEARCH = `${BASE_SIMPRO_LUMEN}/panic-button/search`;
export const PANIC_BUTTON_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/panic-button/update/${id}` }
export const HIERARCHY_FTTH_GET = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths`
export const HIERARCHY_FTTH_ADD = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths`
export const HIERARCHY_FTTH_SEARCH = `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/search`
export const HIERARCHY_FTTH_SHOW = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`}
export const HIERARCHY_FTTH_UPDATE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`}
export const HIERARCHY_FTTH_DELETE = (id) => { return `${BASE_SIMPRO_LUMEN}/hierarchy-ftths/${id}`}
export const WAYPOINT_SEARCH = `${BASE_SIMPRO_LUMEN}/waypoint/search`

246
src/views/SimproV2/CreatedProyek/DIalogHierarchy.js

@ -0,0 +1,246 @@
import React, { useEffect, useState, useMemo } from 'react'
import { Modal, ModalHeader, ModalBody, } from 'reactstrap';
import { Button } from 'reactstrap';
import { Table, Tooltip } from 'antd';
import 'antd/dist/antd.css';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
import { HIERARCHY_FTTH_DELETE, HIERARCHY_FTTH_SEARCH, USER_LIST } from '../../../const/ApiConst';
import axios from "../../../const/interceptorApi"
import { NotificationContainer, NotificationManager } from 'react-notifications';
import DialogForm from './DialogFormHierarchy';
import DialogUserGantt from './DialogUserGantt';
const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName }) => {
const token = localStorage.getItem("token")
const HEADER = {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
}
}
const [openDialogForm, setOpenDialogForm] = useState(false)
const [openDialogUserGantt, setOpenDialogUserGantt] = useState(false)
const [dataHierarchy, setDataHierarchy] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [idGantt, setIdGantt] = useState(0)
const [humanResource, setHumanResource] = useState([])
useEffect(() => {
if (idTask > 0) {
getdataHierarchy();
}
}, [idTask, openDialog])
useEffect(() => {
getDataHumanResource();
}, [])
useEffect(() => {
if (!openDialog) {
setDataHierarchy([]);
} else {
}
}, [openDialog])
const getDataHumanResource = async () => {
const result = await axios
.get(USER_LIST, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.status == 200) {
setTransferUser(result.data.data);
} else {
}
}
const setTransferUser = (data) => {
const finalData = []
data.map((val, index) => {
let data = {
key: val.id,
title: val.name
}
finalData.push(data)
});
setHumanResource(finalData)
}
const getdataHierarchy = async () => {
const payload = {
"columns": [
{ "name": "project_id", "logic_operator": "=", "value": idTask, "operator": "AND" }
]
}
const result = await axios
.post(HIERARCHY_FTTH_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.status == 200) {
setDataHierarchy(result.data.data);
} else {
NotificationManager.error(`Data gantt project gagal terload silahkan coba lagi!`, 'Failed!!');
}
}
const handleCancel = () => {
setDataHierarchy([]);
closeDialog('cancel', 'none')
}
const handleDelete = (id) => {
setIdDelete(id)
setAlertDelete(true)
}
const handleUserGant = (id) => {
setIdGantt(id)
setOpenDialogUserGantt(true)
}
const RenderTable = useMemo(() => {
const columns = [
{
title: 'Action',
dataIndex: '',
key: 'id',
className: "nowrap",
render: (text, record) =>
<>
<Tooltip title="Delete Gantt">
<Button size="small" size={"sm"} color='danger' onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip>{" "}
</>
,
},
{ title: 'Nama', dataIndex: 'name', key: 'name' },
{ title: 'Tanggal dibuat', dataIndex: 'created_at', key: 'created_at', render: (text, record) => (<div style={{ whiteSpace: "nowrap" }}>{text ? moment(text).format("D-M-YYYY") : "-"}</div>) },
];
return (
<Table
size="small"
columns={columns}
rowKey={"id"}
dataSource={dataHierarchy}
pagination={{ position: ["bottomLeft"] }}
/>
)
}, [dataHierarchy])
const cancelDelete = () => {
setAlertDelete(false)
setIdDelete(0)
}
const onConfirmDelete = async () => {
let urlDel = HIERARCHY_FTTH_DELETE(idDelete)
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getdataHierarchy()
setIdDelete(0)
setAlertDelete(false)
NotificationManager.success(`Data Hierarchy berhasil dihapus`, 'Success!!');
} else {
setIdDelete(0)
setAlertDelete(false)
NotificationManager.error(`Data Hierarchy gagal dihapus`, 'Failed!!');
}
}
const handleOpenDialogForm = () => {
setOpenDialogForm(true)
}
const toggleDialogForm = () => {
setOpenDialogForm(!openDialogForm)
}
const closeDialogForm = (status) => {
if (status == "success") {
getdataHierarchy()
NotificationManager.success(`Gantt berhasil dibuat!`, 'Success!!');
} else if (status == "failed") {
NotificationManager.error(`Gantt gagal dibuat!`, 'Failed!!');
}
setOpenDialogForm(false)
}
const toggleDialogUser = () => {
if (openDialogUserGantt) {
setIdGantt(0)
}
setOpenDialogUserGantt(!openDialogUserGantt)
}
const closeDialogUser = (status) => {
if (status == "success") {
NotificationManager.success(`Gantt Permission berhasil disimpan!`, 'Success!!');
} else if (status == "failed") {
NotificationManager.error(`Gantt Permission gagal disimpan!`, 'Failed!!');
}
setOpenDialogUserGantt(false)
setIdGantt(0)
}
return (
<>
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize withBtn" toggle={closeDialog} style={{ width: "100%" }}>
<div>Hierarchy Project {proyekName} </div>
</ModalHeader>
<ModalBody>
<div style={{ width: '100%', overflow: "auto" }}>
{RenderTable}
</div>
</ModalBody>
{/* <ModalFooter>
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button>
</ModalFooter> */}
</Modal>
<NotificationContainer />
<SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert>
<DialogForm
idTask={idTask}
openDialog={openDialogForm}
toggleDialog={toggleDialogForm}
closeDialog={closeDialogForm}
/>
<DialogUserGantt
idGantt={idGantt}
humanResource={humanResource}
openDialog={openDialogUserGantt}
toggleDialog={toggleDialogUser}
closeDialog={closeDialogUser}
/>
</>
)
}
export default DialogHierarchy;

116
src/views/SimproV2/CreatedProyek/index.js

@ -65,6 +65,7 @@ import DialogTableTools from "./DialogTableTools";
import DialogDocument from "./DialogDocument";
import DialogInitDocument from "./DialogInitDocument";
import DialogGantt from "./DialogGantt";
import DialogHierarchy from "./DIalogHierarchy";
// import DialogAsignHr from './AsignHrProject';
import AssignHrProject from "./AsignHrProject";
import AssignK3Project from "./AssignK3Project";
@ -98,6 +99,7 @@ const CreatedProyek = ({ params, ...props }) => {
const [openDialogMaterial, setOpenDialogMaterial] = useState(false);
const [openDialogTools, setOpenDialogTools] = useState(false);
const [openDialogGantt, setOpenDialogGantt] = useState(false);
const [openDialogHierarchy, setOpenDialogHierarchy] = useState(false);
const [openDialogAsignHR, setOpenDialogAsignHR] = useState(false);
const [openDialogAssignK3, setOpenDialogAssignK3] = useState(false);
const [dataK3, setDataK3] = useState([]); // transfer list
@ -125,7 +127,9 @@ const CreatedProyek = ({ params, ...props }) => {
const [projectApproval, setProjectApproval] = useState(null);
const [loadVersionGantt, setLoadVersionGantt] = useState(false);
const [loadHierarchy, setLoadHierarchy] = useState(false);
const [dataVersionGantt, setDataVersionGantt] = useState([]);
const [dataHierarchy, setDataHierarchy] = useState([]);
const pageName = params.name;
@ -302,6 +306,33 @@ const CreatedProyek = ({ params, ...props }) => {
}
};
const getdataHierarchy = async (idTask) => {
setLoadHierarchy(true);
const payload = {
columns: [
{
name: "proyek_id",
logic_operator: "=",
value: idTask,
operator: "AND",
},
],
};
const result = await axios
.post(VERSION_GANTT_SEARCH, payload, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.status == 200) {
setDataHierarchy(result.data.data);
setLoadHierarchy(false);
} else {
NotificationManager.error(
`Data gantt project gagal terload silahkan coba lagi!`,
"Failed!!"
);
}
};
const getDataToolsResource = async () => {
const result = await axios
.get(TOOLS_RESOURCE_LIST, HEADER)
@ -356,6 +387,12 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogGantt(true);
};
const handleOpenDialogHierarchy = (data) => {
setidTask(data.id);
setProyekName(data.nama);
setOpenDialogHierarchy(true);
};
const toggleDialogGantt = () => {
setOpenDialogGantt(!openDialogGantt);
};
@ -364,6 +401,14 @@ const CreatedProyek = ({ params, ...props }) => {
setOpenDialogGantt(false);
};
const toggleDialogHierarchy = () => {
setOpenDialogHierarchy(!openDialogHierarchy);
};
const closeDialogHierarchy = () => {
setOpenDialogHierarchy(false);
};
const handleOpenDialogMaterial = (data) => {
setidTask(data.id);
setProyekName(data.nama);
@ -987,15 +1032,25 @@ const CreatedProyek = ({ params, ...props }) => {
}}
></div>
)}
<div
className="menu-list"
onClick={() => handleOpenDialogGantt(text)}
>
<span className="menu-icon">
<i className="fa fa-bars"></i>
</span>
<span className="menu-text">More Gantt Menu ...</span>
</div>
{text.type_proyek_id == 9 ?
<div
className="menu-list"
onClick={() => handleOpenDialogHierarchy(text)}
>
<span className="menu-icon">
<i className="fa fa-bars"></i>
</span>
<span className="menu-text">More Hierarchy Menu ...</span>
</div> :
<div
className="menu-list"
onClick={() => handleOpenDialogGantt(text)}
>
<span className="menu-icon">
<i className="fa fa-bars"></i>
</span>
<span className="menu-text">More Gantt Menu ...</span>
</div>}
</>
)}
</div>
@ -1026,15 +1081,26 @@ const CreatedProyek = ({ params, ...props }) => {
content={popupMenuGantt(text, record)}
trigger="click"
>
<Button
onClick={() => getdataGantt(text.id)}
size="small"
type="link"
style={{ color: "green" }}
>
<i className="fa fa-bars"></i>
</Button>
</Popover>
{
text.type_proyek_id == 9 ?
<Button
onClick={() => getdataHierarchy(text.id)}
size="small"
type="link"
style={{ color: "green" }}
>
<i className="fa fa-bars"></i>
</Button> :
<Button
onClick={() => getdataGantt(text.id)}
size="small"
type="link"
style={{ color: "green" }}
>
<i className="fa fa-bars"></i>
</Button>
}
</Popover>
</>
),
},
@ -1255,6 +1321,19 @@ const CreatedProyek = ({ params, ...props }) => {
[openDialogGantt]
);
const renderDialogHierarchy = useMemo(
() => (
<DialogHierarchy
openDialog={openDialogHierarchy}
closeDialog={closeDialogHierarchy}
toggleDialog={toggleDialogHierarchy}
idTask={idTask}
proyekName={proyekName}
/>
),
[openDialogHierarchy]
);
return (
<div>
<NotificationContainer />
@ -1278,6 +1357,7 @@ const CreatedProyek = ({ params, ...props }) => {
{RenderDialogTableTools}
{RenderDialogDoc}
{renderDialogGantt}
{renderDialogHierarchy}
{RenderDialogAsignHr}
{RenderDialogAssignK3}
<Card>

Loading…
Cancel
Save