From 3c93d6af1a5b1ae8fe8f337eb81110e9f4ffbc5f Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 15 May 2025 02:33:12 +0000 Subject: (최겸) 기술영업 아이템리스트 관련 컴포넌트 추가 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/items-tech/item-tech-container.tsx | 95 +++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 components/items-tech/item-tech-container.tsx (limited to 'components/items-tech') diff --git a/components/items-tech/item-tech-container.tsx b/components/items-tech/item-tech-container.tsx new file mode 100644 index 00000000..8fefbcc9 --- /dev/null +++ b/components/items-tech/item-tech-container.tsx @@ -0,0 +1,95 @@ +"use client" + +import * as React from "react" +import { useRouter, usePathname, useSearchParams } from "next/navigation" +import { ChevronDown } from "lucide-react" + +import { Button } from "@/components/ui/button" +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu" + +interface ItemType { + id: string + name: string +} + +interface ItemTechContainerProps { + itemTypes: ItemType[] + children: React.ReactNode +} + +export function ItemTechContainer({ + itemTypes, + children, +}: ItemTechContainerProps) { + const router = useRouter() + const pathname = usePathname() + const searchParamsObj = useSearchParams() + + // useSearchParams를 메모이제이션하여 안정적인 참조 생성 + const searchParams = React.useMemo( + () => searchParamsObj || new URLSearchParams(), + [searchParamsObj] + ) + + // URL에서 현재 선택된 아이템 타입 가져오기 + const itemType = searchParams.get("type") || "ship" + + // 선택한 아이템 타입에 해당하는 이름 찾기 + const selectedItem = itemTypes.find((item) => item.id === itemType)?.name || "조선 아이템" + + // 아이템 타입 변경 핸들러 + const handleItemTypeChange = React.useCallback((value: string) => { + const params = new URLSearchParams(searchParams.toString()) + params.set("type", value) + + router.push(`${pathname}?${params.toString()}`) + }, [router, pathname, searchParams]) + + return ( + <> + {/* 상단 영역: 제목 왼쪽 / 아이템 타입 선택기 오른쪽 */} +
+ {/* 왼쪽: 타이틀 & 설명 */} +
+

아이템 관리

+

+ 조선 및 해양 아이템을 등록하고 관리할 수 있습니다. +

+
+ + {/* 오른쪽: 아이템 타입 드롭다운 */} + + + + + + {itemTypes.map((item) => ( + handleItemTypeChange(item.id)} + className={item.id === itemType ? "bg-muted" : ""} + > + {item.name} + + ))} + + +
+ + {/* 컨텐츠 영역 */} +
+
+ {children} +
+
+ + ) +} \ No newline at end of file -- cgit v1.2.3