pelagia-portal/App/app/(portal)/admin/users/page.tsx
Hardik 9758dcd8ab feat(admin): add client-side search, sort, and filter chips to all admin tables
Adds a reusable useTableControls hook and TableControls/SortableTh
components, then wires them into all six admin table pages (users,
vendors, vessels, sites, accounts, products). Each page now supports
a global search bar, clickable sortable column headers with ↑/↓/⇅
indicators, and role/status filter chips — all purely client-side with
no URL params or server round-trips. Server pages continue to fetch the
full list and pass it as props to a new *-table.tsx Client Component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 02:46:52 +05:30

31 lines
869 B
TypeScript

import { auth } from "@/auth";
import { db } from "@/lib/db";
import { hasPermission } from "@/lib/permissions";
import { redirect } from "next/navigation";
import { UsersTable } from "./users-table";
import type { Metadata } from "next";
export const metadata: Metadata = { title: "User Management" };
export default async function AdminUsersPage() {
const session = await auth();
if (!session?.user) redirect("/login");
if (!hasPermission(session.user.role, "manage_users")) redirect("/dashboard");
const users = await db.user.findMany({ orderBy: { createdAt: "desc" } });
return (
<UsersTable
users={users.map((u) => ({
id: u.id,
employeeId: u.employeeId,
name: u.name,
email: u.email,
role: u.role,
isActive: u.isActive,
createdAt: u.createdAt.toISOString(),
}))}
/>
);
}