1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
6 * OpenAPI StockTransfers Receive Endpoint
7 * POST /api/v1/openapi/stock-transfers/[id]/receive?location=5
8 * Acknowledge receipt of store-to-store stock transfer
10export async function POST(
12 { params }: { params: Promise<{ id: string }> }
15 const authData = await getStoredAuth();
16 if (!authData || !authData.authenticated) {
17 return NextResponse.json(
18 { error: 'Authentication required' },
23 const { searchParams } = new URL(request.url);
24 const queryParams: Record<string, string | number> = {};
26 const location = searchParams.get('location');
27 if (location) queryParams.location = parseInt(location);
29 const result = await fieldpineServerApi.apiCall(
30 `/StockTransfers/${await params.then(p => p.id)}/receive`,
34 cookie: authData.apiKey,
39 return NextResponse.json({
46 console.error('StockTransfers receive error:', error);
47 return NextResponse.json(
48 { error: 'Failed to receive stock transfer' },