import { NextResponse } from 'next/server'; import { getTop100Shipments } from '@/services/shipments'; import { getQuestSession, getActiveCompany } from '@/lib/permissions'; export const dynamic = 'force-dynamic'; export async function GET() { const session = await getQuestSession(); const activeCompany = await getActiveCompany(); if (!session || !activeCompany) { return NextResponse.json({ error: 'No active company' }, { status: 401 }); } try { const shipments = await getTop100Shipments(activeCompany.epicor_cust_id); return NextResponse.json(shipments); } catch (err) { const message = err instanceof Error ? err.message : String(err); return NextResponse.json({ error: message }, { status: 500 }); } }