From 624cfcf4edb106e6cf0b041d9437ceaa94b6a46d Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Thu, 2 Oct 2025 18:02:11 +0900
Subject: (디버깅) 돌체 디버깅 - serialNo, 변경사항 카운트
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ship-vendor-document/edit-revision-dialog.tsx | 137 +++++++--------------
1 file changed, 43 insertions(+), 94 deletions(-)
(limited to 'components/ship-vendor-document/edit-revision-dialog.tsx')
diff --git a/components/ship-vendor-document/edit-revision-dialog.tsx b/components/ship-vendor-document/edit-revision-dialog.tsx
index 2b8735e7..9ca4c65d 100644
--- a/components/ship-vendor-document/edit-revision-dialog.tsx
+++ b/components/ship-vendor-document/edit-revision-dialog.tsx
@@ -31,17 +31,23 @@ import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Button } from "@/components/ui/button"
import { Badge } from "@/components/ui/badge"
-import {
- Edit,
- FileText,
- Loader2,
+import {
+ Edit,
+ FileText,
+ Loader2,
AlertTriangle,
Trash2,
- CheckCircle,
- Clock
+ CheckCircle
} from "lucide-react"
import { toast } from "sonner"
import { updateRevisionAction, deleteRevisionAction } from "@/lib/vendor-document-list/enhanced-document-service" // ✅ 서버 액션 import
+import {
+ createEditRevisionSchema,
+ getUsageOptions,
+ getUsageTypeOptions,
+ getRevisionGuide,
+ B3RevisionInput
+} from "./revision-validation"
/* -------------------------------------------------------------------------------------------------
* Schema & Types
@@ -84,88 +90,16 @@ interface AttachmentInfo {
updatedAt: Date
}
-// drawingKind에 따른 동적 스키마 생성 (수정용)
-const createEditRevisionSchema = (drawingKind: string) => {
- const baseSchema = {
- usage: z.string().min(1, "Please select a usage"),
- revision: z.string().min(1, "Please enter a revision").max(50, "Revision must be 50 characters or less"), // ✅ revision 필드 추가
- comment: z.string().optional(),
- }
- // B3인 경우에만 usageType 필드 추가
- if (drawingKind === 'B3') {
- return z.object({
- ...baseSchema,
- usageType: z.string().min(1, "Please select a usage type"),
- })
- } else {
- return z.object({
- ...baseSchema,
- usageType: z.string().optional(),
- })
- }
-}
-// drawingKind에 따른 용도 옵션
-const getUsageOptions = (drawingKind: string) => {
- switch (drawingKind) {
- case 'B3':
- return [
- { value: "Approval", label: "Approval" },
- { value: "Working", label: "Working" },
- { value: "Comments", label: "Comments" },
- ]
- case 'B4':
- return [
- { value: "Pre", label: "Pre" },
- { value: "Working", label: "Working" },
- ]
- case 'B5':
- return [
- { value: "Pre", label: "Pre" },
- { value: "Working", label: "Working" },
- ]
- default:
- return [
- { value: "Pre", label: "Pre" },
- { value: "Working", label: "Working" },
- ]
- }
-}
-// B3 전용 용도 타입 옵션
-const getUsageTypeOptions = (usage: string) => {
- switch (usage) {
- case 'Approval':
- return [
- { value: "Full", label: "Full" },
- { value: "Partial", label: "Partial" },
- ]
- case 'Working':
- return [
- { value: "Full", label: "Full" },
- { value: "Partial", label: "Partial" },
- ]
- case 'Comments':
- return [
- { value: "Comments", label: "Comments" },
- ]
- default:
- return []
- }
-}
-
-// ✅ 리비전 가이드 생성 (NewRevisionDialog와 동일)
-const getRevisionGuide = () => {
- return "Enter in R01, R02, R03... format"
-}
interface EditRevisionDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
revision: RevisionInfo | null
drawingKind?: string
- onSuccess: (action: 'update' | 'delete', result?: any) => void
+ onSuccess: (action: 'update' | 'delete', result?: unknown) => void
}
/* -------------------------------------------------------------------------------------------------
@@ -302,8 +236,8 @@ export function EditRevisionDialog({
// ✅ 리비전 가이드 텍스트
const revisionGuide = React.useMemo(() => {
- return getRevisionGuide()
- }, [])
+ return getRevisionGuide(drawingKind)
+ }, [drawingKind])
// revision이 변경될 때 폼 데이터 초기화
React.useEffect(() => {
@@ -324,7 +258,6 @@ export function EditRevisionDialog({
form.setValue("usageType", "Comments")
} else {
// Comments가 아닌 경우, 초기 로드가 아니라면 초기화
- const currentValue = form.getValues("usageType")
if (revision && watchedUsage !== revision.usage) {
form.setValue("usageType", "")
}
@@ -471,15 +404,31 @@ export function EditRevisionDialog({