summaryrefslogtreecommitdiff
path: root/lib/tbe-last/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tbe-last/service.ts')
-rw-r--r--lib/tbe-last/service.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/tbe-last/service.ts b/lib/tbe-last/service.ts
index da0a5a4c..346576e5 100644
--- a/lib/tbe-last/service.ts
+++ b/lib/tbe-last/service.ts
@@ -1,11 +1,11 @@
// lib/tbe-last/service.ts
'use server'
-import { revalidatePath, unstable_cache } from "next/cache";
+import { revalidatePath, revalidateTag, unstable_cache } from "next/cache";
import db from "@/db/db";
import { and, desc, asc, eq, sql, or, isNull, isNotNull, ne, inArray } from "drizzle-orm";
import { tbeLastView, tbeDocumentsView } from "@/db/schema";
-import { rfqPrItems } from "@/db/schema/rfqLast";
+import { rfqPrItems, rfqsLast } from "@/db/schema/rfqLast";
import {rfqLastDetails, rfqLastTbeDocumentReviews, rfqLastTbePdftronComments, rfqLastTbeVendorDocuments,rfqLastTbeSessions } from "@/db/schema";
import { filterColumns } from "@/lib/filter-columns";
import { GetTBELastSchema } from "./validations";
@@ -320,10 +320,22 @@ export async function updateTbeEvaluation(
// 상태 업데이트
if (data.status !== undefined) {
updateData.status = data.status
-
+
// 완료 상태로 변경 시 종료일 설정
if (data.status === "완료") {
updateData.actualEndDate = new Date()
+
+ // TBE 완료 시 연결된 RFQ 상태를 "TBE 완료"로 업데이트
+ if (currentTbeSession.rfqsLastId) {
+ await db
+ .update(rfqsLast)
+ .set({
+ status: "TBE 완료",
+ updatedBy: userId,
+ updatedAt: new Date()
+ })
+ .where(eq(rfqsLast.id, currentTbeSession.rfqsLastId))
+ }
}
}
@@ -337,10 +349,11 @@ export async function updateTbeEvaluation(
// 캐시 초기화
revalidateTag(`tbe-session-${tbeSessionId}`)
revalidateTag(`tbe-sessions`)
-
+
// RFQ 관련 캐시도 초기화
if (currentTbeSession.rfqsLastId) {
revalidateTag(`rfq-${currentTbeSession.rfqsLastId}`)
+ revalidateTag(`rfqs`)
}
return {