summaryrefslogtreecommitdiff
path: root/app/api/sync/workflow/status/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/sync/workflow/status/route.ts')
-rw-r--r--app/api/sync/workflow/status/route.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/api/sync/workflow/status/route.ts b/app/api/sync/workflow/status/route.ts
new file mode 100644
index 00000000..a4c5d1d0
--- /dev/null
+++ b/app/api/sync/workflow/status/route.ts
@@ -0,0 +1,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 }
+ )
+ }
+} \ No newline at end of file