From 41bdba862edf3095c240ed316c3df31b31021ed8 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 24 Nov 2025 20:50:31 +0900 Subject: (김준회) bidding: 빌드 오류 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bidding/detail/table/bidding-award-dialog.tsx | 202 ++++------------------ lib/bidding/failure/biddings-closure-dialog.tsx | 62 +++---- 2 files changed, 61 insertions(+), 203 deletions(-) (limited to 'lib') diff --git a/lib/bidding/detail/table/bidding-award-dialog.tsx b/lib/bidding/detail/table/bidding-award-dialog.tsx index ff104fac..b168e884 100644 --- a/lib/bidding/detail/table/bidding-award-dialog.tsx +++ b/lib/bidding/detail/table/bidding-award-dialog.tsx @@ -35,12 +35,6 @@ interface BiddingAwardDialogProps { open: boolean onOpenChange: (open: boolean) => void onSuccess: () => void - onApprovalPreview?: (data: { - templateName: string - variables: Record - title: string - selectionReason: string - }) => void } interface AwardedCompany { @@ -54,8 +48,7 @@ export function BiddingAwardDialog({ biddingId, open, onOpenChange, - onSuccess, - onApprovalPreview + onSuccess }: BiddingAwardDialogProps) { const { toast } = useToast() const { data: session } = useSession() @@ -114,36 +107,43 @@ const userId = session?.user?.id || '2'; return } - // 결재 템플릿 변수 준비 - const { mapBiddingAwardToTemplateVariables } = await import('@/lib/bidding/handlers') - - try { - const variables = await mapBiddingAwardToTemplateVariables({ - biddingId, - selectionReason, - requestedAt: new Date() - }) + // 서버 액션을 사용하여 결재 상신 + startTransition(async () => { + try { + const result = await requestBiddingAwardWithApproval({ + biddingId, + selectionReason: selectionReason.trim(), + currentUser: { + id: Number(userId), + epId: session?.user?.epId || null, + email: session?.user?.email || undefined, + }, + }) - // 상위 컴포넌트로 결재 미리보기 데이터 전달 - if (onApprovalPreview) { - onApprovalPreview({ - templateName: '입찰 결과 업체 선정 품의 요청서', - variables, - title: `낙찰 - ${bidding?.title}`, - selectionReason + if (result.status === 'pending_approval') { + toast({ + title: '성공', + description: '낙찰 결재가 상신되었습니다.', + }) + onOpenChange(false) + setSelectionReason('') + onSuccess() + } else { + toast({ + title: '오류', + description: '결재 상신에 실패했습니다.', + variant: 'destructive', + }) + } + } catch (error) { + console.error('낙찰 결재 상신 실패:', error) + toast({ + title: '오류', + description: error instanceof Error ? error.message : '결재 상신 중 오류가 발생했습니다.', + variant: 'destructive', }) } - - onOpenChange(false) - setSelectionReason('') - } catch (error) { - console.error('낙찰 템플릿 변수 준비 실패:', error) - toast({ - title: '오류', - description: '결재 문서 준비 중 오류가 발생했습니다.', - variant: 'destructive', - }) - } + }) } @@ -276,136 +276,4 @@ const userId = session?.user?.id || '2'; ) - - return ( - <> - - - - - - 낙찰 처리 - - - 낙찰된 업체의 발주비율과 선정 사유를 확인하고 낙찰을 완료하세요. - - - -
-
- {/* 낙찰 업체 정보 */} - - - - - 낙찰 업체 정보 - - - - {isLoading ? ( -
-
-

낙찰 업체 정보를 불러오는 중...

-
- ) : awardedCompanies.length > 0 ? ( -
- - - - 업체명 - 견적금액 - 발주비율 - 발주금액 - - - - {awardedCompanies.map((company) => ( - - -
- 낙찰 - {company.companyName} -
-
- - {company.finalQuoteAmount.toLocaleString()}원 - - - {company.awardRatio}% - - - {(company.finalQuoteAmount * company.awardRatio / 100).toLocaleString()}원 - -
- ))} -
-
- - {/* 최종입찰가 요약 */} -
-
- - 최종입찰가 -
- - {finalBidPrice.toLocaleString()}원 - -
-
- ) : ( -
- -

낙찰된 업체가 없습니다

-

- 먼저 업체 수정 다이얼로그에서 발주비율을 산정해주세요. -

-
- )} -
-
- - {/* 낙찰 사유 */} -
- -