1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
6 * BUCK Stocktake Status Endpoint
7 * GET /api/v1/buck/stocktake/status?id=1
8 * Uses: buck?3=retailmax.elink.stocktake.status&100=1
10export async function GET(request: NextRequest) {
12 const authData = await getStoredAuth();
13 if (!authData || !authData.authenticated) {
14 return NextResponse.json(
15 { error: 'Authentication required' },
20 const { searchParams } = new URL(request.url);
21 const id = searchParams.get('id');
24 return NextResponse.json(
25 { error: 'Stocktake ID required' },
30 // Build BUCK endpoint for stocktake status
31 // buck?3=retailmax.elink.stocktake.status&100=1
32 const buckParams: Record<string, string> = {
33 '3': 'retailmax.elink.stocktake.status',
37 const result = await fieldpineServerApi.buckApiCall(buckParams, authData.apiKey!);
39 return NextResponse.json({
46 console.error('Stocktake status BUCK API error:', error);
47 return NextResponse.json(
48 { error: 'Failed to fetch stocktake status' },