diff options
| -rw-r--r-- | lib/items-ship/table/Items-ship-table.tsx | 3 | ||||
| -rw-r--r-- | lib/items-ship/table/add-items-dialog.tsx | 22 | ||||
| -rw-r--r-- | lib/items-ship/table/delete-items-dialog.tsx | 19 | ||||
| -rw-r--r-- | lib/items-ship/table/items-ship-table-columns.tsx | 2 | ||||
| -rw-r--r-- | lib/items-ship/table/items-table-toolbar-actions.tsx | 2 | ||||
| -rw-r--r-- | lib/items-ship/table/update-items-sheet.tsx | 6 | ||||
| -rw-r--r-- | lib/items-ship/validations.ts | 4 |
7 files changed, 18 insertions, 40 deletions
diff --git a/lib/items-ship/table/Items-ship-table.tsx b/lib/items-ship/table/Items-ship-table.tsx index 486c1481..6fec9ac0 100644 --- a/lib/items-ship/table/Items-ship-table.tsx +++ b/lib/items-ship/table/Items-ship-table.tsx @@ -14,6 +14,7 @@ import { getShipbuildingItems } from "../service" import { getShipbuildingColumns } from "./items-ship-table-columns"
import { ItemsTableToolbarActions } from "./items-table-toolbar-actions"
import { DeleteItemsDialog } from "./delete-items-dialog"
+import { UpdateItemSheet } from "./update-items-sheet"
// 서비스에서 반환하는 데이터 타입 정의
type ShipbuildingItem = {
@@ -21,7 +22,7 @@ type ShipbuildingItem = { itemId: number;
workType: "기장" | "전장" | "선실" | "배관" | "철의";
shipTypes: string;
- itemCode: string | null;
+ itemCode: string;
itemName: string;
description: string | null;
createdAt: Date;
diff --git a/lib/items-ship/table/add-items-dialog.tsx b/lib/items-ship/table/add-items-dialog.tsx index 4abf5f8a..fdfe54cc 100644 --- a/lib/items-ship/table/add-items-dialog.tsx +++ b/lib/items-ship/table/add-items-dialog.tsx @@ -24,7 +24,6 @@ import { } from "../validations"
import { createShipbuildingItem } from "../service"
-import { ItemType } from "./excel/item-excel-template"
import { Plus } from "lucide-react"
import { toast } from "sonner"
import {
@@ -35,11 +34,6 @@ import { SelectValue,
} from "@/components/ui/select"
-
-interface AddItemDialogProps {
- itemType?: ItemType
-}
-
const workTypes = [
{ value: "기장", label: "기장" },
{ value: "전장", label: "전장" },
@@ -48,7 +42,7 @@ const workTypes = [ { value: "철의", label: "철의" },
] as const
-export function AddItemDialog({ itemType = 'shipbuilding' }: AddItemDialogProps) {
+export function AddItemDialog() {
const [open, setOpen] = React.useState(false)
const [isSubmitting, setIsSubmitting] = React.useState(false)
@@ -127,7 +121,7 @@ export function AddItemDialog({ itemType = 'shipbuilding' }: AddItemDialogProps) <FormItem>
<FormLabel>아이템 코드</FormLabel>
<FormControl>
- <Input placeholder={`예: ${itemType === 'shipbuilding' ? 'SB001' : itemType === 'offshoreTop' ? 'OT001' : 'OH001'}`} {...field} />
+ <Input placeholder={'예: SB001'} {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -172,7 +166,7 @@ export function AddItemDialog({ itemType = 'shipbuilding' }: AddItemDialogProps) >
<FormControl>
<SelectTrigger>
- <SelectValue placeholder={`${itemType === 'shipbuilding' ? '기능(공종)' : itemType === 'offshoreTop' ? '예: TM, TS' : '예: HA, HE'}을 선택하세요`} />
+ <SelectValue placeholder={'기능(공종)을 선택하세요'} />
</SelectTrigger>
</FormControl>
<SelectContent>
@@ -190,10 +184,9 @@ export function AddItemDialog({ itemType = 'shipbuilding' }: AddItemDialogProps) />
{/* 조선 아이템인 경우 선종 필드 표시 */}
- {itemType === 'shipbuilding' && (
- <FormField
- control={form.control}
- name="shipTypes"
+ <FormField
+ control={form.control}
+ name="shipTypes"
render={({ field }) => (
<FormItem>
<FormLabel>선종</FormLabel>
@@ -203,8 +196,7 @@ export function AddItemDialog({ itemType = 'shipbuilding' }: AddItemDialogProps) <FormMessage />
</FormItem>
)}
- />
- )}
+ />
<DialogFooter className="mt-4">
<Button type="submit" disabled={isSubmitting}>
{isSubmitting ? "추가 중..." : "추가"}
diff --git a/lib/items-ship/table/delete-items-dialog.tsx b/lib/items-ship/table/delete-items-dialog.tsx index 1b847550..53e047fb 100644 --- a/lib/items-ship/table/delete-items-dialog.tsx +++ b/lib/items-ship/table/delete-items-dialog.tsx @@ -30,37 +30,22 @@ import { import { Item } from "@/db/schema/items" import { removeShipbuildingItems } from "../service" -import { ItemType } from "./excel/item-excel-template" interface DeleteItemsDialogProps extends React.ComponentPropsWithoutRef<typeof Dialog> { items: Row<Item>["original"][] - itemType?: ItemType showTrigger?: boolean onSuccess?: () => void } export function DeleteItemsDialog({ items, - itemType = 'shipbuilding', showTrigger = true, onSuccess, ...props }: DeleteItemsDialogProps) { const [isDeletePending, startDeleteTransition] = React.useTransition() const isDesktop = useMediaQuery("(min-width: 640px)") - - // 아이템 타입에 따른 텍스트 설정 - const getItemTypeText = () => { - switch (itemType) { - case 'offshoreTop': - return '해양 Top 아이템'; - case 'offshoreHull': - return '해양 Hull 아이템'; - default: - return '조선 아이템'; - } - }; async function onDelete() { try { @@ -101,7 +86,7 @@ export function DeleteItemsDialog({ <DialogDescription> 이 작업은 되돌릴 수 없습니다. 선택한{" "} <span className="font-medium">{items.length}</span> - 개의 {getItemTypeText()}이(가) 영구적으로 삭제됩니다. + 개의 조선 아이템이(가) 영구적으로 삭제됩니다. </DialogDescription> </DialogHeader> <DialogFooter className="gap-2 sm:space-x-0"> @@ -144,7 +129,7 @@ export function DeleteItemsDialog({ <DrawerDescription> 이 작업은 되돌릴 수 없습니다. 선택한{" "} <span className="font-medium">{items.length}</span> - 개의 {getItemTypeText()}이(가) 영구적으로 삭제됩니다. + 개의 조선 아이템이(가) 영구적으로 삭제됩니다. </DrawerDescription> </DrawerHeader> <DrawerFooter className="gap-2 sm:space-x-0"> diff --git a/lib/items-ship/table/items-ship-table-columns.tsx b/lib/items-ship/table/items-ship-table-columns.tsx index 158cd791..2b46db92 100644 --- a/lib/items-ship/table/items-ship-table-columns.tsx +++ b/lib/items-ship/table/items-ship-table-columns.tsx @@ -24,7 +24,7 @@ interface ShipbuildingTableItem { itemId: number;
workType: "기장" | "전장" | "선실" | "배관" | "철의";
shipTypes: string;
- itemCode: string | null;
+ itemCode: string;
itemName: string;
description: string | null;
createdAt: Date;
diff --git a/lib/items-ship/table/items-table-toolbar-actions.tsx b/lib/items-ship/table/items-table-toolbar-actions.tsx index a8cca179..ba3a6cee 100644 --- a/lib/items-ship/table/items-table-toolbar-actions.tsx +++ b/lib/items-ship/table/items-table-toolbar-actions.tsx @@ -25,7 +25,7 @@ interface ShipbuildingItem { itemId: number; workType: "기장" | "전장" | "선실" | "배관" | "철의"; shipTypes: string; - itemCode: string | null; + itemCode: string; itemName: string; description: string | null; createdAt: Date; diff --git a/lib/items-ship/table/update-items-sheet.tsx b/lib/items-ship/table/update-items-sheet.tsx index 8bab9b14..e021e145 100644 --- a/lib/items-ship/table/update-items-sheet.tsx +++ b/lib/items-ship/table/update-items-sheet.tsx @@ -50,7 +50,7 @@ interface UpdateItemSheetProps { itemId: number;
workType: "기장" | "전장" | "선실" | "배관" | "철의";
shipTypes: string;
- itemCode: string | null;
+ itemCode: string;
itemName: string;
description: string | null;
createdAt: Date;
@@ -62,11 +62,11 @@ interface UpdateItemSheetProps { export function UpdateItemSheet({ item, open, onOpenChange }: UpdateItemSheetProps) {
const [isSubmitting, setIsSubmitting] = React.useState(false)
-
+ // 초기값 설정
const form = useForm<UpdateShipbuildingItemSchema>({
resolver: zodResolver(updateShipbuildingItemSchema),
defaultValues: {
- itemCode: item.itemCode || "",
+ itemCode: item.itemCode,
itemName: item.itemName,
description: item.description || "",
workType: item.workType,
diff --git a/lib/items-ship/validations.ts b/lib/items-ship/validations.ts index dbaff859..cb297f99 100644 --- a/lib/items-ship/validations.ts +++ b/lib/items-ship/validations.ts @@ -37,14 +37,14 @@ export const createItemSchema = z.object({ })
export const updateItemSchema = z.object({
- itemCode: z.string().optional(),
+ itemCode: z.string(),
itemName: z.string().optional(),
description: z.string().optional(),
})
// 조선 아이템 업데이트 스키마
export const updateShipbuildingItemSchema = z.object({
- itemCode: z.string().optional(),
+ itemCode: z.string(),
itemName: z.string().optional(),
description: z.string().optional(),
workType: z.string().optional(),
|
