Skip to content

Commit a029d7c

Browse files
committed
User inventory page implementation with imported user inventory table
1 parent 507673b commit a029d7c

2 files changed

Lines changed: 112 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// src/pages/user_dashboard.tsx (Update the import path)
2+
//import "";
3+
import { useEffect,useState } from "react";
4+
5+
import InventoryItemModal from "../popups/user_inventory_select_popup";
6+
7+
export type InventoryItem = {
8+
id: number;
9+
name: string;
10+
date: string;
11+
};
12+
13+
const UserInventoryTable = () => {
14+
const [inventory, setInventory] = useState<InventoryItem[]>([]);
15+
const [selectedItem, setSelectedItem] = useState<InventoryItem | null>(null);
16+
const [isModalOpen, setIsModalOpen] = useState(false);
17+
18+
// Mock data (replace with Django API call later)
19+
useEffect(() => {
20+
const mockInventory: InventoryItem[] = Array.from(
21+
{ length: 30 },
22+
(_, i) => ({
23+
id: i + 1,
24+
name: `Item ${i + 1}`,
25+
date:
26+
((Math.floor(Math.random() * 10) % 11) + 1).toString() +
27+
"/" +
28+
(Math.floor(Math.random() * 10) + 1).toString() +
29+
"/2026",
30+
}),
31+
);
32+
{
33+
/* have
34+
is_due_soon = date is larger than 2 weeks
35+
in the array? -- as flag for due soon inventory */
36+
}
37+
setInventory(mockInventory);
38+
}, []);
39+
40+
return (
41+
<>
42+
{/* Scrollable container */}
43+
<div className="flex-1 cursor-pointer overflow-y-auto rounded-md border">
44+
{/* logic for clicking to open pop-up window to edit/resolve an item*/}
45+
46+
{inventory.length === 0 ? (
47+
<p className="py-6 text-center text-gray-500">No items found.</p>
48+
) : (
49+
inventory.map((item) => (
50+
<div
51+
key={item.id}
52+
onClick={() => {
53+
setSelectedItem(item);
54+
setIsModalOpen(true);
55+
}}
56+
className="flex items-center justify-between border-b px-3 py-3 last:border-b-0 hover:bg-gray-50"
57+
>
58+
<span className="font-medium text-gray-800">{item.name}</span>
59+
<span className="font-medium text-gray-800">
60+
date:{item.date}
61+
</span>
62+
</div>
63+
))
64+
)}
65+
</div>
66+
<InventoryItemModal
67+
isOpen={isModalOpen}
68+
item={selectedItem}
69+
onClose={() => setIsModalOpen(false)}
70+
/>
71+
</>
72+
);
73+
};
74+
export default UserInventoryTable;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// src/pages/user_dashboard.tsx (Update the import path)
2+
//import "";
3+
4+
import Head from "next/head";
5+
6+
import UserNavbar from "../components/ui/user_navbar";
7+
import UserInventoryTable from "../components/ui/user_tables/user_inventory_table";
8+
9+
const UserInventoryPage = () => {
10+
return (
11+
<>
12+
<Head>
13+
<title>My Inventory</title>
14+
</Head>
15+
{/* Navbar */}
16+
<UserNavbar />
17+
{/* Page background */}
18+
<div className="min-h-screen bg-gray-100 p-6">
19+
{/* 2. Main content wrapper */}
20+
<main className="mx-auto h-[80vh] max-w-6xl">
21+
{/* Components for Statistics, Recent Activity, and Quick Actions */}
22+
<h1 className="mb-6 text-3xl font-bold">My Inventory</h1>
23+
24+
{/* Inventory Grid */}
25+
<div className="grid h-full grid-flow-col grid-rows-1 gap-4">
26+
<div className="row-span-4 flex flex-col rounded-xl bg-white p-4 shadow">
27+
<h2 className="mb-2 text-xl font-semibold">My Inventory</h2>
28+
<UserInventoryTable />
29+
</div>
30+
</div>
31+
</main>
32+
</div>
33+
</>
34+
);
35+
};
36+
37+
// export to make the function available to other parts of the app
38+
export default UserInventoryPage;

0 commit comments

Comments
 (0)