added demo data

This commit is contained in:
pramod.mahajan 2025-10-31 00:53:42 +05:30
parent c594d146cc
commit 7329319417

View File

@ -7,8 +7,6 @@ import { initPopover } from "./GridService";
* CIVIL BOQ / INVENTORY DEMO DATA * CIVIL BOQ / INVENTORY DEMO DATA
* Each row = BOQ item, grouped by "Category" * Each row = BOQ item, grouped by "Category"
*/ */
// BOQ data
const boqData = [ const boqData = [
{ {
id: 1, id: 1,
@ -72,6 +70,18 @@ const boqData = [
}, },
{ {
id: 6, id: 6,
category: "Masonry Works",
itemCode: "M-002",
description: "Block Masonry AAC 200mm wall",
unit: "Sqm",
quantity: 240,
rate: 1100,
site: "Green City",
vendor: "Ambuja Blocks",
status: "Pending",
},
{
id: 7,
category: "Plastering Works", category: "Plastering Works",
itemCode: "P-001", itemCode: "P-001",
description: "Internal Plaster 12mm thick", description: "Internal Plaster 12mm thick",
@ -82,9 +92,47 @@ const boqData = [
vendor: "L&T Finishes", vendor: "L&T Finishes",
status: "Completed", status: "Completed",
}, },
{
id: 8,
category: "Plastering Works",
itemCode: "P-002",
description: "External Plaster 20mm thick",
unit: "Sqm",
quantity: 800,
rate: 320,
site: "Sunshine Plaza",
vendor: "Hindustan Plaster",
status: "In Progress",
},
{
id: 9,
category: "Flooring Works",
itemCode: "F-001",
description: "Vitrified Tiles 600x600mm",
unit: "Sqm",
quantity: 600,
rate: 650,
site: "Green City - Clubhouse",
vendor: "Kajaria",
status: "Pending",
},
{
id: 10,
category: "Flooring Works",
itemCode: "F-002",
description: "Granite Flooring 20mm thick",
unit: "Sqm",
quantity: 300,
rate: 1250,
site: "Skyline Heights - Lobby",
vendor: "Classic Stone",
status: "Completed",
},
]; ];
// BOQ columns /**
* COLUMN DEFINITIONS
*/
const boqColumns = [ const boqColumns = [
{ key: "itemCode", title: "Item Code", sortable: true, pinned: "left" }, { key: "itemCode", title: "Item Code", sortable: true, pinned: "left" },
{ key: "description", title: "Description", sortable: true, width: 300 }, { key: "description", title: "Description", sortable: true, width: 300 },
@ -108,6 +156,11 @@ const boqColumns = [
{(r.quantity * r.rate).toLocaleString()} {(r.quantity * r.rate).toLocaleString()}
</span> </span>
), ),
aggregate: (vals) =>
"₹" +
vals
.reduce((sum, val) => sum + val, 0)
.toLocaleString(),
}, },
{ key: "vendor", title: "Vendor", sortable: true, width: 180 }, { key: "vendor", title: "Vendor", sortable: true, width: 180 },
{ key: "site", title: "Site Location", sortable: true, width: 200 }, { key: "site", title: "Site Location", sortable: true, width: 200 },
@ -132,122 +185,119 @@ const boqColumns = [
}, },
]; ];
// Main component /**
* DEMO COMPONENT
*/
export default function DemoBOQGrid() { export default function DemoBOQGrid() {
const wrapperRef = useRef(null); useEffect(() => {
// 🔥 Initialize Bootstrap popovers after first render
// initialize scrollbar
useEffect(() => {
if (!wrapperRef.current) return;
const ps = new PerfectScrollbar(wrapperRef.current, {
wheelPropagation: false,
suppressScrollX: false,
});
return () => ps.destroy();
}, []);
// initialize bootstrap popover
useEffect(() => {
initPopover(); initPopover();
}, []); }, []);
const wrapperRef = useRef()
useEffect(() => {
if (!wrapperRef.current) return;
const ps = new PerfectScrollbar(wrapperRef.current, {
wheelPropagation: false,
suppressScrollX: false,
});
return () => ps.destroy();
}, []);
return ( return (
<div className="container-fluid py-3"> <div className="container-fluid py-3">
<div className="d-flex justify-content-between align-items-center mb-3"> <button
<h5 className="fw-semibold">📦 BOQ (Bill of Quantities)</h5> type="button"
<button className="btn btn-outline-primary"
type="button" data-bs-toggle="popover"
className="btn btn-outline-primary" data-bs-placement="right"
data-bs-toggle="popover" data-bs-content="This is a popover via CDN!"
data-bs-placement="right" >
data-bs-content="This is a Bootstrap Popover initialized via CDN!" Click me
> </button>
<i className="bx bx-help-circle"></i> Popover Test
</button>
</div>
<div className="card p-3"> <div className="card p-3">
<div ref={wrapperRef} style={{ maxHeight: "70vh", overflow: "auto" }}> <PmsGrid
<PmsGrid data={boqData.map((r) => ({
data={boqData.map((r) => ({ ...r,
...r, amount: r.quantity * r.rate,
amount: r.quantity * r.rate, }))}
}))} columns={boqColumns}
columns={boqColumns} features={{
features={{ search: true,
search: true, selection: true,
selection: true, pagination: true,
pagination: true, export: true,
export: true, pinning: true,
pinning: true, resizing: true,
resizing: true, reorder: true,
reorder: true, columnVisibility: true,
columnVisibility: true, pageSizeSelector: true,
expand: true, // groupByKey: "category",
aggregation: true, aggregation: true,
maxHeight: "60vh", expand: true,
actions: (row, toggleExpand) => ( maxHeight: "60vh",
actions: (row, toggleExpand) => (
<>
<button <button
className="btn btn-sm btn-outline-primary" className="btn btn-sm btn-outline-primary"data-bs-toggle="popover" data-bs-content="Popover text"
data-bs-toggle="popover"
data-bs-content={`Expand details for ${row.itemCode}`}
onClick={() => toggleExpand(row.id)} onClick={() => toggleExpand(row.id)}
> >
<i className="bx bx-detail me-1"></i> Details <i className="bx bx-detail me-1"></i>
Details
</button> </button>
), </>
}} ),
renderExpanded={(row) => ( }}
<div className="p-3 bg-light border rounded"> renderExpanded={(row) => (
<h6 className="fw-semibold mb-2">Item Details</h6> <div className="p-3 bg-light border rounded">
<div className="row small"> <h6 className="fw-semibold mb-2">Item Details</h6>
<div className="col-md-4 mb-2"> <div className="row small">
<strong>Item Code:</strong> {row.itemCode} <div className="col-md-4 mb-2">
</div> <strong>Item Code:</strong> {row.itemCode}
<div className="col-md-4 mb-2"> </div>
<strong>Category:</strong> {row.category} <div className="col-md-4 mb-2">
</div> <strong>Category:</strong> {row.category}
<div className="col-md-4 mb-2"> </div>
<strong>Unit:</strong> {row.unit} <div className="col-md-4 mb-2">
</div> <strong>Unit:</strong> {row.unit}
<div className="col-md-4 mb-2"> </div>
<strong>Quantity:</strong> {row.quantity} <div className="col-md-4 mb-2">
</div> <strong>Quantity:</strong> {row.quantity}
<div className="col-md-4 mb-2"> </div>
<strong>Rate:</strong> {row.rate.toLocaleString()} <div className="col-md-4 mb-2">
</div> <strong>Rate:</strong> {row.rate.toLocaleString()}
<div className="col-md-4 mb-2"> </div>
<strong>Total Amount:</strong>{" "} <div className="col-md-4 mb-2">
<span className="text-success fw-semibold"> <strong>Total Amount:</strong>{" "}
{(row.quantity * row.rate).toLocaleString()} <span className="text-success fw-semibold">
</span> {(row.quantity * row.rate).toLocaleString()}
</div> </span>
<div className="col-md-6 mb-2"> </div>
<strong>Vendor:</strong> {row.vendor} <div className="col-md-6 mb-2">
</div> <strong>Vendor:</strong> {row.vendor}
<div className="col-md-6 mb-2"> </div>
<strong>Site:</strong> {row.site} <div className="col-md-6 mb-2">
</div> <strong>Site Location:</strong> {row.site}
<div className="col-md-12"> </div>
<strong>Status:</strong>{" "} <div className="col-md-12">
<span <strong>Status:</strong>{" "}
className={`badge bg-${ <span
row.status === "Completed" className={`badge bg-${
? "success" row.status === "Completed"
: row.status === "Pending" ? "success"
? "warning" : row.status === "Pending"
: "info" ? "warning"
}`} : "info"
> }`}
{row.status} >
</span> {row.status}
</div> </span>
</div> </div>
</div> </div>
)} </div>
/> )}
</div> />
</div> </div>
</div> </div>
); );
} }