diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-23 09:02:07 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-23 09:02:07 +0000 |
| commit | 5c9b39eb011763a7491b3e8542de9f6d4976dd65 (patch) | |
| tree | ef18c420a72b0e4c8d5dfd03ae1e8648dda906f7 /lib/tech-vendors/table | |
| parent | a75541e1a1aea596bfca2a435f39133b9b72f193 (diff) | |
(최겸) 기술영업 벤더 개발
Diffstat (limited to 'lib/tech-vendors/table')
| -rw-r--r-- | lib/tech-vendors/table/add-vendor-dialog.tsx | 50 | ||||
| -rw-r--r-- | lib/tech-vendors/table/excel-template-download.tsx | 4 | ||||
| -rw-r--r-- | lib/tech-vendors/table/update-vendor-sheet.tsx | 58 | ||||
| -rw-r--r-- | lib/tech-vendors/table/vendor-all-export.ts | 1 |
4 files changed, 69 insertions, 44 deletions
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 }) => (
<FormItem>
<FormLabel>벤더 타입 *</FormLabel>
- <Select onValueChange={field.onChange} defaultValue={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder="벤더 타입을 선택하세요" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="조선">조선</SelectItem>
- <SelectItem value="해양TOP">해양TOP</SelectItem>
- <SelectItem value="해양HULL">해양HULL</SelectItem>
- </SelectContent>
- </Select>
+ <div className="space-y-2">
+ {["조선", "해양TOP", "해양HULL"].map((type) => (
+ <div key={type} className="flex items-center space-x-2">
+ <input
+ type="checkbox"
+ id={type}
+ checked={field.value?.includes(type as "조선" | "해양TOP" | "해양HULL")}
+ onChange={(e) => {
+ 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"
+ />
+ <label htmlFor={type} className="text-sm font-medium cursor-pointer">
+ {type}
+ </label>
+ </div>
+ ))}
+ </div>
<FormMessage />
</FormItem>
)}
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 */} + <FormField + control={form.control} + name="techVendorType" + render={({ field }) => ( + <FormItem className="md:col-span-2"> + <FormLabel>벤더 타입 *</FormLabel> + <div className="space-y-2"> + {["조선", "해양TOP", "해양HULL"].map((type) => ( + <div key={type} className="flex items-center space-x-2"> + <input + type="checkbox" + id={`update-${type}`} + checked={field.value?.includes(type as "조선" | "해양TOP" | "해양HULL")} + onChange={(e) => { + 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" + /> + <label htmlFor={`update-${type}`} className="text-sm font-medium cursor-pointer"> + {type} + </label> + </div> + ))} + </div> + <FormMessage /> + </FormItem> + )} + /> + {/* status with icons */} <FormField control={form.control} diff --git a/lib/tech-vendors/table/vendor-all-export.ts b/lib/tech-vendors/table/vendor-all-export.ts index a1ad4fd1..f2650102 100644 --- a/lib/tech-vendors/table/vendor-all-export.ts +++ b/lib/tech-vendors/table/vendor-all-export.ts @@ -108,6 +108,7 @@ function createBasicInfoSheet( address: vendor.address, representativeName: vendor.representativeName, createdAt: vendor.createdAt ? formatDate(vendor.createdAt) : "", + techVendorType: vendor.techVendorType?.split(',').join(', ') || vendor.techVendorType, }); }); } |
