From cf2460d31b29aad93964c3afc46b5bfb0bb94015 Mon Sep 17 00:00:00 2001 From: "Mac\\David" Date: Sun, 7 Jul 2024 20:38:02 +0800 Subject: [PATCH] update dashboard --- src/app/api/teamprojects/actions.ts | 2 +- .../ProgressByTeam/ProgressByTeam.tsx | 4 +- .../ProjectCashFlow/ProjectCashFlow.tsx | 5 +- .../ProjectFinancialCard.tsx | 4 +- .../ProjectResourceConsumptionRanking.tsx | 64 +++++++++++++++++-- 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/src/app/api/teamprojects/actions.ts b/src/app/api/teamprojects/actions.ts index 926d05a..65106b6 100644 --- a/src/app/api/teamprojects/actions.ts +++ b/src/app/api/teamprojects/actions.ts @@ -55,7 +55,7 @@ export const fetchAllTeamConsumption = cache(async (teamIdList: number[],tableSo if (teamIdList.length !== 0) { const queryParams = new URLSearchParams(); queryParams.append('teamIdList', teamIdList.join(',')); - return serverFetchJson(`${BASE_API_URL}/dashboard/searchTeamConsumption?${queryParams.toString()}&tableSorting=${tableSorting}`); + return serverFetchJson(`${BASE_API_URL}/dashboard/searchTeamConsumption?${queryParams.toString()}&tableSorting=${tableSorting}`); } else { return []; } diff --git a/src/components/ProgressByTeam/ProgressByTeam.tsx b/src/components/ProgressByTeam/ProgressByTeam.tsx index 2131125..f855206 100644 --- a/src/components/ProgressByTeam/ProgressByTeam.tsx +++ b/src/components/ProgressByTeam/ProgressByTeam.tsx @@ -367,7 +367,7 @@ const ProgressByTeam: React.FC = () => { field: "alert", headerName: "Alert", renderCell: (params: any) => { - if (params.row.alert === true) { + if (params.row.alert === 1) { return ( @@ -492,7 +492,7 @@ const ProgressByTeam: React.FC = () => { const spentManhours = currentPageProjectSpentManhourList[dataPointIndex]; const value = series[seriesIndex][dataPointIndex]; const tooltipContent = ` -
+
${projectCode} - ${projectName}
Budget Manhours: ${budgetManhours} hours diff --git a/src/components/ProjectCashFlow/ProjectCashFlow.tsx b/src/components/ProjectCashFlow/ProjectCashFlow.tsx index d86e712..854531c 100644 --- a/src/components/ProjectCashFlow/ProjectCashFlow.tsx +++ b/src/components/ProjectCashFlow/ProjectCashFlow.tsx @@ -570,7 +570,7 @@ const ProjectCashFlow: React.FC = () => { stroke: { lineCap: "round", }, - labels: ["Accounts Receivable","Account Invoiced"], + labels: ["Received Amount","Invoiced Amount"], }; const expenditureOptions: ApexOptions = { @@ -620,7 +620,7 @@ const ProjectCashFlow: React.FC = () => { stroke: { lineCap: "round", }, - labels: ["Accounts Expenditure"], + labels: ["Expenditure"], }; const rows = [ @@ -848,6 +848,7 @@ const ProjectCashFlow: React.FC = () => { > ${totalFee.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
+
= ({ > {CostPerformanceIndex}
+
)} {Number(CostPerformanceIndex) >= 1 && ( @@ -175,6 +176,7 @@ const ProjectFinancialCard: React.FC = ({ > {CostPerformanceIndex}
+
)}
@@ -197,7 +199,7 @@ const ProjectFinancialCard: React.FC = ({ className="text-lg font-medium ml-5" style={{ color: "#71d19e" }} > - {CashFlowStatus} + {ProjectedCashFlowStatus}

diff --git a/src/components/ProjectResourceConsumptionRanking/ProjectResourceConsumptionRanking.tsx b/src/components/ProjectResourceConsumptionRanking/ProjectResourceConsumptionRanking.tsx index 84ce0c0..58e4372 100644 --- a/src/components/ProjectResourceConsumptionRanking/ProjectResourceConsumptionRanking.tsx +++ b/src/components/ProjectResourceConsumptionRanking/ProjectResourceConsumptionRanking.tsx @@ -55,6 +55,7 @@ const ProjectResourceConsumptionRanking: React.FC = () => { const [receiptFromDate, setReceiptFromDate] = useState(null); const [receiptToDate, setReceiptToDate] = useState(null); const [selectedRows, setSelectedRows] = useState([]); + const [chartProjectColor, setChartProjectColor]:any[] = useState([]); const [chartProjectName, setChartProjectName]:any[] = useState([]); const [chartProjectDisplayName, setChartProjectDisplayName]:any[] = useState([]); const [chartProjectBudgetedHour, setChartProjectBudgetedHour]:any[] = useState([]); @@ -131,15 +132,29 @@ const ProjectResourceConsumptionRanking: React.FC = () => { const projectBudgetedManHour = [] const projectSpentManHour = [] const manhourConsumptionPercentage = [] + const chartColor = [] + let c = 0 for (let i = 0; i < teamProjectResult.length; i++){ - teamProjectResult[i].color = color[i] + console.log(teamProjectResult[i]) - projectNo.push(teamProjectResult[i].team + "(" + teamProjectResult[i].teamLead + ")") + projectNo.push(teamProjectResult[i].projectCode + "(" + teamProjectResult[i].team + ")") projectName.push(teamProjectResult[i].projectName) projectBudgetedManHour.push(teamProjectResult[i].budgetedManhour) projectSpentManHour.push(teamProjectResult[i].spentManhour) manhourConsumptionPercentage.push(teamProjectResult[i].manhourConsumptionPercentage) + if (i === 0) { + chartColor.push(color[c]) + teamProjectResult[i].color = color[c] + } else if (teamProjectResult[i].team !== teamProjectResult[i - 1].team) { + c = c + 1 + chartColor.push(color[c]) + teamProjectResult[i].color = color[c] + } else if (teamProjectResult[i].team === teamProjectResult[i - 1].team){ + chartColor.push(color[c]) + teamProjectResult[i].color = color[c] + } } + setChartProjectColor(chartColor) setChartProjectName(projectNo) setChartProjectDisplayName(projectName) setChartProjectBudgetedHour(projectBudgetedManHour) @@ -319,6 +334,18 @@ const ProjectResourceConsumptionRanking: React.FC = () => { }, flex: 0.1, }, + { + id: "projectCode", + field: "projectCode", + headerName: "Project No", + minWidth:100 + }, + { + id: "projectName", + field: "projectName", + headerName: "Project", + minWidth:300 + }, { id: "team", field: "team", @@ -331,6 +358,27 @@ const ProjectResourceConsumptionRanking: React.FC = () => { headerName: "Team Leader", minWidth: 70 }, + { + id: "expectedStage", + field: "expectedStage", + headerName: "Expected Stage", + minWidth: 300, + renderCell: (params: any) => { + if (params.row.expectedStage != null){ + const expectedStage = params.row.expectedStage; + const lines = expectedStage.split(",").map((line:any, index:any) => ( + + {line.trim()} +
+
+ )); + return
{lines}
; + } else { + return
-
; + } + + }, + }, { id: "budgetedManhour", field: "budgetedManhour", @@ -370,12 +418,18 @@ const ProjectResourceConsumptionRanking: React.FC = () => { }, minWidth: 70 }, + { + id: "comingPaymentMilestone", + field: "comingPaymentMilestone", + headerName: "Coming Payment Milestone", + minWidth: 100 + }, { id: "alert", field: "alert", headerName: "Alert", renderCell: (params: any) => { - if (params.row.alert === true) { + if (params.row.alert === 1) { return ( @@ -587,7 +641,7 @@ const ProjectResourceConsumptionRanking: React.FC = () => { if (i === selectedRowsData.length && i > 0) { projectArray.push("Remained"); } else if (selectedRowsData.length > 0) { - projectArray.push(selectedRowsData[i].team); + projectArray.push(selectedRowsData[i].projectName); totalBudgetManhour += Number(selectedRowsData[i].budgetedManhour); totalSpent += Number(selectedRowsData[i].spentManhour); pieChartColorArray.push(selectedRowsData[i].color); @@ -639,7 +693,7 @@ const ProjectResourceConsumptionRanking: React.FC = () => { const currentPageProjectBudgetedManhour = chartProjectBudgetedHour.slice(startIndex, endIndex) const currentPageProjectSpentManhour = chartProjectSpentHour.slice(startIndex, endIndex) const currentPageData = chartManhourConsumptionPercentage.slice(startIndex, endIndex); - const colorArray = color.slice(startIndex, endIndex); + const colorArray = chartProjectColor.slice(startIndex, endIndex); console.log(currentPage) console.log(Math.ceil(chartManhourConsumptionPercentage.length / recordsPerPage)) setCurrentPageProjectList(currentPageProjectData)