"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" import { InformationButton } from "@/components/information/information-button" 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) => { // 기존 파라미터 무시, type만 세팅 const params = new URLSearchParams(); params.set("type", value); router.push(`${pathname}?${params.toString()}`); }, [router, pathname]); return ( <> {/* 상단 영역: 제목 왼쪽 / 아이템 타입 선택기 오른쪽 */}
조선 및 해양 자재를 등록하고 관리할 수 있습니다.
*/}