Cost Centre on PO forms now shows only Vessels (plain vesselId field). Sites are a separate concept and not selectable as cost centres. - PurchaseOrder.vesselId is required again (NOT NULL restored) - Vessel.siteId and vessel->site relation removed from schema - DB migration: drops Vessel.siteId column, restores PO.vesselId NOT NULL - All PO forms (new/edit/import/manager-edit): plain vessel <select> with code-prefixed labels (e.g. "HNR1 — HNR 1") - History, approvals, dashboard, my-orders, payments: back to vesselId filter params and po.vessel.name display - Admin vessels: removed Site column and site-assignment dropdown - Admin sites detail page: removed "Assigned Vessels" section - Sites table: removed Vessels count column (no longer linked) - seed-prod.ts and seed.ts: vessels created without siteId - SearchableSelect accounting code picker retained from previous commit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1 KiB
TypeScript
39 lines
1 KiB
TypeScript
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
import { hasPermission } from "@/lib/permissions";
|
|
import { redirect } from "next/navigation";
|
|
import { SitesTable } from "./sites-table";
|
|
import type { Metadata } from "next";
|
|
|
|
export const metadata: Metadata = { title: "Sites" };
|
|
|
|
export default async function SitesPage() {
|
|
const session = await auth();
|
|
if (!session?.user) redirect("/login");
|
|
if (!hasPermission(session.user.role, "manage_sites")) redirect("/dashboard");
|
|
|
|
const sites = await db.site.findMany({
|
|
orderBy: { name: "asc" },
|
|
include: {
|
|
_count: { select: { inventory: true } },
|
|
},
|
|
});
|
|
|
|
const canEdit = session.user.role === "ADMIN";
|
|
|
|
return (
|
|
<SitesTable
|
|
canEdit={canEdit}
|
|
sites={sites.map((s) => ({
|
|
id: s.id,
|
|
code: s.code,
|
|
name: s.name,
|
|
address: s.address ?? null,
|
|
latitude: s.latitude ?? null,
|
|
longitude: s.longitude ?? null,
|
|
isActive: s.isActive,
|
|
inventoryCount: s._count.inventory,
|
|
}))}
|
|
/>
|
|
);
|
|
}
|