summaryrefslogtreecommitdiff
path: root/lib/items-tech/table/update-items-sheet.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-05-20 09:01:22 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-05-20 09:01:22 +0000
commit45f4c426c98d86a251644a4858740bec989edf83 (patch)
treeb0a3f1ce6ac3e4493ee53c93ef33841c8eb34cfb /lib/items-tech/table/update-items-sheet.tsx
parent11f13979825d28180956fc27600176bfc47457e1 (diff)
(최겸) 기술영업 아이템리스트 수정 및 개발 0520
Diffstat (limited to 'lib/items-tech/table/update-items-sheet.tsx')
-rw-r--r--lib/items-tech/table/update-items-sheet.tsx140
1 files changed, 46 insertions, 94 deletions
diff --git a/lib/items-tech/table/update-items-sheet.tsx b/lib/items-tech/table/update-items-sheet.tsx
index 2db3b193..efab4b1a 100644
--- a/lib/items-tech/table/update-items-sheet.tsx
+++ b/lib/items-tech/table/update-items-sheet.tsx
@@ -29,7 +29,6 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
-import { Textarea } from "@/components/ui/textarea"
import { toast } from "sonner"
import {
@@ -75,22 +74,19 @@ interface CommonItemFields {
type ShipbuildingItem = CommonItemFields & {
workType: "기장" | "전장" | "선실" | "배관" | "철의"
shipTypes: string
+ itemList: string | null
}
type OffshoreTopItem = CommonItemFields & {
workType: "TM" | "TS" | "TE" | "TP"
- itemList1: string | null
- itemList2: string | null
- itemList3: string | null
- itemList4: string | null
+ itemList: string | null
+ subItemList: string | null
}
type OffshoreHullItem = CommonItemFields & {
workType: "HA" | "HE" | "HH" | "HM" | "NC"
- itemList1: string | null
- itemList2: string | null
- itemList3: string | null
- itemList4: string | null
+ itemList: string | null
+ subItemList: string | null
}
type UpdateItemSchema = {
@@ -99,10 +95,8 @@ type UpdateItemSchema = {
description?: string
workType?: string
shipTypes?: string
- itemList1?: string
- itemList2?: string
- itemList3?: string
- itemList4?: string
+ itemList?: string
+ subItemList?: string
}
interface UpdateItemSheetProps {
@@ -118,7 +112,6 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
// 초기값 설정
const form = useForm<UpdateItemSchema>({
defaultValues: {
- itemCode: item.itemCode,
itemName: item.itemName,
description: item.description || "",
workType: item.workType,
@@ -133,16 +126,15 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
switch (itemType) {
case 'shipbuilding':
return {
- shipTypes: (item as ShipbuildingItem).shipTypes
+ shipTypes: (item as ShipbuildingItem).shipTypes,
+ itemList: (item as ShipbuildingItem).itemList || ""
};
case 'offshoreTop':
case 'offshoreHull':
const offshoreItem = item as OffshoreTopItem | OffshoreHullItem;
return {
- itemList1: offshoreItem.itemList1 || "",
- itemList2: offshoreItem.itemList2 || "",
- itemList3: offshoreItem.itemList3 || "",
- itemList4: offshoreItem.itemList4 || "",
+ itemList: offshoreItem.itemList || "",
+ subItemList: offshoreItem.subItemList || ""
};
default:
return {};
@@ -158,19 +150,22 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
case 'shipbuilding':
result = await modifyShipbuildingItem({
...data,
- id: item.id
+ id: item.id,
+ itemCode: item.itemCode // itemCode는 변경 불가, 원래 값 사용
});
break;
case 'offshoreTop':
result = await modifyOffshoreTopItem({
...data,
- id: item.id
+ id: item.id,
+ itemCode: item.itemCode // itemCode는 변경 불가, 원래 값 사용
});
break;
case 'offshoreHull':
result = await modifyOffshoreHullItem({
...data,
- id: item.id
+ id: item.id,
+ itemCode: item.itemCode // itemCode는 변경 불가, 원래 값 사용
});
break;
default:
@@ -227,34 +222,19 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
{getItemTypeLabel()} 정보를 수정합니다. 수정할 필드를 입력해주세요.
</SheetDescription>
</SheetHeader>
+
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
- <FormField
- control={form.control}
- name="itemCode"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Material Group</FormLabel>
- <FormControl>
- <Input placeholder="Material Group을 입력하세요" {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="itemName"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Description</FormLabel>
- <FormControl>
- <Input placeholder="Description을 입력하세요" {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
+ {/* Material Group을 Form 안으로 이동 */}
+ <div className="mt-4">
+ <div className="grid gap-2">
+ <label className="text-sm font-medium leading-none">
+ Material Group (수정 불가)
+ </label>
+ <Input value={item.itemCode} disabled readOnly />
+ </div>
+ </div>
+
<FormField
control={form.control}
name="workType"
@@ -285,32 +265,15 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
{/* 조선 아이템 전용 필드 */}
{itemType === 'shipbuilding' && (
- <FormField
- control={form.control}
- name="shipTypes"
- render={({ field }) => (
- <FormItem>
- <FormLabel>선종</FormLabel>
- <FormControl>
- <Input placeholder="선종을 입력하세요" {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- )}
-
- {/* 해양 TOP 또는 HULL 아이템 전용 필드 */}
- {(itemType === 'offshoreTop' || itemType === 'offshoreHull') && (
<>
<FormField
control={form.control}
- name="itemList1"
+ name="shipTypes"
render={({ field }) => (
<FormItem>
- <FormLabel>Item List 1</FormLabel>
+ <FormLabel>선종</FormLabel>
<FormControl>
- <Input placeholder="Item List 1을 입력하세요" {...field} />
+ <Input placeholder="선종을 입력하세요" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -318,25 +281,31 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
/>
<FormField
control={form.control}
- name="itemList2"
+ name="itemList"
render={({ field }) => (
<FormItem>
- <FormLabel>Item List 2</FormLabel>
+ <FormLabel>아이템 리스트</FormLabel>
<FormControl>
- <Input placeholder="Item List 2를 입력하세요" {...field} />
+ <Input placeholder="아이템 리스트를 입력하세요" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
+ </>
+ )}
+
+ {/* 해양 TOP 또는 HULL 아이템 전용 필드 */}
+ {(itemType === 'offshoreTop' || itemType === 'offshoreHull') && (
+ <>
<FormField
control={form.control}
- name="itemList3"
+ name="itemList"
render={({ field }) => (
<FormItem>
- <FormLabel>Item List 3</FormLabel>
+ <FormLabel>아이템 리스트</FormLabel>
<FormControl>
- <Input placeholder="Item List 3을 입력하세요" {...field} />
+ <Input placeholder="아이템 리스트를 입력하세요" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -344,12 +313,12 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
/>
<FormField
control={form.control}
- name="itemList4"
+ name="subItemList"
render={({ field }) => (
<FormItem>
- <FormLabel>Item List 4</FormLabel>
+ <FormLabel>서브 아이템 리스트</FormLabel>
<FormControl>
- <Input placeholder="Item List 4를 입력하세요" {...field} />
+ <Input placeholder="서브 아이템 리스트를 입력하세요" {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -357,23 +326,6 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt
/>
</>
)}
-
- <FormField
- control={form.control}
- name="description"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Size/Dimension</FormLabel>
- <FormControl>
- <Textarea
- placeholder="Size/Dimension을 입력하세요"
- {...field}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
<SheetFooter>
<SheetClose asChild>
<Button variant="outline">취소</Button>