pelagia-portal/App/app/(portal)/admin/vessels/page.tsx
Hardik e3851a1799 feat(sidebar+vessels): Purchasing section, split Administration, Cost Centre rename
Sidebar:
- Inventory section renamed to Purchasing
- Manager gets separate Administration section for Vendors only
- Admin gets full Administration (Vendors + Users + Accounting Codes + Companies)
- Sites hidden from Manager when NEXT_PUBLIC_INVENTORY_ENABLED=false
- Cost Centres replaces Vessels in the Purchasing nav link

Admin vessel pages:
- All headings, titles, dialogs, breadcrumbs: Vessels -> Cost Centre
- Error messages updated accordingly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 02:53:33 +05:30

34 lines
951 B
TypeScript

import { auth } from "@/auth";
import { db } from "@/lib/db";
import { hasPermission } from "@/lib/permissions";
import { redirect } from "next/navigation";
import { VesselsTable } from "./vessels-table";
import { nextId } from "@/lib/id-generators";
import type { Metadata } from "next";
export const metadata: Metadata = { title: "Cost Centre Management" };
export default async function AdminVesselsPage() {
const session = await auth();
if (!session?.user) redirect("/login");
if (!hasPermission(session.user.role, "manage_vessels_accounts")) redirect("/dashboard");
const vessels = await db.vessel.findMany({
orderBy: { name: "asc" },
});
const suggestedCode = nextId("SITE", vessels.map((v) => v.code));
return (
<VesselsTable
suggestedCode={suggestedCode}
vessels={vessels.map((v) => ({
id: v.id,
code: v.code,
name: v.name,
isActive: v.isActive,
}))}
/>
);
}