diff options
Diffstat (limited to 'lib/items-tech/table/add-items-dialog.tsx')
| -rw-r--r-- | lib/items-tech/table/add-items-dialog.tsx | 125 |
1 files changed, 36 insertions, 89 deletions
diff --git a/lib/items-tech/table/add-items-dialog.tsx b/lib/items-tech/table/add-items-dialog.tsx index 86333189..a3af0a8c 100644 --- a/lib/items-tech/table/add-items-dialog.tsx +++ b/lib/items-tech/table/add-items-dialog.tsx @@ -32,7 +32,6 @@ import { SelectTrigger,
SelectValue,
} from "@/components/ui/select"
-import { Textarea } from "@/components/ui/textarea"
import { toast } from "sonner"
import { createShipbuildingItem, createOffshoreTopItem, createOffshoreHullItem } from "../service"
@@ -47,14 +46,15 @@ const shipbuildingWorkTypes = [ { label: "철의", value: "철의" },
] as const
-// 선종 유형 정의
-const shipTypes = [
- { label: "A-MAX", value: "A-MAX" },
- { label: "S-MAX", value: "S-MAX" },
- { label: "LNGC", value: "LNGC" },
- { label: "VLCC", value: "VLCC" },
- { label: "CONT", value: "CONT" },
-] as const
+// // 선종 유형 정의
+// const shipTypes = [
+// { label: "A-MAX", value: "A-MAX" },
+// { label: "S-MAX", value: "S-MAX" },
+// { label: "LNGC", value: "LNGC" },
+// { label: "VLCC", value: "VLCC" },
+// { label: "CONT", value: "CONT" },
+// { label: "OPTION", value: "OPTION" },
+// ] as const
// 해양 TOP 공종 유형 정의
const offshoreTopWorkTypes = [
@@ -79,13 +79,12 @@ const itemFormSchema = z.object({ itemName: z.string().min(1, "아이템 명은 필수입니다"),
description: z.string().optional(),
workType: z.string().min(1, "공종은 필수입니다"),
+ // 조선 및 해양 아이템 공통 필드
+ itemList: z.string().optional(),
// 조선 아이템 전용 필드
shipTypes: z.string().optional(),
// 해양 아이템 전용 필드
- itemList1: z.string().optional(),
- itemList2: z.string().optional(),
- itemList3: z.string().optional(),
- itemList4: z.string().optional(),
+ subItemList: z.string().optional(),
})
type ItemFormValues = z.infer<typeof itemFormSchema>
@@ -102,18 +101,17 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { const getDefaultValues = () => {
const defaults: ItemFormValues = {
itemCode: "",
- itemName: "",
+ itemName: "기술영업",
description: "",
workType: getDefaultWorkType(),
}
if (itemType === 'shipbuilding') {
- defaults.shipTypes = "A-MAX"
+ defaults.shipTypes = "OPTION"
+ defaults.itemList = ""
} else {
- defaults.itemList1 = ""
- defaults.itemList2 = ""
- defaults.itemList3 = ""
- defaults.itemList4 = ""
+ defaults.itemList = ""
+ defaults.subItemList = ""
}
return defaults
@@ -151,7 +149,8 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { itemName: data.itemName,
workType: data.workType,
shipTypes: data.shipTypes,
- description: data.description || null
+ description: data.description || null,
+ itemList: data.itemList || null
});
break;
@@ -161,10 +160,8 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { itemName: data.itemName,
workType: data.workType as "TM" | "TS" | "TE" | "TP",
description: data.description || null,
- itemList1: data.itemList1 || null,
- itemList2: data.itemList2 || null,
- itemList3: data.itemList3 || null,
- itemList4: data.itemList4 || null
+ itemList: data.itemList || null,
+ subItemList: data.subItemList || null
});
break;
@@ -174,10 +171,8 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { itemName: data.itemName,
workType: data.workType as "HA" | "HE" | "HH" | "HM" | "NC",
description: data.description || null,
- itemList1: data.itemList1 || null,
- itemList2: data.itemList2 || null,
- itemList3: data.itemList3 || null,
- itemList4: data.itemList4 || null
+ itemList: data.itemList || null,
+ subItemList: data.subItemList || null
});
break;
@@ -256,19 +251,6 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { />
<FormField
control={form.control}
- name="itemName"
- render={({ field }) => (
- <FormItem>
- <FormLabel>아이템 명</FormLabel>
- <FormControl>
- <Input {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
name="workType"
render={({ field }) => (
<FormItem>
@@ -292,41 +274,15 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { )}
/>
{itemType === 'shipbuilding' && (
- <FormField
- control={form.control}
- name="shipTypes"
- render={({ field }) => (
- <FormItem>
- <FormLabel>선종</FormLabel>
- <Select onValueChange={field.onChange} defaultValue={field.value}>
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder="선종을 선택하세요" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- {shipTypes.map((type) => (
- <SelectItem key={type.value} value={type.value}>
- {type.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
- {(itemType === 'offshoreTop' || itemType === 'offshoreHull') && (
<>
<FormField
control={form.control}
- name="itemList1"
+ name="shipTypes"
render={({ field }) => (
<FormItem>
- <FormLabel>아이템 리스트 1</FormLabel>
+ <FormLabel>선종</FormLabel>
<FormControl>
- <Input {...field} />
+ <Input placeholder="선종을 입력하세요" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -334,10 +290,10 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { />
<FormField
control={form.control}
- name="itemList2"
+ name="itemList"
render={({ field }) => (
<FormItem>
- <FormLabel>아이템 리스트 2</FormLabel>
+ <FormLabel>아이템 리스트</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
@@ -345,12 +301,16 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { </FormItem>
)}
/>
+ </>
+ )}
+ {(itemType === 'offshoreTop' || itemType === 'offshoreHull') && (
+ <>
<FormField
control={form.control}
- name="itemList3"
+ name="itemList"
render={({ field }) => (
<FormItem>
- <FormLabel>아이템 리스트 3</FormLabel>
+ <FormLabel>아이템 리스트</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
@@ -360,10 +320,10 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { />
<FormField
control={form.control}
- name="itemList4"
+ name="subItemList"
render={({ field }) => (
<FormItem>
- <FormLabel>아이템 리스트 4</FormLabel>
+ <FormLabel>서브 아이템 리스트</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
@@ -373,19 +333,6 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { />
</>
)}
- <FormField
- control={form.control}
- name="description"
- render={({ field }) => (
- <FormItem>
- <FormLabel>설명</FormLabel>
- <FormControl>
- <Textarea {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
<div className="flex justify-end space-x-2">
<Button type="button" variant="outline" onClick={() => setOpen(false)}>
취소
|
