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