summaryrefslogtreecommitdiff
path: root/lib/approval/handlers-registry.ts
blob: beb6b971f0760c70010b849544a7c4fa33cf1822 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
 * 결재 후 실행될 액션 핸들러 중앙 등록소
 * 
 * 모든 결재 가능한 액션의 핸들러를 한 곳에서 등록
 * instrumentation.ts 또는 Next.js middleware에서 import하여 초기화
 */

import { registerActionHandler } from './approval-workflow';

/**
 * 모든 핸들러를 등록하는 초기화 함수
 * 앱 시작 시 한 번만 호출
 */
export async function initializeApprovalHandlers() {
  console.log('[Approval Handlers] Registering all handlers...');

  // 1. PQ 실사 관련 핸들러
  const { 
    requestPQInvestigationInternal,
    reRequestPQInvestigationInternal
  } = await import('@/lib/vendor-investigation/handlers');
  
  // PQ 실사의뢰 핸들러 등록 (결재 승인 후 실행될 함수 requestPQInvestigationInternal )
  registerActionHandler('pq_investigation_request', requestPQInvestigationInternal);
  
  // PQ 실사 재의뢰 핸들러 등록 (결재 승인 후 실행될 함수 reRequestPQInvestigationInternal )
  registerActionHandler('pq_investigation_rerequest', reRequestPQInvestigationInternal);

  // 2. 발주 요청 핸들러
  // const { createPurchaseOrderInternal } = await import('@/lib/purchase-order/handlers');
  // registerActionHandler('purchase_order_request', createPurchaseOrderInternal);

  // 3. 정규업체 등록 핸들러
  const { registerVendorInternal } = await import('@/lib/vendor-regular-registrations/handlers');
  // 정규업체 등록 핸들러 등록 (결재 승인 후 실행될 함수 registerVendorInternal )
  registerActionHandler('vendor_regular_registration', registerVendorInternal);

  // 4. 벤더 가입 승인 핸들러
  const { approveVendorWithMDGInternal } = await import('@/lib/vendors/approval-handlers');
  // 벤더 가입 승인 핸들러 등록 (결재 승인 후 실행될 함수 approveVendorWithMDGInternal)
  registerActionHandler('vendor_approval', approveVendorWithMDGInternal);

  // 5. 계약 승인 핸들러
  // const { approveContractInternal } = await import('@/lib/contract/handlers');
  // registerActionHandler('contract_approval', approveContractInternal);

  // 6. RFQ 발송 핸들러 (첨부파일이 있는 경우)
  const { sendRfqWithApprovalInternal } = await import('@/lib/rfq-last/approval-handlers');
  // RFQ 발송 핸들러 등록 (결재 승인 후 실행될 함수 sendRfqWithApprovalInternal)
  registerActionHandler('rfq_send_with_attachments', sendRfqWithApprovalInternal);

  // 7. 기술영업 RFQ 발송 핸들러 (DRM 파일이 있는 경우)
  const {
    sendTechSalesRfqWithApprovalInternal,
    resendTechSalesRfqWithDrmInternal
  } = await import('@/lib/techsales-rfq/approval-handlers');
  // 기술영업 RFQ 발송 핸들러 등록 (결재 승인 후 실행될 함수 sendTechSalesRfqWithApprovalInternal)
  registerActionHandler('tech_sales_rfq_send_with_drm', sendTechSalesRfqWithApprovalInternal);
  // 기술영업 RFQ 재발송 핸들러 등록 (결재 승인 후 실행될 함수 resendTechSalesRfqWithDrmInternal)
  registerActionHandler('tech_sales_rfq_resend_with_drm', resendTechSalesRfqWithDrmInternal);

  // 8. 컴플라이언스 Red Flag 해소 핸들러
  const { resolveRedFlagAfterApproval } = await import('@/lib/compliance/approval-handlers');
  registerActionHandler('compliance_red_flag_resolution', resolveRedFlagAfterApproval);

  // 8. 입찰초대 핸들러
  const { requestBiddingInvitationInternal } = await import('@/lib/bidding/handlers');
  // 입찰초대 핸들러 등록 (결재 승인 후 실행될 함수 requestBiddingInvitationInternal)
  registerActionHandler('bidding_invitation', requestBiddingInvitationInternal);

  // 9. 폐찰 핸들러
  const { requestBiddingClosureInternal } = await import('@/lib/bidding/handlers');
  // 폐찰 핸들러 등록 (결재 승인 후 실행될 함수 requestBiddingClosureInternal)
  registerActionHandler('bidding_closure', requestBiddingClosureInternal);

  // 10. 낙찰 핸들러
  const { requestBiddingAwardInternal } = await import('@/lib/bidding/handlers');
  // 낙찰 핸들러 등록 (결재 승인 후 실행될 함수 requestBiddingAwardInternal)
  registerActionHandler('bidding_award', requestBiddingAwardInternal);

  // ... 추가 핸들러 등록

  console.log('[Approval Handlers] All handlers registered successfully');
}

/**
 * 등록된 모든 핸들러 목록 조회 (디버깅용)
 */
export async function listRegisteredHandlers() {
  const { getRegisteredHandlers } = await import('./approval-workflow');
  return await getRegisteredHandlers();
}