Some checks failed
PR checks / checks (pull_request) Failing after 3s
The company form outgrew the modal once the branding (logo/stamp) section was added. Add/edit now live on their own routes: - /admin/companies/new - /admin/companies/[id]/edit - createCompany returns the new id and the create flow lands on the edit page so logo/stamp can be uploaded immediately - list "+ Add Company" is a link; row "Edit" navigates to the edit page - branding is its own card on the edit page (independent uploads) - list page no longer mints a presigned URL per company (moved to edit) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1 KiB
TypeScript
36 lines
1 KiB
TypeScript
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
import { hasPermission } from "@/lib/permissions";
|
|
import { redirect } from "next/navigation";
|
|
import { CompaniesTable } from "./companies-table";
|
|
import type { Metadata } from "next";
|
|
|
|
export const metadata: Metadata = { title: "Company Management" };
|
|
|
|
export default async function AdminCompaniesPage() {
|
|
const session = await auth();
|
|
if (!session?.user) redirect("/login");
|
|
if (!hasPermission(session.user.role, "manage_vessels_accounts")) redirect("/dashboard");
|
|
|
|
const companies = await db.company.findMany({
|
|
orderBy: { name: "asc" },
|
|
});
|
|
|
|
return (
|
|
<CompaniesTable
|
|
companies={companies.map((c) => ({
|
|
id: c.id,
|
|
name: c.name,
|
|
code: c.code,
|
|
gstNumber: c.gstNumber,
|
|
address: c.address,
|
|
telephone: c.telephone,
|
|
mobile: c.mobile,
|
|
email: c.email,
|
|
invoiceEmail: c.invoiceEmail,
|
|
invoiceAddress: c.invoiceAddress,
|
|
isActive: c.isActive,
|
|
}))}
|
|
/>
|
|
);
|
|
}
|