summaryrefslogtreecommitdiff
path: root/components/tech-vendors/tech-vendor-container.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-06-23 09:02:07 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-06-23 09:02:07 +0000
commit5c9b39eb011763a7491b3e8542de9f6d4976dd65 (patch)
treeef18c420a72b0e4c8d5dfd03ae1e8648dda906f7 /components/tech-vendors/tech-vendor-container.tsx
parenta75541e1a1aea596bfca2a435f39133b9b72f193 (diff)
(최겸) 기술영업 벤더 개발
Diffstat (limited to 'components/tech-vendors/tech-vendor-container.tsx')
-rw-r--r--components/tech-vendors/tech-vendor-container.tsx100
1 files changed, 100 insertions, 0 deletions
diff --git a/components/tech-vendors/tech-vendor-container.tsx b/components/tech-vendors/tech-vendor-container.tsx
new file mode 100644
index 00000000..583d507c
--- /dev/null
+++ b/components/tech-vendors/tech-vendor-container.tsx
@@ -0,0 +1,100 @@
+"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 VendorType {
+ id: string
+ name: string
+ value: string
+}
+
+interface TechVendorContainerProps {
+ vendorTypes: VendorType[]
+ children: React.ReactNode
+}
+
+export function TechVendorContainer({
+ vendorTypes,
+ children,
+}: TechVendorContainerProps) {
+ const router = useRouter()
+ const pathname = usePathname()
+ const searchParamsObj = useSearchParams()
+
+ // useSearchParams를 메모이제이션하여 안정적인 참조 생성
+ const searchParams = React.useMemo(
+ () => searchParamsObj || new URLSearchParams(),
+ [searchParamsObj]
+ )
+
+ // URL에서 현재 선택된 벤더 타입 가져오기
+ const vendorType = searchParams.get("vendorType") || "all"
+
+ // 선택한 벤더 타입에 해당하는 이름 찾기
+ const selectedVendor = vendorTypes.find((vendor) => vendor.id === vendorType)?.name || "전체"
+
+ // 벤더 타입 변경 핸들러
+ const handleVendorTypeChange = React.useCallback((value: string) => {
+ const params = new URLSearchParams(searchParams.toString())
+ if (value === "all") {
+ params.delete("vendorType")
+ } else {
+ params.set("vendorType", value)
+ }
+
+ router.push(`${pathname}?${params.toString()}`)
+ }, [router, pathname, searchParams])
+
+ return (
+ <>
+ {/* 상단 영역: 제목 왼쪽 / 벤더 타입 선택기 오른쪽 */}
+ <div className="flex items-center justify-between">
+ {/* 왼쪽: 타이틀 & 설명 */}
+ <div>
+ <h2 className="text-2xl font-bold tracking-tight">기술영업 벤더 리스트</h2>
+ <p className="text-muted-foreground">
+ 기술영업 벤더에 대한 요약 정보를 확인하고 관리할 수 있습니다.
+ </p>
+ </div>
+
+ {/* 오른쪽: 벤더 타입 드롭다운 */}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" className="min-w-[150px]">
+ {selectedVendor}
+ <ChevronDown className="ml-2 h-4 w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-[200px]">
+ {vendorTypes.map((vendor) => (
+ <DropdownMenuItem
+ key={vendor.id}
+ onClick={() => handleVendorTypeChange(vendor.id)}
+ className={vendor.id === vendorType ? "bg-muted" : ""}
+ >
+ {vendor.name}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+
+ {/* 컨텐츠 영역 */}
+ <section className="overflow-hidden">
+ <div>
+ {children}
+ </div>
+ </section>
+ </>
+ )
+} \ No newline at end of file