All checks were successful
PR checks / checks (pull_request) Successful in 31s
Companies can upload a logo and a stamp/seal (Admin → Companies → Edit → Branding); both render on exported PDF and XLSX purchase orders. A fixed brand-colour bar (#92D050, matching the sample PO) runs along the bottom of every export. - Company.logoKey / stampKey + migration - buildCompanyAssetKey() deterministic storage keys (overwrite-in-place) - uploadCompanyAsset / removeCompanyAsset server actions (≤4MB PNG/JPG/WebP, manage_vessels_accounts gated) - CompanyBrandingUploader in the company edit dialog with live previews - Export route embeds logo (top-left), stamp (signatory block) and brand bar in both ExcelJS and print-HTML paths - Unit test (storage keys) + integration test (branding actions) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
import { hasPermission } from "@/lib/permissions";
|
|
import { generateDownloadUrl } from "@/lib/storage";
|
|
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" },
|
|
});
|
|
|
|
const rows = await Promise.all(
|
|
companies.map(async (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,
|
|
logoUrl: c.logoKey ? await generateDownloadUrl(c.logoKey) : null,
|
|
stampUrl: c.stampKey ? await generateDownloadUrl(c.stampKey) : null,
|
|
isActive: c.isActive,
|
|
}))
|
|
);
|
|
|
|
return <CompaniesTable companies={rows} />;
|
|
}
|