Skip to content

Commit 507673b

Browse files
committed
User groups page implementation with imported user groups table
1 parent 36245b0 commit 507673b

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// src/pages/user_dashboard.tsx (Update the import path)
2+
//import "";
3+
import { useEffect,useState } from "react";
4+
5+
import GroupsItemModal from "../popups/user_groups_select_popup";
6+
7+
export type MyGroups = {
8+
id: number;
9+
name: string;
10+
};
11+
12+
const UserGroupsTable = () => {
13+
const [selectedItem, setSelectedItem] = useState<MyGroups | null>(null);
14+
const [isModalOpen, setIsModalOpen] = useState(false);
15+
16+
// Mock data (replace with Django API call later)
17+
const [groups, SetGroups] = useState<MyGroups[]>([]);
18+
// groups mock data
19+
useEffect(() => {
20+
const mockGroups: MyGroups[] = Array.from({ length: 30 }, (_, i) => ({
21+
id: i + 1,
22+
name: `Group ${i + 1}`,
23+
}));
24+
SetGroups(mockGroups);
25+
}, []);
26+
27+
return (
28+
<>
29+
{/* Scrollable container */}
30+
<div className="flex-1 cursor-pointer overflow-y-auto rounded-md border">
31+
{/* logic for clicking to open pop-up window to edit/resolve an item*/}
32+
33+
{groups.length === 0 ? (
34+
<p className="py-6 text-center text-gray-500">No groups found.</p>
35+
) : (
36+
groups.map((item) => (
37+
<div
38+
key={item.id}
39+
onClick={() => {
40+
setSelectedItem(item);
41+
setIsModalOpen(true);
42+
}}
43+
className="flex items-center justify-between border-b px-3 py-3 last:border-b-0 hover:bg-gray-50"
44+
>
45+
<span className="font-medium text-gray-800">{item.name}</span>
46+
</div>
47+
))
48+
)}
49+
</div>
50+
<GroupsItemModal
51+
isOpen={isModalOpen}
52+
item={selectedItem}
53+
onClose={() => setIsModalOpen(false)}
54+
/>
55+
</>
56+
);
57+
};
58+
export default UserGroupsTable;

client/src/pages/user_groups.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 {useState, useEffect} from "react";
8+
import UserGroupsTable from "../components/ui/user_tables/user_groups_table";
9+
10+
// type MyGroups = {
11+
// id: number;
12+
// name: string;
13+
// }
14+
15+
{
16+
/* optional: later have a list for friends in said groups or something in above "my groups" */
17+
}
18+
19+
// The Header component is now one directory level up from 'pages',
20+
// so the path is '../components/Header'
21+
//import Header from '../components/Header';
22+
23+
const UserGroupsPage = () => {
24+
return (
25+
<>
26+
<Head>
27+
<title>My Groups</title>
28+
</Head>
29+
{/* Page background */}
30+
<UserNavbar />
31+
<div className="min-h-screen bg-gray-100 p-6">
32+
{/* 2. Main content wrapper */}
33+
<main className="mx-auto h-[80vh] max-w-6xl">
34+
{/* Components for Statistics, Recent Activity, and Quick Actions */}
35+
<h1 className="mb-6 text-3xl font-bold">My Groups</h1>
36+
37+
{/* Inventory Grid */}
38+
<div className="grid h-full grid-flow-col grid-rows-1 gap-4">
39+
<div className="row-span-4 flex flex-col rounded-xl bg-white p-4 shadow">
40+
<h2 className="mb-2 text-xl font-semibold">My Groups</h2>
41+
<UserGroupsTable />
42+
</div>
43+
</div>
44+
</main>
45+
</div>
46+
</>
47+
);
48+
};
49+
50+
// export to make the function available to other parts of the app
51+
export default UserGroupsPage;

0 commit comments

Comments
 (0)