From 2bdc7f890c5cfbc75e0c424c1886e141c09c634c Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 22 May 2023 10:17:23 +0700 Subject: [PATCH] Gantt ftth parents --- src/views/Dashboard/DashboardProject.js | 29 ++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/views/Dashboard/DashboardProject.js b/src/views/Dashboard/DashboardProject.js index 9568ab5..a061d1d 100644 --- a/src/views/Dashboard/DashboardProject.js +++ b/src/views/Dashboard/DashboardProject.js @@ -86,6 +86,8 @@ const DashboardProject = () => { const [assignedHrCount, setAssignedHrCount] = useState(0); const [actualHrCount, setActualHrCount] = useState(0); const [dataGantt, setDataGantt] = useState({}); + const [dataGanttParents, setDataGanttParents] = useState({}); + const [isReadyGanttParents, setIsReadyGanttParents] = useState(false); let history = useHistory(); @@ -96,6 +98,7 @@ const DashboardProject = () => { getReportDistribution() getComments() getGantt() + getGanttParents() return () => { console.log('unmount RenderMap'); } @@ -154,6 +157,19 @@ const DashboardProject = () => { } } + const getGanttParents = async () => { + setIsReadyGanttParents(false) + const url = `${BASE_OSPRO}/api/hierarchy-ftths/tree-gantt/${GANTT_ID}` + try { + const response = await axios.get(url, HEADER) + setDataGanttParents(response) + setIsReadyGanttParents(true) + } catch (error) { + console.error('Failed to get gantt data:', error) + setIsReadyGanttParents(true) + } + } + const getAssignedHR = async () => { const url = `${BASE_OSPRO}/api/project/manpower/assigned/${GANTT_ID}` try { @@ -565,7 +581,18 @@ const DashboardProject = () => {
Project
-
{isReadyProjectDetail ? projectName : }
+
+ {isReadyProjectDetail && isReadyGanttParents && isReadyGantt + ? (() => { + let parentNames = ""; + for (let i = dataGanttParents.data.data.length - 1; i >= 0; i--) { + parentNames += " - "; + parentNames += dataGanttParents.data.data[i].name; + } + return projectName + parentNames + " - " + dataGantt.data.data.name_version; + })() + : } +