|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import React, { useEffect, useState, useMemo } from 'react' |
|
|
|
|
import { Modal, ModalHeader, ModalBody, } from 'reactstrap'; |
|
|
|
|
import { Button } from 'reactstrap'; |
|
|
|
|
import { Space, Table, Tooltip, Spin } from 'antd'; |
|
|
|
|
import { Table, Tooltip, Spin } from 'antd'; |
|
|
|
|
import 'antd/dist/antd.css'; |
|
|
|
|
import moment from 'moment'; |
|
|
|
|
import SweetAlert from 'react-bootstrap-sweetalert'; |
|
|
|
@ -14,8 +14,7 @@ import DialogFormGantt from './DialogFormGantt';
|
|
|
|
|
import DialogGantt from './DialogGantt'; |
|
|
|
|
import { useTranslation } from 'react-i18next'; |
|
|
|
|
import _ from 'lodash'; |
|
|
|
|
const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, dataViewStartDate }) => { |
|
|
|
|
const token = localStorage.getItem("token") |
|
|
|
|
const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName, dataViewStartDate, token, role_id, user_id, companyName, companyId, isLogin }) => { |
|
|
|
|
const HEADER = { |
|
|
|
|
headers: { |
|
|
|
|
"Content-Type": "application/json", |
|
|
|
@ -26,7 +25,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
const [id, setId] = useState(0) |
|
|
|
|
const [parentId, setParentId] = useState(0) |
|
|
|
|
const [parentName, setParentName] = useState(null) |
|
|
|
|
const [dataGantt, setDataGantt] = useState([]) |
|
|
|
|
const [typeDialog, setTypeDialog] = useState("add") |
|
|
|
|
const [openDialogForm, setOpenDialogForm] = useState(false) |
|
|
|
|
const [openDialogGantt, setOpenDialogGantt] = useState(false) |
|
|
|
@ -36,7 +34,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
const [alertDelete, setAlertDelete] = useState(false) |
|
|
|
|
const [idDelete, setIdDelete] = useState(0) |
|
|
|
|
const [idGantt, setIdGantt] = useState(0) |
|
|
|
|
const [humanResource, setHumanResource] = useState([]) |
|
|
|
|
const { t } = useTranslation(); |
|
|
|
|
const [loading, setLoading] = useState(true); |
|
|
|
|
useEffect(() => { |
|
|
|
@ -44,40 +41,11 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
setLoading(true); |
|
|
|
|
getdataHierarchy(); |
|
|
|
|
} |
|
|
|
|
}, [idTask, openDialog, closeDialog, openDialogFormGantt]) |
|
|
|
|
}, [idTask, openDialog, openDialogFormGantt]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!openDialog) { |
|
|
|
|
setDataHierarchy([]); |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, [openDialog, closeDialog]) |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
} |
|
|
|
|
}, [openDialog]) |
|
|
|
|
|
|
|
|
|
const handleAdd = async () => { |
|
|
|
|
await setTypeDialog("Save") |
|
|
|
@ -137,8 +105,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
const closeDialogFromHierarchy = (type, data) => { |
|
|
|
|
if (type == 'save') { |
|
|
|
|
saveHierarchy(data) |
|
|
|
|
} else { |
|
|
|
|
updateHierarchy(data) |
|
|
|
|
} |
|
|
|
|
setId(0); |
|
|
|
|
setOpenDialogForm(false); |
|
|
|
@ -157,11 +123,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const updateHierarchy = async (data) => { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getdataHierarchy = async () => { |
|
|
|
|
const url = HIERARCHY_FTTH_TREE(idTask) |
|
|
|
|
const result = await axios |
|
|
|
@ -311,9 +272,6 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
</div> |
|
|
|
|
</Spin> |
|
|
|
|
</ModalBody> |
|
|
|
|
{/* <ModalFooter> |
|
|
|
|
<Button className="capitalize" color="secondary" onClick={() => handleCancel()}>Batal</Button> |
|
|
|
|
</ModalFooter> */} |
|
|
|
|
</Modal> |
|
|
|
|
<NotificationContainer /> |
|
|
|
|
<SweetAlert |
|
|
|
@ -335,6 +293,13 @@ const DialogHierarchy = ({ openDialog, closeDialog, toggleDialog, idTask, proyek
|
|
|
|
|
hierarchyId={parentId} |
|
|
|
|
hierarchyName={parentName} |
|
|
|
|
idTask={idTask} |
|
|
|
|
role_id={role_id} |
|
|
|
|
user_id={user_id} |
|
|
|
|
token={token} |
|
|
|
|
isLogin={isLogin} |
|
|
|
|
companyName={companyName} |
|
|
|
|
proyekName={proyekName} |
|
|
|
|
companyId={companyId} |
|
|
|
|
openDialogHierarchy={openDialog} |
|
|
|
|
dataViewStartDate={dataViewStartDate} |
|
|
|
|
/> |
|
|
|
|