This commit is contained in:
phaichayon
2026-07-15 05:46:59 +07:00
parent b51bf3e02a
commit df1821982d
10 changed files with 932 additions and 1346 deletions

View File

@@ -12,9 +12,15 @@ type Params = {
params: Promise<{ id: string }>;
};
export async function GET(_request: NextRequest, { params }: Params) {
export async function GET(request: NextRequest, { params }: Params) {
try {
const { id } = await params;
const templateVariant = request.nextUrl.searchParams.get('templateVariant');
if (templateVariant && templateVariant !== 'product-v1') {
return NextResponse.json({ message: 'Unsupported template variant' }, { status: 400 });
}
const { organization, session, membership } = await requireOrganizationAccess({
permission: PERMISSIONS.crmQuotationPdfPreview
});
@@ -36,7 +42,9 @@ export async function GET(_request: NextRequest, { params }: Params) {
return NextResponse.json({ message: 'Forbidden' }, { status: 403 });
}
const pdf = await generateQuotationPreviewPdf(id, organization.id);
const pdf = await generateQuotationPreviewPdf(id, organization.id, {
templateVariant
});
return new NextResponse(pdf.buffer, {
headers: {