diff --git a/src/components/Project/pmsInfrastructure/BuildingTable.jsx b/src/components/Project/pmsInfrastructure/BuildingTable.jsx new file mode 100644 index 00000000..cf4e4afa --- /dev/null +++ b/src/components/Project/pmsInfrastructure/BuildingTable.jsx @@ -0,0 +1,35 @@ +import React from "react"; + +import FloorTable from "./FloorTable"; +import { useSelectedProject } from "../../../slices/apiDataManager"; +import { useProjectInfra } from "../../../hooks/useProjects"; +import { PmsGrid } from "../../../services/pmsGrid"; + +export default function BuildingTable() { + const project = useSelectedProject() + + const {projectInfra} = useProjectInfra(project,null) + const columns = [ + { key: "buildingName", title: "Building", sortable: true,}, + { key: "plannedWork", title: "Planned Work" }, + { key: "completedWork", title: "Completed Work" }, + { key: "percentage", title: "Completion %" }, + ]; + + return ( + ( + + )} + /> + ); +} diff --git a/src/components/Project/pmsInfrastructure/FloorTable.jsx b/src/components/Project/pmsInfrastructure/FloorTable.jsx new file mode 100644 index 00000000..f7694b04 --- /dev/null +++ b/src/components/Project/pmsInfrastructure/FloorTable.jsx @@ -0,0 +1,28 @@ +import React from "react"; +import WorkAreaTable from "./WorkAreaTable"; +import { PmsGrid } from "../../../services/pmsGrid"; + +export default function FloorTable({ floors }) { + const columns = [ + { key: "floorName", title: "Floor", sortable: true, }, + { key: "plannedWork", title: "Planned Work" }, + { key: "completedWork", title: "Completed Work" }, + { key: "percentage", title: "Completion %" }, + ]; + + return ( + ( + + )} + /> + ); +} diff --git a/src/components/Project/pmsInfrastructure/WorkAreaTable.jsx b/src/components/Project/pmsInfrastructure/WorkAreaTable.jsx new file mode 100644 index 00000000..dc923cff --- /dev/null +++ b/src/components/Project/pmsInfrastructure/WorkAreaTable.jsx @@ -0,0 +1,39 @@ +import React, { useState, useEffect } from "react"; +import { PmsGrid } from "../../../services/pmsGrid"; +// import { GridService } from "./gridService"; +// import TaskTable from "./TaskTable"; + +export default function WorkAreaTable({ workAreas }) { + const [taskData, setTaskData] = useState({}); // workAreaId → tasks + + const columns = [ + { key: "areaName", title: "Work Area", }, + { key: "plannedWork", title: "Planned Work" }, + { key: "completedWork", title: "Completed Work" }, + { key: "percentage", title: "Completion %" }, + ]; + +// const loadTasks = async (workAreaId) => { +// if (!taskData[workAreaId]) { +// const res = await GridService.getTasksByWorkArea(workAreaId); +// setTaskData((prev) => ({ ...prev, [workAreaId]: res })); +// } +// }; + + return ( + { + // loadTasks(area.id); + // return ; + // }} + /> + ); +} diff --git a/src/pages/project/ProjectDetails.jsx b/src/pages/project/ProjectDetails.jsx index d6fbd55d..fe22d913 100644 --- a/src/pages/project/ProjectDetails.jsx +++ b/src/pages/project/ProjectDetails.jsx @@ -24,6 +24,7 @@ import { useProjectAccess } from "../../hooks/useProjectAccess"; import "./ProjectDetails.css"; import ProjectOrganizations from "../../components/Project/ProjectOrganizations"; +import BuildingTable from "../../components/Project/pmsInfrastructure/BuildingTable"; const ProjectDetails = () => { const projectId = useSelectedProject(); @@ -88,7 +89,7 @@ const ProjectDetails = () => { case "teams": return ; case "infra": - return ; + return case "workplan": return ; case "directory": diff --git a/src/services/pmsGrid/BasicTable.jsx b/src/services/pmsGrid/BasicTable.jsx index 872912a2..550f35eb 100644 --- a/src/services/pmsGrid/BasicTable.jsx +++ b/src/services/pmsGrid/BasicTable.jsx @@ -738,7 +738,7 @@ export default function DemoBOQGrid() { reorder: true, columnVisibility: true, pageSizeSelector: true, - // groupByKey: "category", + // groupByKey: "status", aggregation: true, expand: true, maxHeight: "70vh", @@ -753,11 +753,7 @@ export default function DemoBOQGrid() { icon: "bx-trash text-danger", onClick: (row) => console.log("Delete", row), }, - { - label: "View", - icon: "bx-show text-info", - onClick: (row) => console.log("View ", row), - }, + ], }} renderExpanded={(row) => ( diff --git a/src/services/pmsGrid/PmsGrid.jsx b/src/services/pmsGrid/PmsGrid.jsx index d554b4ad..2645f042 100644 --- a/src/services/pmsGrid/PmsGrid.jsx +++ b/src/services/pmsGrid/PmsGrid.jsx @@ -170,6 +170,7 @@ export default function PmsGrid({ Export CSV )} +
@@ -235,10 +236,8 @@ export default function PmsGrid({ /> )} - {features.expand && ( - + {features.expand && ( + onDragStart(e, col.key)} - onDragOver={(e)=> e.preventDefault()} + onDragOver={(e) => e.preventDefault()} onDrop={(e) => onDrop(e, col.key)} className={`pms-col-header vs-th ${ col.pinned ? `pinned pinned-${col.pinned}` : "" @@ -356,6 +355,7 @@ export default function PmsGrid({ (features.selection ? 1 : 0) + (features.actions ? 1 : 0) } + className="text-start" > {g.key} {features.aggregation && @@ -406,128 +406,127 @@ export default function PmsGrid({ ); // render a single row (function hoisted so it can reference visibleColumns) - function renderRow(row) { - const isSelected = selected.has(row[rowKey]); - const isExpanded = expanded.has(row[rowKey]); + function renderRow(row) { + const isSelected = selected.has(row[rowKey]); + const isExpanded = expanded.has(row[rowKey]); - return ( - - - {/* Selection checkbox (always left) */} - {features.selection && ( - - toggleSelect(row[rowKey])} - /> - - )} - - {/* Expand toggle next to selection */} - {features.expand && ( - - - - )} - - {/* Data columns */} - {visibleColumns.map((col) => { - const style = { - minWidth: col.width || 120, - width: col.width || undefined, - }; - - if (col.pinned) style.position = "sticky"; - if (col.pinned === "left") - style.left = `${getLeftOffset(colState, col.key)}px`; - if (col.pinned === "right") - style.right = `${getRightOffset(colState, col.key)}px`; - - return ( - - {col.render ? col.render(row) : row[col.key] ?? ""} + return ( + + + {/* Selection checkbox (always left) */} + {features.selection && ( + + toggleSelect(row[rowKey])} + /> - ); - })} + )} - {/* Actions column (always right) */} - {features.actions && ( - -
+ + + )} + + {/* Data columns */} + {visibleColumns.map((col) => { + const style = { + minWidth: col.width || 120, + width: col.width || undefined, + }; + + if (col.pinned) style.position = "sticky"; + if (col.pinned === "left") + style.left = `${getLeftOffset(colState, col.key)}px`; + if (col.pinned === "right") + style.right = `${getRightOffset(colState, col.key)}px`; + + return ( + + {col.render ? col.render(row) : row[col.key] ?? ""} + + ); + })} + + {/* Actions column (always right) */} + {features.actions && ( + - {Array.isArray(features.actions) - ? features.actions.map((act, i) => ( - - )) - : typeof features.actions === "function" - ? features.actions(row, toggleExpand) - : null} -
- - )} - - - {/* 🔹 5. Expanded row content (full width) */} - {isExpanded && renderExpanded && ( - - - {renderExpanded(row)} - +
+ {Array.isArray(features.actions) + ? features.actions.map((act, i) => ( + + )) + : typeof features.actions === "function" + ? features.actions(row, toggleExpand) + : null} +
+ + )} - )} -
- ); -} + {/* 🔹 5. Expanded row content (full width) */} + {isExpanded && renderExpanded && ( + + + {renderExpanded(row)} + + + )} +
+ ); + } } // small helpers to compute sticky offsets