Multi-step cart workflows for both shipment and allocation requests: - Ship-to address selection from Epicor portal_CustomerShipToAddresses - Inventory browser dialog (shipment) / coil browser dialog (allocation) - Cart persistence in DB with duplicate detection - Details form (order#, PO#, pickup date, instructions, email recipients) - Review & submit with confirmation dialog - Cancel with permission gate and confirmation - Shared components: stepper, ship-to selector, cart table, header form, review - 16 API routes, 4 services, 13 components, 6 pages - Phase 2 complete: 16/16 tasks done Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getQuestSession, getActiveCompany, requirePermission } from '@/lib/permissions';
|
|
import { cancelRequest } from '@/services/alloc-requests';
|
|
|
|
/**
|
|
* POST: Cancel an allocation request
|
|
*/
|
|
export async function POST(
|
|
_request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const session = await getQuestSession();
|
|
const activeCompany = await getActiveCompany();
|
|
|
|
if (!session || !activeCompany) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
try {
|
|
// Note: using cancel_shipment_request permission for now
|
|
// If a separate cancel_allocation_request permission is needed, add it later
|
|
await requirePermission('cancel_shipment_request');
|
|
} catch {
|
|
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
|
|
}
|
|
|
|
try {
|
|
const { id } = await params;
|
|
const cancelled = await cancelRequest(id, activeCompany.id, session.user.id);
|
|
return NextResponse.json(cancelled);
|
|
} catch (error) {
|
|
console.error('Error cancelling allocation request:', error);
|
|
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
return NextResponse.json({ error: message }, { status: 500 });
|
|
}
|
|
}
|