diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/[lng]/evcp/(evcp)/(procurement)/basic-contract/vendor-gtc/[id]/page.tsx | 158 |
1 files changed, 78 insertions, 80 deletions
diff --git a/app/[lng]/evcp/(evcp)/(procurement)/basic-contract/vendor-gtc/[id]/page.tsx b/app/[lng]/evcp/(evcp)/(procurement)/basic-contract/vendor-gtc/[id]/page.tsx index a2746dfa..a2b3449c 100644 --- a/app/[lng]/evcp/(evcp)/(procurement)/basic-contract/vendor-gtc/[id]/page.tsx +++ b/app/[lng]/evcp/(evcp)/(procurement)/basic-contract/vendor-gtc/[id]/page.tsx @@ -2,9 +2,6 @@ import * as React from "react" import { notFound } from "next/navigation" import { type SearchParams } from "@/types/table" -import { getValidFilters } from "@/lib/data-table" -import { Skeleton } from "@/components/ui/skeleton" -import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton" import { Shell } from "@/components/shell" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" @@ -13,17 +10,10 @@ import { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbS import { formatDateTime } from "@/lib/utils" import { Button } from "@/components/ui/button" import Link from "next/link" - -import { - getGtcClauses, - getUsersForFilter, - getVendorClausesForDocument -} from "@/lib/gtc-contract/gtc-clauses/service" import { getGtcDocumentById } from "@/lib/gtc-contract/service" -import { searchParamsCache } from "@/lib/gtc-contract/gtc-clauses/validations" -import { GtcClausesVendorTable } from "@/lib/basic-contract/gtc-vendor/clause-table" import { UpdateVendorDocumentStatusButton } from "@/lib/basic-contract/vendor-table/update-vendor-document-status-button" import { getVendorById } from "@/lib/vendors/repository" +import { AgreementCommentList } from "@/lib/basic-contract/agreement-comments/agreement-comment-list" interface GtcClausesPageProps { params: Promise<{ id: string }> @@ -48,31 +38,44 @@ export default async function GtcClausesPage(props: GtcClausesPageProps) { const contractId = searchParams.contractId ? parseInt(searchParams.contractId as string) : undefined const templateId = searchParams.templateId ? parseInt(searchParams.templateId as string) : undefined - // 문서 정보 조회 - const document = await getGtcDocumentById(documentId) - if (!document) { - notFound() + // 🔥 새로운 코멘트 시스템: gtc_documents 불필요, basic_contract_templates만 사용 + // templateId는 basic_contract_templates.id를 의미 + + console.log(`📋 계약서 템플릿 조회: templateId=${templateId}, documentId=${documentId}`); + + // templateId로 basic_contract_template 조회 + const { getBasicContractTemplateByIdService } = await import("@/lib/basic-contract/service"); + const template = templateId + ? await getBasicContractTemplateByIdService(templateId.toString()) + : null; + + if (!template) { + console.error(`❌ 기본계약서 템플릿을 찾을 수 없음. templateId: ${templateId}`); + notFound(); } + + console.log(`✅ 템플릿 찾음: ${template.templateName} (ID: ${template.id})`); + + // document 객체 생성 (페이지에서 필요한 최소한의 정보) + const document = { + id: template.id, + title: template.templateName, + type: 'standard' as const, + revision: template.revision || 1, + projectId: null, + projectCode: null, + projectName: null, + fileName: template.fileName, + filePath: template.filePath, + isActive: template.status === 'ACTIVE', + createdAt: template.createdAt, + updatedAt: template.updatedAt, + }; console.log(document, "document") - const search = searchParamsCache.parse(searchParams) - const validFilters = getValidFilters(search.filters) - - // 병렬로 데이터 조회 - const promises = Promise.all([ - getGtcClauses({ - ...search, - filters: validFilters, - documentId, - }), - getUsersForFilter(), - getVendorClausesForDocument({ documentId, vendorId }), // vendorId 전달 - vendorId ? getVendorById(vendorId) : Promise.resolve(null), // vendor 데이터 추가 - - ]) - - const [_, __, vendorData] = await promises.then(values => values) + // 벤더 정보 조회 (vendorId가 있을 때만) + const vendorData = vendorId ? await getVendorById(vendorId) : null const vendorDocument = vendorData?.vendorDocument || null return ( @@ -90,7 +93,7 @@ export default async function GtcClausesPage(props: GtcClausesPageProps) { <BreadcrumbSeparator /> <BreadcrumbItem> <BreadcrumbPage> - {vendorName ? `${vendorName} GTC 협의` : 'GTC 조항 관리'} + {vendorName ? `${vendorName} GTC 협의` : 'GTC 협의 관리'} </BreadcrumbPage> </BreadcrumbItem> </BreadcrumbList> @@ -116,7 +119,7 @@ export default async function GtcClausesPage(props: GtcClausesPageProps) { <div> <CardTitle className="text-base">벤더 협의 정보</CardTitle> <CardDescription className="text-sm mt-1"> - {vendorName}과(와)의 GTC 조항 협의를 진행합니다 + {vendorName}과(와)의 GTC 협의를 진행합니다 </CardDescription> </div> </div> @@ -141,55 +144,50 @@ export default async function GtcClausesPage(props: GtcClausesPageProps) { </div> </CardHeader> - {vendorData && contractId && ( + {vendorDocument && contractId && ( <CardContent className="py-2"> - <div className="flex justify-between items-center"> - <div className="text-sm text-muted-foreground"> - 총 {vendorData.totalModified || 0}개 조항 협의됨, {vendorData.totalExcluded || 0}개 조항 제외됨 - </div> - + <div className="flex justify-end items-center"> {/* 협의 완료 업데이트 버튼 */} - {vendorDocument && ( - <UpdateVendorDocumentStatusButton - vendorDocumentId={vendorDocument.id} - documentId={documentId} - vendorId={vendorId} - currentStatus={vendorDocument.reviewStatus as "draft" | "complete" | "reviewing"} - /> - )} + <UpdateVendorDocumentStatusButton + vendorDocumentId={vendorDocument.id} + documentId={documentId} + vendorId={vendorId} + currentStatus={vendorDocument.reviewStatus as "draft" | "complete" | "reviewing"} + /> </div> </CardContent> )} </Card> )} - {/* 템플릿 정보 섹션 */} - <React.Suspense fallback={<TemplateInfoSkeleton />}> - <DocumentInfo document={document} /> - </React.Suspense> + {/* 템플릿 정보 섹션 */} + <React.Suspense fallback={<TemplateInfoSkeleton />}> + <DocumentInfo document={document} /> + </React.Suspense> </div> - {/* 조항 테이블 */} - <React.Suspense - fallback={ - <DataTableSkeleton - columnCount={vendorId ? 10 : 8} - searchableColumnCount={2} - filterableColumnCount={vendorId ? 5 : 3} - cellWidths={["10rem", "15rem", "20rem", "30rem", "12rem", "12rem", "12rem", "8rem"]} - shrinkZero - /> - } - > - <GtcClausesVendorTable - promises={promises} - documentId={documentId} - document={document} - vendorId={vendorId} - vendorName={vendorName} - contractId={contractId} - /> - </React.Suspense> + {/* 기본계약서 협의 코멘트 섹션 - contractId가 있을 때만 표시 */} + {contractId ? ( + <Card> + <CardHeader className="pb-3"> + <div className="flex items-center justify-between"> + <div> + <CardTitle className="text-lg">협의 코멘트</CardTitle> + <CardDescription> + {vendorName ? `${vendorName}과(와)의 ` : ''}계약서 협의 내용을 작성하고 공유합니다 + </CardDescription> + </div> + </div> + </CardHeader> + <CardContent className="h-[600px] pt-0"> + <AgreementCommentList + basicContractId={contractId} + currentUserType="SHI" + readOnly={false} + /> + </CardContent> + </Card> + ) : null} </Shell> ) } @@ -203,7 +201,7 @@ export async function generateMetadata(props: GtcClausesPageProps) { if (isNaN(documentId)) { return { - title: "GTC 조항 관리", + title: "GTC 협의 관리", } } @@ -212,18 +210,18 @@ export async function generateMetadata(props: GtcClausesPageProps) { if (!document) { return { - title: "GTC 조항 관리", + title: "GTC 협의 관리", } } - const baseTitle = `GTC 조항 관리 - ${document.type === "standard" ? "표준" : "프로젝트"} v${document.revision}` + const baseTitle = `GTC 협의 관리 - ${document.type === "standard" ? "표준" : "프로젝트"} v${document.revision}` const title = vendorName ? `${vendorName} ${baseTitle}` : baseTitle const description = vendorName - ? `${vendorName}과(와)의 GTC 조항 협의를 관리합니다.` + ? `${vendorName}과(와)의 GTC 협의를 관리합니다.` : document.project - ? `${document.project.name} (${document.project.code}) 프로젝트의 GTC 조항을 관리합니다.` - : "표준 GTC 조항을 관리합니다." + ? `${document.project.name} (${document.project.code}) 프로젝트의 GTC 협의를 관리합니다.` + : "표준 GTC 협의를 관리합니다." return { title, @@ -231,7 +229,7 @@ export async function generateMetadata(props: GtcClausesPageProps) { } } catch (error) { return { - title: "GTC 조항 관리", + title: "GTC 협의 관리", } } } |
