2026-05-09 18:37:16 +02:00
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
|
|
|
|
|
|
import { withAuth, withPermission } from '@/lib/api/helpers';
|
|
|
|
|
import { errorResponse, NotFoundError } from '@/lib/errors';
|
|
|
|
|
import { listDealDocumentsForBerth } from '@/lib/services/documents.service';
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-14 15:50:56 +02:00
|
|
|
* GET /api/v1/berths/[id]/interest-documents (renamed from
|
|
|
|
|
* `/deal-documents` in the 2026-05-14 terminology sweep — canonical
|
|
|
|
|
* noun is "interest").
|
2026-05-09 18:37:16 +02:00
|
|
|
*
|
|
|
|
|
* Lists documents attached to interests currently linked to this berth.
|
|
|
|
|
* Same permission gate as the berth page itself (berths.view).
|
|
|
|
|
*/
|
|
|
|
|
export const GET = withAuth(
|
|
|
|
|
withPermission('berths', 'view', async (_req, ctx, params) => {
|
|
|
|
|
try {
|
|
|
|
|
const berthId = params.id;
|
|
|
|
|
if (!berthId) throw new NotFoundError('Berth');
|
|
|
|
|
const data = await listDealDocumentsForBerth(ctx.portId, berthId);
|
|
|
|
|
return NextResponse.json({ data });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return errorResponse(error);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|