// types/enhanced-documents.ts import { type InferSelectModel } from "drizzle-orm" import { documents, issueStages, revisions, documentAttachments, enhancedDocumentsView } from "@/db/schema/vendorDocu" // DB 스키마에서 추출한 기본 타입들 export type Document = InferSelectModel export type IssueStage = InferSelectModel export type Revision = InferSelectModel export type DocumentAttachment = InferSelectModel export type EnhancedDocument = InferSelectModel // 확장된 스테이지 타입 (리비전과 첨부파일 포함) export type StageWithRevisions = IssueStage & { revisions: Array } // 완전한 문서 타입 (모든 관련 데이터 포함) export type FullDocument = Document & { stages: StageWithRevisions[] currentStage?: IssueStage latestRevision?: Revision } // 컴포넌트에서 사용할 확장된 문서 타입 (EnhancedDocument와 호환) export type EnhancedDocumentWithStages = EnhancedDocument & { // EnhancedDocument가 이미 documentId를 가지고 있는지 확인 documentId: number allStages?: Array<{ id: number stageName: string stageStatus: string stageOrder: number planDate: string | null actualDate: string | null assigneeName: string | null priority: string }> } // 서버 액션용 입력 타입들 export type CreateDocumentInput = { contractId: number docNumber: string title: string pic?: string issuedDate?: string } export type UpdateDocumentInput = Partial & { id: number } export type CreateStageInput = { documentId: number stageName: string planDate?: string stageOrder?: number priority?: 'HIGH' | 'MEDIUM' | 'LOW' assigneeId?: number assigneeName?: string description?: string reminderDays?: number } export type UpdateStageInput = Partial & { id: number } export type CreateRevisionInput = { issueStageId: number revision: string uploaderType: 'vendor' | 'client' | 'contractor' uploaderId?: number uploaderName: string comment?: string attachments?: Array<{ fileName: string filePath: string fileType?: string fileSize: number }> } export type UpdateRevisionStatusInput = { id: number revisionStatus: 'SUBMITTED' | 'UNDER_REVIEW' | 'APPROVED' | 'REJECTED' | 'SUPERSEDED' reviewerId?: number reviewerName?: string reviewComments?: string } // API 응답 타입들 export type ApiResponse = { success: boolean data?: T error?: string message?: string } export type PaginatedResponse = { data: T[] total: number pageCount: number currentPage: number }