From 5c9b39eb011763a7491b3e8542de9f6d4976dd65 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 23 Jun 2025 09:02:07 +0000 Subject: (최겸) 기술영업 벤더 개발 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tech-vendors/table/add-vendor-dialog.tsx | 50 ++++++++++--------- lib/tech-vendors/table/excel-template-download.tsx | 4 +- lib/tech-vendors/table/update-vendor-sheet.tsx | 58 +++++++++++++++------- lib/tech-vendors/table/vendor-all-export.ts | 1 + 4 files changed, 69 insertions(+), 44 deletions(-) (limited to 'lib/tech-vendors/table') diff --git a/lib/tech-vendors/table/add-vendor-dialog.tsx b/lib/tech-vendors/table/add-vendor-dialog.tsx index bc260d51..da9880d4 100644 --- a/lib/tech-vendors/table/add-vendor-dialog.tsx +++ b/lib/tech-vendors/table/add-vendor-dialog.tsx @@ -25,13 +25,7 @@ import { FormMessage, } from "@/components/ui/form" import { Input } from "@/components/ui/input" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select" + import { Textarea } from "@/components/ui/textarea" import { Plus, Loader2 } from "lucide-react" @@ -52,9 +46,7 @@ const addVendorSchema = z.object({ address: z.string().optional(), phone: z.string().optional(), website: z.string().optional(), - techVendorType: z.enum(["조선", "해양TOP", "해양HULL"], { - required_error: "벤더 타입을 선택해주세요", - }), + techVendorType: z.array(z.enum(["조선", "해양TOP", "해양HULL"])).min(1, "최소 하나의 벤더 타입을 선택해주세요"), representativeName: z.string().optional(), representativeEmail: z.string().email("올바른 이메일 주소를 입력해주세요").optional().or(z.literal("")), representativePhone: z.string().optional(), @@ -87,7 +79,7 @@ export function AddVendorDialog({ onSuccess }: AddVendorDialogProps) { address: "", phone: "", website: "", - techVendorType: undefined, + techVendorType: [], representativeName: "", representativeEmail: "", representativePhone: "", @@ -110,6 +102,7 @@ export function AddVendorDialog({ onSuccess }: AddVendorDialogProps) { address: data.address || null, phone: data.phone || null, website: data.website || null, + techVendorType: data.techVendorType.join(','), representativeName: data.representativeName || null, representativeEmail: data.representativeEmail || null, representativePhone: data.representativePhone || null, @@ -218,18 +211,29 @@ export function AddVendorDialog({ onSuccess }: AddVendorDialogProps) { render={({ field }) => ( 벤더 타입 * - +
+ {["조선", "해양TOP", "해양HULL"].map((type) => ( +
+ { + const currentValue = field.value || []; + if (e.target.checked) { + field.onChange([...currentValue, type]); + } else { + field.onChange(currentValue.filter((v) => v !== type)); + } + }} + className="w-4 h-4" + /> + +
+ ))} +
)} diff --git a/lib/tech-vendors/table/excel-template-download.tsx b/lib/tech-vendors/table/excel-template-download.tsx index db2c5fb5..b6011e2c 100644 --- a/lib/tech-vendors/table/excel-template-download.tsx +++ b/lib/tech-vendors/table/excel-template-download.tsx @@ -72,7 +72,7 @@ export async function exportTechVendorTemplate() { phone: '02-1234-5678', email: 'sample1@example.com', website: 'https://example1.com', - techVendorType: '조선', + techVendorType: '조선,해양TOP', representativeName: '홍길동', representativeEmail: 'ceo1@example.com', representativePhone: '010-1234-5678', @@ -93,7 +93,7 @@ export async function exportTechVendorTemplate() { phone: '051-234-5678', email: 'sample2@example.com', website: 'https://example2.com', - techVendorType: '해양TOP', + techVendorType: '해양HULL', representativeName: '김철수', representativeEmail: 'ceo2@example.com', representativePhone: '010-2345-6789', diff --git a/lib/tech-vendors/table/update-vendor-sheet.tsx b/lib/tech-vendors/table/update-vendor-sheet.tsx index cc6b4003..774299f1 100644 --- a/lib/tech-vendors/table/update-vendor-sheet.tsx +++ b/lib/tech-vendors/table/update-vendor-sheet.tsx @@ -65,24 +65,6 @@ type StatusConfig = { // 상태 표시 유틸리티 함수 const getStatusConfig = (status: StatusType): StatusConfig => { switch(status) { - case "PENDING_REVIEW": - return { - Icon: ClipboardList, - className: "text-yellow-600", - label: "가입 신청 중" - }; - case "IN_REVIEW": - return { - Icon: FilePenLine, - className: "text-blue-600", - label: "심사 중" - }; - case "REJECTED": - return { - Icon: XCircle, - className: "text-red-600", - label: "심사 거부됨" - }; case "ACTIVE": return { Icon: Activity, @@ -127,6 +109,7 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps) phone: vendor?.phone ?? "", email: vendor?.email ?? "", website: vendor?.website ?? "", + techVendorType: vendor?.techVendorType ? vendor.techVendorType.split(',').filter(Boolean) : [], status: vendor?.status ?? "ACTIVE", }, }) @@ -141,6 +124,7 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps) phone: vendor?.phone ?? "", email: vendor?.email ?? "", website: vendor?.website ?? "", + techVendorType: vendor?.techVendorType ? vendor.techVendorType.split(',').filter(Boolean) : [], status: vendor?.status ?? "ACTIVE", }); @@ -172,7 +156,8 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps) id: String(vendor.id), userId: Number(session.user.id), // Add user ID from session comment: statusComment, // Add comment for status changes - ...data // 모든 데이터 전달 - 서비스 함수에서 필요한 필드만 처리 + ...data, // 모든 데이터 전달 - 서비스 함수에서 필요한 필드만 처리 + techVendorType: data.techVendorType ? data.techVendorType.join(',') : undefined, }) if (error) throw new Error(error) @@ -312,6 +297,41 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps) )} /> + {/* techVendorType */} + ( + + 벤더 타입 * +
+ {["조선", "해양TOP", "해양HULL"].map((type) => ( +
+ { + const currentValue = field.value || []; + if (e.target.checked) { + field.onChange([...currentValue, type]); + } else { + field.onChange(currentValue.filter((v) => v !== type)); + } + }} + className="w-4 h-4" + /> + +
+ ))} +
+ +
+ )} + /> + {/* status with icons */}