From 1dc24d48e52f2e490f5603ceb02842586ecae533 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Thu, 24 Jul 2025 11:06:32 +0000
Subject: (대표님) 정기평가 피드백 반영, 설계 피드백 반영, (최겸) 기술영업
 피드백 반영
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/items-tech/table/add-items-dialog.tsx | 38 +++++++++++++++++++------------
 1 file changed, 24 insertions(+), 14 deletions(-)

(limited to 'lib/items-tech/table/add-items-dialog.tsx')

diff --git a/lib/items-tech/table/add-items-dialog.tsx b/lib/items-tech/table/add-items-dialog.tsx
index 1b0d00c7..01a072da 100644
--- a/lib/items-tech/table/add-items-dialog.tsx
+++ b/lib/items-tech/table/add-items-dialog.tsx
@@ -53,6 +53,7 @@ const offshoreTopWorkTypes = [
   { label: "TS", value: "TS" },
   { label: "TE", value: "TE" },
   { label: "TP", value: "TP" },
+  { label: "TA", value: "TA" },
 ] as const
 
 // 해양 HULL 공종 유형 정의
@@ -68,7 +69,7 @@ const offshoreHullWorkTypes = [
 
 // 기본 아이템 스키마
 const itemFormSchema = z.object({
-  itemCode: z.string().optional(),
+  itemCode: z.string(),
   workType: z.string().min(1, "공종은 필수입니다"),
   // 조선 및 해양 아이템 공통 필드
   itemList: z.string().optional(),
@@ -126,6 +127,8 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
   const onSubmit = async (data: ItemFormValues) => {
     startAddTransition(async () => {
       try {
+        let result;
+        
         switch (itemType) {
           case 'shipbuilding':
             if (!data.shipTypes) {
@@ -133,7 +136,7 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
               return
             }
             
-            await createShipbuildingItem({
+            result = await createShipbuildingItem({
               itemCode: data.itemCode || "",
               workType: data.workType as "기장" | "전장" | "선실" | "배관" | "철의" | "선체",
               shipTypes: data.shipTypes,
@@ -142,16 +145,16 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
             break;
           
           case 'offshoreTop':
-            await createOffshoreTopItem({
+            result = await createOffshoreTopItem({
               itemCode: data.itemCode || "",
-              workType: data.workType as "TM" | "TS" | "TE" | "TP",
+              workType: data.workType as "TM" | "TS" | "TE" | "TP" | "TA",
               itemList: data.itemList || null,
               subItemList: data.subItemList || null
             });
             break;
           
           case 'offshoreHull':
-            await createOffshoreHullItem({
+            result = await createOffshoreHullItem({
               itemCode: data.itemCode || "",
               workType: data.workType as "HA" | "HE" | "HH" | "HM" | "HO" | "HP" | "NC",
               itemList: data.itemList || null,
@@ -164,10 +167,15 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
             return;
         }
         
-        toast.success("아이템이 성공적으로 추가되었습니다")
-        setOpen(false)
-        form.reset(getDefaultValues())
-        router.refresh()
+        // 결과 확인하여 성공/실패에 따라 다른 메시지 표시
+        if (result?.success) {
+          toast.success("아이템이 성공적으로 추가되었습니다")
+          setOpen(false)
+          form.reset(getDefaultValues())
+          router.refresh()
+        } else {
+          toast.error(result?.message || "아이템 추가에 실패했습니다")
+        }
       } catch (error) {
         toast.error("아이템 추가 중 오류가 발생했습니다")
         console.error(error)
@@ -225,7 +233,9 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
               name="itemCode"
               render={({ field }) => (
                 <FormItem>
-                  <FormLabel>아이템 코드</FormLabel>
+                  <FormLabel>
+                    자재 그룹 <span style={{ color: 'red' }}>*</span>
+                  </FormLabel>
                   <FormControl>
                     <Input {...field} />
                   </FormControl>
@@ -238,7 +248,7 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
               name="workType"
               render={({ field }) => (
                 <FormItem>
-                  <FormLabel>공종</FormLabel>
+                  <FormLabel>공종 <span style={{ color: 'red' }}>*</span></FormLabel>
                   <Select onValueChange={field.onChange} defaultValue={field.value}>
                     <FormControl>
                       <SelectTrigger>
@@ -264,7 +274,7 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
                   name="shipTypes"
                   render={({ field }) => (
                     <FormItem>
-                      <FormLabel>선종</FormLabel>
+                      <FormLabel>선종 <span style={{ color: 'red' }}>*</span></FormLabel>
                       <FormControl>
                         <Input placeholder="선종을 입력하세요" {...field} />
                       </FormControl>
@@ -294,7 +304,7 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
                   name="itemList"
                   render={({ field }) => (
                     <FormItem>
-                      <FormLabel>아이템 리스트</FormLabel>
+                      <FormLabel>자재명</FormLabel>
                       <FormControl>
                         <Input {...field} />
                       </FormControl>
@@ -307,7 +317,7 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) {
                   name="subItemList"
                   render={({ field }) => (
                     <FormItem>
-                      <FormLabel>서브 아이템 리스트</FormLabel>
+                      <FormLabel>자재명(상세)</FormLabel>
                       <FormControl>
                         <Input {...field} />
                       </FormControl>
-- 
cgit v1.2.3

