summaryrefslogtreecommitdiff
path: root/lib/rfq-last/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rfq-last/vendor')
-rw-r--r--lib/rfq-last/vendor/rfq-vendor-table.tsx46
-rw-r--r--lib/rfq-last/vendor/send-rfq-dialog.tsx8
2 files changed, 43 insertions, 11 deletions
diff --git a/lib/rfq-last/vendor/rfq-vendor-table.tsx b/lib/rfq-last/vendor/rfq-vendor-table.tsx
index 17433773..b8a5184f 100644
--- a/lib/rfq-last/vendor/rfq-vendor-table.tsx
+++ b/lib/rfq-last/vendor/rfq-vendor-table.tsx
@@ -309,7 +309,17 @@ export function RfqVendorTable({
try {
setIsUpdatingShortList(true);
- const vendorIds = selectedRows
+ // response가 있는 벤더들만 필터링
+ const vendorsWithResponse = selectedRows.filter(vendor =>
+ vendor.response && vendor.response.vendor&& vendor.response.isDocumentConfirmed
+ );
+
+ if (vendorsWithResponse.length === 0) {
+ toast.warning("응답이 있는 벤더를 선택해주세요.");
+ return;
+ }
+
+ const vendorIds = vendorsWithResponse
.map(vendor => vendor.vendorId)
.filter(id => id != null);
@@ -474,19 +484,36 @@ export function RfqVendorTable({
});
// 기본계약 생성 결과 표시
+ let message = "";
if (result.contractResults && result.contractResults.length > 0) {
const totalContracts = result.contractResults.reduce((acc, r) => acc + r.totalCreated, 0);
- toast.success(`${data.vendors.length}개 업체에 RFQ를 발송하고 ${totalContracts}개의 기본계약을 생성했습니다.`);
+ message = `${data.vendors.length}개 업체에 RFQ를 발송하고 ${totalContracts}개의 기본계약을 생성했습니다.`;
} else {
- toast.success(`${data.vendors.length}개 업체에 RFQ를 발송했습니다.`);
+ message = `${data.vendors.length}개 업체에 RFQ를 발송했습니다.`;
}
- // 페이지 새로고침
- router.refresh();
+ // 성공 결과를 반환
+ return {
+ success: true,
+ message: message,
+ totalSent: result.totalSent || data.vendors.length,
+ totalFailed: result.totalFailed || 0,
+ totalContracts: result.totalContracts || 0,
+ totalTbeSessions: result.totalTbeSessions || 0
+ };
+
} catch (error) {
console.error("RFQ 발송 실패:", error);
- toast.error("RFQ 발송에 실패했습니다.");
- throw error;
+
+ // 실패 결과를 반환
+ return {
+ success: false,
+ message: error instanceof Error ? error.message : "RFQ 발송에 실패했습니다.",
+ totalSent: 0,
+ totalFailed: data.vendors.length,
+ totalContracts: 0,
+ totalTbeSessions: 0
+ };
}
}, [rfqId, rfqCode, router]);
@@ -1513,6 +1540,7 @@ export function RfqVendorTable({
// 참여 의사가 있는 선택된 벤더 수 계산
const participatingCount = selectedRows.length;
const shortListCount = selectedRows.filter(v => v.shortList).length;
+ const vendorsWithResponseCount = selectedRows.filter(v => v.response && v.response.vendor && v.response.isDocumentConfirmed).length;
// 견적서가 있는 선택된 벤더 수 계산
const quotationCount = selectedRows.filter(row =>
@@ -1582,7 +1610,7 @@ export function RfqVendorTable({
variant="outline"
size="sm"
onClick={handleShortListConfirm}
- disabled={isUpdatingShortList}
+ disabled={isUpdatingShortList || vendorsWithResponseCount===0}
// className={ "border-green-500 text-green-600 hover:bg-green-50" }
>
{isUpdatingShortList ? (
@@ -1594,7 +1622,7 @@ export function RfqVendorTable({
<>
<CheckSquare className="h-4 w-4 mr-2" />
Short List 확정
- {participatingCount > 0 && ` (${participatingCount})`}
+ {vendorsWithResponseCount > 0 && ` (${vendorsWithResponseCount})`}
</>
)}
</Button>
diff --git a/lib/rfq-last/vendor/send-rfq-dialog.tsx b/lib/rfq-last/vendor/send-rfq-dialog.tsx
index e63086ad..42470ecc 100644
--- a/lib/rfq-last/vendor/send-rfq-dialog.tsx
+++ b/lib/rfq-last/vendor/send-rfq-dialog.tsx
@@ -812,8 +812,12 @@ export function SendRfqDialog({
hasToSendEmail: hasToSendEmail,
});
+ if (!sendResult) {
+ throw new Error("서버 응답이 없습니다.");
+ }
+
if (!sendResult.success) {
- throw new Error(sendResult.message);
+ throw new Error(sendResult.message || "RFQ 발송에 실패했습니다.");
}
toast.success(sendResult.message);
@@ -821,7 +825,7 @@ export function SendRfqDialog({
} catch (error) {
console.error("RFQ 발송 실패:", error);
- toast.error("RFQ 발송에 실패했습니다.");
+ toast.error(error instanceof Error ? error.message : "RFQ 발송에 실패했습니다.");
} finally {
setIsSending(false);
setIsGeneratingPdfs(false);