blob: a4c5d1d0c8c8d61d5a7e597e12757bdc4805f30e (
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
35
36
37
38
39
40
41
|
// app/api/sync/workflow/status/route.ts
import { NextRequest, NextResponse } from "next/server"
import { workflowService } from "@/lib/vendor-document-list/workflow-service"
import { getServerSession } from "next-auth"
import { authOptions } from "@/app/api/auth/[...nextauth]/route"
export async function GET(request: NextRequest) {
try {
const session = await getServerSession(authOptions)
if (!session?.user?.id) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
const { searchParams } = new URL(request.url)
const contractId = searchParams.get('contractId')
const targetSystem = searchParams.get('targetSystem') || 'SWP'
if (!contractId) {
return NextResponse.json(
{ error: 'Contract ID is required' },
{ status: 400 }
)
}
const status = await workflowService.getWorkflowStatus(
Number(contractId),
targetSystem
)
return NextResponse.json(status)
} catch (error) {
console.error('Failed to get workflow status:', error)
return NextResponse.json(
{
error: 'Failed to get workflow status',
message: error instanceof Error ? error.message : 'Unknown error'
},
{ status: 500 }
)
}
}
|