summaryrefslogtreecommitdiff
path: root/app/api/sync/batches/route.ts
blob: 66a0ab9043418b827459c0706f623315017d2c99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//api/sync/batches/route.ts

import { syncService } from "@/lib/vendor-document-list/sync-service"
import { NextRequest, NextResponse } from "next/server"

export async function GET(request: NextRequest) {
  try {
    const { searchParams } = new URL(request.url)
    const projectId = searchParams.get('projectId')
    const targetSystem = searchParams.get('targetSystem') || 'SHI'
    const limit = parseInt(searchParams.get('limit') || '10')

    if (!projectId) {
      return NextResponse.json(
        { error: 'Vendor ID is required' },
        { status: 400 }
      )
    }

    const batches = await syncService.getRecentSyncBatches(
      parseInt(projectId),
      targetSystem,
      limit
    )

    return NextResponse.json(batches)
  } catch (error) {
    console.error('Failed to get sync batches:', error)
    return NextResponse.json(
      { error: 'Failed to get sync batches' },
      { status: 500 }
    )
  }
}