|
|
@@ -21,13 +21,18 @@ import { ClientProjectResult} from "@/app/api/clientprojects"; |
|
|
|
import { ConstructionOutlined } from "@mui/icons-material"; |
|
|
|
import ReactApexChart from "react-apexcharts"; |
|
|
|
import { ApexOptions } from "apexcharts"; |
|
|
|
import { useSearchParams } from 'next/navigation'; |
|
|
|
import { fetchAllClientSubsidiaryProjects} from "@/app/api/clientprojects/actions"; |
|
|
|
// const ReactApexChart = dynamic(() => import('react-apexcharts'), { ssr: false }); |
|
|
|
|
|
|
|
interface Props { |
|
|
|
clientSubsidiaryProjectResult: ClientSubsidiaryProjectResult[]; |
|
|
|
// clientSubsidiaryProjectResult: ClientSubsidiaryProjectResult[]; |
|
|
|
} |
|
|
|
|
|
|
|
const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => { |
|
|
|
const ProgressByClient: React.FC<Props> = () => { |
|
|
|
const searchParams = useSearchParams(); |
|
|
|
const customerId = searchParams.get('customerId'); |
|
|
|
const subsidiaryId = searchParams.get('subsidiaryId'); |
|
|
|
const [activeTab, setActiveTab] = useState("financialSummary"); |
|
|
|
const [SearchCriteria, setSearchCriteria] = React.useState({}); |
|
|
|
const { t } = useTranslation("dashboard"); |
|
|
@@ -56,6 +61,32 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
const [chartProjectName, setChartProjectName]:any[] = useState([]); |
|
|
|
const [chartManhourConsumptionPercentage, setChartManhourConsumptionPercentage]:any[] = useState([]); |
|
|
|
const color = ["#f57f90", "#94f7d6", "#87c5f5", "#ab95f5", "#fcd68b"]; |
|
|
|
const [clientSubsidiaryProjectResult, setClientSubsidiaryProjectResult]:any[] = useState([]); |
|
|
|
|
|
|
|
const fetchData = async () => { |
|
|
|
if (customerId && subsidiaryId) { |
|
|
|
try { |
|
|
|
if (subsidiaryId === '-'){ |
|
|
|
console.log("ss") |
|
|
|
const clickResult = await fetchAllClientSubsidiaryProjects( |
|
|
|
Number(customerId),Number(0)) |
|
|
|
console.log(clickResult) |
|
|
|
setClientSubsidiaryProjectResult(clickResult); |
|
|
|
} else { |
|
|
|
const clickResult = await fetchAllClientSubsidiaryProjects( |
|
|
|
Number(customerId), |
|
|
|
Number(subsidiaryId)) |
|
|
|
console.log(clickResult) |
|
|
|
setClientSubsidiaryProjectResult(clickResult); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('Error fetching client subsidiary projects:', error); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
const projectName = [] |
|
|
|
const manhourConsumptionPercentage = [] |
|
|
@@ -68,6 +99,12 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
setChartManhourConsumptionPercentage(manhourConsumptionPercentage) |
|
|
|
}, [clientSubsidiaryProjectResult]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
fetchData() |
|
|
|
}, [customerId,subsidiaryId]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rows2 = [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
@@ -155,37 +192,37 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
></span> |
|
|
|
); |
|
|
|
}, |
|
|
|
flex: 0.1, |
|
|
|
flex:0.1 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "projectName", |
|
|
|
field: "projectName", |
|
|
|
headerName: "Project", |
|
|
|
flex: 1, |
|
|
|
minWidth:300 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "team", |
|
|
|
field: "team", |
|
|
|
headerName: "Team", |
|
|
|
flex: 0.8, |
|
|
|
minWidth: 50 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "teamLeader", |
|
|
|
field: "teamLeader", |
|
|
|
id: "teamLead", |
|
|
|
field: "teamLead", |
|
|
|
headerName: "Team Leader", |
|
|
|
flex: 0.8, |
|
|
|
minWidth: 70 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "expectedStage", |
|
|
|
field: "expectedStage", |
|
|
|
headerName: "Expected Stage", |
|
|
|
flex: 1, |
|
|
|
minWidth: 300 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "budgetedManhour", |
|
|
|
field: "budgetedManhour", |
|
|
|
headerName: "Budgeted Manhour", |
|
|
|
flex: 0.8, |
|
|
|
minWidth: 70 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "spentManhour", |
|
|
@@ -201,7 +238,7 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
return <span>{params.row.spentManhour}</span>; |
|
|
|
} |
|
|
|
}, |
|
|
|
flex: 0.8, |
|
|
|
minWidth: 70 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "remainedManhour", |
|
|
@@ -216,13 +253,13 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
return <span>{params.row.remainedManhour}</span>; |
|
|
|
} |
|
|
|
}, |
|
|
|
flex: 1, |
|
|
|
minWidth: 70 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "comingPaymentMilestone", |
|
|
|
field: "comingPaymentMilestone", |
|
|
|
headerName: "Coming Payment Milestone", |
|
|
|
flex: 1, |
|
|
|
minWidth: 100 |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "alert", |
|
|
@@ -239,7 +276,7 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
return <span></span>; |
|
|
|
} |
|
|
|
}, |
|
|
|
flex: 0.2, |
|
|
|
flex:0.1 |
|
|
|
}, |
|
|
|
]; |
|
|
|
const optionstest: ApexOptions = { |
|
|
@@ -463,7 +500,7 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
}; |
|
|
|
|
|
|
|
const handleSelectionChange = (newSelectionModel: GridRowSelectionModel) => { |
|
|
|
const selectedRowsData:any = clientSubsidiaryProjectResult.filter((row) => |
|
|
|
const selectedRowsData:any = clientSubsidiaryProjectResult.filter((row:any) => |
|
|
|
newSelectionModel.includes(row.projectId), |
|
|
|
); |
|
|
|
console.log(selectedRowsData); |
|
|
@@ -533,9 +570,9 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
<CardHeader className="text-slate-500" title="Project Resource Consumption" /> |
|
|
|
<div style={{ display: "inline-block", width: "99%" }}> |
|
|
|
<ReactApexChart |
|
|
|
options={optionstest} |
|
|
|
series={optionstest.series} |
|
|
|
type="line" |
|
|
|
options={options} |
|
|
|
series={options.series} |
|
|
|
type="bar" |
|
|
|
height={350} |
|
|
|
/> |
|
|
|
</div> |
|
|
@@ -590,13 +627,13 @@ const ProgressByClient: React.FC<Props> = ({ clientSubsidiaryProjectResult }) => |
|
|
|
Please select the project you want to check. |
|
|
|
</div> |
|
|
|
)} |
|
|
|
{/* {percentageArray.length > 0 && ( |
|
|
|
{percentageArray.length > 0 && ( |
|
|
|
<ReactApexChart |
|
|
|
options={options2} |
|
|
|
series={percentageArray} |
|
|
|
type="donut" |
|
|
|
/> |
|
|
|
)} */} |
|
|
|
)} |
|
|
|
</Card> |
|
|
|
</Grid> |
|
|
|
<Grid item xs={12} md={12} lg={12}> |
|
|
|